Skip to content

refactor(agents): consolidate session and runtime operations - #166560

Merged
steipete merged 3 commits into
mainfrom
deslop/d13-agents-runtime-misc-20261007
Oct 7, 2026
Merged

steipete merged 3 commits into
mainfrom
deslop/d13-agents-runtime-misc-20261007

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Agent session, CLI, sandbox, command, and worktree runtime paths repeat internal work that can share existing owners.

User Impact

No user-visible change. Features, messages, configuration keys, CLI flags, protocol shapes, and persisted data remain unchanged. No migrations or operator actions are required.

Why This Change Was Made

Share CLI recovery and output handling, sandbox pin preparation and option/list projections, session reload construction and file-stat projection, extension dispatch, catalog snapshots, keybinding definitions, and worktree restore/cleanup operations. Remove unused private asynchronous auth-lock implementations while retaining the public backend contract.

Candidate head: 8a866c08c2b70c2a0b7eb14592d7e72ffb50f6fb. The conflict-free rebase includes main’s terminal font fixture fix; the stable patch ID is unchanged.

The final measured delta is 784 added / 1,340 removed: 556 net production lines removed across 44 files. Tests, fixtures, test-support, generated files, and declaration files are excluded; no tests were edited. This is 0.71% of 78,846 baseline production LOC, below the 3% campaign target and 1,000-line normal lane minimum. It uses the explicitly authorized 500–999-line exception with the complete file-by-file coverage log below. The deep pass and implementation exceeded two hours. Candidates with measured growth, changed ordering, expanded subclass APIs, or protected dependencies were removed.

Shared paths retain explicit differences: retry eligibility and budgets, sync/worker authority checks and settlement, authored catalog headers, sequential listing, exact optional fields, abort precedence, and cleanup ordering. No changes touch the protected PR-tooling import closure, state/config-session owners, audit, cron, dependencies, schemas, or changelog.

Evidence

  • Existing full subsystem and sibling entry-point test plans ran across 294 selected files: 3,748 unique reported passing cases. Two capacity cases failed; existing skips remain unchanged. No assertion, timeout, retry, skip, budget, or suppression was weakened or added.
  • Both capacity failures reproduced on clean main 66d898f6662ae0de956d664a141fad2789a3cc9a: service.capacity.test.ts:703:79, “waits beyond five minutes for allocation until release” and “… until abort.” The initial one-second poll expires before the simulated six-minute advance. Test/allocation/lease/backoff blobs match the candidate. The cause of the initial missed observation remains unresolved; no fix is claimed here. Local test phases took 4,182.45s and 2,831.21s; tests are unchanged, so no new test CI cost is introduced.
  • Production typecheck and all 27 core test-type graphs passed. Runtime import cycles: 0; Madge cycles: 0. SDK surface check passed; API comparison found no added/removed entrypoints, direct exports, or direct signature changes. Reachable internal declaration changes were inspected.
  • Exact before/after equivalence checks passed for all 41 keybinding definitions and order on macOS/Linux/Windows, and eight configured-shell outcomes.
  • Independent isolated review completed; compiler/source evidence resolved two false findings. Final correction review is scoped-clean at P2. The final frozen-source focused run passed 135 cases across seven files, including lint-suppression checks (926.61s total). Final production typecheck and targeted lint passed.
  • Every changed-check step passed across the original invocation and its continuation. The initially timed-out Knip proof is now complete on the pre-rebase head: pnpm deadcode:full, the full-tree unused-file scan, and the full-tree scan of all six export categories passed sequentially on a standard Hetzner runner, with no findings (7m14s including setup). The direct commands used the repository's Knip version/configuration without the stage wrapper's 600-second deadline. That lease is released.
  • The rebase onto 1b395594318bbd0db6f2467f35b10cc8ac1d30d0 preserves the exact patch ID and 556-line reduction. Fresh production types, runtime cycles (0), Madge cycles (0), and all three lint-suppression tests passed. All 44 candidate files, the lock/package/workspace inputs, and Knip configurations are byte-identical across the rebase; the clean pre-rebase Knip proof is retained. Hosted CI on the final exact head passed, including the formerly failing type stripe.
  • Earlier hosted CI completed every selected test shard after rerunning two canceled shards. Its unrelated terminal UI type failure was independently reproduced on main and has now been fixed in the rebased base. Historical exact-head attribution. The rebased head has green CI and is ready for the authorized squash merge.
Deep-pass production coverage: every assigned file and final disposition

D13 production coverage

Largest-file-first inspection covered the five assigned directories and 370 production modules (78,846 baseline LOC). Tests, fixtures, test-support, generated files, and declaration files are excluded. Protected PR-tooling closure files remain unchanged. The table records final dispositions, including implemented candidates that were rejected. This is coverage evidence, not a claim that every retained line is irreducible.

D13 lead session-runtime coverage

File Finding / decision
agent-session-prompting.ts Inlined the one-use nine-argument steering preparation adapter inside its existing queued admission. Shared observer error collection uses notifyListeners; all notifications still settle and preserve AggregateError order.
agent-session-base.ts Retained exact original auth error branches after SDK review: sharing through a new protected method would extend the subclass API. Event fields, write settlement, signed source custody, and queue identity stay unchanged.
agent-session-compaction.ts Implemented and then rejected a five-line outcome-projection consolidation: selecting status after notifying listeners could change decisions if a synchronous listener mutates the shared outcome. Restored exact baseline bytes; manual and automatic paths retain their original ordering.
session-manager-entries.ts One leaf selection type, construction and adoption core serves sync and worker paths. Each path retains validation, authority, conflict, commit receipt and navigation timing. Other append families have tiny builders whose extraction does not reduce code.
sdk.ts Retained public initialization, turn context precedence, image replacement, provider attribution and metadata publication. Distinct state snapshots have different mutation lifetimes.
agent-session-extensions.ts Read full binding/reload/resource/tool composition. Command sources and async handlers have distinct projections/callback semantics; further mapping helpers would add API/type plumbing.
agent-session-models.ts Read full metadata owner. Model and thinking commits differ in auth, prior state, two-operation publication and notification aggregation; guards must retain exact await positions.
agent-session-tree.ts Read full navigation/summarization. Summary and raw branch routes intentionally differ in target selection, labeling and persisted outcome; same authority fence stays.
exec.ts One capture operation tracks truncation for stream chunks and decoder flush. Only live stream overflow terminates process; flush records the same outcome after settlement.
context-token-pressure.ts Read complete estimator; different string/JSON/tool-result/legacy content policies and rounding are independent retained contracts.
compaction/request-budget.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
agent-session-inspection.ts Post-compaction usage and provider checkpoint rules differ. Live identity checks and unknown usage outcome remain.
agent-session-types.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
agent-session-execution.ts Retry backoff, transcript removal, aborted attempt accounting and rate-limit windows retained.
provider-config.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
agent-session-utils.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
steering-message-identity.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
session-tool-result-redaction.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
compaction/compaction.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
source-info.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
session-file-parser.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
event-bus.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
manual-compaction-preflight.ts Retained narrow core import. Reusing session result-unwrapping would widen this pure helper through the broad runtime barrel for only a few lines; rejected.
provider-display-names.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
auth-guidance.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
agent-session-transcript.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
session-persistence-deprecation.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
http-dispatcher.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
queued-user-message-retirement.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
agent-session.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
session-model-usage.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
telemetry.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
diagnostics.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
index.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
footer-data-provider.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
system-prompt-metadata.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
messages.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
bash-executor.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
compaction/runtime.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
slash-commands.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
transcript-turn-error.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
compaction/index.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.
defaults.ts Retained the existing public type/re-export or canonical lifecycle/codec contract; no smaller equivalent path found.

d13 SessionManager persistence coverage

File (largest first, original lines) Finding / disposition
session-manager-core.ts (759) Implemented shared reload snapshot reader for retargeting and committed append views, also used by metadata worker. Retains bounded limits, explicit read-fence bypass, original snapshot fields, and caller-owned adoption validation. Navigation/cache/opaque ancestry operations retained.
session-manager.ts (735) Full/bounded opening, rewrite planning and sync SDK paths already use common owners. Rejected folding async hydration verification into an awaited helper because another await would move live-authority assertions away from publication. Public sync wrappers retained for named SDK/instrumentation contract.
session-manager-persistence.ts (716) Native/worker paths differ materially in transaction rollback, acknowledgement recovery, input custody, projection scheduling and post-commit authority. Retained existing shared receipt helpers; no safe whole-path collapse.
session-manager-append.ts (631) Shared adoption already owns sync/worker receipts. Sync keyed replay and worker-prepared custody require distinct entry paths. Retry preparation has meaningful error/captured-fence differences; retained.
session-manager-suffix-persistence.ts (527) Generator already shares full native/worker rewrite planning. Preserved custom-payload byte custody, bounded ancestry, loaded/durable prefix distinction, and post-commit adoption.
session-manager-metadata.worker.ts (522) Implemented common reload reader. Branch/suffix dispatch remains separate to retain command/result type correlation. Metadata message admission, pending input custody, exact event-byte preparation, and serialization failure receipt retained.
session-manager-write-admission.ts (387) Reused existing assertManager for native database admission instead of restating identity then current-authority checks. Check ordering and exact error stay identical. Other admission/resource owners retained.
session-manager-incognito.ts (343) Actor/native readers have distinct admission, signal, history validation, and custody. Existing context-source adapter shares payload processing; no extra abstraction added.
session-manager-branching.ts (303) Opaque physical path vs logical branch, labels, detached preparation, and committed identity publication remain separate necessary operations.
session-manager-codec.ts (214) Replaced hand-written reverse compaction/reset boundary search with findLast; a last reset still returns null and a last compaction returns the same object. Legacy tagged migration and normalization are compatibility contracts; retained. Context path selection/cycle guard already delegates final context assembly to core.
session-manager-message-runtime.ts (213) Redaction revalidation, store-alias guard, execution/worker cleanup and committed-error behavior retained.
session-manager-metadata-runtime.ts (194) Actor and SQLite adapters already share command mutation and result publication. Actor acknowledgement failure recovery is materially different from native cleanup.
session-manager-current-turn.ts (162) Native/async routes already share walkSessionCurrentTurn; async witness requires exact entry/version/owner checks across reads.
session-manager-persistence-entry.ts (150) Shared canonicalization and persisted-message receipt owners retained.
session-manager-metadata.ts (135) Shared model/thinking append and publication owner retained.
session-manager-types.ts (118) Public discriminated entry contracts retained.
session-manager-maintenance.worker.ts (116) Replaced three identical-shape operation overloads with one correlated command generic overload, retaining exact per-command output types and implementation.
session-manager-incognito-scope.ts (103) Binding, admission signals, and synchronous SDK rejection boundary retained.
session-compaction-persistence.ts (100) Synchronous and asynchronous AsyncLocalStorage invocation lifetimes differ; retained explicit finally ownership.
session-manager-persistence-error.ts (81) Distinct committed receipt/error contracts retained.
session-manager-message-admission.ts (56) Pending-input and fresh-message checks retain distinct host owners.
session-persistence-operation.ts (48) Existing generator drivers already provide common preparation with distinct sync/async execution.
session-manager-metadata-error.ts (36) Public error shape and stable singleton identity retained.
session-manager-message-error.ts (24) Committed target copying and error fields retained.
session-manager-view-types.ts (21) Type-only aliases retained; shared reload runtime lives in a separate module to preserve this module's type-only role.
session-manager-id.ts (10) Distinct managed session and entry ID contracts retained.

d13 session registry/settings deep pass

Owner Starting LOC Disposition
model-registry.ts 1009 Implemented shared source capture for static/generated inventory, composed catalog, and authored input; preserves metadata provenance, request-authority stripping and authored row mutation. Replaced duplicate nested routing compat branches with one keyed loop. Shared shallow map-value clone across snapshot/fork copies, retaining deep model clones. Authored/dynamic model-row construction retained: defaults, normalized pricing, input admission and max-token provenance differ.
auth-storage.ts 733 Deleted unused private async-lock implementations, obsolete readRaw and imports. Native storage accepts only the synchronous subset; public AuthStorageBackend and fromStorage signatures remain intact. Whole-repo git grep shows no production withLockAsync caller. OAuth's durable fence owner already runs provider I/O outside synchronous locks; retained publication/claim/owner tests explicitly throw if async locks are used.
settings-manager.ts 695 Retained. Scoped state, nested-field write merge and global/project cloning contracts already share helpers. Public getters/setters are SDK/UI behavior and were not removed or dynamically synthesized. Deferred writes, per-scope error retention and overrides remain unchanged.
resource-loader.ts 420 Retained after full read. Resource loading differences are real: skill diagnostics come from skill owner, prompt reads are best-effort, theme reads record warnings. Registration occurs for all kinds before any refresh. Canonical path winner arrays cannot safely be derived from metadata map keys because formerly losing symlink aliases can change targets. Existing conflict and source-scope code already shares loops.
keybindings.ts 307 Implemented typed action table with keys/description tuples and one definition conversion. All 41 application actions, defaults, descriptions and insertion order retained, including Windows differences. TUI declaration augmentation derives exact application keys; retired-name targets still typecheck against application + TUI literals.
settings-storage.ts 203 Retained. Atomic replacement preserves modes, umask, symlink chains and fail-closed rename. Lock-first absent-file observation is required by existing cross-process first-writer tests. Storage interfaces/default settings are published contracts.
model-registry-schema.ts 182 Retained unchanged. Schema and validation-path behavior are explicit preservation boundaries; no schema/generalization work.
prompt-templates.ts 171 Implemented shared ordered user/project source-scope lookup. Rejected unconditional path.resolve shortcut: absolute path spelling (including dot segments and trailing slashes) is preserved by the current helper and can be visible in filePath. Discovery, descriptions and prompt bytes unchanged.
auth-storage-projection.ts 127 Retained. API-key/token SecretRef checks have distinct discriminated field names, preserve external metadata and resolved-value non-persistence. Current snapshot authority and provider-default filtering remain explicit.
resolve-config-value.ts 127 Implemented one configured-shell unsuccessful-result branch. ENOENT still permits default-shell fallback; nonzero exit and other spawn errors do not. Caching and error strings unchanged.
auth-storage-oauth-refresh.ts 123 Narrowed private adapter dependency to Pick<AuthStorageBackend, 'withLock'>; enables removal above. Kept publication reread, exact credential equality, owner checks and credential identity merge unchanged.
auth-storage-oauth-registry.ts 74 Retained. Login, refresh capability and resolution have separate status/return contracts. Per-storage WeakMap is lifecycle authority.
model-registry-runtime.ts 44 Retained. Runtime setup/reset/binding has distinct lifecycle operations and separate private WeakMap ownership.
auth-storage-types.ts 37 Retained unchanged, including public custom-backend withLockAsync contract.
auth-storage-error.ts 6 Retained exact error class/name/cause contract.

d13 session tools and extensions coverage

File Base LOC Decision
extensions/types.ts 1280 Read end to end. Public SDK event types, overloads, UI contracts, and compatibility docs; no behavior-neutral structural cut without altering supported type inference or documentation.
extensions/runner.ts 866 Shared the remaining tool_call handler loop with dispatchHandlers. Explicit fail-fast policy retains context laziness, handler order, blocking, and unisolated tool-call errors.
tools/read.ts 640 Reused existing abort-race owner already used by ls; removed explicit resolver/listener lifecycle while preserving queued byte capture, abort rejection text, decoding, images, pagination and detached output.
tools/write.ts 475 Shared local persisted stat projection with edit; write-specific ENOENT/ENOTDIR policy remains explicit. Kept recovery state machine and incremental highlighting distinctions.
tools/edit-diff.ts 425 Read end to end. Unicode boundary mapping, no-op diagnostic precedence, exact/fuzzy uniqueness and line-ending restoration are distinct contracts; no safe parallel path collapse found.
extensions/loader.ts 254 Shared await-and-revalidate flow for three async persistence actions; legacy sync adapters and deprecation behavior retained.
tools/edit.ts 241 Shared local persisted stat projection with write; edit still accepts only ENOENT as absence. Kept exact/fuzzy replacement input and post-write recovery behavior.
tools/read-page.ts 182 Read end to end. Full-fit selection and clipped line/cursor continuation carry different exact notices and budget accounting; existing core already shared.
tools/tool-schemas.ts 178 Schema changes excluded by standing campaign authorization. No schema edits.
tools/ls.ts 166 Read end to end. Existing abort-race owner and page footer budgeting are coherent; empty directory and no-fitting-entry states retained.
tools/edit-replacements.ts 156 Read end to end. Normalized/original offsets and consumed terminator selection protect mixed line endings and duplicate lines; kept linear apply and boundary mapping separate.
tools/render-utils.ts 117 Reviewed shared output helpers; read/write differ in prefix, normalization/highlighting, trailing blank lines and totals. Further extraction would add parameter/adapter volume without meaningful reduction.
tools/file-diff.ts 107 One structuredPatch computation already serves both human and patch receipts; overwrite/creation limits preserve different complexity contracts.
tools/file-mutation-queue.ts 93 Admission and physical-key queues have distinct ordering/lifetime responsibilities. Kept settlement and cleanup identity guards.
tools/path-utils.ts 92 Pure normalization and distinct local/remote path ownership; Unicode fallback variants preserve authorized parent boundary.
tools/tool-contracts.ts 65 Public inferred schema types and distinct output contracts; preserved.
tools/tool-definition-wrapper.ts 56 One metadata projection now serves both adapter directions, retaining optional-field omission, dynamic execution receiver and internal capability copying.
extensions/metadata-actions.ts 49 Kept target binding and write-admission scope owner; distinct metadata and full persistence capabilities intentionally separate.
extensions/provider-actions.ts 46 Kept queued-registration flush and immediate owner delegation; error handling and registration order already common.
tools/file-tool-planning.ts 43 Two result variants require distinct discriminator checks and returned fields; shared worker admission already owns sizing.
tools/file-tool-planning.worker.ts 40 Validation discriminators protect worker boundary. No new schema/protocol change.
tools/file-write-verification.ts 30 Absorbs duplicated stat-to-receipt projection with caller-supplied absence policy. Persisted byte verification unchanged.
extensions/wrapper.ts 24 Single mapping adapter owns ExtensionRunner context injection; no competing implementation.
tools/bash-operations.ts 21 Minimal injectable public contract; preserved.
tools/private-temp-file.ts 20 Single random exclusive temp-file owner; no structural duplication.
tools/read-tool-contract.ts 17 One tagged output projection; explicit image/text precedence retained.
tools/truncate.ts 13 Existing narrow shared-owner facade retained.
extensions/index.ts 13 Public re-export facade retained.
tools/limits.ts 6 Existing canonical integer coercion adapter retained.
tools/index.ts 4 Public re-export facade retained.

d13 worktrees deep-pass coverage

File Baseline lines Largest-first review and final disposition
service.ts 1297 Removed one-use creation delegation; cleanup derives path/branch from destination instead of a duplicate materialization record. Guard composition preserved.
service-preparation.ts 738 Read end to end. Protected PR-tool import closure; unchanged.
snapshot-restore.ts 697 Shared restore/finalization projection settlement adapter; exact and ordinary restoration commit points preserved.
checkout.ts 675 Read end to end. Protected PR-tool import closure; unchanged.
snapshot-inventory.ts 650 Read end to end. Protected PR-tool import closure; unchanged.
snapshot-exact-state.ts 638 Read end to end. Protected PR-tool import closure; unchanged.
removal-recovery.ts 576 Retained: completed-marker versus partial-checkout recovery has materially different native custody and evidence.
snapshot-host.ts 556 Retained: explicit ordinary snapshot retirement and timed exact-state expiry have distinct contracts.
eviction.runtime.ts 520 Read end to end. Protected PR-tool import closure; unchanged.
registry-run-end.worker.ts 474 Read end to end. Protected PR-tool import closure; unchanged.
removal-git.ts 435 Shared repository verification, detached-HEAD validation and native Git exclusion for retained and object-only restore.
gc-removal.ts 405 Unified claim and owned-removal failure handling; acquired-claim fact preserves different contention and compensation behavior.
registry.ts 387 Read end to end. Protected PR-tool import closure; unchanged.
removal.ts 375 Retained: ordinary, lossless, forced and exact-state paths have distinct snapshot/deletion/finalization authority.
run-lease.ts 374 Read end to end. Protected PR-tool import closure; unchanged.
branches.runtime.ts 373 Read end to end. Protected PR-tool import closure; unchanged.
git.ts 373 Read end to end. Protected PR-tool import closure; unchanged.
snapshot-restore-exact.ts 315 Consumes shared exact-restore core; receipt, index publication, no-replace files and finalization order unchanged.
eviction.ts 296 Retained: dependency claims are acquired progressively; admitted deletion must settle independently of cancellation.
capacity.runtime.ts 289 Read end to end. Protected PR-tool import closure; unchanged.
registry-read.kernel.ts 269 Read end to end. Protected PR-tool import closure; unchanged.
checkout-git-config.ts 262 Read end to end. Protected PR-tool import closure; unchanged.
template-cache.ts 256 Read end to end. Protected PR-tool import closure; unchanged.
allocation.ts 248 Read end to end. Protected PR-tool import closure; unchanged.
capacity-owner.ts 237 Retained: foreground admission and background cleanup yield/checkpoint contracts differ; cache-fill helper would grow code.
pending-slots.worker.ts 228 Read end to end. Protected PR-tool import closure; unchanged.
template-registry.worker.ts 224 Read end to end. Protected PR-tool import closure; unchanged.
capacity.ts 220 Read end to end. Protected PR-tool import closure; unchanged.
checkout-apfs.ts 220 Read end to end. Protected PR-tool import closure; unchanged.
empty-source.ts 209 Retained: creation validates immutable initial commit; expiry instead checks retained ownership and Git registrations.
types.ts 209 Retained unchanged: public/internal protocol and ownership shapes.
capacity.worker.ts 200 Read end to end. Protected PR-tool import closure; unchanged.
gc-artifacts.ts 182 Retained: custom-root preservation and pending-slot recovery differ from default-root orphan deletion.
removal-recovery-inventory.ts 179 Retained: raw bytes versus Git conversion fallback independently prove source equivalence.
owner-protection.ts 177 Retained: pass census is advisory; synchronous lifecycle and remote-placement checks remain live.
filesystem-refs.native.ts 174 Read end to end. Protected PR-tool import closure; unchanged.
template-registry-async.ts 172 Read end to end. Protected PR-tool import closure; unchanged.
git-worktree-operations.runtime.ts 165 Read end to end. Protected PR-tool import closure; unchanged.
provisioned-snapshot.ts 163 Read end to end. Protected PR-tool import closure; unchanged.
registry-run-end.ts 162 Read end to end. Protected PR-tool import closure; unchanged.
provisioned-files.ts 160 Retained: initial inclusion may skip existing files; restore requires exact no-replace publication and saved chunks.
run-lease-owner.ts 155 Read end to end. Protected PR-tool import closure; unchanged.
run-end-lifecycle.ts 149 Read end to end. Protected PR-tool import closure; unchanged.
gc-limits.ts 136 Retained: dependency-blocked work can become eligible after another deletion; attempted state cannot replace live census.
registry-read.ts 136 Read end to end. Protected PR-tool import closure; unchanged.
git-worktree-operations.ts 133 Retained unchanged: internal worker/effect shapes.
git-lock.ts 132 Read end to end. Protected PR-tool import closure; unchanged.
git-path-inventory.ts 131 Read end to end. Protected PR-tool import closure; unchanged.
filesystem-native.ts 128 Read end to end. Protected PR-tool import closure; unchanged.
filesystem-backend.ts 126 Read end to end. Protected PR-tool import closure; unchanged.
snapshot-index-objects.ts 126 Read end to end. Protected PR-tool import closure; unchanged.
removal-finalization.ts 125 Retained: publishes removed lifecycle before housekeeping; failed cleanup recording uses retained claim.
dispatch.worker.ts 117 Retained: explicit typed operation dispatch; no new generated routing or type laundering.
registry-retirement.worker.ts 117 Retained: defer versus missing-path retirement have different transaction admission and projection checks.
provisioned-file-inspection.ts 115 Read end to end. Protected PR-tool import closure; unchanged.
git-maintenance.ts 110 Retained: pack-index repair and broader maintenance own separate budgets and retry semantics.
preparation-timing.ts 109 Read end to end. Protected PR-tool import closure; unchanged.
gc-progress.ts 107 Retained: attempted IDs, complete counters and bounded issue detail have distinct contracts.
capacity-store.ts 106 Read end to end. Protected PR-tool import closure; unchanged.
checkout-profiles.ts 106 Retained: profile definitions and selected directory entries require different typed Git proofs.
registry-retirement.ts 94 Retained: narrow existing transport and timeout deferral logic.
base-ref.ts 86 Retained: explicit ref validation and default remote fallback differ in fetch and error contracts.
gc-protection.ts 82 Retained: retry receipts, revision/fingerprint reuse and current owner protection differ in authority.
pending-slots.ts 79 Read end to end. Protected PR-tool import closure; unchanged.
run-lease-store.ts 77 Read end to end. Protected PR-tool import closure; unchanged.
provisioned-snapshot-store.ts 76 Read end to end. Protected PR-tool import closure; unchanged.
run-lease-store.kernel.ts 73 Read end to end. Protected PR-tool import closure; unchanged.
activity.ts 70 Retained: publication rollback owns a newly acquired lock, while reused process locks remain held.
filesystem-apfs.native.ts 67 Read end to end. Protected PR-tool import closure; unchanged.
gc-dependencies.ts 67 Read end to end. Protected PR-tool import closure; unchanged.
checkout-policy.ts 66 Retained: owner/session/projection evidence independently selects trusted source-only execution.
errors.ts 65 Read end to end. Protected PR-tool import closure; unchanged.
checkout-inspection.ts 59 Retained: provisioned-ledger fast path deliberately avoids Git; absent ledgers must reach orphan recovery.
orphan-paths.ts 54 Retained: canonical path overlap and retirement namespaces independently protect unknown user data.
repository-paths.ts 52 Read end to end. Protected PR-tool import closure; unchanged.
removal-errors.ts 37 Retained: exception types and message classification are externally consumed.
gc-fingerprint.runtime.ts 34 Read end to end. Protected PR-tool import closure; unchanged.
gc-result.ts 32 Retained: user-visible text and optional observed legacy fields must stay identical.
name.ts 31 Read end to end. Protected PR-tool import closure; unchanged.
provisioned-snapshot.worker.ts 31 Retained: exact reset versus chunk insertion mutations already minimal.
capacity-contract.ts 24 Read end to end. Protected PR-tool import closure; unchanged.
run-lease-store.worker.ts 22 Retained: simple transaction owner; sharing with template schema owner would add abstraction without reduction.
service-list.ts 21 Retained: row retirement preserves current-reread race semantics.
snapshot-exact-state-contract.ts 20 Retained unchanged: schema and byte-exact data contract.
filesystem-backend.types.ts 15 Retained unchanged: backend contract.
template-registry.ts 14 Read end to end. Protected PR-tool import closure; unchanged.
owner.ts 11 Read end to end. Protected PR-tool import closure; unchanged.

d13 sandbox coverage

Production file Pass Decision / evidence
remote-fs-bridge.ts (700) Complete owner and main/sibling tests read; implemented Common pin preparation; transport encoding retained to preserve exact optional-key shape; preserve protected mount, hardlink, signal, explicit canonical pin and command ordering.
docker.ts (660) Complete owner read Provisioning reservation, immutable container identity, hot mismatch, Podman target, partial allocation cleanup differ from browser and must remain explicit. Ordered scalar option group implemented.
browser.ts (625) Complete owner read Browser-only CDP contract, bridge auth/custody and cache identity forbid merging Docker lifecycle wholesale.
context.ts (602) Complete owner read Different workspace/skill/credential ownership and late browser authority retained. Reusing returned workspace layout possible.
fs-bridge-path-safety.ts (551) Complete owner read Candidate repeated lexical/canonical entry frames; no security or mount authority removed.
runtime-status.ts (550) Complete owner read Distinct native/current/exact ordered DB authority contracts; leave untouched concurrent config/sessions owner boundary.
fs-bridge.ts (507) Complete owner read Mutation command construction repeats; file/read/stat semantics differ materially from remote bridge.
remote-shell-backend.ts (498) Complete owner read Runtime bootstrap, skill refresh and exec finalization lifetimes retained.
registry.kernel.ts (451) Complete owner read Storage merge precedence differs between containers and browsers; no persistent-state semantic change.
remote-shell-command.ts (445) Complete owner read Stateful shell parser states matter; candidate repeated parentheses step.
podman-runtime.ts (434) Complete owner read Distinct platform connection, identity, version and mount contracts retained.
docker-backend.ts (418) Complete owner read Distinct process termination and cleanup authority retained.
validate-sandbox-security.ts (405) Complete owner read Repeated lexical/canonical checks intentionally close path alias gaps; profile messages differ.
registry.ts (338) Complete owner read DB authority and cleanup boundaries retained; no edits.
fs-paths.ts (328) Complete owner read Input namespace ordering and mount tie priorities retained.
mount-plan.ts (288) Complete owner read Container mount visibility graph distinguishes overmount ancestry and backing identity.
config.ts (265) Complete owner read Scoped override resolution candidate; every nullish/array/merge precedence must remain.
manage.ts (222) Complete owner read Container/browser list loops consolidated with explicit manager/entry conversion; generation removal ownership retained.
prune.ts (176) Complete owner read Already shared expiry loop; browser/container removal authority differs.
registry-lifecycle.ts (160) Complete owner read Shared state cleanup owner differs from active admission; retain.
container-inspect.ts (158) Complete owner read Strict/recorded Podman absence semantics differ; no blind merging.
fs-bridge-mutation-helper.ts (155) Complete owner read Existing typed pinned operation encoder reused; no edits.
fs-bridge.types.ts (140) Complete contract read Public shape preserved.
remote-fs-bridge-pinned-frame.ts (187) Complete owner read Canonical/logical paths and pin basename contracts preserved.
remote-shell-transport.ts (345) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
container-lifecycle.ts (327) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
backend.ts (302) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
docker-mount-source.ts (262) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
workspace-mounts.ts (244) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
ssh.ts (241) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
workspace-authority.ts (239) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
dependency-template.ts (214) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
local-workspace-quiescence.ts (213) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
tool-policy.ts (203) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
local-workspace.ts (169) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
sanitize-env-vars.ts (150) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
ssh-backend.ts (149) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
shared.ts (145) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
types.ts (126) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
container-engine.ts (123) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
backend-handle.types.ts (97) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
novnc-auth.ts (94) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
process-cleanup.ts (85) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
host-paths.ts (84) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
backend.types.ts (81) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
constants.ts (73) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
remote-fs-bridge-canonical-path.ts (72) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
secret-owner.ts (68) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
remote-fs-bridge-paths.ts (67) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
config-hash.ts (64) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
state-owner.ts (60) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
provisioning-error.ts (60) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
file-mutation-identity.ts (55) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
remote-shell-bootstrap-python.ts (53) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
browser-bridges.ts (46) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
current-config.ts (45) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
docker-partial-cleanup.ts (44) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
network-mode.ts (40) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
registry-write.worker.ts (39) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
registry.types.ts (39) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
bind-spec.ts (38) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
fs-bridge-stat-parse.ts (35) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
docker-user.ts (33) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
path-utils.ts (29) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
registry-import.worker.ts (20) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
remote-fs-bridge.types.ts (17) Complete owner read Minimal constant/type/hash owner retained.
config-contract.ts (16) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
types.docker.ts (13) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
fs-bridge-rename-targets.ts (13) Complete owner read Small typed/transport/lifecycle owner; distinct contracts retained.
hash.ts (5) Complete owner read Minimal constant/type/hash owner retained.
browser-network.ts (1) Complete owner read Minimal constant/type/hash owner retained.

D13 CLI runner deep-pass coverage

File Baseline LOC Net removed Decision and invariant
prepare.ts 1963 0 Read complete preparation owner and cleanup/custody tests. Implemented cleanup composition, measured +9 total production LOC with its helper, then removed the experiment. Keep staged cleanup registration, resource claims, credential selection, prompt transport, and authority checks explicit.
execute.ts 702 0 Retained distinct node/plugin/process contracts, host environment assembly, fork persistence, provisional diagnostics, and cleanup precedence; no sound larger consolidation.
execute-plugin.ts 693 0 Retained native permission and structured-input handlers: denial text, policy schemas, pending approvals, live authority, and callback fencing differ.
execute-tool-tracking.ts 676 0 Retained correlation groups, bounded evidence, and separate parsed/host delivery facts. Similar maps have different lifetimes and authority.
cli-run-settlement.ts 637 0 Retained blocked/delivered-failure/success result shapes and session binding decisions. Optional key absence is observable and differs among variants.
execute-process.ts 571 12 Shared late and early structured-output parser; table-driven identical stdout/stderr logging while preserving info-before-debug order and verbose sampling time. Buffer/progress paths retained: stdout and stderr have different liveness and parse responsibilities.
bundle-mcp.ts 567 0 Retained provider adapters and sequential bearer reprojection after discovery. Config hash/canonical resume hash, exclusive servers, policy discovery, and refreshed bearer filtering differ.
model-call-diagnostics.ts 528 6 Normalized scalar assistant text into the existing bounded block path. Empty text, fallback reservation, byte/item caps, stop reason, and truncation marker remain identical.
cli-run-transcript.ts 511 0 Retained durable and caller-memory writes with their separate authority fences; no schema/store changes.
session-history.ts 507 0 Retained hook/reset history and model compaction history differences, bounded byte/event cuts, Unicode-safe reseed truncation, and note exclusion.
execute-events.ts 468 0 Retained active parsed versus display-only maps and timestamps; combining them would change event ordering or diagnostics.
helpers.ts 460 6 Unified prompt-ineligibility branches into one guard; unchanged first/always/never behavior, transport checks, and prompt bytes. Retained image hydration and argv ordering.
cli-live-session-registry.ts 334 0 Retained active, retired-cleanup, and retiring-handle ownership: each guards a different reuse window.
cli-native-tool-approval.ts 321 0 Retained Bash binding, allowlist, post-await authority, and approval-detail limits; authority branches are not duplicates.
execute-node-claude.ts 320 0 Retained node result versus approval decoders and node-specific timeout/cancellation ownership.
types.ts 299 0 Read all public/internal run and prepared-context contracts; no unused contract removal found.
bundle-mcp-codex.ts 293 0 Read Codex projection and run policy owner; unchanged. Native MCP acquisition, agent scoping, and local bearer boundaries are explicit and distinct.
history-boundary.ts 290 0 Retained transcript admission, physical identity, credential fingerprint, writer adoption, and fresh-history guards; config/session owner untouched.
mcp-grant-context.ts 279 0 Retained explicit narrow grant projection and absent-versus-undefined field contracts; generic projection added complexity without substantial reduction.
run-diagnostics.ts 221 0 Retained run versus harness outcome mapping, private error payloads, and execution-owner updates.
cli-run-recovery.ts 211 41 Shared ordered checkpoint-fork and fresh-session retry body; table owns reason-specific eligible error codes. Preserved original fallback error, monotonic budget, hook receiver, optional fresh hook, successor tracking, delivery settlement, and failure logging.
prepare-mcp.ts 190 0 Retained capability policy, projection admission, and native authority selection as distinct operations.
prompt-context.ts 185 0 Retained private hook context versus raw transport composition and borrowed model snapshot ownership.
execute-plugin-watchdog.ts 167 0 Retained overall active budget, silence deadline, suspend credits, and ask-user grace; derived fields have different reset behavior.
execute-logging.ts 163 1 Removed the redundant never alias while retaining the exhaustive return required by consistent-return lint; a future unhandled union member remains a type error. Redaction and CLI log text unchanged.
bundle-mcp-gemini.ts 159 0 Retained three settings operations: inherited base merge, web-only override, and per-attempt capture artifact lifetime.
claude-skills-plugin.ts 139 0 Retained native-skill collision naming, missing path warnings, symlink/copy platform contract, and resource claim ownership.
bundle-mcp-claude.ts 118 0 Existing variadic argument core already shared. Retained strict-config replacement and normalized MCP denial identity.
live-session-fingerprint.ts 108 0 Retained distinct omitted and unstable argv classes, selected-secret normalization, and exact hash field order.
prepare-tool-policy.ts 104 0 Retained caller cap conflict, wildcard handling, disableTools override, and mediated completion restrictions.
execution-target.ts 98 0 Retained per-run assertion, node selection, reply backend attachment, and plugin consumer lifetime.
tool-authority.ts 97 0 Retained original requester capture and per-answer route/currentness revalidation.
skills-prompt.ts 92 0 Retained skill snapshot reuse, sandbox remapping, lazy entry loading, and repeated authority assertions around awaits.
delivery-evidence.ts 90 0 Existing boolean/array projection loops already consolidated; retained snapshot versus live-reference behavior.
reliability.ts 89 0 Retained watchdog limit mathematics, cron/resume differences, and queue scope semantics.
execute-messaging.ts 88 0 Retained bounded unique evidence and target/content extraction; duplicate sends and source replies are separate facts.
before-agent-reply.ts 84 0 Retained isolated/control bypass and synthetic-result payload identity.
exit-error.ts 83 0 Retained checkpoint unsupported classifier and structured/prefix/tail error precedence.
execute-ask-user-deadline.ts 75 0 Retained weak deadline ownership, ambiguity suppression, selected deadline caching, and listener transitions.
no-output-timeout-policy.ts 63 0 Retained retry safety and outstanding-work grace; timeout messages unchanged.
bundle-mcp-runtime.ts 58 0 Existing backend argument/capture helpers already consolidate adapters; atomic writes intentionally differ for Claude.
model-capabilities.ts 47 0 Retained requested/normalized model and provider precedence; thinking and selectable context can select different first matches.
output-error.ts 44 0 Retained terminal facts before provider classification and raw error metadata.
prepare-claude.ts 42 6 Normalize dotted numeric alias suffix before the existing alias table, removing seven duplicate entries; unrecognized input still returns its original trimmed spelling.
reseed-envelope.ts 42 0 Retained strict legacy envelope disambiguation and byte-identical hash; malformed boundaries remain rejected.
run-admission.ts 41 0 Retained logical-model authority and source admission assertions after awaits.
bootstrap-transport.ts 38 0 Retained prompt transport availability and personal-bootstrap invalidation hashing.
toml-inline.ts 36 0 Read complete implementation; retained concise existing scalar serialization and error contracts.
cli-backend-auth-policy.ts 33 0 Retained bounded core-only auth owner table and trust boundary.
tool-policy.ts 31 0 Read complete implementation; retained concise existing scalar serialization and error contracts.
cleanup.ts 25 0 Read cleanup owner. Experimental composition helper removed after measured net growth; required settlement fallback-stop behavior untouched.
auth-profile-preparation-error.ts 25 0 Retained selected-profile terminal fact and original failure attribution.
execute-deps.ts 23 0 Retained test/runtime dependency owner and watchdog clock seam.
log.ts 11 0 Retained shared subsystem logger and bounded digest metadata.
execute-output-buffer.ts 7 0 Retained UTF-8-safe tail helper with dedicated multibyte tests; broader capture abstraction did not justify itself.
session-binding.types.ts 7 0 Retained the three stable session binding facts.
execute.runtime.ts 2 0 Retained facade used outside assigned directory; cutting it over requires caller ownership outside scope.
prepare.runtime.ts 2 0 Retained facade used outside assigned directory; cutting it over requires caller ownership outside scope.

d13 command coverage

Baseline lines File Coverage and decision
887 attempt-execution.ts Read end to end. CLI and embedded paths share common run params already; distinct admission, binding recovery, prompt persistence, and authority ordering retained.
807 delivery.ts Consolidated ordered nested log fields and payload duplicate filtering; routing refresh, double media dedupe, source-only grants, custody and JSON ordering retained.
687 post-run.ts Read end to end. Foreground CLI compaction and deferred embedded maintenance have different custody/settlement contracts; retained.
674 run-embedded-attempt.ts Read end to end. Implemented thinking hydration extraction with explicit primary/fallback behavior, measured jointly at +5 production LOC, removed candidate. Retry authority/media barriers retained.
673 session.ts Read end to end. Exact key lookup and cross-partition ID scan differ in ownership/legacy-row selection. Persisted metadata clearing is an explicit field contract; retained.
667 model-selection.ts Derived override provenance after adopting repaired entry instead of tracking/recomputing three mutable projections. Retained locked-session, operator, parent, fallback and account policy boundaries.
597 cli-compaction.ts Read end to end. Native harness fallback and context engine compaction differ in admission, binding cleanup, successor acceptance and maintenance. Timeout cleanup must retain work until idle; retained.
570 attempt-execution.helpers.ts Unified first-visible ACP chunk initialization for ordinary, buffered, and stripped-prefix output. Claude scans differ in bounded head/tail purposes and remain separate.
485 prepare.ts Read end to end. Session selector validation, admission, worktree lease, ACP placement, skills and bootstrap ordering retained.
451 acp-lifecycle.ts Removed saturated flag: active plus closed identity count is monotone until joint cleanup and already owns the 4096 bound. Existing replay and saturation regressions retained.
364 acp-execution.ts Read end to end. Runtime admission, elicitation, transcript and delivery lifecycle ordering retained; not equivalent to embedded deferred settlement.
317 transcript-persistence.ts Read end to end. ACP/CLI already share one transcript persistence owner. Distinct stop reasons, context usage, user admission and assistant hooks retained.
315 session-store.ts Read end to end. Session lifecycle fence, concurrency projection and count semantics retained. No schema/store changes.
305 session-preparation.ts Unified two initial session update paths under one local entry construction/persistence operation; each retains its initial entry choice, timestamp and update ordering.
287 types.ts Read full trusted/public option surface. Public ingress distinctions and descriptions retained; no exported shape changes.
219 shared-types.ts Read shared option types; named ownership scopes already factor common behavior. No type-only churn.
205 maintenance.ts Read end to end. Preflight source authority differs from system-owned followup; retained.
201 delivery-result.ts Grouped sent/suppressed and partial/failed projections with explicit varying fields. All optional fields and original insertion order retained.
189 lifecycle.ts Read end to end. Attempt finishing latch differs from mutable callback state across retries; terminal error metadata and projection retained.
154 assistant-transcript-repair.ts Read end to end. Sequential append barrier and exact idempotency/cleanup semantics retained.
138 cleanup.ts Read end to end. Accepted terminal writes, restart-recovery cleanup, owner release and finally order retained.
134 model-selection-catalog.ts Read end to end. Implemented primary/fallback hydration core; +5 LOC after typing and explicit variation, so removed. Deferred catalog ownership remains unchanged.
133 session-helpers.ts Read end to end. Preflight delivery plan differs from final delivery refresh/error handling; retained.
87 compaction-accounting.ts Read end to end. Candidate budget acceptance, durable fact observation and carry count are distinct state; retained.
79 attempt-auth-selection.ts Read end to end. Explicit versus automatic auth admission remains separate; retained.
76 attempt-execution.shared.ts Unified missing/rejected persistence cleanup after owner publication; retains published cache fact and stale-write rejection.
74 model-ref.ts Read end to end. Parsing/manifest aliases and runtime normalization have distinct phases; retained.
72 attempt-callbacks.ts Read end to end. Same-candidate restart and terminal handling preserve independent state.
64 cli-compaction-context.ts Read end to end. Explicit projection prevents transport-only fields leaking into context engine; retained.
59 runtime-loaders.ts Read end to end. Lazy runtime boundaries and delivery retention before inference retained.
58 ingress-diagnostics.ts Read end to end. Ingress-only diagnostic projection retained.
58 delivery-authority.ts Read end to end. Restart-only signal and platform retryability are authority contracts; retained.
49 claude-cli-project-dir.ts Read end to end. External Claude path/hash behavior retained.
47 run-context.ts Read end to end. Existing table-driven group normalization and nullish precedence retained.
35 maintenance-budget.ts Read end to end. Infinite budget, parent cancellation and deadline logging retained.
33 explicit-session-key.ts Read end to end. Sentinel and persisted legacy-owner paths retained.
23 run-embedded-attempt.types.ts Read full internal orchestration contract; already uses owner types.
23 attempt-execution.runtime.ts Read full runtime barrel; deliberate lazy load boundary retained.
9 session-store.runtime.ts Read full runtime barrel; deliberate lazy write boundary retained.
3 delivery.runtime.ts Read full runtime barrel; deliberate lazy delivery boundary retained.

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 7, 2026
@steipete
steipete marked this pull request as ready for review October 7, 2026 10:42
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 8a866c08c2b70c2a0b7eb14592d7e72ffb50f6fb
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/sandbox/docker.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/manage.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/remote-fs-bridge.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/tool-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sessions/auth-storage-oauth-refresh.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/sessions/auth-storage.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 7, 2026, 8:25 AM ET / 12:25 UTC (Revision 4).

ClawSweeper review

What this changes

The PR shares repeated agent session, CLI recovery, sandbox, extension, and worktree operations and removes unused private authentication-lock implementations.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this remains a useful maintainer-authored consolidation that is absent from current main, and the inspected diff introduces no actionable correctness defect.

Priority: P3
Reviewed head: 8a866c08c2b70c2a0b7eb14592d7e72ffb50f6fb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful consolidation with substantial recorded validation and no actionable source findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The trusted-author exemption applies to this internal refactor. Existing runtime owners and authority checks remain in place; supplied tests and equivalence checks are supplemental validation, not claimed live proof. No stored-data contract changes require migration evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The trusted-author exemption applies to this internal refactor. Existing runtime owners and authority checks remain in place; supplied tests and equivalence checks are supplemental validation, not claimed live proof. No stored-data contract changes require migration evidence.
Evidence reviewed 9 items Pinned introduction reviewed: Inspected the introduced hunks across all five affected directories against the pinned merge base, including the original code shown in the diff. No dependency, workflow, schema, config-option, or test changes are introduced.
Re-review continuity verified: Compared GitHub’s complete tree for previously reviewed head f8f826c with the checkout’s tracked blob identities: all 44 introduced files are byte-identical. The prior review had no code findings. Local historical comparison encountered unavailable promisor objects, so the GitHub tree API supplied the independent comparison.
Captured body identity and validation follow-up: The API body matches the supplied snapshot: SHA-256 8553756eb8a8027326036c7b81d636911d3bd2211951ad38f8a3096cf441f1ba, 61,166 UTF-16 units. Its inspected Evidence section reports completed full-tree Knip scans on the pre-rebase head, unchanged scan scope, and a final scan still running on the pinned head. This updates the older export-proof blocker rather than establishing scan completion on the new head.
Findings None None.
Security None None.

How this fits together

OpenClaw’s agent runtime turns admitted requests into model execution, session updates, tool operations, and reply delivery. These changes consolidate internal operations while retaining their existing runtime owners.

flowchart TD
  A[Admitted agent request] --> B[Session and model preparation]
  B --> C[CLI or agent execution]
  C --> D[Recovery and settlement]
  C --> E[Sandbox file operations]
  C --> F[Worktree lifecycle]
  D --> G[Session updates and reply delivery]
Loading

Before merge

  • Complete next step (P2) - Record the result of the already-running full-tree Knip scan for head 8a866c0 without weakening scan scope or safeguards.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -556. Total -556 across 44 files.

View PR surface stats
Area Files Added Removed Net
Source 44 784 1340 -556
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 44 784 1340 -556

Review metrics

Metric Value Why it matters
Re-review continuity 44 of 44 introduced file blobs unchanged The rebase preserves the previously reviewed production code and supports reuse of its relevant validation.

Stored data model

Persistent data-model change detected: serialized state: src/agents/command/attempt-execution.shared.ts, serialized state: src/agents/sessions/tools/edit.ts, serialized state: src/agents/sessions/tools/write.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Retain one implementation for repeated operations while preserving existing admission, ordering, cancellation, and public-contract differences.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR consolidates existing behavior rather than reporting a failing user flow; no introduced failure was established by source inspection.

Is this the best way to solve the issue?

Yes: sharing existing internal owners is a maintainable approach, and the inspected hunks preserve the meaningful differences between callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4ed39a25f674.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is internal consolidation with no intended user-visible behavior or configuration change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The trusted-author exemption applies to this internal refactor. Existing runtime owners and authority checks remain in place; supplied tests and equivalence checks are supplemental validation, not claimed live proof. No stored-data contract changes require migration evidence.

Evidence

What I checked:

  • Pinned introduction reviewed: Inspected the introduced hunks across all five affected directories against the pinned merge base, including the original code shown in the diff. No dependency, workflow, schema, config-option, or test changes are introduced. (8a866c08c2b7)
  • Re-review continuity verified: Compared GitHub’s complete tree for previously reviewed head f8f826c with the checkout’s tracked blob identities: all 44 introduced files are byte-identical. The prior review had no code findings. Local historical comparison encountered unavailable promisor objects, so the GitHub tree API supplied the independent comparison. (8a866c08c2b7)
  • Captured body identity and validation follow-up: The API body matches the supplied snapshot: SHA-256 8553756eb8a8027326036c7b81d636911d3bd2211951ad38f8a3096cf441f1ba, 61,166 UTF-16 units. Its inspected Evidence section reports completed full-tree Knip scans on the pre-rebase head, unchanged scan scope, and a final scan still running on the pinned head. This updates the older export-proof blocker rather than establishing scan completion on the new head. (8a866c08c2b7)
  • Sandbox containment retained: The shared pin preparation passes through writable, directory, descendant, cancellation, and canonical-path inputs to the existing containment owner. The inspected owner still validates mount containment, writable mounts, protected paths, and requested basenames before mutation. (src/agents/sandbox/remote-fs-bridge.ts:625, 8a866c08c2b7)
  • Authentication contract preserved: The public backend interface still includes withLockAsync, and fromStorage still accepts that interface. Removed methods belong to private backends; production OAuth refresh consumes withLock, with existing regression coverage explicitly rejecting use of withLockAsync. (src/agents/sessions/auth-storage.ts:318, 8a866c08c2b7)
  • Session and worktree boundaries preserved: Session reload consolidation retains bounded versus full reads and read-fence selection without changing stored formats. Both exact worktree restore routes retain repository verification, native Git locks, detached-HEAD verification, and their existing finalization callbacks. (src/agents/worktrees/removal-git.ts:349, 8a866c08c2b7)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • tzy-17: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record completion of the already-running full-tree Knip scan for the pinned head, preserving its existing scope and safeguards.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-07T10:48:41.136Z sha f8f826c :: blocked before merge. :: none
  • reviewed 2026-10-07T11:00:02.356Z sha f8f826c :: needs changes before merge. :: none
  • reviewed 2026-10-07T11:37:37.526Z sha f8f826c :: blocked before merge. :: none

@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head validation update for f8f826c30ec60326bbe8c3157f777320ab591b12.

CI run 37609156598, attempt 2, completed. Both test shards canceled by the first attempt's fail-fast monitor (checks-node-changed-compact-small-5 and checks-node-changed-compact-large-8) passed on the requested failed-job rerun. No canceled or pending check run remains in the paginated exact-head census.

The census contains 220 latest check runs: 92 successful, 125 skipped by workflow/draft/scope selection, one neutral, and the following two failures. The ordinary ready-PR CI run completed its selected work; the original draft-skipped run is not counted as proof.

Failed check Attribution and evidence
check-test-types-core-2 Inherited main failure: ui/src/components/terminal/terminal-panel-fonts.test.ts(56,5) reports TS2353 because signal is not accepted by bootTerminalPanelSession. Independently reproduced with exit 2 on clean current-main commit 0dc20916873149b6f6803d1eae711c8d44f3de9e using node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.ui-components.json --noEmit. The test and its UI parameter owner are outside all 44 changed lane paths. Their main blobs are 1583eed926aadde7c26896ad2edc113b10dd20e5 and 5556fc03df12a7b2c53a7e246edf837f5f95112e; the new font test does not exist on the lane head before the merge with main.
openclaw/ci-gate Aggregate of the same type failure. Its log identifies check-test-types-hosted-core-shard finished with failure (selected=true). All selected Node test shards completed successfully after the rerun.

The separate openclaw/ci-gate commit status projects that failed CI result. The dependency-review and security-sensitive-review commit statuses both succeeded.

Local continuation is complete: all nine remaining changed-check commands passed. The final focused tests passed 135 cases across seven files, and final production types and isolated P2 review passed. The earlier full subsystem test evidence and unchanged-baseline capacity failures remain described in the PR body.

Merge remains blocked on separate full-tree export proof. The native scan timed out twice locally at its unchanged 600-second limit. A bounded diagnostic reached the existing 16 MiB debug-output cap during workspace discovery and produced no usable export result. The AWS transfer attempt produced no proof and its lease was released; subsequent allocations were refused at the coordinator's 21/20 fleet limit. No task-owned lease remains active. Ordinary PR CI explicitly omits this export scan, so its completed checks do not close this gap. No timeout, output limit, suppression, baseline, ignore, or scope was relaxed.

@steipete
steipete force-pushed the deslop/d13-agents-runtime-misc-20261007 branch from f8f826c to 8a866c0 Compare October 7, 2026 12:17
@steipete
steipete merged commit ccadf6a into main Oct 7, 2026
151 checks passed
@steipete
steipete deleted the deslop/d13-agents-runtime-misc-20261007 branch October 7, 2026 12:41
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…w#166560)

Consolidate agent session, CLI runner, command, sandbox, and worktree operations through their existing owners. Preserve feature behavior, user-visible text, configuration, protocol, and persisted-data contracts.

Remove 556 net production lines across 44 files. Tests remain unchanged; the PR includes the complete deep-pass coverage log for the approved 500–999-line campaign exception.

Validation includes the full subsystem test run (two capacity failures reproduced on main), 135 passing final focused cases, production and test types, zero runtime and Madge cycles, SDK checks, isolated review, and clean direct sequential Knip scans. Rebase the unchanged patch onto the terminal UI fixture fix and pass hosted CI on head 8a866c0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant