Skip to content

Commit 62d313b

Browse files
authored
Merge pull request #17 from mcpplibs/feat/observable-process-units
feat: release OS 0.3 with owned units and retirement
2 parents 8416263 + da1d722 commit 62d313b

12 files changed

Lines changed: 492 additions & 29 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Declared units and live continuation identities
2+
3+
This record describes the source group under review. The public dependency
4+
versions have not yet been advanced to this ABI.
5+
6+
`owned_unit::retire` seals admission and takes an explicit `program` from
7+
`self` or `describe`. Both id and birth identify a still-live continuation.
8+
A helper may outlive the publisher that started it, so its previous numeric
9+
unit is not a sufficient return location. The build owner is an appropriate
10+
continuation when it remains alive through retirement. An expired identity,
11+
an inaccessible destination or a different native session yields unknown.
12+
Migration does not authorize termination or admission into the continuation.
13+
14+
`unit_observer` retains the original native observation reference. Its public
15+
surface contains observation and lifetime operations only; native controls
16+
and the native job are private. A compile-failure consumer verifies that it
17+
cannot be supplied as a declared spawn unit or used to terminate a unit.
18+
The C ABI observe/close restriction is a caller precondition on systems whose
19+
unit is a numeric group, rather than a kernel-enforced read-only handle.
20+
21+
The source tests use the existing directory-local blocking IPC transport.
22+
The native consumers measure paired startup and listener start/stop samples,
23+
retain outliers, and test sealed admission after both unknown and successful
24+
retirement. Three native source builds are required; cross-compilation alone
25+
does not qualify native lifetime behavior or cost.
26+
27+
## 2026-11-06 dependency-group preparation
28+
29+
The final source group names OpenKal 0.24, Linux 0.25, macOS 0.22, Windows
30+
0.20 and Emscripten 0.13. OS 0.3.0 uses platform 0.24 for its hosted and
31+
image consumers. Its public manifest is advanced only after the lower source
32+
archives and index entries are available. Native source controls establish
33+
API behaviour; the final complete package CI and ordinary public resolution
34+
remain separate qualification gates.

‎.github/workflows/ci.yml‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ name: CI
1313
# run under node (checks/emscripten); a program that starts one
1414
# fails at LINK naming the openkal symbol (checks/absent)
1515
#
16-
# The library is built with the released mcpp, 2026.11.2.1. The ok images
17-
# (MCPP_PLATFORM) and checks/hosted (its manifest) select openkal-platform
18-
# 0.23.0 and take their C library and C++ run-time from it (openkal 0.23's
19-
# implementations among them; openkal-musl 0.27.0 embeds its allocator, which
20-
# needs mcpp 2026.11 or later). The library
16+
# The library is built with the released mcpp, 2026.11.5.1. The ok images
17+
# (MCPP_PLATFORM) and checks/hosted select openkal-platform 0.24 and its
18+
# OpenKal 0.24 implementation, musl 0.28 and C++ runtime 0.19 group. The library
2119
# itself needs 2026.10.27.1 or later, the first that selects a platform
2220
# (SPEC-013). A dispatch may name a branch of mcpp instead (`mcpp_ref'), which
2321
# the latest released mcpp builds and which is then used.
@@ -37,7 +35,7 @@ env:
3735
MCPP_SOURCE_REF: ${{ github.event.inputs.mcpp_ref || vars.MCPP_SOURCE_REF || '' }}
3836
# 2026.11.3.1: the std module compiled with the platform's words (openkal-platform 0.23.0's
3937
# `-fcf-protection=full` refused every `import std` of an earlier mcpp's).
40-
MCPP_INSTALL: ${{ (github.event.inputs.mcpp_ref || vars.MCPP_SOURCE_REF) && 'mcpp' || 'mcpp@2026.11.3.1' }}
38+
MCPP_INSTALL: ${{ (github.event.inputs.mcpp_ref || vars.MCPP_SOURCE_REF) && 'mcpp' || 'mcpp@2026.11.5.1' }}
4139
XLINGS_VERSION: v2026.10.26.1
4240
XLINGS_NON_INTERACTIVE: '1'
4341

@@ -113,7 +111,7 @@ jobs:
113111
run: |
114112
profile='${{ matrix.profile }}'
115113
mcpp test --profile "$profile" 2>&1 | tee tests.log
116-
for name in platform_test fs_test process_test ipc_test dirs_terminal_test linux_test; do
114+
for name in platform_test fs_test process_test ipc_test unit_test dirs_terminal_test linux_test; do
117115
grep -q "^$name \.\.\. ok" tests.log || { echo "::error::$name did not run or did not pass"; exit 1; }
118116
done
119117
@@ -211,7 +209,7 @@ jobs:
211209
run: |
212210
profile='${{ matrix.profile }}'
213211
mcpp test --profile "$profile" ${{ matrix.target }} 2>&1 | tee tests.log
214-
for name in platform_test fs_test process_test ipc_test dirs_terminal_test linux_test library_test; do
212+
for name in platform_test fs_test process_test ipc_test unit_test dirs_terminal_test linux_test library_test; do
215213
grep -q "^$name \.\.\. ok" tests.log || { echo "::error::$name did not run or did not pass"; exit 1; }
216214
done
217215
@@ -229,7 +227,7 @@ jobs:
229227
# openkal 0.23.0, which this release is written against, is the one
230228
# openkal-platform 0.23.3's version group names; mcpp 2026.11.3.1 and
231229
# later pin it for their openkal rows.
232-
MCPP_PLATFORM: openkal-platform@0.23.3
230+
MCPP_PLATFORM: openkal-platform@0.24.0
233231
defaults:
234232
run:
235233
shell: bash
@@ -260,7 +258,7 @@ jobs:
260258
run: |
261259
set -euo pipefail
262260
mcpp test --target x86_64-openkal 2>&1 | tee tests.log
263-
for name in platform_test fs_test process_test ipc_test dirs_terminal_test linux_test; do
261+
for name in platform_test fs_test process_test ipc_test unit_test dirs_terminal_test linux_test; do
264262
grep -q "^$name \.\.\. ok" tests.log || { echo "::error::$name did not pass as an image"; exit 1; }
265263
done
266264
mcpp test --target aarch64-openkal --no-run
@@ -281,7 +279,7 @@ jobs:
281279
# openkal 0.23.0, which this release is written against, is the one
282280
# openkal-platform 0.23.3's version group names; mcpp 2026.11.3.1 and
283281
# later pin it for their openkal rows.
284-
MCPP_PLATFORM: openkal-platform@0.23.3
282+
MCPP_PLATFORM: openkal-platform@0.24.0
285283
strategy:
286284
fail-fast: false
287285
matrix:
@@ -399,7 +397,7 @@ jobs:
399397
run: |
400398
for t in tests/*_test.cpp; do
401399
n=$(basename "$t")
402-
case "$n" in process_test.cpp|ipc_test.cpp) continue ;; esac
400+
case "$n" in process_test.cpp|ipc_test.cpp|unit_test.cpp) continue ;; esac
403401
[ -f "checks/emscripten/tests/$n" ] || { echo "::error::checks/emscripten/tests has no $n"; exit 1; }
404402
done
405403
- name: Tests, under node
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: declared unit lifecycle
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
concurrency:
6+
group: unit-lifecycle-${{ github.ref }}
7+
cancel-in-progress: true
8+
env:
9+
XLINGS_NON_INTERACTIVE: '1'
10+
11+
jobs:
12+
native:
13+
name: declared unit and blocking ACK (${{ matrix.os }})
14+
runs-on: ${{ matrix.os }}
15+
timeout-minutes: 45
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- { os: ubuntu-24.04, backend: openkal-linux, toolchain: gcc@16.1.0, revision: 225c545f8353570c277ebe79d0bb47b882826bca }
21+
- { os: macos-15, backend: openkal-macos, toolchain: llvm@23.1.3, revision: 3b9686e9260f4a14169602c865751eea2af5f9e0 }
22+
- { os: windows-2025, backend: openkal-windows, toolchain: msvc@system, revision: 9e8f5ab1c1202bf6a46929e82bec77e2667db730 }
23+
defaults:
24+
run:
25+
shell: bash
26+
steps:
27+
- uses: actions/checkout@v4
28+
# Immutable published OpenKal0.24/backend release commits; no prototype refs.
29+
- uses: actions/checkout@v4
30+
with:
31+
repository: mcpplibs/openkal
32+
ref: c17bc255b9672325a726f0afa69f15f20c766b73
33+
path: deps/openkal
34+
- uses: actions/checkout@v4
35+
with:
36+
repository: mcpplibs/${{ matrix.backend }}
37+
ref: ${{ matrix.revision }}
38+
path: deps/backend
39+
- uses: ilammy/msvc-dev-cmd@v1
40+
if: runner.os == 'Windows'
41+
- name: Install the published build tool (Unix)
42+
if: runner.os != 'Windows'
43+
run: |
44+
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.10.26.1
45+
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"
46+
- name: Install the published build tool (Windows)
47+
if: runner.os == 'Windows'
48+
shell: pwsh
49+
run: |
50+
irm https://d2learn.org/xlings-install.ps1.txt | iex
51+
"$env:USERPROFILE\.xlings\subos\current\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
52+
- name: Install the actual native compiler
53+
run: |
54+
xlings update
55+
xlings install mcpp@2026.11.5.1 -y -g
56+
spec='${{ matrix.toolchain }}'
57+
case "$spec" in
58+
msvc@system) mcpp toolchain default msvc ;;
59+
*) mcpp toolchain install "${spec%@*}" "${spec#*@}"
60+
mcpp toolchain default "$spec" ;;
61+
esac
62+
- name: Select the coherent source group under review
63+
env:
64+
IMPLEMENTATION: ${{ matrix.backend }}
65+
run: |
66+
python - <<'PY'
67+
from pathlib import Path
68+
import os,re
69+
root=Path('mcpp.toml')
70+
text=root.read_text()
71+
text=re.sub(r'^openkal = .*$', 'openkal = { path = "deps/openkal" }', text, flags=re.M)
72+
text=re.sub(r'^'+re.escape(os.environ['IMPLEMENTATION'])+r' = .*$', os.environ['IMPLEMENTATION']+' = { path = "deps/backend" }', text, flags=re.M)
73+
root.write_text(text)
74+
backend=Path('deps/backend/mcpp.toml')
75+
backend.write_text(re.sub(r'^openkal = .*$', 'openkal = { path = "../openkal" }', backend.read_text(), flags=re.M))
76+
PY
77+
- name: Compile and run the real lifecycle/ACK consumer
78+
run: |
79+
set -o pipefail
80+
mcpp test unit_test --verbose 2>&1 | tee unit-lifecycle.log
81+
binary=$(find target -type f \( -name unit_test -o -name unit_test.exe \) | head -1)
82+
test -n "$binary"
83+
"$binary" | tee unit-cost.jsonl
84+
- name: An observer cannot admit or terminate a program
85+
run: |
86+
set +e
87+
(cd checks/observer-control && mcpp build) > observer-control.log 2>&1
88+
result=$?
89+
set -e
90+
test "$result" -ne 0
91+
python - <<'PYCONTROL'
92+
from pathlib import Path
93+
log=Path('observer-control.log').read_text()
94+
assert 'unit_observer' in log and ('declared_unit' in log or 'owned_unit' in log) and 'terminate' in log, log
95+
PYCONTROL
96+
- uses: actions/upload-artifact@v4
97+
if: always()
98+
with:
99+
name: unit-lifecycle-${{ matrix.os }}
100+
path: |
101+
unit-lifecycle.log
102+
unit-cost.jsonl
103+
observer-control.log

‎README.md‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ with compile-time platform constants and a few platform modules.
66

77
```toml
88
[dependencies]
9-
os = { namespace = "mcpplibs", version = "0.2.9" }
9+
os = { namespace = "mcpplibs", version = "0.3.0" }
1010
```
1111

1212
```cpp
@@ -34,6 +34,29 @@ what is not a kernel question: the machine beneath the system (`machine`), the d
3434
loader (`library`: the C library's on Linux and macOS, kernel32's on Windows), and the
3535
platform modules.
3636
37+
## Declared process units
38+
39+
Version 0.3.0 provides `process::owned_unit` and the observation-only
40+
`process::unit_observer`. Create an owned unit before starting its external
41+
members, retain `reference()` in the supervising invocation, and pass the unit
42+
through `spawn_options::declared_unit`. The existing `process::spawn` performs
43+
the start. The creating program is a member; `terminate()` can end it too.
44+
`own_unit` and `declared_unit` are mutually exclusive.
45+
46+
An observer opens that opaque reference and reports `unit_state::occupied`,
47+
`empty` or `unknown`. Its type exposes neither admission nor termination.
48+
Closing it terminates nothing. Missing native identity, including loss of all
49+
native reference holders on a system that requires them, remains `unknown`.
50+
51+
`owned_unit::retire(continuation)` seals admission before observing the end of
52+
external members. The continuation identifies the surviving supervising
53+
program outside the helper's unit, obtained from `self` or `describe` with
54+
both identifier and birth retained. A dead, reused or
55+
unreachable continuation does not authorize membership migration. The caller
56+
can finish its bookkeeping after successful retirement. Retirement does not
57+
grant control of the continuation's unit. Output recovery requires a positive
58+
`empty` observation; leader termination alone is insufficient.
59+
3760
## The program's C library
3861
3962
A program over this package chooses its C library. It can be the system's own (glibc,
@@ -87,7 +110,7 @@ dropped (0.2.8).
87110
| `mcpplibs.os.error` | `errc` (openkal's closed set of conditions), `error`, `result<T>` |
88111
| `mcpplibs.os.env` | variables (names without case on Windows), `NAME=value` entries as overrides (`assignments`), arguments, the program's own image, lists of directories in the host's separator (`split_list`, `join_list`), PATH search with PATHEXT |
89112
| `mcpplibs.os.fs` | `write_atomic`, `publish` (no replace), `append`, `sync`, `caps`, `lock`, links, `set_executable`, `stamp_of`, `identity_of`, `owner_of`, `writable`, `locate`, `absolute`, `names_a_place`, `canonical`, a bounded `read`; what a volume does, measured (`measure`, `volume_type`), and the operations that follow it (`place`, `exchange`); names in the host's rules without the file system: `generic`, `native`, `extended`, `is_absolute`, `same`, `within` |
90-
| `mcpplibs.os.process` | `spawn`, `run` (and with bounds: a hard bound, a grace, a drain, output limits), `exec`, a command line joined as it is for the command interpreter (`one_string`), pipes, both outputs on one pipe, output onto this program's error output, units and `end_unit`, bound lifetime, bounded waits and reads; `self`, `describe`, `alive`, `threads` |
113+
| `mcpplibs.os.process` | `spawn`, `run` (and with bounds: a hard bound, a grace, a drain, output limits), `exec`, a command line joined as it is for the command interpreter (`one_string`), pipes, both outputs on one pipe, output onto this program's error output, units and `end_unit`, declared units, observation and retirement, bound lifetime, bounded waits and reads; `self`, `describe`, `alive`, `threads` |
91114
| `mcpplibs.os.interrupt` | `requested`, `wait`, `end_as_requested`, `end_as_output_closed` |
92115
| `mcpplibs.os.stdio` | the three streams as bytes; a bounded read of input; the output sent to the error stream for a while (`output_to_error`) |
93116
| `mcpplibs.os.terminal` | `interactive`, `size`, `sequences`, `color`, `raw_mode` (with or without the interrupting keystroke), `foreground` |

‎checks/hosted/mcpp.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ version = "0.1.0"
1313
os = { path = "../.." }
1414

1515
[target.'cfg(any(linux, macos, windows))']
16-
platform = "openkal-platform@0.23.3"
16+
platform = "openkal-platform@0.24.0"
1717

1818
# The tests are the package's own, each reached by an include from
1919
# tests/<name>.cpp here (a test program is a file of the package that runs it).

‎checks/hosted/tests/unit_test.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Restate imports for the dependency scanner, as the other hosted wrappers do.
2+
#include "../../../tests/check.hpp"
3+
import std;
4+
import mcpplibs.os.process;
5+
import mcpplibs.os.ipc;
6+
import mcpplibs.os.env;
7+
#include "../../../tests/unit_test.cpp"

‎checks/observer-control/mcpp.toml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# A negative compilation check: an observer supplies no unit control authority.
2+
[package]
3+
name = "observer-control-misuse"
4+
version = "0.1.0"
5+
6+
[dependencies]
7+
os = { path = "../.." }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import std;
2+
import mcpplibs.os.process;
3+
4+
int main() {
5+
auto observer = mcpplibs::os::process::unit_observer::open("opaque reference");
6+
mcpplibs::os::process::spawn_options options;
7+
options.declared_unit = &*observer; // An observer cannot admit a program.
8+
observer->terminate(); // It has no unit control operation.
9+
}

‎mcpp.toml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
namespace = "mcpplibs"
33
name = "os"
4-
version = "0.2.9"
4+
version = "0.3.0"
55
description = "mcpplibs.os: a C++ operating-system library over openkal --- processes, files, environment, terminals, directories and local IPC, with compile-time platform constants and a few platform modules."
66
license = "Apache-2.0"
77
authors = ["mcpplibs"]
@@ -12,23 +12,23 @@ repo = "https://github.com/mcpplibs/os"
1212
# own C and C++ runtime. A program that wants the standalone arrangement, or
1313
# the image arrangement of `<arch>-openkal`, selects it in its own manifest.
1414
[dependencies]
15-
openkal = "0.23.0"
15+
openkal = "0.24.0"
1616

1717
[target.linux.dependencies]
18-
openkal-linux = "0.24.1"
18+
openkal-linux = "0.25.0"
1919

2020
[target.macos.dependencies]
21-
openkal-macos = "0.21.3"
21+
openkal-macos = "0.22.0"
2222

2323
[target.windows.dependencies]
24-
openkal-windows = "0.19.0"
24+
openkal-windows = "0.20.0"
2525

2626
# Emscripten (`wasm32-emscripten`): openkal written above the C library, with
2727
# twelve of openkal's fifteen interfaces. `openkal.process', `openkal.exec' and
2828
# `openkal.space' are absent, so a program that starts one fails at link
2929
# naming the symbol; `openkal.task' is present in a `-pthread' link only.
3030
[target.'cfg(os = "emscripten")'.dependencies]
31-
openkal-emscripten = "0.12.0"
31+
openkal-emscripten = "0.13.0"
3232

3333
[targets.os]
3434
kind = "lib"

0 commit comments

Comments
 (0)