@sema-agent/core 7.68.3 → 7.68.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/core/engine-notice.d.ts +5 -0
- package/dist/core/governance-codes.d.ts +3 -1
- package/dist/core/governance-codes.js +3 -0
- package/dist/core/mods/message-display.d.ts +3 -0
- package/dist/core/mods/message-display.js +2 -2
- package/dist/core/process-identity.d.ts +14 -2
- package/dist/core/process-identity.js +5 -3
- package/dist/core/runner/caller-stop-gate.d.ts +3 -3
- package/dist/core/runner/contracts.d.ts +2 -2
- package/dist/core/runner/end-of-run.d.ts +29 -0
- package/dist/core/runner/end-of-run.js +22 -0
- package/dist/core/runner/prepare-task.d.ts +4 -1
- package/dist/core/runner/prepare-task.js +3 -3
- package/dist/core/runner/run-notification-lane.d.ts +2 -0
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/runtask.js +7 -2
- package/dist/core/task-spec.d.ts +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/stores/file/data-root-declaration.d.ts +32 -0
- package/dist/stores/file/data-root-declaration.js +19 -0
- package/dist/stores/file/fs-atomic.d.ts +22 -2
- package/dist/stores/file/fs-atomic.js +63 -10
- package/dist/stores/file/index.d.ts +1 -0
- package/dist/stores/file/index.js +1 -0
- package/dist/stores/file/permission-rule-adopt.js +3 -3
- package/dist/stores/file/permission-rule-store.js +2 -2
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +5 -1
- package/wire-changes/core-stores-sql@7.68.4.json +39 -0
- package/wire-changes/core@7.68.4.json +187 -0
- package/wire-changes/mods-kernel@7.68.4.json +39 -0
- package/wire-changes/primitives@7.68.4.json +39 -0
- package/wire-changes/wiki-gate@7.68.4.json +39 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## 7.68.4 — 2026-11-16
|
|
2
|
+
|
|
3
|
+
### A host can declare that every process opening a file data root runs in this one process table, and the directory locks under that root then judge a lock written by an engine before 7.67.0 by its pid; without the declaration nothing changes but the refusal's sentence and one re-read under the reclaim gate, below (#4667; ruled C-R2243; new host declaration; default unchanged; narrowing: none; widening: one, below, open to veto @server @cli; hard-breaking: none; closed sets: one, `EngineNoticeCode` +1; exports: two, `declareDataRoot`, `DataRootDeclaration`, and one optional member on the exported class `FileStoreLockError`, `ownerFingerprintUnread`; wire: none)
|
|
4
|
+
|
|
5
|
+
- **Before.** On a host that names its pid namespace (Linux), a file store's directory lock whose record names no namespace was never judged: it may come from another process table under the same host name, so it was refused `store.dir_in_use` (`ownerUncheckable: "pid_namespace_unrecorded"`) until removed by hand — 7.67.0's narrowing (its CHANGELOG, "a Linux deployment upgrading over claims and locks written before it reads them live until they are removed"). Every engine before 7.67.0 wrote its locks that way (`v / pid / startedAtMs / startedSinceBootMs / host`), and a host that leaves one behind at a normal stop (a second store over the same root that is never closed) or at a kill leaves it for the upgraded engine: one refusal per start, one lock named per refusal. Its sentence also said "this host has more than one" pid namespace, which the judgment never measured. Measured on 7.68.3 (the pin file run against 7.68.3's sources, macOS with the namespace link seamed: 29 of the 30 cells that ran are red, most of them because the declaration does not exist there; the green one, A1, only checks which namespace the column reads).
|
|
6
|
+
- **Now.** `declareDataRoot(root, { singleProcessTable: true })` states that every process opening `root` runs in this process table (no other container or host mounts it). A lock at or under a declared root whose record names no namespace is then judged by the one judgment every lock gets — the pid signalled, gone ⇒ reclaimed; a pid that exists is reclaimed only when both recorded start times are falsified by its current holder, refused as a live owner otherwise — and the reclaim is said once, `store.lock_reclaimed_on_declaration` (operator; `detail: { path, pid, root }`); the lock is rewritten naming this namespace. One seat per root: every directory lock under it reads the declaration (the data root's `LOCK`, the background-agent, checkpoint and workflow-run ledgers, the permission-rule writer lock, the artifact stub's ledger, an adoption's two locks), whichever store or door opened it. Only the literal `true` is taken; any other value, a stray or missing member and a root that is no path are refused `config.invalid_argument`. The root is resolved as `FileStorageBackend` resolves its own (`resolveDataRoot`: created if absent, then its physical path), so a `..` after a symlink names the directory the stores open, never its lexical twin.
|
|
7
|
+
- **Widening (open to veto).** Under the declaration a lock that names no namespace and whose process is gone from this table is reclaimed where it was refused. It is the deployment's statement, not the engine's observation: a deployment that declares it while a second container or host has the root mounted (replicas over one volume, two generations of a pod during a rolling upgrade) can have a live writer's lock reclaimed. `docs/INTEGRATION-CORE.md` §5.15a lists who may and who may not declare it.
|
|
8
|
+
- **One change without the declaration.** A reclaim re-reads the lock under its gate and removes only the record it judged. A bare-pid record (the form before 7.6.1) replaced in that window by a record of the same pid that this engine reads only for its pid (below) is no longer taken for it: the reclaim does not remove it, and the next pass judges it on its own reading. Without the declaration this reaches only a host that names no pid namespace (macOS), where that next pass judges it by its pid as before (by code: `sameOwner` in `src/stores/file/fs-atomic.ts` also compares whether the record's fingerprint was read); under the declaration such a record is refused and stays (pin C6).
|
|
9
|
+
- **Not changed.** Without the declaration: every verdict, code and lock as before, but for the re-read above; the refusal of a record that names no namespace drops the unmeasured half-sentence and names the way out (the declaration, what it asserts, and "if no process uses it, remove …"), one sentence. With it: a record naming another namespace (`another_pid_namespace`) or another host (`another_host`) is refused word for word as without it (pin C1); a lock whose writer still runs is refused as before (B1); where this host names no namespace (macOS) nothing changes and nothing is said (G1). A record this engine reads only the pid of — a later engine version's, or a JSON record with no version, which no engine wrote — had its host and namespace not read, which is not the same as not written: it is refused with and without the declaration, word for word, untouched and unannounced, and its refusal does not offer the declaration; its reason stays `pid_namespace_unrecorded`, whose sentence says the record was "written without naming its pid namespace" — not true of such a record (its namespace was not read, not shown to be unwritten); it is met where a later engine's lock is found, after a downgrade (C5 each shape; `FileStoreLockError` carries `ownerFingerprintUnread: true` for it, and a store that says a lock refusal again in its own words keeps it, C7); a record of this version that left the namespace out is still judged under it (C5-control). A `singleProcessTable` only a prototype supplies is no member (F2). Still refused, still removed by hand: a current-form record met after a container restart or a pod rebuild (KNOWN-LIMITS KL-4667-a). Not reached by the declaration: a memory writer's session account (its holder and its namespace were introduced together in 7.67.0, so no earlier engine wrote one without it); the root export `isProcessLive` called by a host on its own records (a host's own run claims are judged as on 7.68.3); and a directory lock outside every declared root — a permission-rule or artifact directory a host places outside the data root reads no declaration until that tree is declared too (C2).
|
|
10
|
+
- **Rules.** +1 input to the comparability step (`processCensus({ singleProcessTable: true })` reads a missing namespace as this one), read only after the default verdict already said `pid_namespace_unrecorded`, only for a record whose fingerprint was read, and only for a lock under a declared root; no new judgment, no new refusal code, no new `ProcessUncheckable` member. +1 notice code. +1 optional member on `FileStoreLockError` (`ownerFingerprintUnread`).
|
|
11
|
+
- **Pins.** `test/backlog4667-legacy-lock-host-declaration.test.ts` — A1–A4 (the record refused and reclaimed; the bare pid), B1–B2 (the live writer refused, a reused pid reclaimed), C1–C7 (the other namespace and the other host word for word; a lock outside the declared root; a `..` after a symlink; a root declared before it exists; each record read only for its pid, refused with and without, and the control; such a record swapped in under the reclaim gate is not the one the reclaim came to remove; each store that says the refusal again), D (every lock seat, refused without and opened with), E1 (the server's shape through the root export: the backend, a second background-agent store and the workflow-run store over a root left with four such locks start once), F1–F2 (bad values; a member only a prototype supplies), G1 (macOS), R0; each cell in a seam column and, where the kernel serves `/proc/self/ns/pid`, a real column. `test/fs-atomic-bootlock-fingerprint.test.ts` unchanged and green.
|
|
12
|
+
- **Consumers.** @server / @cli: a local deployment that alone opens its data root can call `declareDataRoot(root, { singleProcessTable: true })` before it opens the stores; a deployment that does not call it behaves exactly as on 7.68.3. A consumer that pins `EngineNoticeCode` as a closed set has one more word.
|
|
13
|
+
|
|
14
|
+
### A run given a `TaskSpec.signal` that is never aborted is let go when it ends: every listener the run hung on that signal, or on the caller-stop gate composed from it, comes off at the run's end (#4668; fix)
|
|
15
|
+
|
|
16
|
+
- **Before.** Since 7.67.0 a top-level leg's message display (the `classic.MessageDisplay` station, opened on every top-level leg whether or not a handler hangs it) hung an abort listener on the caller-stop gate — the signal composed from the host's `signal` with `AbortSignal.any` — and never took it off. The runtime holds a composed signal that carries an abort listener until it aborts, so everything the listener closes over (the leg's prepared state, its conversation, its image bytes) stayed reachable after the run, one copy per run, whether the host kept its controller or dropped it. Measured on 7.68.3: seven live signals per run, and a fresh Runner's brain, runner and spec reachable after every run; a host that gave no signal, or aborted it after the run, did not leak. A second path: a prepare that refused after hanging its listener on the host's own signal (for example, `spec.tools` changed after the call) left that listener on a kept signal, holding the leg's controller and harness.
|
|
17
|
+
- **Affected.** Hosts that pass `TaskSpec.signal` to `runTask` / `runTaskStream` — directly, or through an entry that hands it to its legs (`runWithVerification`, a delegated child given its parent's tool signal) — and do not abort it after the run. The display path since 7.67.0; the prepare path is older (by reading the code; not measured on earlier releases).
|
|
18
|
+
- **Now.** One rule: a run listens to a signal it does not own only through the run's end, minted by the stream leg when the run starts and ended once the run has settled — its result published by the run body, or by the failure backstop after a throw. Both listeners go through it; the leg's forwarding listener still comes off at the loop's end as before. A host need not abort its signal after the run (now stated on `TaskSpec.signal` and in the integration guide).
|
|
19
|
+
- **Not changed.** A host abort while the run is live stops it as before, and the display still drops the message it was showing (nothing more of it reaches the stream, nothing is said of it). The caller-stop gate keeps answering after the run's end. An abort after the run ended adds no frame, notice or error.
|
|
20
|
+
- **Rules.** +1 (the run listens to a signal it does not own only through its end) for −2 per-site releases: the display had none, and prepare's own release was reached only by a prepare that returned. The release is an explicit `removeEventListener`; the `{ signal }` listener option was not used, because the runtime keeps the latest listener hung with it reachable through its target for as long as the target lives (measured: with it, the last run stayed reachable on a kept signal).
|
|
21
|
+
- **Pins.** `test/backlog4668-run-end-releases-caller-signal.test.ts` — R (five shapes: `runTask`, `runTaskStream` with an image and a tool turn, `runWithVerification`, a delegated child, a prepare that refuses; × kept / dropped / no signal / aborted after the end), N (a nested run on a parent tool's signal is collected while the parent still runs), L (no listener a run added stays attached, five shapes), C (40 runs on one Runner and one kept controller: live signals flat; 70 → 280 on 7.68.3), B (a mid-run abort still stops the loop and still drops the message on display; the display's listener comes off only after the result is published; an abort after the end adds nothing). 17 of its 31 cells are red against 7.68.3's sources (B3 among them: there the display's listener never comes off).
|
|
22
|
+
- **Measured after, and what is left.** The implementation car's long run (the engine alone, no network, 300 small runs given a signal that is never aborted, the heap after a forced collection, the least-squares slope per run, three alternations): about 272–282 KB kept per run before, in each of the three shapes; after, about 1.2 KB per run with a fresh Runner each run and about 8.6 KB per run on one Runner whose sessions are released (about 9.9 KB with the sessions left in the store, which holds them by design). That remainder still grows linearly and does not level off: the runtime keeps one entry for every signal composed from a long-lived source until the source dies (three compositions per run from the host's signal, about 0.5 KB), and per-session state outlives a released session (sampled, not traced) — tracked as #4671, not changed here.
|
|
23
|
+
- **Consumers.** No change needed. A host that aborts its controller after every run only to avoid this can stop.
|
|
24
|
+
|
|
25
|
+
no-notes: #4545(repository tooling only: `scripts/verify-clearance.mjs` and its pins count the clearance gate off the ledger; nothing in the package changes), #4546(named only by the car-tools-4545 merge header, as the commit held back; nothing for it lands here), #4547(repository tooling only: `scripts/merge-queue-audit.mjs` and its pins; nothing in the package changes), #4563(repository tooling only: `scripts/remote-gate.sh` ships a tree to the test host by difference; nothing in the package changes)
|
|
26
|
+
|
|
1
27
|
## 7.68.3 — 2026-11-14
|
|
2
28
|
|
|
3
29
|
### A composition's later legs continue the session its first leg entered and never enter it again: a file rewind, a branch point and the other operations a run performs on entering a session now act once, on the leg that enters (#4510; behavior change; narrowing: one, below, open to veto @server; widening: none; two further changes of reading, below (a goal handed an empty `sessionId`; a session deleted between two legs); hard-breaking: none; closed sets: none; exports: none; wire: none)
|
|
@@ -229,6 +229,11 @@ export interface EngineNotice {
|
|
|
229
229
|
* name this pid: `detail: { lock, path, pid }`, `lock` one of `"directory_fence"`, `"boot"` (a file
|
|
230
230
|
* store's data root) or `"mailbox"` (a box lock, unreadable at release or not removable). Said on the
|
|
231
231
|
* default seat; audience `operator`; once per failed release.
|
|
232
|
+
* - `"store.lock_reclaimed_on_declaration"` — a file store's directory lock whose record names no pid
|
|
233
|
+
* namespace was removed because the host declared, with `declareDataRoot(root, { singleProcessTable:
|
|
234
|
+
* true })`, that every process opening that data root runs in this process table, and the process the
|
|
235
|
+
* record names is gone from it. `detail: { path, pid, root }` — the lock, the pid it named, the declared
|
|
236
|
+
* root that covers it. Said on the default seat; audience `operator`; once per lock removed.
|
|
232
237
|
* - `"memory.notice_unscoped"` — a memory notice (the engine's, or a file store's) named no single
|
|
233
238
|
* scope, so it was kept off every session's memory notices; said here only when the memory engine has
|
|
234
239
|
* no incident sink (with one, the sink is told `memory.announcement_withheld`). `detail: { stage }`.
|
|
@@ -154,7 +154,7 @@ export type NoticeAudience = "user" | "operator";
|
|
|
154
154
|
* the union's catalog ({@link EngineNotice.code}). The groups below say only which family a row joins,
|
|
155
155
|
* so the catalog is not written a second time here and the two cannot drift.
|
|
156
156
|
*/
|
|
157
|
-
export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.inherit_env_declared_late", "config.command_sandbox_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.host_sink_failed", "config.seat_malformed", "config.env_knob_adjusted", "config.read_deny_home", "config.permission_rules_skipped", "config.process_start_time_unavailable", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "config.legacy_tool_name", "config.toolpolicy.unmatched_names", "config.agent.unknown_tool", "permission.allowed_tool_not_granted", "permission.allow_rule_not_used_in_auto", "mods.registration_refused", "mods.display_withheld", "mods.stop_ended", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "delegation.resume_lane_missing", "delegation.delivery_discarded", "delegation.settlement_external", "delegation.settlement_write_failed", "delegation.durable_row_unpersisted", "delegation.parked_card_unreadable", "mcp.injection_dropped", "protocol.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.server_unavailable", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.harvest_refused", "memory.harvest_conflict", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "memory.notice_unscoped", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "model.fallback", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "context.messages_omitted", "instructions.withheld", "instructions.family_undeclared", "task.user_steer_undrained", "task.user_followup_undrained", "task.undelivered_input_dropped", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.completed_past_limit", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "approval.approver_defect", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "memory.mount_failed", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "tool_result.media_persisted", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "store.tail_segment_unjudged", "store.lock_retained", "engine.debug_trace", "session.lineage_rerooted", "rewind.boundary_unrecorded", "verify.verifier_is_implementer", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped", "model.context_window_assumed", "config.store_ephemeral"];
|
|
157
|
+
export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.inherit_env_declared_late", "config.command_sandbox_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.host_sink_failed", "config.seat_malformed", "config.env_knob_adjusted", "config.read_deny_home", "config.permission_rules_skipped", "config.process_start_time_unavailable", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "config.legacy_tool_name", "config.toolpolicy.unmatched_names", "config.agent.unknown_tool", "permission.allowed_tool_not_granted", "permission.allow_rule_not_used_in_auto", "mods.registration_refused", "mods.display_withheld", "mods.stop_ended", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "delegation.resume_lane_missing", "delegation.delivery_discarded", "delegation.settlement_external", "delegation.settlement_write_failed", "delegation.durable_row_unpersisted", "delegation.parked_card_unreadable", "mcp.injection_dropped", "protocol.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.server_unavailable", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.harvest_refused", "memory.harvest_conflict", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "memory.notice_unscoped", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "model.fallback", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "context.messages_omitted", "instructions.withheld", "instructions.family_undeclared", "task.user_steer_undrained", "task.user_followup_undrained", "task.undelivered_input_dropped", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.completed_past_limit", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "approval.approver_defect", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "memory.mount_failed", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "tool_result.media_persisted", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "store.tail_segment_unjudged", "store.lock_retained", "store.lock_reclaimed_on_declaration", "engine.debug_trace", "session.lineage_rerooted", "rewind.boundary_unrecorded", "verify.verifier_is_implementer", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped", "model.context_window_assumed", "config.store_ephemeral"];
|
|
158
158
|
/** A catalogued code (see {@link ENGINE_NOTICE_CODES}); {@link NOTICE_MINTER} says who mints it. NOT the type of
|
|
159
159
|
* `EngineNotice.code`, which stays `string` — a host forwarding its own notices through the same
|
|
160
160
|
* sink is a supported shape, and narrowing that field would break it. */
|
|
@@ -315,6 +315,7 @@ declare const NOTICE_AUDIENCE_TABLE: {
|
|
|
315
315
|
readonly "config.process_start_time_unavailable": "operator";
|
|
316
316
|
readonly "store.tail_segment_unjudged": "operator";
|
|
317
317
|
readonly "store.lock_retained": "operator";
|
|
318
|
+
readonly "store.lock_reclaimed_on_declaration": "operator";
|
|
318
319
|
readonly "memory.notice_unscoped": "operator";
|
|
319
320
|
readonly "delegation.settlement_external": "operator";
|
|
320
321
|
readonly "delegation.settlement_write_failed": "operator";
|
|
@@ -495,6 +496,7 @@ declare const NOTICE_MINTER_TABLE: {
|
|
|
495
496
|
readonly "fs.staging_file_swept": "engine";
|
|
496
497
|
readonly "store.tail_segment_unjudged": "engine";
|
|
497
498
|
readonly "store.lock_retained": "engine";
|
|
499
|
+
readonly "store.lock_reclaimed_on_declaration": "engine";
|
|
498
500
|
readonly "engine.debug_trace": "engine";
|
|
499
501
|
readonly "session.lineage_rerooted": "engine";
|
|
500
502
|
readonly "rewind.boundary_unrecorded": "engine";
|
|
@@ -279,6 +279,7 @@ export const ENGINE_NOTICE_CODES = Object.freeze([
|
|
|
279
279
|
"fs.staging_file_swept",
|
|
280
280
|
"store.tail_segment_unjudged",
|
|
281
281
|
"store.lock_retained",
|
|
282
|
+
"store.lock_reclaimed_on_declaration",
|
|
282
283
|
"engine.debug_trace",
|
|
283
284
|
"session.lineage_rerooted",
|
|
284
285
|
"rewind.boundary_unrecorded",
|
|
@@ -432,6 +433,7 @@ const NOTICE_AUDIENCE_TABLE = {
|
|
|
432
433
|
"config.process_start_time_unavailable": "operator",
|
|
433
434
|
"store.tail_segment_unjudged": "operator",
|
|
434
435
|
"store.lock_retained": "operator",
|
|
436
|
+
"store.lock_reclaimed_on_declaration": "operator",
|
|
435
437
|
"memory.notice_unscoped": "operator",
|
|
436
438
|
"delegation.settlement_external": "operator",
|
|
437
439
|
"delegation.settlement_write_failed": "operator",
|
|
@@ -593,6 +595,7 @@ const NOTICE_MINTER_TABLE = {
|
|
|
593
595
|
"fs.staging_file_swept": "engine",
|
|
594
596
|
"store.tail_segment_unjudged": "engine",
|
|
595
597
|
"store.lock_retained": "engine",
|
|
598
|
+
"store.lock_reclaimed_on_declaration": "engine",
|
|
596
599
|
"engine.debug_trace": "engine",
|
|
597
600
|
"session.lineage_rerooted": "engine",
|
|
598
601
|
"rewind.boundary_unrecorded": "engine",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ClassicEventBase } from "../hooks.js";
|
|
2
2
|
import { type EngineNotice } from "../engine-notice.js";
|
|
3
3
|
import type { QueueSlot } from "../push-queue.js";
|
|
4
|
+
import type { RunEnd } from "../runner/end-of-run.js";
|
|
4
5
|
import type { TaskEvent, TaskEventIdentity } from "../task-event.js";
|
|
5
6
|
import { type LegEvents, type LegModBus } from "./stations.js";
|
|
6
7
|
/** The station's pace (CC 2.1.316 `VTs`, cli316.js:288153: a raise every 100 ms, three in flight, a window's ten seconds). */
|
|
@@ -44,6 +45,8 @@ export interface MessageDisplayInput {
|
|
|
44
45
|
readonly ident: () => TaskEventIdentity;
|
|
45
46
|
/** The caller's stop: once it fires, nothing more of any message is shown (and nothing is said of what is not). */
|
|
46
47
|
readonly signal: AbortSignal;
|
|
48
|
+
/** The run's end (runner/end-of-run.ts): the station hears `signal` through it, until then — the caller's stop outlives the run. */
|
|
49
|
+
readonly runEnd: Pick<RunEnd, "listen">;
|
|
47
50
|
/** The leg's notice sink (`RunnerDeps.onNotice`): an answer that did not stand is said through the engine's one notice throat. */
|
|
48
51
|
readonly onNotice: ((notice: EngineNotice) => void) | undefined;
|
|
49
52
|
readonly sessionId: string;
|
|
@@ -71,10 +71,10 @@ export function openMessageDisplay(input) {
|
|
|
71
71
|
m.finalSlot?.fill([]);
|
|
72
72
|
m.finish();
|
|
73
73
|
};
|
|
74
|
-
input.
|
|
74
|
+
input.runEnd.listen(input.signal, () => {
|
|
75
75
|
for (const m of [...messages])
|
|
76
76
|
drop(m);
|
|
77
|
-
}
|
|
77
|
+
});
|
|
78
78
|
const open = (whole) => {
|
|
79
79
|
let resolveDone;
|
|
80
80
|
const done = new Promise((resolve) => (resolveDone = resolve));
|
|
@@ -85,6 +85,16 @@ export type ProcessVerdict = {
|
|
|
85
85
|
readonly state: "uncheckable";
|
|
86
86
|
readonly why: ProcessUncheckable;
|
|
87
87
|
};
|
|
88
|
+
/** What a census is told besides the records it judges. */
|
|
89
|
+
export interface ProcessCensusOptions {
|
|
90
|
+
/**
|
|
91
|
+
* The host has declared that every process which could have written the records this census judges runs in THIS process
|
|
92
|
+
* table — no other container and no other host opens what those records guard. A record that names NO pid namespace is
|
|
93
|
+
* then read as naming this one, and judged like any record written here. It fills in only what a record leaves unsaid: a
|
|
94
|
+
* record that names another namespace, or another host, is exactly as uncomparable as without it.
|
|
95
|
+
*/
|
|
96
|
+
readonly singleProcessTable?: true;
|
|
97
|
+
}
|
|
88
98
|
/** One question session over the process table. */
|
|
89
99
|
export interface ProcessCensus {
|
|
90
100
|
/** The verdict on one record. Within one census each pid is signalled at most once and its start time is
|
|
@@ -118,7 +128,9 @@ export declare function processFingerprint(pid?: number): ProcessFingerprint;
|
|
|
118
128
|
* one), is `uncheckable` — and the pid is never signalled: a number from another table names nothing
|
|
119
129
|
* here, and signalling it would judge whatever unrelated process happens to hold it. With no namespace
|
|
120
130
|
* on either side (macOS), the host name decides alone. A record naming no host at all (a pre-fingerprint
|
|
121
|
-
* spelling) is compared on the namespace alone.
|
|
131
|
+
* spelling) is compared on the namespace alone. A record naming no namespace is read as naming this one
|
|
132
|
+
* when the census was told so ({@link ProcessCensusOptions.singleProcessTable}) — the one input the host
|
|
133
|
+
* can supply, and only to this step.
|
|
122
134
|
* 2. EXISTS? `kill(pid, 0)`: only ESRCH is `gone`. EPERM is a process that exists; any other error is the
|
|
123
135
|
* table refusing the question — `uncheckable`, never `gone`.
|
|
124
136
|
* 3. SAME PROCESS? The record's start time against the one observed now. One-sided: whatever holds a
|
|
@@ -130,7 +142,7 @@ export declare function processFingerprint(pid?: number): ProcessFingerprint;
|
|
|
130
142
|
* this host's own uptime names a boot that is over. A record and an observation sharing no measure at all
|
|
131
143
|
* are `uncheckable` (`start_time_unknown`); otherwise the process is `running`.
|
|
132
144
|
*/
|
|
133
|
-
export declare function processCensus(): ProcessCensus;
|
|
145
|
+
export declare function processCensus(options?: ProcessCensusOptions): ProcessCensus;
|
|
134
146
|
/**
|
|
135
147
|
* Is the process a record names possibly still the one that wrote it? `false` ONLY when it is proven gone
|
|
136
148
|
* (see {@link processCensus}): a record from another process table, a pid the table will not answer about,
|
|
@@ -7,7 +7,7 @@ import { deliverEngineNotice } from "./engine-notice.js";
|
|
|
7
7
|
const UNCHECKABLE_TEXT = Object.freeze({
|
|
8
8
|
another_host: "it was written on another host",
|
|
9
9
|
another_pid_namespace: "it was written in another pid namespace (another container, or one this process cannot name)",
|
|
10
|
-
pid_namespace_unrecorded: "it was written without naming its pid namespace (by an engine before this one, or by a process that could not read it),
|
|
10
|
+
pid_namespace_unrecorded: "it was written without naming its pid namespace (by an engine before this one, or by a process that could not read it), so another process table under this host name may have written it",
|
|
11
11
|
start_time_unknown: "no start time could be compared, so a process now holding that pid cannot be told apart from the one that wrote it",
|
|
12
12
|
probe_refused: "the process table refused the question",
|
|
13
13
|
});
|
|
@@ -165,7 +165,8 @@ const RUNNING = Object.freeze({ state: "running" });
|
|
|
165
165
|
function uncheckable(why) {
|
|
166
166
|
return { state: "uncheckable", why };
|
|
167
167
|
}
|
|
168
|
-
export function processCensus() {
|
|
168
|
+
export function processCensus(options) {
|
|
169
|
+
const singleProcessTable = options?.singleProcessTable === true;
|
|
169
170
|
const signalled = new Map();
|
|
170
171
|
const observed = new Map();
|
|
171
172
|
const signal = (pid) => {
|
|
@@ -188,7 +189,8 @@ export function processCensus() {
|
|
|
188
189
|
verdict(record) {
|
|
189
190
|
if (typeof record.host === "string" && record.host !== "" && record.host !== thisHost())
|
|
190
191
|
return uncheckable("another_host");
|
|
191
|
-
const
|
|
192
|
+
const recorded = typeof record.pidNs === "string" && record.pidNs !== "" ? record.pidNs : null;
|
|
193
|
+
const theirs = recorded ?? (singleProcessTable ? ownPidNamespace() : null);
|
|
192
194
|
if (theirs !== ownPidNamespace())
|
|
193
195
|
return uncheckable(theirs === null ? "pid_namespace_unrecorded" : "another_pid_namespace");
|
|
194
196
|
const answer = signal(record.pid);
|
|
@@ -18,8 +18,8 @@ export interface CallerStopGate {
|
|
|
18
18
|
readonly signal: AbortSignal;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* The caller's own signal is COMPOSED into the read face, not listened to
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* The caller's own signal is COMPOSED into the read face, not listened to, so the gate keeps answering after the leg
|
|
22
|
+
* dropped its own listener on that signal — which is exactly when the end-of-task pass runs. A listener hung ON the read
|
|
23
|
+
* face outlives the run with it (a composed signal that carries one is held until it aborts): listen through the run's end.
|
|
24
24
|
*/
|
|
25
25
|
export declare function mintCallerStopGate(callerSignal: AbortSignal | undefined): CallerStopGate;
|
|
@@ -544,7 +544,7 @@ export interface Prepared {
|
|
|
544
544
|
permissionRuleOrg?: {
|
|
545
545
|
adjudicate: (req: ToolCallRequest) => Promise<OrgGateVerdict>;
|
|
546
546
|
};
|
|
547
|
-
/**
|
|
547
|
+
/** Takes the `spec.signal` abort listener off once the leg's loop ended (its job is over); the run's end takes it off on every exit. */
|
|
548
548
|
releaseSignal: () => void;
|
|
549
549
|
/** The leg has stopped: its children's mode ceiling moves to the session's current leg (called once its loop settled). */
|
|
550
550
|
endModeCeiling: () => void;
|
|
@@ -3150,7 +3150,7 @@ export interface RunnerSelfSeat {
|
|
|
3150
3150
|
*/
|
|
3151
3151
|
export type PrepareTaskFn = (spec: TaskSpec, deps: RunnerDeps, sessions: SessionStore, resume?: PrepareResume, internals?: RunInternals, runnerSelf?: RunnerSelfSeat, runIdSink?: {
|
|
3152
3152
|
runId?: string;
|
|
3153
|
-
}, holdSessionLock?: (sessionId: string) => Promise<void>, legWrites?: LegWrites, noticeDestinations?: import("../task-notification.js").NoticeDestinationJudge, promptSubmitRef?: import("../input-author.js").PromptSubmitRef) => Promise<Prepared>;
|
|
3153
|
+
}, holdSessionLock?: (sessionId: string) => Promise<void>, legWrites?: LegWrites, noticeDestinations?: import("../task-notification.js").NoticeDestinationJudge, promptSubmitRef?: import("../input-author.js").PromptSubmitRef, runEnd?: import("./end-of-run.js").RunEnd) => Promise<Prepared>;
|
|
3154
3154
|
/** One leg's view of the Runner's session write ledger (`session-write-ledger.ts`): `issue` starts a write of the leg (`what` = the
|
|
3155
3155
|
* entry type, for a report) or refuses it once `close` ran — the leg's hold ended; a write still in flight is reported when it settles. */
|
|
3156
3156
|
export interface LegWrites {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run's end: one per run, and the one release of every listener the run hangs on a signal it does not own.
|
|
3
|
+
*
|
|
4
|
+
* A run reaches signals that can outlive it — the caller's `TaskSpec.signal` (a host may keep one controller for many runs, or
|
|
5
|
+
* never abort it), the caller-stop gate composed from it, a parent leg's tool signal a child run is handed. A listener left on
|
|
6
|
+
* such a signal stays reachable for as long as the signal does, and so does everything it closes over (the run's prepared
|
|
7
|
+
* state, its conversation, its images). A composed signal (`AbortSignal.any`) or a timeout signal that carries an abort
|
|
8
|
+
* listener is held by the runtime itself until it aborts, so dropping the signal frees nothing either.
|
|
9
|
+
*
|
|
10
|
+
* The rule: the run listens to such a signal only through {@link RunEnd.listen}. The stream leg mints the end when the run
|
|
11
|
+
* starts and ends it once the run has settled — its result published by the run body, or by the failure backstop after a
|
|
12
|
+
* throw — so every listener is taken off whether or not its signal ever fired, and the host owes no abort after the run. A
|
|
13
|
+
* listener whose job ends sooner takes itself off sooner (the release `listen` returns); none outlives the run. Ending the run
|
|
14
|
+
* fires nothing and answers nothing: the caller-stop gate still answers "did the caller ask this run to stop?".
|
|
15
|
+
*
|
|
16
|
+
* The release is an explicit `removeEventListener`, not the `{ signal }` listener option: the runtime keeps the latest
|
|
17
|
+
* listener hung with that option reachable through its target for as long as the target lives, so on a host's long-lived
|
|
18
|
+
* signal it would keep the last run reachable.
|
|
19
|
+
*/
|
|
20
|
+
export interface RunEnd {
|
|
21
|
+
/**
|
|
22
|
+
* Hear `signal` abort, once, until the run ends. The return takes the listener off sooner (idempotent). Hangs nothing once
|
|
23
|
+
* the run ended. A signal that already fired is the caller's to read: an abort is not replayed to a late listener.
|
|
24
|
+
*/
|
|
25
|
+
listen(signal: AbortSignal, onAbort: () => void): () => void;
|
|
26
|
+
/** The run ended: every listener still hung through `listen` is taken off; idempotent. */
|
|
27
|
+
end(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare function mintRunEnd(): RunEnd;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function mintRunEnd() {
|
|
2
|
+
let hung = new Set();
|
|
3
|
+
return {
|
|
4
|
+
listen(signal, onAbort) {
|
|
5
|
+
if (hung === undefined)
|
|
6
|
+
return () => undefined;
|
|
7
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
8
|
+
const release = () => {
|
|
9
|
+
signal.removeEventListener("abort", onAbort);
|
|
10
|
+
hung?.delete(release);
|
|
11
|
+
};
|
|
12
|
+
hung.add(release);
|
|
13
|
+
return release;
|
|
14
|
+
},
|
|
15
|
+
end() {
|
|
16
|
+
const all = hung;
|
|
17
|
+
hung = undefined;
|
|
18
|
+
for (const release of all ?? [])
|
|
19
|
+
release();
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SessionStore } from "../session.js";
|
|
2
2
|
export { runGuardChain, type GuardChainArgs, type GuardChainOutcome } from "./prepare-context-lane.js";
|
|
3
3
|
import type { LegWrites } from "./session-write-ledger.js";
|
|
4
|
+
import { type RunEnd } from "./end-of-run.js";
|
|
4
5
|
export { gatedCallIdOf, USAGE_WINDOW_REAP_MARGIN_MS } from "./park-commit.js";
|
|
5
6
|
export { batchContextAt } from "./prepare-park-ask.js";
|
|
6
7
|
export { compensateUnparkedPause } from "./prepare-suspend-saga.js";
|
|
@@ -126,7 +127,9 @@ legWrites?: LegWrites,
|
|
|
126
127
|
noticeDestinations?: NoticeDestinationJudge,
|
|
127
128
|
/** `$.prompt.submit`'s binding — the stream that runs this leg filled it with its own steer relay; the leg's facade entry reads
|
|
128
129
|
* it at call time. Absent when prepareTask runs outside a Runner's stream, and then every such call is dropped. */
|
|
129
|
-
promptSubmitRef?: PromptSubmitRef
|
|
130
|
+
promptSubmitRef?: PromptSubmitRef,
|
|
131
|
+
/** The run's end (end-of-run.ts): the caller's signal is listened to through it. Absent outside a Runner's stream. */
|
|
132
|
+
runEnd?: RunEnd): Promise<Prepared>;
|
|
130
133
|
/** The entry IS the contract the notification lane's seat names ({@link PrepareTaskFn}, contracts.ts):
|
|
131
134
|
* a signature change reds HERE, at the declaration, as `false` failing the `true` bound. IDENTITY, not assignability:
|
|
132
135
|
* the parameter tuple (arity, optionality, each type) and the return type must be the SAME type in both directions —
|
|
@@ -59,6 +59,7 @@ import { joinedCrossBoundaryTree, prepareCrossBoundaryLane } from "./cross-bound
|
|
|
59
59
|
import { prepareSafetyScan } from "./prepare-safety-scan.js";
|
|
60
60
|
import { prepareAcquireReconcile } from "./prepare-acquire-reconcile.js";
|
|
61
61
|
import { settleBranchWriteBack } from "./branch-writeback.js";
|
|
62
|
+
import { mintRunEnd } from "./end-of-run.js";
|
|
62
63
|
import { prepareHandsMount, resolveHandsLessReadFace } from "./prepare-hands-readface.js";
|
|
63
64
|
import { createContextRoomSeat } from "./context-room.js";
|
|
64
65
|
import { discloseUnevaluableWindow } from "./clock-and-limits.js";
|
|
@@ -324,7 +325,7 @@ function refuseRegistryScopeMismatch(spec, internals) {
|
|
|
324
325
|
function validateInputFaultNotice(onError, sessionId) {
|
|
325
326
|
return ({ toolName, toolCallId, error }) => onError?.(new Error(`tool input pre-validation (validateInput) threw for ${toolName} (call ${toolCallId}) — read as no verdict; the call proceeded to the gate: ${thrownText(error)}`), { phase: "hook", sessionId });
|
|
326
327
|
}
|
|
327
|
-
export async function prepareTask(request, deps, sessions, resume, internals, runnerSelf, runIdSink, holdSessionLock, legWrites, noticeDestinations, promptSubmitRef) {
|
|
328
|
+
export async function prepareTask(request, deps, sessions, resume, internals, runnerSelf, runIdSink, holdSessionLock, legWrites, noticeDestinations, promptSubmitRef, runEnd) {
|
|
328
329
|
const runId = uuidv7();
|
|
329
330
|
if (runIdSink !== undefined)
|
|
330
331
|
runIdSink.runId = runId;
|
|
@@ -897,8 +898,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
897
898
|
abortController.abort();
|
|
898
899
|
void harness.abort();
|
|
899
900
|
};
|
|
900
|
-
|
|
901
|
-
releaseSignal = () => sig.removeEventListener("abort", onExternalAbort);
|
|
901
|
+
releaseSignal = (runEnd ?? mintRunEnd()).listen(sig, onExternalAbort);
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
const approvalWords = approvalWordsSeat(harness, (error) => deps.onError?.(error, { phase: "degraded", sessionId }));
|
|
@@ -22,6 +22,8 @@ export interface RunNotificationLaneInput<R> {
|
|
|
22
22
|
holdSessionLock: ((sessionId: string) => Promise<void>) | undefined;
|
|
23
23
|
/** borrowed-mutable (the Runner's) — this leg's view of the session write ledger, handed to prepare; the stream layer closes it at the leg's end. */
|
|
24
24
|
legWrites: import("./session-write-ledger.js").LegWrites;
|
|
25
|
+
/** borrowed-readonly — the run's end (end-of-run.ts), handed to prepare: the caller's signal is listened to through it. */
|
|
26
|
+
runEnd: import("./end-of-run.js").RunEnd;
|
|
25
27
|
/** borrowed-readonly — `$.prompt.submit`'s binding the stream layer filled with its own relay, handed to prepare (whose facade reads
|
|
26
28
|
* it at call time); absent outside a Runner's stream. */
|
|
27
29
|
promptSubmitRef: import("../input-author.js").PromptSubmitRef | undefined;
|
|
@@ -14,7 +14,7 @@ export function runNotificationLane(input) {
|
|
|
14
14
|
return obligations.run(() => runNotificationLaneAs(input, obligations));
|
|
15
15
|
}
|
|
16
16
|
async function runNotificationLaneAs(input, obligations) {
|
|
17
|
-
const { spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, promptSubmitRef, runner, self, sessions, sessionReadStates, sessionModeSeats, sessionMcpPools, pendingSessionNotifications, prepareTask, next } = input;
|
|
17
|
+
const { spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, runEnd, promptSubmitRef, runner, self, sessions, sessionReadStates, sessionModeSeats, sessionMcpPools, pendingSessionNotifications, prepareTask, next } = input;
|
|
18
18
|
const prepareResume = resume
|
|
19
19
|
? {
|
|
20
20
|
leafId: resume.cp.leafId,
|
|
@@ -151,7 +151,7 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
151
151
|
sessionReadStates,
|
|
152
152
|
sessionModeSeats, sessionMcpPools,
|
|
153
153
|
onTaskNotification: laneSink,
|
|
154
|
-
}, self, taskIdRef, holdSessionLock, legWrites, (destination, delivery) => pendingSessionNotifications.discardsStaleNotice(destination, delivery), promptSubmitRef);
|
|
154
|
+
}, self, taskIdRef, holdSessionLock, legWrites, (destination, delivery) => pendingSessionNotifications.discardsStaleNotice(destination, delivery), promptSubmitRef, runEnd);
|
|
155
155
|
try {
|
|
156
156
|
pendingSessionNotifications.admit(sessionAddressOf(prepared), prepared.sessionBox);
|
|
157
157
|
const settling = pendingSessionNotifications.settleBoxDebts(sessionAddressOf(prepared), prepared.abortController.signal);
|
|
@@ -35,6 +35,7 @@ import { ToolDetachHub } from "../tool-detach.js";
|
|
|
35
35
|
import { assertContextSettingsValue, assertContextSettingsWords, contextOverlayFor } from "../context-settings.js";
|
|
36
36
|
import { createRunState } from "./initial-run-state.js";
|
|
37
37
|
import { SessionWriteLedger } from "./session-write-ledger.js";
|
|
38
|
+
import { mintRunEnd } from "./end-of-run.js";
|
|
38
39
|
import { teardownLegBudget } from "./teardown-bounded.js";
|
|
39
40
|
import { emitSettled, reconciledEnd } from "./tool-end-body.js";
|
|
40
41
|
import { answerFaceForRedeemedCall } from "./decide-continuation.js";
|
|
@@ -325,6 +326,7 @@ export class Runner {
|
|
|
325
326
|
};
|
|
326
327
|
const namedSessionId = spec.sessionId;
|
|
327
328
|
const legWrites = this.sessionWrites.openLeg((err, sessionId) => this.deps.onError?.(err, { phase: "degraded", sessionId }));
|
|
329
|
+
const runEnd = mintRunEnd();
|
|
328
330
|
const receivedPeers = receivePeerDeclarations(spec, this.deps);
|
|
329
331
|
const declarationHold = this.holdDeclarations(receivedDeclarations(receivedPeers), namedSessionId);
|
|
330
332
|
const run = (async () => {
|
|
@@ -338,6 +340,7 @@ export class Runner {
|
|
|
338
340
|
queue,
|
|
339
341
|
holdSessionLock: namedSessionId ? undefined : holdSessionLock,
|
|
340
342
|
legWrites,
|
|
343
|
+
runEnd,
|
|
341
344
|
setResult: (r) => {
|
|
342
345
|
resultValue = r;
|
|
343
346
|
const pcs = internals?.inheritedGate?.parentConstraints;
|
|
@@ -405,6 +408,7 @@ export class Runner {
|
|
|
405
408
|
}).onRunRejected);
|
|
406
409
|
void settled.then(() => acceptedSteerInputs.clear(), () => acceptedSteerInputs.clear());
|
|
407
410
|
void settled.then(() => declarationHold.release(), () => declarationHold.release());
|
|
411
|
+
void settled.then(() => runEnd.end(), () => runEnd.end());
|
|
408
412
|
const { reapSuspended } = streamReap({
|
|
409
413
|
live, runner: this.depsSeat,
|
|
410
414
|
locallyClaimedTokens: this.locallyClaimedTokens, parentConstraintRegistry: this.parentConstraintRegistry, suspendedEnvReaps: this.suspendedEnvReaps,
|
|
@@ -440,9 +444,9 @@ export class Runner {
|
|
|
440
444
|
return stream;
|
|
441
445
|
}
|
|
442
446
|
runLocked(input) {
|
|
443
|
-
const { spec, queue, setResult, onSuggestions, onReady, onSuspend, manualCompactRef, taskIdRef, holdSessionLock, legWrites, resume, internals, notifyRef, promptSubmitRef, captureOptOutRef, mcpRedialRef, entryActor, entryTracer } = input;
|
|
447
|
+
const { spec, queue, setResult, onSuggestions, onReady, onSuspend, manualCompactRef, taskIdRef, holdSessionLock, legWrites, runEnd, resume, internals, notifyRef, promptSubmitRef, captureOptOutRef, mcpRedialRef, entryActor, entryTracer } = input;
|
|
444
448
|
return runNotificationLane({
|
|
445
|
-
spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, promptSubmitRef,
|
|
449
|
+
spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, runEnd, promptSubmitRef,
|
|
446
450
|
runner: this.depsSeat, self: this, sessions: this.sessions, sessionReadStates: this.sessionReadStates, sessionModeSeats: this.sessionModeSeats, sessionMcpPools: this.sessionMcpPools, pendingSessionNotifications: this.pendingSessionNotifications,
|
|
447
451
|
prepareTask,
|
|
448
452
|
next: ({ prepared, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, modelCatalog, notificationLane, unsubscribeTaskNotifications, deliveryObligations }) => {
|
|
@@ -467,6 +471,7 @@ export class Runner {
|
|
|
467
471
|
reserve: () => queue.reserve(),
|
|
468
472
|
ident,
|
|
469
473
|
signal: loopLatch.callerStop.signal,
|
|
474
|
+
runEnd,
|
|
470
475
|
onNotice: this.deps.onNotice,
|
|
471
476
|
sessionId: prepared.sessionId,
|
|
472
477
|
});
|
package/dist/core/task-spec.d.ts
CHANGED
|
@@ -1795,6 +1795,8 @@ export interface TaskSpec {
|
|
|
1795
1795
|
* External cancellation. When it aborts, the task aborts (the brain request is cancelled and any
|
|
1796
1796
|
* pending tool-policy gate releases). Pass a parent tool's `ToolExecuteContext.signal` here so a
|
|
1797
1797
|
* nested `runTask` stops the instant the parent does instead of running to its own `limits.maxWalltimeMs`.
|
|
1798
|
+
* The run holds nothing on it once it has ended: the host need not abort it after the run, and may keep one
|
|
1799
|
+
* signal for many runs.
|
|
1798
1800
|
*/
|
|
1799
1801
|
signal?: AbortSignal;
|
|
1800
1802
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -186,7 +186,7 @@ export type { FileHistoryStore, FileHistoryResult, FileHistoryTrackResult, FileH
|
|
|
186
186
|
export type { InMemoryFileHistoryStoreOptions } from "./core/file-history-store.js";
|
|
187
187
|
export { DEFAULT_FILE_HISTORY_BOUNDARY_KEEP, resolveFileHistoryRetention, fileHistoryBoundariesToKeep } from "./core/file-history-retention.js";
|
|
188
188
|
export type { FileHistoryRetentionPolicy } from "./core/file-history-retention.js";
|
|
189
|
-
export { FileStorageBackend, FileSessionRepo, FileCheckpointStore, CHECKPOINT_LEDGER_EVENT_KINDS, readCheckpointLedger, FileToolResultStore, FileSessionPolicyStore, FileFileHistoryStore, FileWorkflowJournalStore, MAX_JOURNAL_RESULT_BYTES, oversizeJournalResult, resolveDataRoot, sanitizeScope, sanitizePathComponent, atomicWriteFile, writeThenLink, ensureDir, readJsonlRecords, AppendLog, FileStoreLockError, type FileStoreLockErrorCode, processFingerprint, isProcessLive, type ProcessFingerprint, type FileStorageBackendOptions, type FileStorageCorruptReadInfo, type FileFileHistoryStoreOptions, type FileSessionRepoOptions, type FileCheckpointStoreOptions, type CheckpointLedgerEventKind, type CheckpointLedgerReading, type ReadCheckpointLedgerOptions, } from "./stores/file/index.js";
|
|
189
|
+
export { FileStorageBackend, FileSessionRepo, FileCheckpointStore, CHECKPOINT_LEDGER_EVENT_KINDS, readCheckpointLedger, FileToolResultStore, FileSessionPolicyStore, FileFileHistoryStore, FileWorkflowJournalStore, MAX_JOURNAL_RESULT_BYTES, oversizeJournalResult, resolveDataRoot, sanitizeScope, sanitizePathComponent, atomicWriteFile, writeThenLink, ensureDir, readJsonlRecords, AppendLog, FileStoreLockError, type FileStoreLockErrorCode, processFingerprint, isProcessLive, type ProcessFingerprint, declareDataRoot, type DataRootDeclaration, type FileStorageBackendOptions, type FileStorageCorruptReadInfo, type FileFileHistoryStoreOptions, type FileSessionRepoOptions, type FileCheckpointStoreOptions, type CheckpointLedgerEventKind, type CheckpointLedgerReading, type ReadCheckpointLedgerOptions, } from "./stores/file/index.js";
|
|
190
190
|
export { CacheBreakDetector, type CacheBreakFinding, type ToolFingerprintInput } from "./core/cache-break-detector.js";
|
|
191
191
|
export { maybeCompact, type MaybeCompactOptions, type CompactionPassStart, type CompactionWindowSafetyInfo, type CompactionRestoreAsk } from "./core/auto-compaction.js";
|
|
192
192
|
export type { MintedAttachmentFrame } from "./core/user-attachment.js";
|
package/dist/index.js
CHANGED
|
@@ -147,7 +147,7 @@ export { describeTrackKey as fileHistoryDescribeTrackKey, fileHistoryExportDiges
|
|
|
147
147
|
export { resolveTrackedFile as fileHistoryResolveTrackedFile, placeProvenDifferent as fileHistoryPlaceProvenDifferent, trackKeyForEdit as fileHistoryTrackKeyForEdit, trackKeyForAnnul as fileHistoryTrackKeyForAnnul, fileHistoryEntryTravels, fileHistoryParentIdentTravels } from "./core/file-history-store.js";
|
|
148
148
|
export { fileHistoryBlobExchangeOf } from "./core/file-history-store.js";
|
|
149
149
|
export { DEFAULT_FILE_HISTORY_BOUNDARY_KEEP, resolveFileHistoryRetention, fileHistoryBoundariesToKeep } from "./core/file-history-retention.js";
|
|
150
|
-
export { FileStorageBackend, FileSessionRepo, FileCheckpointStore, CHECKPOINT_LEDGER_EVENT_KINDS, readCheckpointLedger, FileToolResultStore, FileSessionPolicyStore, FileFileHistoryStore, FileWorkflowJournalStore, MAX_JOURNAL_RESULT_BYTES, oversizeJournalResult, resolveDataRoot, sanitizeScope, sanitizePathComponent, atomicWriteFile, writeThenLink, ensureDir, readJsonlRecords, AppendLog, FileStoreLockError, processFingerprint, isProcessLive, } from "./stores/file/index.js";
|
|
150
|
+
export { FileStorageBackend, FileSessionRepo, FileCheckpointStore, CHECKPOINT_LEDGER_EVENT_KINDS, readCheckpointLedger, FileToolResultStore, FileSessionPolicyStore, FileFileHistoryStore, FileWorkflowJournalStore, MAX_JOURNAL_RESULT_BYTES, oversizeJournalResult, resolveDataRoot, sanitizeScope, sanitizePathComponent, atomicWriteFile, writeThenLink, ensureDir, readJsonlRecords, AppendLog, FileStoreLockError, processFingerprint, isProcessLive, declareDataRoot, } from "./stores/file/index.js";
|
|
151
151
|
export { CacheBreakDetector } from "./core/cache-break-detector.js";
|
|
152
152
|
export { maybeCompact } from "./core/auto-compaction.js";
|
|
153
153
|
export { brainToRuntime } from "./core/runtime.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a host states about a file data root — facts about the DEPLOYMENT the engine cannot observe from inside one process.
|
|
3
|
+
*
|
|
4
|
+
* `singleProcessTable: true` states: every process that opens this data root runs in this one process table — no other
|
|
5
|
+
* container and no other host mounts it (a self-launched, single-user process over a local disk). The directory locks under
|
|
6
|
+
* the root then read a lock record that names no pid namespace (one written by an engine before the namespace was recorded)
|
|
7
|
+
* as written in this table, and judge it by its pid and start times like any lock written here. Without the declaration such
|
|
8
|
+
* a record is not comparable on a host that names its pid namespace (Linux), because a restarted container keeps its host
|
|
9
|
+
* name while its pids live in another table, and it is refused until removed by hand.
|
|
10
|
+
*
|
|
11
|
+
* It is NOT true — and must not be declared — where two containers, pods or hosts can have the root mounted at once: several
|
|
12
|
+
* replicas over one volume, or a rolling upgrade during which two generations of a pod both run.
|
|
13
|
+
*/
|
|
14
|
+
export interface DataRootDeclaration {
|
|
15
|
+
/** Every process that opens the data root runs in this one process table. Only the literal `true`. */
|
|
16
|
+
readonly singleProcessTable: true;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Declare a fact about a file data root ({@link DataRootDeclaration}). Call it before the first store over the root is
|
|
20
|
+
* opened; a lock judged before the call was judged without it. Declaring a root twice is declaring it once, and the
|
|
21
|
+
* declaration lasts for the process.
|
|
22
|
+
*
|
|
23
|
+
* The root is resolved exactly as `FileStorageBackend` resolves its own ({@link resolveDataRoot}: NFC-normalized, created
|
|
24
|
+
* if absent, then its physical path), so the declaration names the directory the stores open — and every directory lock at
|
|
25
|
+
* or under it, whichever store or door takes it, reads the declaration.
|
|
26
|
+
*
|
|
27
|
+
* Refused `config.invalid_argument`: a root that is not a non-empty string, a declaration that is not a plain record, a member
|
|
28
|
+
* the declaration does not take, and a `singleProcessTable` that is anything but the literal `true` (`"true"`, `1`, `false`
|
|
29
|
+
* included — a deployment for which the fact does not hold makes no declaration; a member only a prototype supplies is no
|
|
30
|
+
* member). A refused call declares nothing.
|
|
31
|
+
*/
|
|
32
|
+
export declare function declareDataRoot(root: string, declaration: DataRootDeclaration): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { holdSingleProcessTableRoot, resolveDataRoot } from "./fs-atomic.js";
|
|
2
|
+
import { optionKeys, receiptRefusal, receiveMembers } from "../../core/own-property-receipt.js";
|
|
3
|
+
import { describeRejectedValue } from "../../core/tool-search-setting.js";
|
|
4
|
+
const DATA_ROOT_DECLARATION_KEYS = optionKeys()({ singleProcessTable: 0 });
|
|
5
|
+
export function declareDataRoot(root, declaration) {
|
|
6
|
+
if (typeof root !== "string" || root === "") {
|
|
7
|
+
throw receiptRefusal(`declareDataRoot: the data root must be a non-empty path (got ${describeRejectedValue(root)})`);
|
|
8
|
+
}
|
|
9
|
+
if (typeof declaration !== "object" || declaration === null) {
|
|
10
|
+
throw receiptRefusal(`declareDataRoot: the declaration must be a record, { singleProcessTable: true } (got ${describeRejectedValue(declaration)})`);
|
|
11
|
+
}
|
|
12
|
+
const read = receiveMembers(declaration, { subject: "declareDataRoot declaration", unit: "member", moment: "at declareDataRoot" }, DATA_ROOT_DECLARATION_KEYS);
|
|
13
|
+
const value = Object.hasOwn(read, "singleProcessTable") ? read.singleProcessTable : undefined;
|
|
14
|
+
if (value !== true) {
|
|
15
|
+
throw receiptRefusal(`declareDataRoot: singleProcessTable must be the literal true (got ${describeRejectedValue(value)}) — it states that every process ` +
|
|
16
|
+
`opening this data root runs in this one process table; where that does not hold, declare nothing`);
|
|
17
|
+
}
|
|
18
|
+
holdSingleProcessTableRoot(resolveDataRoot(root));
|
|
19
|
+
}
|
|
@@ -246,6 +246,12 @@ export declare class FileStoreLockError extends Error {
|
|
|
246
246
|
* remedy is a person's: remove {@link lockPath} if no process uses the directory.
|
|
247
247
|
*/
|
|
248
248
|
readonly ownerUncheckable?: ProcessUncheckable | undefined;
|
|
249
|
+
/**
|
|
250
|
+
* Present when the lock record is of a version this engine does not read: only its pid was read, so what
|
|
251
|
+
* {@link ownerUncheckable} says is what this engine could read of it — a namespace it shows as missing was
|
|
252
|
+
* not READ, not shown to be unwritten.
|
|
253
|
+
*/
|
|
254
|
+
readonly ownerFingerprintUnread?: true | undefined;
|
|
249
255
|
readonly name = "FileStoreLockError";
|
|
250
256
|
constructor(code: FileStoreLockErrorCode, message: string,
|
|
251
257
|
/** The lock file whose acquisition was refused. */
|
|
@@ -259,15 +265,29 @@ export declare class FileStoreLockError extends Error {
|
|
|
259
265
|
* nothing proves it is, so the refusal is the same `store.dir_in_use` with the cause attached, and the
|
|
260
266
|
* remedy is a person's: remove {@link lockPath} if no process uses the directory.
|
|
261
267
|
*/
|
|
262
|
-
ownerUncheckable?: ProcessUncheckable | undefined
|
|
268
|
+
ownerUncheckable?: ProcessUncheckable | undefined,
|
|
269
|
+
/**
|
|
270
|
+
* Present when the lock record is of a version this engine does not read: only its pid was read, so what
|
|
271
|
+
* {@link ownerUncheckable} says is what this engine could read of it — a namespace it shows as missing was
|
|
272
|
+
* not READ, not shown to be unwritten.
|
|
273
|
+
*/
|
|
274
|
+
ownerFingerprintUnread?: true | undefined);
|
|
263
275
|
}
|
|
276
|
+
/** A store's own words for a lock refusal: the same refusal — its code and everything it says about the owner —
|
|
277
|
+
* said again in `message`, against `lockPath`. */
|
|
278
|
+
export declare function rewordedLockRefusal(err: FileStoreLockError, message: string, lockPath: string): FileStoreLockError;
|
|
264
279
|
/** The clause every refusal of an uncheckable lock owner says, whichever store words the rest — `undefined`
|
|
265
|
-
* for a refusal whose owner was proven running (or that names no owner).
|
|
280
|
+
* for a refusal whose owner was proven running (or that names no owner). A record that names no pid namespace
|
|
281
|
+
* is refused only where the host has not declared the data root's one process table, so its clause also names
|
|
282
|
+
* that declaration, beside the person's remedy — when the declaration would supply what is missing. */
|
|
266
283
|
export declare function uncheckableOwnerClause(err: {
|
|
267
284
|
readonly lockPath: string;
|
|
268
285
|
readonly ownerPid?: number;
|
|
269
286
|
readonly ownerUncheckable?: ProcessUncheckable;
|
|
287
|
+
readonly ownerFingerprintUnread?: true;
|
|
270
288
|
}): string | undefined;
|
|
289
|
+
/** Hold a declared root (its physical path). The door that judges the declaration and resolves the root is `declareDataRoot`. */
|
|
290
|
+
export declare function holdSingleProcessTableRoot(physicalRoot: string): void;
|
|
271
291
|
/**
|
|
272
292
|
* The coarse boot guard (§2.4): an `O_EXCL` owner file (`root/LOCK` for the whole data dir; one per store
|
|
273
293
|
* ledger directory via {@link acquireStoreDirLock}) that forbids two processes sharing it. A second
|