Skip to content

PRD-220: Land drift audit, annotations, and helper consolidation#155

Draft
peterulsteen wants to merge 3 commits into
mainfrom
symphony/prd-220
Draft

PRD-220: Land drift audit, annotations, and helper consolidation#155
peterulsteen wants to merge 3 commits into
mainfrom
symphony/prd-220

Conversation

@peterulsteen
Copy link
Copy Markdown
Contributor

Summary

Squash-merge of integration branch symphony/prd-220 containing the completed portion of PRD-220 — Fix Stale Mocks in closedloop-electron. Test-only changes; no production runtime modified.

Bundles three already-merged-to-integration PRs:

What's deferred to follow-up

These small remaining items will land in one short follow-up PR rather than four orchestrated FEAs:

  • FR6 — mock-hygiene convention in apps/desktop/CLAUDE.md (~15 lines)
  • FR8 — one-time verification of .github/workflows/test.yml (PR description note)
  • FR4 spot-fixes — any drift the audit flagged as actually stale (audit indicates very few)
  • FR5 — drift-check script: prototype or invoke PRD's explicit fallback to FR6 alone

ClosedLoop FEA-618 / 619 / 620 / 621 will be marked OBSOLETE in favor of one consolidated successor.

Test plan

  • CI green on this PR (lint + typecheck + test via .github/workflows/test.yml)
  • Local: pnpm -C apps/desktop test passes (note: typecheck locally requires GITHUB_TOKEN for @closedloop-ai/loops-api@0.2.9; CI installs cleanly)
  • Spot-check apps/desktop/test/DRIFT-AUDIT.md rendered on the PR diff

🤖 Generated with Claude Code

@peterulsteen peterulsteen requested a review from a team May 5, 2026 18:57
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

peterulsteen and others added 3 commits May 5, 2026 13:58
…st.ts (#124)

- Classifies telemetry-loop-integration.test.ts as Class C (not stale)
- Documents actual symphony-loop.ts spawn sites (lines 1836, 4349, 4374,
  4407, 4446, 4467, 4500) correcting PRD's inaccurate citations (1733,
  3697-3830)
- Documents telemetry emission sites (lines 2923, 3339, 3409, 4162,
  4253, 4517)
- Records close-out rationale: all 6 tests pass against current production
  code, no PTY migration ever existed in the codebase
- Confirms zero matches for spawnPtySession/spawnPty/pty.spawn/node-pty

Testing: tsx --test apps/desktop/test/telemetry-loop-integration.test.ts
  passes 6/6 tests; just desktop-lint clean

Risks: None identified

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add drift-check comments in spawn-related tests pointing to their
  current production source line numbers in symphony-interactive.ts,
  codex.ts, learnings.ts, error-handlers.ts, boot-recovery.ts,
  spawn-retry.ts, and git-helpers.ts so test/source drift can be
  detected mechanically.
- Document the known Class (i)/Class (ii) drift in spawn-hardening
  tests (a) and (a-unref) at the top of spawn-hardening.test.ts;
  remediation is deferred to Feature 3.
- Replace inline buildMockChildProcess() and makeEnoentError() copies
  in spawn-enoent-characterization and spawn-retry tests with imports
  from the shared helpers/spawn-test-utils module.
- Restore setShellPathForTest() calls in loop-finalizer and
  symphony-loop-auto-clone tests after PATH overrides so child
  processes resolve binaries from the test fixture directory.

Testing:
- Static change only; existing test suites continue to import the same
  helpers and behave identically. Run `just desktop-test` to confirm.

Risks:
- Low. Comments and import refactors only; no production code touched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Audited all 73 test files in apps/desktop/test/ against production
  sources; 63 files have no drift patterns, 10 are annotated
- Annotated drift-check headers in boot-recovery, codex-log-parsing,
  codex-spawn-enoent, error-handlers, git-helpers-shell-safety,
  spawn-enoent-characterization, spawn-retry, and spawn-hardening
- Vocabulary decision adopted: two-form standard --
  // drift-check: matches for Class (i) line-anchor annotations,
  // drift-check: replicates for Class (ii) pattern-replication sites.
  Applied consistently to spawn-enoent-characterization (489, 1047),
  spawn-hardening tests (b)/(c)/(d) (489, 1047, codex.ts:1985,
  learnings.ts:264), reflecting the entire pattern-replication surface
  per PRD-220 vocabulary rationale.
- Fixed boot-recovery.test.ts annotation anchor: :303 -> :308
  (isProcessRunning(pid) line in boot-recovery.ts)
- Swept stale prose contradictions in codex-spawn-enoent.test.ts header
  block (lines 17-23) so prose line citations no longer contradict
  adjacent // drift-check: annotations
- Added JSDoc on makeEnoentError documenting code: 'ENOENT' and
  syscall: 'spawn' fields, with note for callers needing a syscall-free
  shape
- New: apps/desktop/test/DRIFT-AUDIT.md -- in-tree mirror of the audit
  table for downstream FEA-618/619/621 to consume without reaching for
  PR description archives
- CLAUDE.md: added a pointer to the new DRIFT-AUDIT.md under Learned
  Patterns
- apps/desktop/package.json: patch version bump 0.13.20 -> 0.13.21

Testing: just desktop-typecheck, just desktop-lint, just desktop-test
all expected to pass; this PR is annotation-only with no production
source changes.

Risks: None identified -- changes confined to test annotations,
test/helpers JSDoc, a new in-tree audit document, a CLAUDE.md pointer,
and a desktop package patch version bump. No production runtime code
modified.
@peterulsteen peterulsteen marked this pull request as draft May 5, 2026 20:37
process to consistently resolve binaries from the test fixture directory.
- **No drift patterns** — file does not use spawn / mock / error-handler
patterns (per PLN-353 Q-001 resolution).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Include all current test files in the audit

This file is introduced as the maintained/authoritative per-file audit, but the table is still the 73-file PR #134 snapshot while the current tree has 89 apps/desktop/test/*.test.ts files; existing files such as onboarding-handoff.test.ts, symphony-loop-multi-repo-execute.test.ts, and symphony-loop-write-plan-artifact.test.ts are omitted. Any reviewer or future drift-check script using this as the baseline will silently skip those tests and cannot tell an intentionally audited file from a missing row.

]);

// Replicate the streamCodexReview pattern: createWriteStream + close→end + finish→resolve
// drift-check: matches apps/desktop/src/server/operations/codex.ts:1767
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Point the Codex flush-gate annotation at Codex code

This new streamCodexReview drift annotation points to codex.ts:1767, but that line is inside streamClaudeReview; the Codex flush-gate being replicated is currently in streamCodexReview around lines 1797 and 1825-1832. A drift checker following this anchor will validate the wrong function and can miss regressions in the Codex review path this test is meant to cover.

/** DRIFT ANNOTATION (PLN-392)
*
* Drift classes present in this file:
* - Class (i) — drift-check annotations referencing production source lines
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Correct the Codex spawn drift classification and anchors

These Codex spawn annotations are marked Class (i)/matches and cite codex.ts:1985,1992,2030, but this test copies the helper logic and the current helpers are at waitForExit line 2006, runCommand line 2013, and writeEvent line 2051. Because the patch makes matches mean line-pointer-only and replicates mean copied logic, the current entries both track the wrong lines and hide these replicated mocks from the high-risk replicates set.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants