Skip to content

test(codex): split the session-catalog suite along module seams - #124397

Merged
steipete merged 3 commits into
mainfrom
steipete/nice-chaplygin-cf7c96
Aug 16, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/nice-chaplygin-cf7c96

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two things, discovered in sequence:

  1. extensions/codex/src/session-catalog.test.ts was 4,818 lines with a grandfathered oxlint max-lines suppression and a config/max-lines-baseline.txt ratchet entry. PR refactor(session-catalog): split codex catalog modules and unify adoption coordination #124178 measured why a naive split is impossible: copying its five vi.mock blocks into N files worker-crashes the non-isolated extension-codex lane (the lane runs fileParallelism: false — one worker accumulates every file's mocked module graphs, and vi.mock("openclaw/plugin-sdk/node-host") forks a large slice of the plugin-sdk graph per file).
  2. While proving the split, the full codex lane turned out to be already red on main: five tests in app-server/run-attempt.configured-mcp.test.ts deterministically time out (120s each), reproduced standalone on macOS (Node 24.19/26.7), on a clean AWS Crabbox Linux box (cbx_59673c86ba92, run run_31cae5037a94), and on an unmodified origin/main clone. Bisect pinned the first bad commit to fix(discord): bind transcript capture to source account [AI] #118579 (fix(discord): bind transcript capture to source account), which widened the in-process CronCreatorAuthorityCapability contract with a required callerOrigin and added transcript tool wiring that reads it. The codex test's hand-built capability fixture (as never) lacked the field, so bindActiveOperatorTurnAuthority threw TypeError: Cannot read properties of undefined (reading 'kind'), rejecting runCodexAppServerAttempt while the tests awaited turn/start — presenting as timeouts, then a worker teardown crash. fix(discord): bind transcript capture to source account [AI] #118579's CI never ran the extension-codex lane (Discord/gateway diffs don't classify into it), so the break landed green — the exact cross-lane trap root AGENTS.md warns about.

Why This Change Was Made

Mock narrowing first, split second, plus the red-main repair:

  • New session-catalog-pty.runtime.ts narrow boundary re-exports exactly the two node-host functions session-catalog-terminal.ts consumes (resolveNodeHostExecutable, runNodePtyCommand). Tests mock this 3-line leaf instead of the plugin-sdk barrel, so the sdk graph stays shared across files. The four remaining mocks (command-rpc, app-server/{request,shared-client,transcript-mirror}) were already narrow local factory mocks, replicated per file.
  • Shared fixtures move to session-catalog.test-helpers.ts (same pattern as app-server/session-binding.test-helpers.ts), identifier-stable so test bodies move verbatim.
  • The suite splits into seven seam-anchored files (listing, listing-cache, node-listing, adoption, adoption-recovery, archive, node-continue), each well under the 1000-counted-line test cap. Suppression and baseline entry removed (ratchet shrinks to 910).
  • The configured-MCP fixture now carries callerOrigin: { kind: "local" }, matching the gateway-minted run-scope contract fix(discord): bind transcript capture to source account [AI] #118579 established. This un-reds the lane; prod behavior was never wrong (the capability is in-process and always minted with the field at runtime).

User Impact

None at runtime — production delta is +3 lines (the re-export boundary) plus an import rewire in session-catalog-terminal.ts. Maintainability: the codex session-catalog suite is navigable, the max-lines ratchet moves forward, and the codex lane is green again for every future PR that runs it.

Evidence

  • AST parity: TypeScript-compiler comparison keyed by describe-chain + title over printer-normalized it arguments — 96/96 tests identical between the old mega-file and the split; session-catalog-create.test.ts byte-identical.
  • Full extensions/codex one-shot on clean AWS Linux boxes (c7a.8xlarge), post-fix: every reported test passes end-to-end in ~245s on BOTH sides of the A/B — split tree (cbx_e4c804319801) and unmodified origin/main + fixture fix (cbx_d0045e753f72) — and both then die identically in end-of-run worker teardown. That teardown crash is a pre-existing main condition of the unsharded serial lane (fileParallelism: false, one worker accumulates all module graphs), invisible on CI's sharded config; the split is A/B-proven outcome-neutral. Follow-up filed to chunk the extension-codex lane like resolveBoundedVitestInvocations already does for gateway-server.
  • Regression fix proof: run-attempt.configured-mcp.test.ts 14/14 post-fix; pre-fix 5 failed / 9 passed (three independent runs + Linux Crabbox).
  • Bisect log: good 7862a5da159 (refactor(session-catalog): split codex catalog modules and unify adoption coordination #124178 merge) → first bad 8668aeb9698 (fix(discord): bind transcript capture to source account [AI] #118579), converged in 6 steps on the single-test repro.
  • Autoreview (Codex, gpt-5.6-sol, high): clean, 0.98. oxlint clean; check-max-lines-ratchet OK at 910 entries.

Follow-up (separate issue): PR-CI lane classification let #118579 change src/agents surfaces that extensions/codex tests import without running the extension-codex lane.

Replace the 4.8k-line grandfathered session-catalog.test.ts with seven
seam-anchored suites plus shared fixtures, and remove its max-lines
suppression and baseline entry. The broad openclaw/plugin-sdk/node-host
vi.mock becomes a narrow session-catalog-pty.runtime.ts boundary so the
non-isolated extension-codex worker no longer re-instantiates the
plugin-sdk graph once per split file (the crash PR #124178 measured).
Test bodies are verbatim; AST parity across the split checked out
96/96 identical.

AI-assisted (Codex worker under maintainer review).
…ture

PR #118579 widened the in-process CronCreatorAuthorityCapability run
scope with a contractually required callerOrigin, and the new transcript
tool wiring reads it during turn startup. The hand-built fixture in
run-attempt.configured-mcp.test.ts predated the field, so
bindActiveOperatorTurnAuthority threw and runCodexAppServerAttempt
rejected while five tests awaited turn/start - 120s timeouts, then a
worker teardown crash. #118579's CI never ran the extension-codex lane
(cross-lane classification gap), so main's codex lane was latently red.
Bisected to 8668aeb; fixture now mints the local-operator origin the
helper's name promises.

AI-assisted (maintainer-diagnosed, Codex-era fixture repair).
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete steipete self-assigned this Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 03:57
@steipete steipete closed this Aug 16, 2026
@steipete steipete reopened this Aug 16, 2026
@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 Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 12:09 AM ET / 04:09 UTC.

ClawSweeper review

What this changes

The branch replaces one large Codex session-catalog test file with seven focused suites and shared fixtures, adds a narrow PTY mock seam, and supplies the required caller origin in an app-server test fixture.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review. The protected maintainer label and current maintainer ownership rule out automated cleanup, while direct source inspection supports the narrow test-boundary refactor and the fixture repair.

Priority: P3
Reviewed head: 57fa68c895a899c88aaa6448cda2f55226c284c4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, source-consistent test refactor with a source-proven fixture repair and no actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned test and internal-fixture PR is outside the external-contributor proof gate; its body nevertheless reports redacted post-fix remote test evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned test and internal-fixture PR is outside the external-contributor proof gate; its body nevertheless reports redacted post-fix remote test evidence.
Evidence reviewed 6 items Narrow runtime boundary: The added module re-exports only the two host functions consumed by the terminal helper; the terminal helper otherwise keeps its existing command parsing and session eligibility flow.
Fixture defect is source-reproducible: Current main reads callerOrigin.kind from an active cron-authority capability, while the pre-PR configured-MCP fixture supplies an active capability without callerOrigin; the branch supplies the local origin.
Authority contract owner: The run-scope type requires callerOrigin and the gateway creates the capability with the admitted caller origin before dispatching the agent run.
Findings None None.
Security None None.

How this fits together

The Codex plugin catalogs, reads, resumes, and archives local or paired-node Codex sessions through app-server and terminal helpers. The changed tests exercise those session-management paths while the production terminal helper resolves and runs the local Codex executable.

flowchart LR
  A[Session catalog tests] --> B[Shared catalog fixtures]
  B --> C[Narrow PTY mock seam]
  C --> D[Catalog terminal helper]
  D --> E[Local Codex executable]
  F[Configured MCP test fixture] --> G[Authority capability]
  G --> H[App-server tool setup]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head checks are still in progress; the full split should be accepted only once the relevant Codex test lane corroborates the supplied remote A/B evidence.
  • Complete next step (P2) - This is an active maintainer-owned PR with no discrete automation repair remaining after review.
Agent review details

Security

None.

PR surface

Source +573, Tests +235, Other -1. Total +807 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 3 578 5 +573
Tests 9 5053 4818 +235
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 13 5631 4824 +807

Review metrics

Metric Value Why it matters
Production versus test LOC production +5/-5 (net 0); tests/test support +5,626/-4,818 (net +808); baseline -1 The runtime change is net-neutral and exists only to isolate the mock boundary; the remaining growth is the intentional test-suite split.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/codex/src/session-catalog.test-helpers.ts, serialized state: extensions/codex/src/session-catalog-adoption-recovery.test.ts, serialized state: extensions/codex/src/session-catalog-adoption.test.ts, serialized state: extensions/codex/src/session-catalog-archive.test.ts, serialized state: extensions/codex/src/session-catalog-listing-cache.test.ts, serialized state: extensions/codex/src/session-catalog-listing.test.ts, and 13 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the minimal PTY re-export seam and caller-origin fixture repair, then merge after exact-head Codex validation confirms the split remains behavior-neutral.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the minimal PTY re-export seam and caller-origin fixture repair, then merge after exact-head Codex validation confirms the split remains behavior-neutral.

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

Yes, from source: the old fixture creates an active authority object without callerOrigin, and current main dereferences callerOrigin.kind during tool setup. The branch supplies the missing local origin; no local test was run because this is a read-only review.

Is this the best way to solve the issue?

Yes. The two-function local re-export narrows only the broad mocked dependency while preserving the terminal helper's existing behavior, and the fixture now matches the authority owner’s current contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against acbbff19bad0.

Labels

Label changes:

  • add P3: This is a behavior-preserving test maintainability and reliability repair with no asserted end-user runtime change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned test and internal-fixture PR is outside the external-contributor proof gate; its body nevertheless reports redacted post-fix remote test evidence.

Label justifications:

  • P3: This is a behavior-preserving test maintainability and reliability repair with no asserted end-user runtime 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: This maintainer-owned test and internal-fixture PR is outside the external-contributor proof gate; its body nevertheless reports redacted post-fix remote test evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Current-source blame and the supplied merged session-catalog history connect this person to the terminal and catalog test surface. (role: recent area contributor; confidence: high; commits: 1d5321192485, 7862a5da1592; files: extensions/codex/src/session-catalog-terminal.ts, extensions/codex/src/session-catalog.test.ts)
  • pgondhi987: The supplied related merged PR introduced the caller-origin authority contract that the repaired configured-MCP fixture now matches. (role: adjacent contract contributor; confidence: medium; commits: 8668aeb96987; files: src/agents/cron-creator-authority-context.ts, extensions/codex/src/app-server/run-attempt.configured-mcp.test.ts)

Rank-up moves

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

  • Let the exact-head Codex checks finish before merge.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for head 57fa68c895a899c88aaa6448cda2f55226c284c4:

  • Exact-head CI run https://github.com/openclaw/openclaw/actions/runs/31925778965 completed green, including the changed Codex extension lane and openclaw/ci-gate.
  • node --import tsx scripts/check-deadcode-exports.mts passed the production, full-tree, and script unused-export scans after the extracted helper internals were made file-private.
  • git diff --check passed.
  • Repository autoreview completed cleanly with no accepted/actionable findings.
  • ClawSweeper reported no findings; its sole rank-up move was to finish exact-head Codex checks, now satisfied by the green run above.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 124397 passed the hosted CI/Testbox gates (gates_mode=hosted_exact_or_recent_parent), with prep and PR head both at the SHA above.

Known proof gap: the pre-existing unsharded extension-codex one-shot teardown crash remains a separate follow-up. The documented split/unsplit clean-box A/B passed every test before the identical teardown failure; exact-head sharded Codex CI is green. No gate was bypassed.

@steipete
steipete merged commit 191d231 into main Aug 16, 2026
186 of 190 checks passed
@steipete
steipete deleted the steipete/nice-chaplygin-cf7c96 branch August 16, 2026 04:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
…claw#124397)

* test(codex): split the session-catalog suite along module seams

Replace the 4.8k-line grandfathered session-catalog.test.ts with seven
seam-anchored suites plus shared fixtures, and remove its max-lines
suppression and baseline entry. The broad openclaw/plugin-sdk/node-host
vi.mock becomes a narrow session-catalog-pty.runtime.ts boundary so the
non-isolated extension-codex worker no longer re-instantiates the
plugin-sdk graph once per split file (the crash PR openclaw#124178 measured).
Test bodies are verbatim; AST parity across the split checked out
96/96 identical.

AI-assisted (Codex worker under maintainer review).

* test(codex): carry caller origin in the cron-authority capability fixture

PR openclaw#118579 widened the in-process CronCreatorAuthorityCapability run
scope with a contractually required callerOrigin, and the new transcript
tool wiring reads it during turn startup. The hand-built fixture in
run-attempt.configured-mcp.test.ts predated the field, so
bindActiveOperatorTurnAuthority threw and runCodexAppServerAttempt
rejected while five tests awaited turn/start - 120s timeouts, then a
worker teardown crash. openclaw#118579's CI never ran the extension-codex lane
(cross-lane classification gap), so main's codex lane was latently red.
Bisected to ffb2614; fixture now mints the local-operator origin the
helper's name promises.

AI-assisted (maintainer-diagnosed, Codex-era fixture repair).

* test(codex): keep catalog fixture internals private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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