Skip to content

fix(server): nested CLI startup and peer link expiry - #303

Merged
lukemaj merged 3 commits into
mainfrom
fix/294-295-cli-and-expiry
Oct 14, 2026
Merged

lukemaj merged 3 commits into
mainfrom
fix/294-295-cli-and-expiry

Conversation

@lukemaj

@lukemaj lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

What: Agent shells can run the CLI with inherited launcher variables, and skewed source clocks cannot put new peer-link expiries past year 9999.
Why: Startup trusted an inherited launcher marker without IPC, and peer-link storage added a target-relative lifetime to the source clock without a ceiling.
So what: Merge after exact-head Sol and Grok reviews and green CI; installed Chromeria stays running for a later authorized deployment.

Closes #295 and #294, the two follow-ups to #164 / PR #290. These repairs support headless cross-machine control used by the Promachos and Drafters. One requested outcome, one PR, no version bump.

For #295, port the complete two-file fix from upstream PR #14263 at d45a887be59265c0b4261812397524a9f3ee4cbb. Only a connected launcher child reads the context; connected-child validation and update handshake remain intact. Upstream main still has the defect. For #294, cap the relative expiry conversion before constructing its DateTime. Finite lifetimes and source clocks behind the target retain their value. Existing stored rows are not rewritten; relinking after deployment replaces their expiry.

Proof

  • Bestia's installed CLI failed with inherited markers and worked with them unset; PATH and T3CODE_HOME were identical. Both Macs reproduced the IPC error with inherited context. This is a product defect; no installed launcher or machine configuration was changed.
  • Before the fix, the nested-client regression fails with the foreign-version error; the real-socket OAuth link test returns precisely +010000-01-01T00:00:00.050Z with the source 1050ms ahead. The fixed test verifies created, stored/read-back, and listed expiry; finite, behind-clock and JavaScript overflow cases also pass.
  • npx -y pnpm@11.10.0 install completed.
  • npx -y pnpm@11.10.0 exec vp test run apps/server/src/cloud/serviceLauncherClient.test.ts apps/server/src/cli/pair.test.ts apps/server/src/peer/peerLinkExpiry.test.ts apps/server/src/peer/PeerLinks.test.ts: 31 passed. Task-owned TMPDIR avoids unrelated /tmp quota failure.
  • Server-only typecheck and touched-file lint/format checks pass. No repository-wide checks, UI/browser work, live database writes, service restarts or deployments.

Diagnosis details: #295 record, #294 record. #302 coordination reserves only the expiry assignment and new helper/test; no toolkit/forwarding edits.

Website impact: none, these are CLI startup and server expiry repairs with no website or UI change.

Elon record

Requirements and who asked: User: fix #295 first and #294, focused regression tests and targeted typecheck, two exact-head independent reviews plus CI before delegated merge, no restart/version bump.
Deleted: Per-provider environment patches, host/PATH/home changes, new token contracts, expiry variants, live-state migrations, restarts and unrelated forwarding changes.
Bottleneck: CLI startup's inherited-marker assumption; reuse the upstream connected-IPC gate. Expiry needs one bounded conversion at storage creation.
Checked myself: Reproduced CLI failures on bestia and both Macs, compared unset-marker result, read complete upstream diff and source consumers, reproduced exact skew via real OAuth/SQLite, and checked focused tests before/after.

Model and harness: GPT-6.1-Sol through Codex in T3 Code.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M labels Oct 14, 2026
@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

The first Fork Stack Model run rejected the two upstream CLI files because they lacked registered fork ownership. Added a nested-cli-startup inventory entry and the two exact allowlist paths, including the upstream removal condition; the local fork stack check now passes. Product code and test proof are unchanged. Current candidate is 5df4d32, with new exact-head independent review rounds required.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

What: Independent review found no blocking or actionable findings at exact head 5df4d3296c706a8b9b2796d7bd782704e209a3b5.
Why: The IPC gate preserves connected launcher validation and update sequencing, and the numeric expiry clamp bounds new stored dates without changing ordinary finite or behind-source lifetimes below the ceiling.
So what: Set review/independent-sol to success for this SHA; the parent retains responsibility for the other independent review, remaining CI, and delivery gates.

Reviewed the complete eight-file cumulative diff against 14f6e5d5b3465e12fb77362cc0ef88db5f8f1fac, both Issues including comments, the PR body/comments, and relevant startup, launcher, authentication, storage, CLI and forwarding consumers. The two-file delta since cancelled head 9fa6950465 is ownership metadata only.

  • Launcher lifecycle: The complete two-file port matches upstream PR #14263 at d45a887be59265c0b4261812397524a9f3ee4cbb. ServiceLauncher.#startChild supplies IPC for active and trial children. Connected children still decode context and reject contradictory or foreign-version context. Trial prepared/committed, update acceptance/rejection, and disconnect handling are unchanged. An inherited marker without IPC becomes unmanaged before decoding, so nested CLI startup no longer fails or claims launcher update capability. The new regression discriminates the former foreign-version failure; existing tests exercise connected-child update and trial handshakes.
  • Expiry semantics: Traced pairing-code peer authorization, permanent TTL issuance, OAuth expires_in, the sole link-creation assignment, SQLite write/read, list/resolve and CLI formatting. The clamp occurs before DateTime construction, including positive JavaScript date overflow. Finite and behind-source results below the ceiling retain the previous seconds-to-milliseconds calculation, as confirmed against the pinned Effect implementation. Target-side token validation and revocation remain authoritative. Existing rows deliberately remain unchanged; relinking replaces their expiry.
  • Proof: The new real-socket OAuth/SQLite regression asserts literal capped dates for creation, stored read-back and listing; focused cases also cover finite lifetime, behind-source skew and overflow. I inspected these test paths and the parent's recorded failing-before/passing-after evidence. The reported 31 focused passes and server typecheck were not independently rerun in this read-only source review. git diff --check passed. No browser, development server, live database, host configuration, or source mutations were performed.
  • Ownership and scope: Both launcher paths have one exact inventory owner and allowlist registration, with an explicit removal condition on upstream absorption. The expiry helper/test fall under the existing peer-links ownership. The current Fork Stack Model job log reports fork-features: OK (36 features) and fork-check: OK. The map includes PR fix(server): nested CLI startup and peer link expiry #303; no toolkit or PeerForwarding changes appear in the diff.

Verdict: clean in the inspected scope, with no unresolved objections. This source-review status does not assert complete CI or live verification.

Reviewer: GPT-6.1-Sol, high effort, Codex harness in T3 Code.

@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: 14f6e5d · PR result: 5df4d32 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

What: Independent review of 5df4d3296c706a8b9b2796d7bd782704e209a3b5 found no blocking defect.

Why: Nested CLI startup ignores an inherited launcher context unless this process has the launcher IPC channel, and a connected child still validates that context and keeps the trial and update handshake. New peer-link expiries are capped at 9999-12-31T23:59:59.999Z before DateTime construction, and a finite lifetime or a sum already under that ceiling is stored unchanged.

So what: review/independent-grok is success on that SHA. Merge still waits on the other exact-head review and CI.

Checked

  • Base 14f6e5d5b3465e12fb77362cc0ef88db5f8f1fac. The product diff matches upstream d45a887be59265c0b4261812397524a9f3ee4cbb on the two CLI files. 9fa6950465..5df4d329 changes only docs/fork-features.md and scripts/fork-upstream-edits.txt.
  • Connected path: context is read only when host.connected is true, so managed = context !== undefined matches the previous managed check for a real launcher child. prepareTrial sends prepared only for a decoded pending update. The launcher still commits only a matching trial child and still rolls back on prepared timeout or trial exit. A disconnected client returns unmanaged and sends nothing. ipc-unavailable has no remaining code consumer.
  • Expiry: peerLinkExpiry is the only expiresAt write. Math.min never lengthens a lifetime. A 60s lifetime stays 60s. A source clock one second behind the target stays at 9999-12-31T23:59:58.000Z. A source 1050ms ahead always sums past the ceiling and is clamped. Relink uses the same upsert, so the next link replaces a bad row. Existing rows are left, as Permanent peer link stores an expiry past year 9999 when the linking machine's clock is ahead #294 records.
  • Ownership: scripts/fork-check.sh in the PR worktree against upstream/main passed. Both CLI files are allowlisted with one owner, nested-cli-startup, whose purpose drops the port when upstream #14263 is absorbed. peerLinkExpiry.ts is a new file under peer-links.
  • No version bump. No PeerForwarding or toolkit edits.

Proof limit: I inspected the tests and call paths and did not re-run them. cli/pair.test.ts does not call resolveStartup (pair uses ServerEnvironment.layerIdentity). The nested-client test does, through ServiceLauncherClient.make, and t3 environment list uses the same resolveStartup via resolveServiceLauncherMode.

@lukemaj
lukemaj merged commit 1bc1191 into main Oct 14, 2026
28 checks passed
@lukemaj
lukemaj deleted the fix/294-295-cli-and-expiry branch October 14, 2026 15:24
@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

What: Both repairs merged in PR #303 as 1bc11912ede0e53e9aa8d75f4e160f3e0873d699.
Why: Nested CLI startup now ignores an ancestor's launcher context without IPC, and source clock skew cannot create a new link expiry past year 9999.
So what: Source delivery is complete; installed runtimes remain unchanged and need a separately authorized deployment. Relink the existing bad-expiry row after deployment if its stored date needs correction.

Exact reviewed head: 5df4d3296c706a8b9b2796d7bd782704e209a3b5, base 14f6e5d5b3465e12fb77362cc0ef88db5f8f1fac. Both newest review contexts were success by lukemaj on that head, after findings comments: Sol #303 (comment) and Grok #303 (comment). All CI checks passed or were deliberately skipped; CI run https://github.com/toolboxmd/chromeria/actions/runs/38586516086. Merge verified live, with unchanged exact PR head and clean merge state.

Focused proof: 31 tests in serviceLauncherClient.test.ts, cli/pair.test.ts, peerLinkExpiry.test.ts and PeerLinks.test.ts. Server-only typecheck exit 0, touched lint/format and fork ownership/stack checks passed. Both new defect regressions were run against old behavior and failed for their intended mechanisms before passing. Product code is identical between tested and final reviewed heads; subsequent commits only add the map PR ref and required fork ownership metadata. No version bump.

Task worktree was clean and had no running process before removal; worktree and local/remote task branch are retired and absence verified. Main checkout remains unchanged, including user-owned scripts/pycache/. No machine configuration, installed launcher, runbook, live database, or service was modified. No deployment/restart or live verification of the repaired installed runtime is claimed. The owning boundary is shared product startup, so no host-specific install patch was made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t3 CLI run from an agent shell on a service-managed server fails: inherits T3_SERVICE_LAUNCHER_CONTEXT

1 participant