@gajae-code/coding-agent 0.22.1-nightly.20261119123316.45023631557.g22d6c082ce45 → 0.22.1
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 +101 -0
- package/dist/types/cli/public-command-errors.d.ts +11 -3
- package/dist/types/commands/sdk.d.ts +2 -1
- package/dist/types/config/file-lock.d.ts +26 -1
- package/dist/types/exec/bash-shell-guardian.d.ts +1 -1
- package/dist/types/gjc-runtime/tmux-common.d.ts +1 -0
- package/dist/types/gjc-runtime/ultragoal-guard.d.ts +10 -1
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +28 -0
- package/dist/types/internal-urls/local-protocol.d.ts +6 -0
- package/dist/types/sdk/authorization-controls.d.ts +5 -0
- package/dist/types/sdk/broker/broker-exit.d.ts +10 -1
- package/dist/types/sdk/broker/broker.d.ts +71 -9
- package/dist/types/sdk/broker/identity.d.ts +2 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +1 -0
- package/dist/types/sdk/broker/lifecycle.d.ts +31 -1
- package/dist/types/sdk/broker/lock-refusal.d.ts +32 -0
- package/dist/types/sdk/broker/process-incarnation.d.ts +6 -6
- package/dist/types/sdk/broker/session-index.d.ts +18 -2
- package/dist/types/sdk/broker/spawn-authority.d.ts +21 -4
- package/dist/types/sdk/broker/startup-failure.d.ts +40 -7
- package/dist/types/sdk/bus/telegram-daemon-cli.d.ts +3 -2
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
- package/dist/types/sdk/bus/telegram-daemon.d.ts +5 -2
- package/dist/types/sdk/cli/session-cli.d.ts +7 -0
- package/dist/types/sdk/cli/spawn-anchor-attestation-cli.d.ts +9 -1
- package/dist/types/sdk/credential-secrets.d.ts +19 -0
- package/dist/types/sdk/job-observation.d.ts +4 -2
- package/dist/types/session/agent-session.d.ts +16 -4
- package/dist/types/session/session-manager.d.ts +36 -1
- package/dist/types/tools/ask.d.ts +7 -6
- package/dist/types/tools/context.d.ts +5 -0
- package/dist/types/tools/descriptors.d.ts +7 -0
- package/dist/types/tools/ultragoal-ask-guard.d.ts +24 -1
- package/package.json +7 -7
- package/src/cli/accounts-cli.ts +7 -4
- package/src/cli/public-command-errors.ts +50 -7
- package/src/cli/update-cli.ts +41 -3
- package/src/commands/harness.ts +18 -13
- package/src/commands/sdk.ts +130 -14
- package/src/config/file-lock-gc.ts +19 -0
- package/src/config/file-lock.ts +244 -123
- package/src/config/model-equivalence.ts +15 -1
- package/src/config/model-registry.ts +56 -5
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +2 -2
- package/src/defaults/gjc/skills/ultragoal/boundary-cohort-gate.md +1 -1
- package/src/defaults/gjc/skills/ultragoal/terminal-critic-gate.md +1 -1
- package/src/exec/bash-shell-guardian.ts +15 -6
- package/src/export/html/index.ts +13 -17
- package/src/gjc-runtime/session-state-lock.ts +15 -5
- package/src/gjc-runtime/tmux-common.ts +18 -0
- package/src/gjc-runtime/tmux-sessions.ts +1 -18
- package/src/gjc-runtime/ultragoal-guard.ts +17 -4
- package/src/gjc-runtime/ultragoal-runtime.ts +150 -6
- package/src/internal-urls/docs-index.generated.ts +7 -7
- package/src/internal-urls/local-protocol.ts +51 -13
- package/src/modes/acp/acp-agent.ts +23 -2
- package/src/modes/components/model-selector.ts +24 -5
- package/src/prompts/system/master-mode.md +3 -2
- package/src/sdk/activity-controls.ts +45 -13
- package/src/sdk/authorization-controls.ts +61 -1
- package/src/sdk/broker/broker-exit.ts +28 -6
- package/src/sdk/broker/broker.ts +429 -68
- package/src/sdk/broker/discovery.ts +3 -1
- package/src/sdk/broker/ensure.ts +55 -1
- package/src/sdk/broker/identity.ts +5 -0
- package/src/sdk/broker/lifecycle-ledger.ts +60 -3
- package/src/sdk/broker/lifecycle.ts +171 -12
- package/src/sdk/broker/lock-refusal.ts +70 -0
- package/src/sdk/broker/process-incarnation.ts +6 -6
- package/src/sdk/broker/session-index.ts +70 -6
- package/src/sdk/broker/spawn-authority.ts +30 -7
- package/src/sdk/broker/startup-failure.ts +64 -17
- package/src/sdk/bus/chat-daemon-control.ts +2 -2
- package/src/sdk/bus/telegram-daemon-cli.ts +25 -2
- package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
- package/src/sdk/bus/telegram-daemon.ts +11 -2
- package/src/sdk/cli/session-cli.ts +33 -2
- package/src/sdk/cli/spawn-anchor-attestation-cli.ts +90 -20
- package/src/sdk/composer-observation.ts +83 -8
- package/src/sdk/credential-secrets.ts +96 -0
- package/src/sdk/host/session-runtime.test.ts +91 -6
- package/src/sdk/job-observation.ts +10 -1
- package/src/sdk/mcp/server.ts +38 -3
- package/src/sdk/session-readonly/scope.ts +33 -16
- package/src/sdk/session.ts +7 -3
- package/src/sdk/side-conversation.ts +3 -45
- package/src/session/agent-session.ts +162 -15
- package/src/session/session-manager.ts +121 -2
- package/src/slash-commands/aside-command.test.ts +4 -0
- package/src/slash-commands/helpers/aside.ts +2 -1
- package/src/tools/ask.ts +167 -11
- package/src/tools/context.ts +5 -0
- package/src/tools/descriptors.ts +10 -0
- package/src/tools/image-gen.ts +4 -4
- package/src/tools/search.ts +23 -3
- package/src/tools/ultragoal-ask-guard.ts +79 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,107 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.22.1] - 2026-11-24
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Gemini CLI OAuth login flow (`gjc auth-broker login google-gemini-cli` or `/login google-gemini-cli`) now shows an explicit warning about Google account suspension risk before proceeding with authentication. The warning recommends using the Google API key or Vertex AI as safer alternatives (#7900).
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- `gjc --export` now refuses every transcript larger than 128 MiB with a "too large to export" error. Before, such a transcript, including a default-store session, could be exported once while it had no session-memory sidecars yet, by building sidecars in its artifact directory (in the managed store for default-store sessions); a later export of the same file was already refused.
|
|
14
|
+
- `gjc --export` no longer repoints this terminal's `gjc --continue` at the exported session.
|
|
15
|
+
|
|
16
|
+
- **Breaking (SDK):** Documented the `MapReduceInput` field rename that shipped in 0.19.0 (#7109) without a migration note. On the type exported from `@gajae-code/coding-agent/commit/map-reduce`, `smolModel` is now `secondaryModel`, `smolApiKey` is now `secondaryApiKey`, and `smolThinkingLevel` is now `secondaryThinkingLevel`. The old names are not accepted as aliases; callers of `runMapReduceAnalysis` must pass the new field names.
|
|
17
|
+
|
|
18
|
+
- The Ultragoal ask guard now admits one `ask` once a human-only blocker is verified: the latest `blocker_classified` event is `human_blocked` and a fresh clean pause terminal-critic verdict is bound to it. Previously `ask` stayed blocked regardless of classification, so a run that was allowed to park for the user could not put the human-only request to them as a structured question. Each `human_blocked` classification admits a single answered `ask` carrying exactly one question (reserved in the ledger before the question opens and recorded as a `human_blocked_ask_answered` event once it is answered; a cancelled ask, an `ask.timeout` auto-selection, or a question about the choices spends nothing; if the answer cannot be recorded it is still returned and the reservation keeps the admission closed, including after a restart), and unlike `goal({"op":"pause"})` no try-harder nudge is spent first. `resolvable`, unverified, rejected, stale, already-spent, and other-session receipts still block `ask`.
|
|
19
|
+
- The human-blocked ask is admitted only in an interactive session; headless answer sources are refused, because the pause verdict is recorded through the session's own CLI and is not independent proof. The reservation recheck also holds the plan lock, so a required-goal change cannot slip in between.
|
|
20
|
+
- Human-blocked ask settlement reads its ledger row back by event id when the append reports a failure, so a row that committed before its audit entry or session activity marker failed is reported as the decision it recorded. Other ledger appends still fail when the activity marker cannot be written, because implicit session resolution depends on it.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- `gjc accounts prefer` can store an organization ID when exactly one active OAuth credential belongs to that organization, even if a disabled credential shares the ID.
|
|
25
|
+
|
|
26
|
+
- `gjc sdk search`, `gjc sdk session list`, and the master peer snapshot show a `spawnedBy` owner (and therefore `self: true`) only on a row from the state root the spawned child's host registered in. Spawn authority is keyed by session id alone, so a session id claimed by more than one state root, or reused by another host after the child stopped, could otherwise name a master that never spawned that row. The master-mode guidance and SDK docs now state that `spawnedBy.self` is an advisory display hint that grants no permission: nothing checks it before send, steer, interrupt, or close.
|
|
27
|
+
|
|
28
|
+
- Reading the SDK broker restart intent no longer fails with `ENOENT ... lstat '<agent>/sdk/broker.restart.json'` when the authorized successor clears the intent during the read. The cleared intent now reads as absent. Before, the race could refuse an ordinary broker startup.
|
|
29
|
+
|
|
30
|
+
- `gjc --export` no longer writes to the session it exports. Before this fix, an export could append replay-metadata patch records to the transcript, rewrite an older-version transcript in the current format, build session-memory sidecar files and a build-lock file in the session's artifact directory, and delete a legacy `.jsonl.spill.*` sidecar next to the transcript. Export now loads a read-only snapshot that never writes to the transcript, its artifact directory, the managed session store, or the terminal breadcrumb, and the HTML output is unchanged.
|
|
31
|
+
- `gjc --export` now exports a legacy v1 transcript that contains a compaction. Before, it failed with `cold_transcript_header_invalid` and could leave partial session-memory sidecar files in the source's artifact directory.
|
|
32
|
+
- If the source transcript disappears while `gjc --export` is opening it, export now reports `File not found` instead of creating a new empty session at that path.
|
|
33
|
+
|
|
34
|
+
- `gjc gc` no longer fails with `EPERM: operation not permitted, scandir '<file>.lock.removing'` on Windows when it runs while another `gjc` process is releasing a file lock. File-lock discovery no longer descends into a lock's removal transition, which never contains a lock.
|
|
35
|
+
|
|
36
|
+
- A detached `gjc harness start` launched without a UTF-8 locale (launchd, cron, a service manager) can start and clean up its tmux-resident owner again. The tmux clients that the harness runs on the owner's private socket now pass `-u`, like the managed-session clients fixed earlier. Before this, tmux replaced the tab in the session binding reply with `_`, so startup failed with `tmux-owner-native_session_identity_unproven` and cleanup reported `tmux-owner-cleanup_uncertain`. On Linux service launches that take the scoped systemd-run bootstrap, the bootstrap's server proof parsed a tab-separated reply through the same client prefix and failed earlier with `tmux-owner-scope_bootstrap_failed`. psmux and interactive attach are unchanged.
|
|
37
|
+
|
|
38
|
+
- Fix Orca setup instructions in `docs/terminal-app-integrations.md` and `README.md`. Previous docs told users to open "Settings → Agents" and add a custom agent, but Orca does not support custom agent registration yet ([stablyai/orca#36718](https://github.com/stablyai/orca/issues/36718)). Instructions now show the workaround: override a built-in agent's command with `gjc`, or run `gjc` directly in the worktree terminal. Support rating downgraded from ★★★★☆ to ★★★☆☆ and linked to upstream feature-request and PR issues.
|
|
39
|
+
|
|
40
|
+
- Codex image generation requests no longer send the legacy `conversation_id` header; the session identifier goes out only as `session_id`, matching the Codex CLI behavior.
|
|
41
|
+
|
|
42
|
+
- IRC-sourced steering exchanges are now deferred to the next natural tool boundary instead of immediately interrupting tool execution, allowing sibling tools to complete naturally without being skipped.
|
|
43
|
+
- Skip result messages now correctly identify the source of steering: for IRC exchanges, the peer name is included (e.g., "Skipped due to incoming IRC message from <peer>"), and for real user interrupts, "user message" is used.
|
|
44
|
+
|
|
45
|
+
- SDK sessions now properly restore native goal state when resuming a saved session and set up the accounting baseline for active goals. Previously, closing a session with an active or paused goal and then resuming it would lose the goal mode state, requiring users to manually recreate the goal, and token accounting would not be initialized for active goals. The goal mode state is now recovered from the durable session branch during initialization, and `onThreadResumed()` is called to establish the token accounting baseline, matching the behavior of interactive goal mode (#7947).
|
|
46
|
+
- When an SDK session is created with explicit empty tool selection (`--no-tools`), persisted goals are no longer restored to prevent automatic continuation attempts with no way to interact with the goal tool. Goals remain accessible through interactive goal mode where the command interface is available (#7947).
|
|
47
|
+
|
|
48
|
+
- Synchronous `local://` resolution (transcript links, edits, session plan paths) no longer fails with `local:// legacy migration must complete before path resolution` for a managed session that has no legacy `artifacts/<id>/local` tree. The resolver now records the `absent` marker for a provably missing legacy tree instead of leaving a marker-less `gjc-local/<id>` directory; sessions that may hold legacy data, or are mid cwd move, still wait for the async migration.
|
|
49
|
+
- A synchronous `C:UsersSJAppDataLocalTempgjc-local01a1e8cb-4652-71fc-91ab-68153b216f06` resolution refused by a pending legacy migration no longer creates an empty `gjc-local/<session-id>` directory first. Each refusal used to leave one marker-less root behind, and local-root cleanup never removed it because it only prunes marker-only roots.
|
|
50
|
+
|
|
51
|
+
- Session listing, including `/resume`, no longer probes a legacy session's migration receipt once per v2 transcript. Coalescing migrated sessions checked the receipt for every (legacy session, v2 transcript) pair in two passes. Each check hashed the receipt name and attempted a no-follow open, so listing slowed down with legacy sessions × v2 sessions. The listing now looks up each legacy session's receipt once to find the destination it names, and runs the existing receipt verification only for that destination. With 553 legacy and 214 v2 sessions, `/resume` opened in about 11 s and now opens in about 5.4 s. The same sessions are listed with the same migration state.
|
|
52
|
+
|
|
53
|
+
- Typing the first character on the `/model` preset list no longer stalls when `models.yml` declares `equivalence` overrides or exclusions. Each catalog refresh reloads that config as a new object, which was compiled anew and discarded the per-model canonical resolution reuse added in #7709, so every rebuild re-ran the full canonical heuristics. A reloaded config with the same content now reuses the compiled config and its resolutions. Measured on a 5,138-model catalog with 19 exclusions: about 240 ms per canonical index rebuild before, about 10 ms after.
|
|
54
|
+
|
|
55
|
+
- Arrow keys on the `/model` preset list no longer stall. Each preset-row build re-merged and re-finalized the credential-scoped catalog once per role selector, and finalizing scanned every runtime and config overlay for each model to restore declared thinking. A row build now reads the scoped catalog at most once whatever the number of role overrides, and catalog finalization and session-scoped discovery merges index overlays and base models once per pass. Measured with a 232-entry `models.yml`: about 900 ms per arrow key before, about 165 ms after.
|
|
56
|
+
|
|
57
|
+
- A `busy` or `endpoint_stale` refusal from `gjc sdk session raw global --op session.close` now gets the same recovery step as `gjc sdk session close`: a busy close recommends inspecting the session, waiting until it is idle and rerunning the same close with the same key, instead of steering the active turn.
|
|
58
|
+
|
|
59
|
+
- A legacy host-unqualified, foreign-host or live-owner `sdk/broker.lock` no longer ends the detached SDK broker with `[Uncaught Exception]` and a crash record. The broker records a typed `startup-lock-refused` exit and `gjc sdk broker run` prints the lock path, refusal code and recovery step to stderr, then exits with status 1 through the public failure output as `broker_unavailable` with the `lock_refused` diagnostic. The lock is never displaced automatically.
|
|
60
|
+
- `gjc sdk session` commands now return `broker_unavailable` with a fixed `lock_refused` diagnostic when broker startup refuses an existing lock, instead of a generic `operation_failed`. The next step tells the operator to resolve the lock owner first and carries no runnable command, because any broker-contacting command would only be refused again. The refusal is reported even when the broker could only persist its startup-failure marker. If cleaning up the spawned broker also failed, the result adds a `broker_cleanup_unverified` diagnostic.
|
|
61
|
+
|
|
62
|
+
- `session.close` with `ifIdle` now refuses `busy` while a session recap request is still open, instead of accepting the close and aborting the recap.
|
|
63
|
+
- `gjc sdk session close --if-idle` rejects a `--json-input` whose `ifIdle` is not `true` as a usage error before contacting the broker, instead of silently overriding it.
|
|
64
|
+
- A `busy` refusal from `gjc sdk session close` now recommends inspecting the session, waiting until it is idle and rerunning the same close, rather than steering the active turn; an `endpoint_stale` close refusal now explains that its key is terminal and the session must be inspected before any new close.
|
|
65
|
+
- `gjc sdk session close` for an indexed session without live endpoint authority now reports `endpoint_stale` with `outcomeCertainty: "not-applied"`, since it refuses before sending any close.
|
|
66
|
+
|
|
67
|
+
- SDK composer/HUD observations (`info`, `catalog`, `complete`) and the factory `jobObservation` view now stay readable while MCP control admission is held (an MCP suspend, resume or reconnect, or an internal conventional `/mcp` connect, disconnect or reconnect or exact-config suspend, resume or reconnect). Previously reads failed with `session_transitioning`, and any read of `jobObservation` during the admission disposed the view, which left bound activity controls permanently `stale_session` afterwards. Factory job mutations (monitor/task cancel, pause, resume, cron delete, failure acknowledgement) are refused with `session_transitioning` for the duration of MCP admission. Internal MCP paths that commit a new generation still retire the view, at the first getter read after the commit; behaviour outside MCP admission is unchanged.
|
|
68
|
+
|
|
69
|
+
- SDK activity controls no longer expose stored credentials in display fields. Job, task and cron labels, task model names, cron expressions and prompts, MCP server names and monitor output now show `[REDACTED]` in place of any stored API key, OAuth token or structured key token. Fields are masked before the SDK's own display limits, so those limits cannot cut a credential into a visible prefix. A value that was already cut upstream and ends in `...` or `…`, such as a long bash command label, has a trailing credential prefix of at least 8 characters masked as well; monitor output gets the same treatment at both ends of its retained window. Opaque refs and the controls they drive still act on the real job, task, cron or server.
|
|
70
|
+
- SDK activity `getDetail()` reports `outputTruncated` only when the masked output exceeds the output limit.
|
|
71
|
+
- SDK composer observation `info()` no longer exposes stored credentials in session name, cwd, model provider, id and name, model profile or HUD branch. A credential split by control characters, tabs, line breaks or U+2028/2029 is masked as well, and a field that contains ANSI escapes is replaced entirely by `[REDACTED]` when it contains a stored credential once its other controls are removed.
|
|
72
|
+
|
|
73
|
+
- Include configured custom providers with empty model catalogs in API-key enrollment/status without exposing credential bytes.
|
|
74
|
+
|
|
75
|
+
- `gjc sdk broker attest-spawn-anchors` now refuses a lifecycle ledger past the bounds the broker applies when it opens it (64 MiB, 10,000 rows, 8 MiB per row by default, shared with `LifecycleLedger`), so it no longer reports or writes an attestation the broker would never load. It also refuses an existing attestation larger than that byte bound or listing anything other than lowercase 64-character hex identities instead of republishing it, does not publish a union past the byte bound, and refuses an agent directory no broker can run for (follow-up to #7533).
|
|
76
|
+
- The restart notice printed after `--write` now names the selected agent directory, shell-quoted, in every route: the supervisor route for `gjc sdk broker run --agent-dir <dir>`, `gjc doctor --check service` and `gjc doctor --fix --repair service.restart-owned --target <id> --allow-risk service-interruption --yes` (both with `GJC_CODING_AGENT_DIR` set to that directory) for a running on-demand broker in installed builds, and `bun run restart:sdk-broker -- --agent-dir <dir>` for source checkouts only (follow-up to #7533).
|
|
77
|
+
- `/aside` MCP registration and REPL hints on native Windows now escape typographic single quotes (U+2018 through U+201B) in the quoted CLI path, which PowerShell also treats as single-quote delimiters.
|
|
78
|
+
|
|
79
|
+
- The restart notice printed by `gjc sdk broker attest-spawn-anchors --write` on Windows now says its commands are quoted for PowerShell, because cmd.exe passes the single quotes through literally. Its on-demand fallback now also says the next `gjc sdk session`, `search` or `spawn` command starts a broker only when broker autostart is on (not `GJC_SDK_BROKER_AUTOSTART=0`) and the command does not run with `--attach-only`.
|
|
80
|
+
|
|
81
|
+
- SDK broker startup no longer stalls when `sdk/lifecycle-ledger.spawn-anchor-attestation.json` is a FIFO. The optional attestation is now read through one descriptor that must be a regular file within the lifecycle ledger byte bound, opened nonblocking and no-follow on POSIX; a FIFO, device, symlink (POSIX), or oversized file is ignored with a warning and pre-marker spawn mirrors stay fenced (follow-up to #7253).
|
|
82
|
+
|
|
83
|
+
- `gjc sdk spawn` no longer refuses a timely child host when another process holds the global session index lock until about 8.7 s past the admission deadline. The post-deadline registration recheck now lasts up to 20 s instead of 8 s, and still admits a late host only on its startup commit record. The recheck ends as soon as the outcome is decided: when the host's failure receipt becomes readable or the host process has provably exited, which also ends a wait for the index lock. A completed index read showing that the host's recorded row no longer matches stops further index reads, but the refusal still waits (within the bound) for the receipt or the exit, because a host rolling back unregisters before it writes its receipt; when the receipt becomes readable, the refusal reports `child_registration_failed` instead of a timeout. A mismatched row whose host neither writes a receipt nor exits is now refused at the 20 s bound rather than at once. An owner whose process incarnation cannot be read, or that the OS cannot open or query (as on Windows, where such a pid has no process reference), is treated as uncertain and keeps the recheck open; only OS-confirmed absence or a changed incarnation counts as exit, and a row that fails only the read-time liveness check also keeps it open, until the outcome is decided or the 20 s bound passes.
|
|
84
|
+
|
|
85
|
+
- `spawnedBy` on `gjc sdk search`, `gjc sdk session list` and `inspect`, and master peer snapshot rows is matched against the canonical (symlink-resolved) state root recorded when the spawned child registered. Previously the stored path spelling was re-resolved at listing time, so retargeting a symlinked state root could attach the old owner to a different host that later reused the child's session id. Spawn authority recorded before this change carries no canonical root, so its children (including ones still running across the upgrade) no longer show an owner on any row. An older Broker refuses to start against an agent directory whose spawn journal was written by this version, which affects downgrading or running a pinned older gjc against the same agent directory.
|
|
86
|
+
|
|
87
|
+
- `gjc sdk spawn` no longer rejects a child host that registered and published readiness in time with `child_registration_timeout` just because the broker observed it late. A session index read that began within the 8 s admission deadline is evaluated against the full identity, authority and liveness check, waiting in the index queue or on the index lock is bounded by the remaining budget, and each poll projects only the awaited child. When no registration row was observed in time but the host published readiness, is still live and wrote no failure receipt, the broker takes one more bounded observation (up to 20 s after the first observation ends) under the same checks, so index lock contention that outlasts the first observation by up to that much no longer rejects a timely host. A registration observed after the deadline is admitted only on the host's startup commit: a record the host writes only after startup completed and can no longer roll back. The commit, the owner and readiness markers must all name the launch, the owner must still be live, and no failure receipt may exist; a host that published readiness but lost its final cutoff check never writes it, so it is never admitted late. Hosts without the commit record are refused when observed late. A host that rolled back at its cutoff is reported as `child_registration_failed` when its failure receipt is observed before the broker settles the spawn, and as `child_registration_timeout` otherwise.
|
|
88
|
+
- A `child_registration_timeout` failure message now says whether no registration row was observed near the deadline, a row was observed but did not match the launched host, the session index could not be read in time, or the host registered but never confirmed readiness, and notes when a post-deadline recheck was taken.
|
|
89
|
+
|
|
90
|
+
- A TTSR rule with `interruptMode: "tool-only"` now interrupts a tool call once when a published tool-argument delta matches and the role default is a managed model fallback chain. Previously the staged attempt was published only after the provider finished, so the abort arrived after the message ended with `toolUse`: the tool was entered and then aborted, and every replayed delta fired the rule again (7 to 10 triggers for one call). The accepted attempt now waits for its published events, ends `aborted` when a subscriber aborted during that delivery, and TTSR checks each assistant stream at most once after it interrupts it, including when a slow `message_start` extension hook delays the next stream's start handling.
|
|
91
|
+
|
|
92
|
+
- **Ultragoal ask guard**: Enforce one-question settlement for custom ask tools. Only the built-in `AskTool` is now permitted for human-blocked ask admissions, preventing custom/extension tools from bypassing durable reservation and settlement accounting (#7799).
|
|
93
|
+
- **Ultragoal ask guard**: An `ask` tool that carried the guard's marker, or that the guard had already wrapped once, was handed back unguarded the next time it was wrapped, so a custom `ask` could run while a run was active. The guard now tracks the wrappers it built itself (#7799).
|
|
94
|
+
|
|
95
|
+
- `gjc update` no longer stays blocked by a leftover staged or pending activation record after the installed binary was reinstalled or swapped outside gjc, as long as that record never started promotion. Records whose promotion may have reached the binary, and records created when no binary existed yet, still require reconciliation.
|
|
96
|
+
|
|
97
|
+
- The Windows installer downloads release assets with the system `curl.exe` (Windows 10 1803 and later) instead of from inside `powershell.exe`, and shows curl's progress bar for the ~160 MB binary. On one machine with AhnLab V3 Internet Security, downloads made from `powershell.exe` ran at 0.3-0.55 MB/s, an install taking several minutes to hours, while `curl.exe` ran at 46-84 MB/s from the same network at the same time; the link to that software is not proven. `curl.exe` uses the proxy `Invoke-WebRequest` would use (`[WebRequest]::DefaultWebProxy`, honouring its bypass list) and ignores proxy environment variables when that is a direct connection; a PAC file with different rules for the redirect host is not honoured. If `curl.exe` is missing or fails without an HTTP error status, the installer warns and falls back to `Invoke-WebRequest` (which shows no progress); an HTTP error status stays final. A download that fails now reports the cause instead of "No prebuilt GJC binary was found".
|
|
98
|
+
|
|
99
|
+
- Closing the window or killing the process during a Windows install no longer leaves `.gjc-install.lock` behind to block every later install with "Another GJC installer is already running". The installer holds the lock open with `DeleteOnClose` for the whole install, so Windows removes it however the installer ends, and a running installer still refuses others. A lock left by an older installer is reclaimed only when its recorded process has exited.
|
|
100
|
+
- The Windows installer can now replace a `gjc.exe` that is running. It renames the old binary aside and moves the new one in without overwriting; if publishing or the post-install check fails it renames the old binary back and reports the original error. The backup path is printed only if that restore failed; otherwise the backup is removed (if it is still in use, as when gjc was running during the install, it is kept as a full-size `.gjc.bak.<id>` file in the install directory and its path is printed; the installer never deletes unknown files by name, so delete that file yourself after closing gjc).
|
|
101
|
+
- When `gjc update` holds `.gjc-install.lock` (its lock is a directory), the installer now says so, with the owner process id and whether it is still running, instead of reporting another installer and advising removal of a lock file. It never removes that lock.
|
|
102
|
+
|
|
103
|
+
- On Windows, concurrent `gjc` processes no longer fail each other's file-lock release and acquisition with `Failed to roll back file lock published during removal transition: owner_mismatch`. The native `access_denied` that NTFS reports while a peer holds a handle inside the lock directory is now treated like `sharing_violation` in file-lock and session-state-lock release, the publication rollback is retried briefly, and exhaustion names the real code. File-lock removal refusals reported to `removeFileLockDirForGc` callers now carry `access_denied` / `sharing_violation` instead of `EACCES`.
|
|
104
|
+
- Lock waiters open, read, and close `<lock>/info` in one synchronous step per poll instead of holding the handle across awaits, which previously blocked the owner's rename of the lock directory. On Windows, an owner record that is refused while another process is removing it (`EPERM`, `EACCES`, `EBUSY`, or `EBADF`) is treated as a changing lock: the waiter polls again, the timeout message says the record is being replaced, and a Windows `EBADF` from a lock identity capture is contention like the other transient codes. `gjc gc --disk` reports a lock tree whose removal Windows refuses as `withheld` rather than `entry_remove_failed: owner_mismatch`. Behavior on other platforms is unchanged.
|
|
105
|
+
|
|
5
106
|
## [0.22.0] - 2026-11-19
|
|
6
107
|
|
|
7
108
|
### Added
|
|
@@ -21,6 +21,12 @@ export interface PublicCommandFailureInput {
|
|
|
21
21
|
*/
|
|
22
22
|
partialResults?: readonly DaemonOperationResult[];
|
|
23
23
|
diagnostics?: readonly PublicCommandDiagnosticCode[];
|
|
24
|
+
/**
|
|
25
|
+
* The failed request was a `session.close` lifecycle mutation. Set where the command path does
|
|
26
|
+
* not say so (`sdk session raw global --op session.close`), so close refusals get the same
|
|
27
|
+
* recovery guidance as `sdk session close`.
|
|
28
|
+
*/
|
|
29
|
+
sessionClose?: true;
|
|
24
30
|
}
|
|
25
31
|
export declare class PublicCommandFailure extends Error {
|
|
26
32
|
readonly input: PublicCommandFailureInput;
|
|
@@ -75,10 +81,10 @@ export type PublicEvidenceStatus = {
|
|
|
75
81
|
};
|
|
76
82
|
export declare const PUBLIC_COMMAND_DIAGNOSTICS: {
|
|
77
83
|
readonly spawn_anchor_identity_unavailable: "The original sdk/broker.identity is missing, invalid, or unreadable. Restore the original identity key before attesting spawn mirrors.";
|
|
78
|
-
readonly spawn_anchor_attestation_invalid: "The existing spawn-anchor attestation is malformed or
|
|
79
|
-
readonly spawn_anchor_ledger_invalid: "The lifecycle ledger is malformed, unsupported, or
|
|
84
|
+
readonly spawn_anchor_attestation_invalid: "The existing spawn-anchor attestation is malformed, unreadable, larger than the lifecycle ledger byte bound, or lists an entry that is not a lowercase 64-character hex identity. Preserve it and investigate before writing.";
|
|
85
|
+
readonly spawn_anchor_ledger_invalid: "The lifecycle ledger is malformed, unsupported, unreadable, or past the bounds the broker applies when it opens it. No attestation was written.";
|
|
80
86
|
readonly spawn_anchor_journal_invalid: "The spawn-authority journal failed authenticated replay validation or could not be read. No attestation was written.";
|
|
81
|
-
readonly spawn_anchor_write_failed: "Spawn-anchor attestation publication failed before rename. The previous attestation was not replaced.";
|
|
87
|
+
readonly spawn_anchor_write_failed: "Spawn-anchor attestation publication failed before rename, or the union would exceed the byte bound the broker loads. The previous attestation was not replaced.";
|
|
82
88
|
readonly spawn_anchor_publication_uncertain: "The attestation was renamed, but its durability could not be confirmed. Inspect the existing attestation before any retry; it may take effect at the next broker start.";
|
|
83
89
|
readonly spawn_anchor_output_failed: "Attestation processing finished, but its result could not be emitted. Inspect the existing attestation before any retry.";
|
|
84
90
|
readonly macos_nofile_limit_low: "The macOS open-file limit is below the recommended minimum; increase it before starting additional concurrent work.";
|
|
@@ -91,6 +97,8 @@ export declare const PUBLIC_COMMAND_DIAGNOSTICS: {
|
|
|
91
97
|
readonly lifecycle_idempotency_conflict: "The broker reported an idempotency conflict. Reconcile existing lifecycle state before deciding whether another request is safe.";
|
|
92
98
|
readonly lifecycle_legacy_history_ambiguous: "The broker refused admission because legacy lifecycle history cannot prove this target is unrelated. This request was not dispatched; this refusal does not settle earlier effects. Preserve the ledger and original operation, request key, and target. For a prior session.create, use read-only session.lookup with its original key and create target; not_found is not proof of no effect. An empty transcript, stopped host, or fresh key does not resolve this fence. Do not edit the ledger, force deletion, or retry with another key; missing identity or terminal effect evidence requires operator investigation.";
|
|
93
99
|
readonly lifecycle_input_refused: "The broker refused the request as invalid input. Correct the request payload and reconcile existing lifecycle state before deciding whether another request is safe.";
|
|
100
|
+
readonly broker_cleanup_unverified: "SDK broker startup failed and cleanup of the spawned broker could not be verified; it may still be running.";
|
|
101
|
+
readonly lock_refused: "SDK broker startup refused an existing broker lock held by a live, foreign-host or host-unqualified owner. The lock is never displaced automatically.";
|
|
94
102
|
readonly usage_transport_exclusive: "Specify exactly one of --stdio or --socket <path>.";
|
|
95
103
|
readonly usage_duplicate_option: "Each option on this command may occur at most once.";
|
|
96
104
|
readonly usage_unknown_argument: "An unrecognized argument was supplied; re-read the command help for its accepted grammar.";
|
|
@@ -4,7 +4,7 @@ import type { Args as ParsedArgs } from "../cli/args";
|
|
|
4
4
|
import { applyStartupModelProfiles } from "../main";
|
|
5
5
|
import { initializeExtensions } from "../modes/runtime-init";
|
|
6
6
|
import { initTheme } from "../modes/theme/theme";
|
|
7
|
-
import { type SessionLifecycleLaunchRequest, writeSessionLifecycleReady } from "../sdk/broker/lifecycle";
|
|
7
|
+
import { type SessionLifecycleLaunchRequest, writeSessionLifecycleReady, writeSessionLifecycleStartupCommit } from "../sdk/broker/lifecycle";
|
|
8
8
|
import { createLifecycleAgentSession } from "../sdk/lifecycle-session";
|
|
9
9
|
import { SessionManager } from "../session/session-manager";
|
|
10
10
|
export declare function lifecycleArgs(request: SessionLifecycleLaunchRequest, cwd: string, agentDir: string): Promise<ParsedArgs>;
|
|
@@ -135,6 +135,7 @@ export declare function runSessionHost(timing?: {
|
|
|
135
135
|
openLifecycleSessionManager?: typeof openLifecycleSessionManager;
|
|
136
136
|
createLifecycleAgentSession?: typeof createLifecycleAgentSession;
|
|
137
137
|
writeSessionLifecycleReady?: typeof writeSessionLifecycleReady;
|
|
138
|
+
writeSessionLifecycleStartupCommit?: typeof writeSessionLifecycleStartupCommit;
|
|
138
139
|
writeMcpConfig?: (filePath: string, contents: string) => Promise<number>;
|
|
139
140
|
}): Promise<void>;
|
|
140
141
|
export type SdkInternalArgv = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NativeDirectoryTreeResult, NativeDirectoryTreeSnapshot, NativeExactUnlinkResult } from "@gajae-code/natives";
|
|
2
|
-
import { renameDirectoryNoReplacePathAsync, renameNoReplacePathAsync } from "@gajae-code/natives";
|
|
2
|
+
import { exactRestore, renameDirectoryNoReplacePathAsync, renameNoReplacePathAsync } from "@gajae-code/natives";
|
|
3
3
|
export interface FileLockOptions {
|
|
4
4
|
staleMs?: number;
|
|
5
5
|
/** Age after which an ownerless removal transition may be adopted; defaults to `staleMs`. */
|
|
@@ -70,6 +70,13 @@ export declare const FILE_LOCK_ORPHAN_TRANSITION_ADOPTION_AGE_MS: number;
|
|
|
70
70
|
/** Release retries cover transient handle denial and a competing exact-removal quarantine cleanup. */
|
|
71
71
|
export declare const FILE_LOCK_RELEASE_RETRY_ATTEMPTS = 20;
|
|
72
72
|
export declare const FILE_LOCK_RELEASE_RETRY_DELAY_MS = 25;
|
|
73
|
+
/**
|
|
74
|
+
* Rolling back a publication that raced a predecessor's retirement renames the published
|
|
75
|
+
* directory, which a peer handle inside it refuses (STATUS_ACCESS_DENIED) until that
|
|
76
|
+
* handle closes. The generation is already published, so the refusal is retried briefly
|
|
77
|
+
* rather than abandoning it; a release has its own outer retry for the detach rename.
|
|
78
|
+
*/
|
|
79
|
+
export declare const FILE_LOCK_ROLLBACK_RETRY_ATTEMPTS = 12;
|
|
73
80
|
export declare const FileLockTestHooks: {
|
|
74
81
|
afterParentMkdir?: (lockPath: string) => void | Promise<void>;
|
|
75
82
|
afterStagingInfoWrite?: (stagingPath: string) => void | Promise<void>;
|
|
@@ -95,7 +102,13 @@ export declare const FileLockTestHooks: {
|
|
|
95
102
|
processIncarnation?: (pid: number) => string | null;
|
|
96
103
|
nativeQuarantineBindings?: () => NativeFileLockBindings;
|
|
97
104
|
nativeExactRemovalProbe?: () => boolean | Promise<boolean>;
|
|
105
|
+
nativeRestoreBinding?: () => typeof exactRestore;
|
|
98
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Native STATUS_ACCESS_DENIED / STATUS_SHARING_VIOLATION from a lock operation: another
|
|
109
|
+
* process briefly holds a handle inside the tree. Contention, never an ownership verdict.
|
|
110
|
+
*/
|
|
111
|
+
export declare function isNativeLockContentionCode(code: string | undefined): code is "access_denied" | "sharing_violation";
|
|
99
112
|
/**
|
|
100
113
|
* Returns the OS-provided process start timestamp for PID-reuse detection.
|
|
101
114
|
* `ps` is available on the supported Unix hosts (macOS and Linux), unlike
|
|
@@ -108,6 +121,13 @@ export declare const FileLockTestHooks: {
|
|
|
108
121
|
* treated as reused.
|
|
109
122
|
*/
|
|
110
123
|
export declare function processStartTime(pid: number): string | null;
|
|
124
|
+
/**
|
|
125
|
+
* Windows refuses to open or stat an `<lock>/info` that another process is deleting or
|
|
126
|
+
* retiring: EPERM/EACCES/EBUSY from open, EBADF from Bun's lstat. None of them is a
|
|
127
|
+
* verdict about the owner; the record is changing under the observer, which must observe
|
|
128
|
+
* again. On POSIX these codes are real permission failures.
|
|
129
|
+
*/
|
|
130
|
+
export declare function isLockInfoChangingError(error: unknown): boolean;
|
|
111
131
|
/** @internal */
|
|
112
132
|
export interface FileLockGcObservation {
|
|
113
133
|
info: FileLockOwnerToken;
|
|
@@ -131,6 +151,11 @@ export interface FileLockOwnerToken {
|
|
|
131
151
|
owner_token?: string;
|
|
132
152
|
timestamp: number;
|
|
133
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* @internal Whether a directory name is a lock's removal transition. It holds the retiring
|
|
156
|
+
* owner's record while that owner deletes it, so it never contains a lock.
|
|
157
|
+
*/
|
|
158
|
+
export declare function isFileLockRemovalTransitionName(name: string): boolean;
|
|
134
159
|
/** Outcome of a guarded lock-dir removal attempt (`removeFileLockDirForGc`). */
|
|
135
160
|
export type FileLockGcRemoval = "removed" | "owner_changed" | "missing" | "cleanup_failed";
|
|
136
161
|
/**
|
|
@@ -11,7 +11,7 @@ export declare function extendOwnedDarwinAncestry<T extends {
|
|
|
11
11
|
uniqueId: bigint;
|
|
12
12
|
parentUniqueId: bigint;
|
|
13
13
|
}>(knownUniqueIds: Set<bigint>, candidates: ReadonlyMap<number, T>): number[];
|
|
14
|
-
export declare function authenticateOwnershipRecord(line: string, ledgerToken: string): {
|
|
14
|
+
export declare function authenticateOwnershipRecord(line: string, ledgerToken: string, processBindings?: Pick<typeof NativeProcess, "fromPid" | "observe">): {
|
|
15
15
|
processRef?: NativeProcess;
|
|
16
16
|
darwinUniqueId?: bigint;
|
|
17
17
|
pending?: true;
|
|
@@ -17,6 +17,7 @@ export declare const GJC_TMUX_OWNER_GENERATION_OPTION = "@gjc-owner-generation";
|
|
|
17
17
|
export declare const GJC_TMUX_OWNER_SERVER_KEY_OPTION = "@gjc-owner-server-key";
|
|
18
18
|
export declare const GJC_TMUX_VERSION_OPTION = "@gjc-version";
|
|
19
19
|
export declare const GJC_PSMUX_PROFILE_FORCE_ENV = "GJC_PSMUX_PROFILE_FORCE";
|
|
20
|
+
export declare function tmuxClientFlags(isPsmux: boolean): string[];
|
|
20
21
|
export interface GjcTmuxProfileCommand {
|
|
21
22
|
description: string;
|
|
22
23
|
args: string[];
|
|
@@ -77,6 +77,10 @@ export declare function isUltragoalBypassPrompt(prompt: string): boolean;
|
|
|
77
77
|
export interface UltragoalPauseBlockDiagnostic {
|
|
78
78
|
blocked: boolean;
|
|
79
79
|
reason: string;
|
|
80
|
+
/** Event id of the `human_blocked` classification, set only when its verified receipt is what allows the pause. */
|
|
81
|
+
classificationEventId?: string;
|
|
82
|
+
/** Whether that classification's single `ask` was already spent on an answered question. */
|
|
83
|
+
askSpent?: boolean;
|
|
80
84
|
}
|
|
81
85
|
/**
|
|
82
86
|
* While an Ultragoal run is active, `goal({"op":"pause"})` is only allowed when the
|
|
@@ -84,8 +88,13 @@ export interface UltragoalPauseBlockDiagnostic {
|
|
|
84
88
|
* event is `human_blocked`, and a later fresh clean pause terminal critic verdict is bound to
|
|
85
89
|
* that exact classification. Reads fail closed so unreadable durable state or
|
|
86
90
|
* ledger data blocks pause rather than silently allowing a give-up.
|
|
91
|
+
*
|
|
92
|
+
* `options.sessionId` pins every read to one session's run. The ask guard passes
|
|
93
|
+
* the asking session so another session's pause receipt can never admit its ask.
|
|
87
94
|
*/
|
|
88
|
-
export declare function isUltragoalPauseBlocked(cwd: string
|
|
95
|
+
export declare function isUltragoalPauseBlocked(cwd: string, options?: {
|
|
96
|
+
sessionId?: string | null;
|
|
97
|
+
}): Promise<UltragoalPauseBlockDiagnostic>;
|
|
89
98
|
export declare function assertUltragoalPauseAllowed(cwd: string, agentDir?: string): Promise<void>;
|
|
90
99
|
/**
|
|
91
100
|
* Guard `goal({"op":"drop"})` during an active Ultragoal run. A *real give-up* (an
|
|
@@ -209,6 +209,34 @@ export declare function recordUltragoalNudgeIfBudgetRemaining(input: {
|
|
|
209
209
|
reason: string;
|
|
210
210
|
currentGoalObjective?: string;
|
|
211
211
|
}): Promise<UltragoalNudgeOutcome>;
|
|
212
|
+
export declare const HUMAN_BLOCKED_ASK_RESERVED_EVENT = "human_blocked_ask_reserved";
|
|
213
|
+
export declare const HUMAN_BLOCKED_ASK_RELEASED_EVENT = "human_blocked_ask_released";
|
|
214
|
+
export declare const HUMAN_BLOCKED_ASK_ANSWERED_EVENT = "human_blocked_ask_answered";
|
|
215
|
+
interface HumanBlockedAskReceipt {
|
|
216
|
+
cwd: string;
|
|
217
|
+
sessionId: string;
|
|
218
|
+
classificationEventId: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Pure: whether the single ask of one `human_blocked` classification is spent.
|
|
222
|
+
* A reservation spends it from the moment the question opens; only a release
|
|
223
|
+
* (the question ended without an answer) hands it back.
|
|
224
|
+
*/
|
|
225
|
+
export declare function isUltragoalHumanBlockedAskSpent(ledger: readonly UltragoalLedgerEvent[], classificationEventId: string): boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Durably reserve the single `ask` a verified human-only blocker admits, before
|
|
228
|
+
* the question opens. Returns `false` when the admission is already spent. The
|
|
229
|
+
* reservation survives a restart, so an answer that could not be recorded still
|
|
230
|
+
* cannot be asked again. `stillAdmissible` re-derives the receipt under the
|
|
231
|
+
* plan and ledger locks, which plan writes, blocker classifications and critic
|
|
232
|
+
* verdicts also take, so a receipt superseded after the guard ran is refused. Rows carry no `goalId`, which keeps them out of every
|
|
233
|
+
* completion-receipt freshness base.
|
|
234
|
+
*/
|
|
235
|
+
export declare function recordUltragoalHumanBlockedAskReserved(input: HumanBlockedAskReceipt, stillAdmissible: () => Promise<boolean>): Promise<boolean>;
|
|
236
|
+
/** Hand a reservation back after its question ended without an answer. */
|
|
237
|
+
export declare function recordUltragoalHumanBlockedAskReleased(input: HumanBlockedAskReceipt): Promise<void>;
|
|
238
|
+
/** Record that the reserved question returned an answer. */
|
|
239
|
+
export declare function recordUltragoalHumanBlockedAskAnswered(input: HumanBlockedAskReceipt): Promise<void>;
|
|
212
240
|
export declare function writePlan(cwd: string, plan: UltragoalPlan, sessionId?: string | null,
|
|
213
241
|
/** Set by callers already inside {@link withUltragoalPlanOwnership} for this plan. */
|
|
214
242
|
options?: {
|
|
@@ -8,6 +8,12 @@ export interface ManagedLegacyLocalMigrationEntry {
|
|
|
8
8
|
}
|
|
9
9
|
/** Opaque authority for a managed session's legacy `local` artifact tree. */
|
|
10
10
|
export interface ManagedLegacyLocalMigrationSource {
|
|
11
|
+
/**
|
|
12
|
+
* Synchronously reports whether the legacy `local` tree may exist. Return
|
|
13
|
+
* false only when it is provably absent (ENOENT); any other probe failure must
|
|
14
|
+
* return true so the async migration gate stays in charge.
|
|
15
|
+
*/
|
|
16
|
+
hasLegacySourceSync(): boolean;
|
|
11
17
|
capture(): Promise<{
|
|
12
18
|
readonly snapshot: NativeDirectoryTreeSnapshot;
|
|
13
19
|
readonly entries: readonly ManagedLegacyLocalMigrationEntry[];
|
|
@@ -29,6 +29,11 @@ export interface AuthorizationFlowState {
|
|
|
29
29
|
url?: string;
|
|
30
30
|
/** One-time browser device challenge, never a stored access token. */
|
|
31
31
|
verificationCode?: string;
|
|
32
|
+
/** OAuth risk warning that must be explicitly confirmed before proceeding. */
|
|
33
|
+
warning?: {
|
|
34
|
+
id: string;
|
|
35
|
+
message: string;
|
|
36
|
+
};
|
|
32
37
|
prompt?: {
|
|
33
38
|
id: string;
|
|
34
39
|
message: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BrokerExitWriterTestBarrier } from "./broker-exit-writer-worker";
|
|
2
|
+
import { type BrokerLockRefusalCode } from "./lock-refusal";
|
|
2
3
|
export type { BrokerExitWriterTestBarrier } from "./broker-exit-writer-worker";
|
|
3
4
|
/** Install a worker-only deterministic commit barrier for publication-fence tests. */
|
|
4
5
|
export declare function setBrokerExitWriterBarrierForTest(barrier?: BrokerExitWriterTestBarrier): void;
|
|
@@ -29,7 +30,7 @@ export interface BrokerExitRecord {
|
|
|
29
30
|
export interface BrokerStartupExitRecord {
|
|
30
31
|
version: 1;
|
|
31
32
|
mode: "startup";
|
|
32
|
-
reason: "startup-deadline" | "startup-signal" | "startup-lock-blocked" | "startup-lock-unavailable";
|
|
33
|
+
reason: "startup-deadline" | "startup-signal" | "startup-lock-blocked" | "startup-lock-unavailable" | "startup-lock-refused";
|
|
33
34
|
fenceReason: null;
|
|
34
35
|
fencedForMs: 0;
|
|
35
36
|
uptimeMs: number;
|
|
@@ -40,6 +41,14 @@ export interface BrokerStartupExitRecord {
|
|
|
40
41
|
writtenAt: number;
|
|
41
42
|
/** For lock refusal reasons: path to the transition or lock that blocked startup. */
|
|
42
43
|
blockingLockPath?: string;
|
|
44
|
+
/** For `startup-lock-refused`: why the live, foreign-host or host-unqualified `broker.lock` was refused. */
|
|
45
|
+
refusalCode?: BrokerLockRefusalCode;
|
|
46
|
+
/**
|
|
47
|
+
* Nonce generated per spawn attempt to bind refusal records to this specific spawn.
|
|
48
|
+
* Prevents false attribution when a foreign broker with a colliding PID writes a
|
|
49
|
+
* record in a shared agent directory.
|
|
50
|
+
*/
|
|
51
|
+
spawnAttemptNonce?: string;
|
|
43
52
|
}
|
|
44
53
|
export type BrokerStartupExitWriteStatus = {
|
|
45
54
|
kind: "written";
|
|
@@ -6,6 +6,7 @@ import { type DirectoryMigrationPolicy } from "../session-directory";
|
|
|
6
6
|
import { type BrokerExitMode, type BrokerExitReason, type BrokerStopRequest } from "./broker-exit";
|
|
7
7
|
import { type BrokerDiscovery, type BrokerPublicationObservation, type RedactedBrokerDiscovery } from "./discovery";
|
|
8
8
|
import { type LifecycleDurableEffectsReceipt, LifecycleLedger, type LifecycleStartupFailureReceipt } from "./lifecycle-ledger";
|
|
9
|
+
import { type ProcessIncarnationObservation } from "./process-incarnation";
|
|
9
10
|
import { type IndexedSession, SessionIndex } from "./session-index";
|
|
10
11
|
import { type MasterCapabilityVerifier, type SpawnLifecycleOwner, type SpawnSubstrateFailure, type SpawnSubstrateProvider } from "./spawn-authority";
|
|
11
12
|
import type { BrokerTaskArtifactOwnerRetirementDisposition } from "./task-artifact-owner-validation";
|
|
@@ -233,7 +234,11 @@ export type SpawnQ26Reconciliation = {
|
|
|
233
234
|
turnId?: string;
|
|
234
235
|
acceptedAt?: number;
|
|
235
236
|
};
|
|
236
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Exact registration a spawn waits for, bounded by `deadlineAt`: the original
|
|
239
|
+
* semantic readiness deadline, or a later one for the single post-deadline
|
|
240
|
+
* recheck after the host published readiness.
|
|
241
|
+
*/
|
|
237
242
|
export interface SpawnRegistrationRequest {
|
|
238
243
|
childId: string;
|
|
239
244
|
cwd: string;
|
|
@@ -242,17 +247,49 @@ export interface SpawnRegistrationRequest {
|
|
|
242
247
|
owner: SpawnLifecycleOwner;
|
|
243
248
|
effectMarker: string;
|
|
244
249
|
deadlineAt: number;
|
|
250
|
+
/**
|
|
251
|
+
* Set only for the post-deadline recheck. The host already registered and
|
|
252
|
+
* published readiness, so the outcome can be decided before `deadlineAt`: the
|
|
253
|
+
* wait ends as soon as `decided()` resolves true (a readable failure receipt,
|
|
254
|
+
* or an owner that provably exited), including while waiting for the index lock.
|
|
255
|
+
* A completed read showing the host's recorded row no longer matches stops the
|
|
256
|
+
* index reads, and the refusal then waits for `decided()` or the bound, because
|
|
257
|
+
* a rolling-back host unregisters before its failure receipt is readable.
|
|
258
|
+
* Polled every {@link SPAWN_LATE_RECHECK_PROBE_MS}.
|
|
259
|
+
*/
|
|
260
|
+
recheck?: {
|
|
261
|
+
decided: () => Promise<boolean>;
|
|
262
|
+
};
|
|
245
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Why a spawn admission saw no matching registration:
|
|
266
|
+
* - `absent`: a completed index read near the deadline held no endpoint row for
|
|
267
|
+
* the child, and no later attempt failed or was abandoned;
|
|
268
|
+
* - `mismatch`: an endpoint row for the child exists but fails the exact
|
|
269
|
+
* identity, authority, or liveness predicate;
|
|
270
|
+
* - `inconclusive`: absence is unproven: no read completed near the deadline,
|
|
271
|
+
* or a later attempt could not read the index in time (queue or lock wait, or
|
|
272
|
+
* a read error);
|
|
273
|
+
* - `unconfirmed`: (flow driver only) a matching registration was observed after
|
|
274
|
+
* the deadline, but readiness was not confirmed and no startup failure appeared.
|
|
275
|
+
*/
|
|
276
|
+
export type SpawnRegistrationMiss = "absent" | "mismatch" | "inconclusive" | "unconfirmed";
|
|
277
|
+
export type SpawnRegistrationResult = {
|
|
278
|
+
ok: true;
|
|
279
|
+
registration: SpawnHostRegistration & {
|
|
280
|
+
lifecycleRequestId: string;
|
|
281
|
+
};
|
|
282
|
+
} | {
|
|
283
|
+
ok: false;
|
|
284
|
+
reason?: SpawnRegistrationMiss;
|
|
285
|
+
};
|
|
246
286
|
/** Q26-only host control seam. It never receives or returns durable request material. */
|
|
247
287
|
export interface SpawnPromptLayer {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
} | {
|
|
254
|
-
ok: false;
|
|
255
|
-
}>;
|
|
288
|
+
/**
|
|
289
|
+
* May be called a second time, once, with a later deadline after a
|
|
290
|
+
* non-mismatch miss when the host published readiness; must be idempotent.
|
|
291
|
+
*/
|
|
292
|
+
awaitRegistration(input: SpawnRegistrationRequest): Promise<SpawnRegistrationResult>;
|
|
256
293
|
dispatch(input: {
|
|
257
294
|
sessionId: string;
|
|
258
295
|
task: string;
|
|
@@ -283,6 +320,31 @@ export declare function spawnRegistrationMatches(candidate: IndexedSession, expe
|
|
|
283
320
|
owner: SpawnLifecycleOwner;
|
|
284
321
|
effectMarker: string;
|
|
285
322
|
}): boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Whether the spawned host's owner process provably exited: the OS confirms
|
|
325
|
+
* the pid is absent, or it now names a process with another incarnation.
|
|
326
|
+
* Every inconclusive observation (an unavailable addon, or a pid that cannot be
|
|
327
|
+
* opened or queried, which `Process.fromPid` reports as `null` on Windows) is
|
|
328
|
+
* not proof of exit.
|
|
329
|
+
*/
|
|
330
|
+
export declare function spawnOwnerProvablyExited(pid: number, expectedIncarnation: string, observe?: (pid: number) => ProcessIncarnationObservation): boolean;
|
|
331
|
+
/**
|
|
332
|
+
* Poll the session index for the exact child host registration.
|
|
333
|
+
*
|
|
334
|
+
* Each read must begin before `deadlineAt`; waiting in the index queue or on the
|
|
335
|
+
* machine-global lock never runs past it. A read that began in time is evaluated
|
|
336
|
+
* even when it completes after the deadline: discarding it would reject a host
|
|
337
|
+
* that registered in time only because the observer was slow. Admission still
|
|
338
|
+
* requires the full predicate against that read, including current liveness and
|
|
339
|
+
* incarnation, never just an early publication timestamp.
|
|
340
|
+
*
|
|
341
|
+
* A recheck (`input.recheck`) ends when its `decided()` probe turns true, so a
|
|
342
|
+
* host that rolled back or died is refused without waiting out the recheck
|
|
343
|
+
* bound. A decisive mismatch row stops the index reads, and the refusal then
|
|
344
|
+
* waits only for that probe (or the bound), because a rolling-back host
|
|
345
|
+
* unregisters before its failure receipt becomes readable.
|
|
346
|
+
*/
|
|
347
|
+
export declare function awaitSpawnHostRegistration(index: SessionIndex, input: SpawnRegistrationRequest): Promise<SpawnRegistrationResult>;
|
|
286
348
|
export declare function normalizeBrokerInput(operation: string, input: Record<string, unknown>): InputNormalization;
|
|
287
349
|
/** Test seam for lifecycle serialization identity. */
|
|
288
350
|
export declare function lifecycleTargetForTest(operation: string, input: Record<string, unknown>): unknown;
|
|
@@ -4,6 +4,8 @@ export declare function getBrokerIdentityKey(agentDir: string): Promise<string>;
|
|
|
4
4
|
export declare function deriveIdempotencyIdentity(agentDir: string, operation: string, callerKey: string, targetHash?: string): Promise<string>;
|
|
5
5
|
/** Pure provenance check for both historical session.spawn identity formats. */
|
|
6
6
|
export declare function deriveSpawnAnchorIdentities(key: Uint8Array, callerKey: string): readonly [string, string];
|
|
7
|
+
/** Shape of every identity {@link deriveSpawnAnchorIdentities} can produce: a lowercase hex HMAC-SHA256 digest. */
|
|
8
|
+
export declare function isSpawnAnchorIdentity(value: unknown): value is string;
|
|
7
9
|
/** Native identity for an idempotency key reserved inside one managed control root. */
|
|
8
10
|
export declare function deriveScopedIdempotencyIdentity(agentDir: string, operation: string, callerKey: string, scope: string): Promise<string>;
|
|
9
11
|
/** Identity format used by lifecycle rows written before target binding. */
|
|
@@ -126,6 +126,7 @@ export interface LifecycleLedgerLimits {
|
|
|
126
126
|
*/
|
|
127
127
|
maxCorruptBytes?: number;
|
|
128
128
|
}
|
|
129
|
+
export declare const DEFAULT_LIFECYCLE_LEDGER_LIMITS: Readonly<Required<LifecycleLedgerLimits>>;
|
|
129
130
|
export declare function isLifecycleLedgerEntry(value: unknown): value is LifecycleLedgerEntry;
|
|
130
131
|
export declare function hasValidTerminalDigests(entry: LifecycleLedgerEntry): boolean;
|
|
131
132
|
export declare class LifecycleLedger {
|
|
@@ -183,6 +183,12 @@ export type SpawnChildHostLaunch = {
|
|
|
183
183
|
env: Readonly<Record<string, string>>;
|
|
184
184
|
effectMarker: string;
|
|
185
185
|
semanticReadyDeadlineAt: number;
|
|
186
|
+
/**
|
|
187
|
+
* Broker-side bound for waiting on the host's own startup verdict after the
|
|
188
|
+
* semantic deadline (the same convention termination scheduling uses). The
|
|
189
|
+
* host does not promise its failure receipt by then.
|
|
190
|
+
*/
|
|
191
|
+
terminationStartDeadlineAt: number;
|
|
186
192
|
};
|
|
187
193
|
export declare function prepareSpawnChildHostLaunch(broker: Broker, input: {
|
|
188
194
|
cwd: string;
|
|
@@ -199,6 +205,7 @@ type EffectMarker = {
|
|
|
199
205
|
};
|
|
200
206
|
type BrokerIndex = Pick<Broker, "index">;
|
|
201
207
|
export declare function setProcessIncarnationForTest(broker: Broker, value: ((pid: number) => string | undefined) | undefined): void;
|
|
208
|
+
export declare function processIncarnationForBroker(broker: BrokerIndex, pid: number): string | undefined;
|
|
202
209
|
/**
|
|
203
210
|
* Retires stale lifecycle markers only when their exact owner is proven gone. These
|
|
204
211
|
* files are launch bookkeeping, not authority for a future process: retaining
|
|
@@ -217,6 +224,16 @@ type RetireExitedLifecycleMarkerPairHook = () => void | Promise<void>;
|
|
|
217
224
|
export declare function retireExitedLifecycleMarkerPair(root: string, id: string): Promise<boolean>;
|
|
218
225
|
export declare function retireExitedLifecycleMarkerPairForTest(root: string, id: string, afterObservation: RetireExitedLifecycleMarkerPairHook): Promise<boolean>;
|
|
219
226
|
export declare function writeEffectMarker(root: string, id: string, marker: EffectMarker): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Host side: record that startup committed. Call only after startup can no
|
|
229
|
+
* longer roll back. Written through an exclusive temp file and an atomic rename,
|
|
230
|
+
* so a reader never sees a partial record.
|
|
231
|
+
*/
|
|
232
|
+
export declare function writeSessionLifecycleStartupCommit(root: string, id: string, effectMarker: string): Promise<void>;
|
|
233
|
+
/** Broker side: whether the host launched as `expected` committed its startup. */
|
|
234
|
+
export declare function hasSessionLifecycleStartupCommit(root: string, id: string, expected: EffectMarker): boolean;
|
|
235
|
+
/** Host side: withdraw this process's startup commit during graceful shutdown. */
|
|
236
|
+
export declare function removeSessionLifecycleStartupCommit(root: string, id: string, effectMarker: string): boolean;
|
|
220
237
|
export declare class LifecycleReadinessCleanupError extends Error {
|
|
221
238
|
constructor(cause: unknown);
|
|
222
239
|
}
|
|
@@ -226,7 +243,7 @@ export interface LifecycleTranscriptEvidence {
|
|
|
226
243
|
digest: string;
|
|
227
244
|
identity: SessionLifecycleTranscriptIdentity;
|
|
228
245
|
}
|
|
229
|
-
type LifecycleFailureArtifact = EffectMarker & SdkStartupFailure & {
|
|
246
|
+
export type LifecycleFailureArtifact = EffectMarker & SdkStartupFailure & {
|
|
230
247
|
rollback: SdkStartupRollbackResult;
|
|
231
248
|
transcript?: LifecycleTranscriptEvidence;
|
|
232
249
|
};
|
|
@@ -238,6 +255,19 @@ export declare class LifecycleFailurePublicationCleanupError extends Error {
|
|
|
238
255
|
export declare function writeSessionLifecycleFailure(root: string, id: string, effectMarker: string, failure: SdkStartupFailure, rollback: SdkStartupRollbackResult, transcript?: LifecycleTranscriptEvidence, ownerIncarnation?: string, ownerPid?: number): Promise<void>;
|
|
239
256
|
export declare function isCanonicalLifecycleCleanupOriginal(root: string, id: string, original: string): boolean;
|
|
240
257
|
export declare function readSessionLifecycleFailure(root: string, id: string, expected: EffectMarker): Promise<LifecycleFailureArtifact | undefined>;
|
|
258
|
+
/**
|
|
259
|
+
* Whether anything occupies the failure receipt path for `expected` or its
|
|
260
|
+
* promotion fence, readable or not. A receipt that is still being published or
|
|
261
|
+
* cannot be read is unknown evidence, not absence.
|
|
262
|
+
*/
|
|
263
|
+
export declare function hasSessionLifecycleFailureEvidence(root: string, id: string, expected: EffectMarker): boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Whether the owner marker and the readiness marker both name exactly
|
|
266
|
+
* `expected`. The host publishes readiness only before its semantic cutoff, but
|
|
267
|
+
* may revoke it if it loses that race, so readiness is evidence, not a commit:
|
|
268
|
+
* callers that need a verdict also require {@link hasSessionLifecycleStartupCommit}.
|
|
269
|
+
*/
|
|
270
|
+
export declare function hasSessionLifecycleReadiness(root: string, id: string, expected: EffectMarker): Promise<boolean>;
|
|
241
271
|
/**
|
|
242
272
|
* Read a failure artifact with startup-time fence reconciliation.
|
|
243
273
|
* Called during startup/restart paths to recover from crashes during fence promotion.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Why broker startup refused an existing `sdk/broker.lock`. */
|
|
2
|
+
export type BrokerLockRefusalCode = "host_unqualified" | "foreign_host" | "live_owner";
|
|
3
|
+
export declare const BROKER_LOCK_REFUSAL_CODES: readonly BrokerLockRefusalCode[];
|
|
4
|
+
/**
|
|
5
|
+
* Startup refusal of an existing `sdk/broker.lock`. The lock is never displaced
|
|
6
|
+
* automatically in these cases, so the refusal is an operator condition rather
|
|
7
|
+
* than a crash: entry points report it and exit non-zero.
|
|
8
|
+
*
|
|
9
|
+
* Kept separate from `broker.ts` so the exit-record and startup-failure modules
|
|
10
|
+
* can name its codes without an import cycle through the broker.
|
|
11
|
+
*/
|
|
12
|
+
export declare class BrokerLockRefusedError extends Error {
|
|
13
|
+
readonly lockPath: string;
|
|
14
|
+
readonly code: BrokerLockRefusalCode;
|
|
15
|
+
readonly ownerPid: number;
|
|
16
|
+
constructor(message: string, lockPath: string, code: BrokerLockRefusalCode, ownerPid: number);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* API-safe message for a broker lock refusal, without exposing paths or stderr.
|
|
20
|
+
* The message indicates whether the owner's liveness could be verified.
|
|
21
|
+
*/
|
|
22
|
+
export declare function brokerLockRefusalApiMessage(code: BrokerLockRefusalCode): string;
|
|
23
|
+
/**
|
|
24
|
+
* Normalizes broker startup or lock refusal errors to extract refusal info and cleanup uncertainty.
|
|
25
|
+
* Returns the primary error (which might be BrokerLockRefusedError or BrokerStartupError with lockRefused),
|
|
26
|
+
* the refusal code if available, and whether cleanup is unverified (AggregateError case).
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeBrokerLockRefusalError(error: unknown): {
|
|
29
|
+
primaryError: unknown;
|
|
30
|
+
refusalCode?: BrokerLockRefusalCode;
|
|
31
|
+
cleanupUnverified: boolean;
|
|
32
|
+
};
|