@webpieces/rules-config 0.4.837 → 0.4.838

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/package.json +4 -2
  2. package/src/builds-log.d.ts +1 -1
  3. package/src/builds-log.js +3 -3
  4. package/src/builds-log.js.map +1 -1
  5. package/src/checklist-docs-validator.js +1 -1
  6. package/src/checklist-docs-validator.js.map +1 -1
  7. package/src/checklist-override.js +1 -1
  8. package/src/checklist-override.js.map +1 -1
  9. package/src/config-file.js +3 -3
  10. package/src/config-file.js.map +1 -1
  11. package/src/config-pruner.d.ts +1 -1
  12. package/src/config-pruner.js +2 -2
  13. package/src/config-pruner.js.map +1 -1
  14. package/src/constants.d.ts +0 -2
  15. package/src/constants.js +1 -3
  16. package/src/constants.js.map +1 -1
  17. package/src/diff-scope.js +1 -1
  18. package/src/diff-scope.js.map +1 -1
  19. package/src/exclude-hook-paths.js +2 -2
  20. package/src/exclude-hook-paths.js.map +1 -1
  21. package/src/home-config-doc-keys.js +2 -2
  22. package/src/home-config-doc-keys.js.map +1 -1
  23. package/src/home-config.js +9 -9
  24. package/src/home-config.js.map +1 -1
  25. package/src/index.d.ts +2 -21
  26. package/src/index.js +7 -129
  27. package/src/index.js.map +1 -1
  28. package/src/instruct-ai-docs.d.ts +1 -1
  29. package/src/instruct-ai-docs.js +3 -3
  30. package/src/instruct-ai-docs.js.map +1 -1
  31. package/src/load-config.js +2 -2
  32. package/src/load-config.js.map +1 -1
  33. package/src/load-template.d.ts +2 -2
  34. package/src/load-template.js +5 -5
  35. package/src/load-template.js.map +1 -1
  36. package/src/orphan-dir-archive.js +3 -3
  37. package/src/orphan-dir-archive.js.map +1 -1
  38. package/src/pr-gate-config.js +4 -4
  39. package/src/pr-gate-config.js.map +1 -1
  40. package/src/pr-gate-section-validators.js +7 -7
  41. package/src/pr-gate-section-validators.js.map +1 -1
  42. package/src/repo-root.d.ts +1 -1
  43. package/src/repo-root.js +5 -5
  44. package/src/repo-root.js.map +1 -1
  45. package/src/repo-scratch-dirs.d.ts +1 -1
  46. package/src/repo-scratch-dirs.js +3 -3
  47. package/src/repo-scratch-dirs.js.map +1 -1
  48. package/src/review-json.d.ts +1 -1
  49. package/src/review-json.js +11 -11
  50. package/src/review-json.js.map +1 -1
  51. package/src/review-provenance.js +4 -4
  52. package/src/review-provenance.js.map +1 -1
  53. package/src/reviewer-instructions.js +2 -2
  54. package/src/reviewer-instructions.js.map +1 -1
  55. package/src/rules-config-design.d.ts +2 -2
  56. package/src/rules-config-design.js +4 -4
  57. package/src/rules-config-design.js.map +1 -1
  58. package/src/skip-rule.d.ts +2 -8
  59. package/src/skip-rule.js +24 -61
  60. package/src/skip-rule.js.map +1 -1
  61. package/src/spec-temp-dirs.js +2 -1
  62. package/src/spec-temp-dirs.js.map +1 -1
  63. package/src/stale-bin-sweep.js +1 -1
  64. package/src/stale-bin-sweep.js.map +1 -1
  65. package/src/subagent-provenance.js +7 -7
  66. package/src/subagent-provenance.js.map +1 -1
  67. package/src/tmp-scratch-sweep.js +1 -1
  68. package/src/tmp-scratch-sweep.js.map +1 -1
  69. package/src/validate-config.js +1 -1
  70. package/src/validate-config.js.map +1 -1
  71. package/src/verdict-schema-renderer.js +2 -2
  72. package/src/verdict-schema-renderer.js.map +1 -1
  73. package/src/agent-worktree-lock.d.ts +0 -21
  74. package/src/agent-worktree-lock.js +0 -77
  75. package/src/agent-worktree-lock.js.map +0 -1
  76. package/src/atomic-file.d.ts +0 -46
  77. package/src/atomic-file.js +0 -114
  78. package/src/atomic-file.js.map +0 -1
  79. package/src/branch-archiver.d.ts +0 -70
  80. package/src/branch-archiver.js +0 -157
  81. package/src/branch-archiver.js.map +0 -1
  82. package/src/branch-mutation-log.d.ts +0 -77
  83. package/src/branch-mutation-log.js +0 -221
  84. package/src/branch-mutation-log.js.map +0 -1
  85. package/src/branch-reaper.d.ts +0 -121
  86. package/src/branch-reaper.js +0 -260
  87. package/src/branch-reaper.js.map +0 -1
  88. package/src/claude-config-dir.d.ts +0 -62
  89. package/src/claude-config-dir.js +0 -87
  90. package/src/claude-config-dir.js.map +0 -1
  91. package/src/harness-agent-activity.d.ts +0 -154
  92. package/src/harness-agent-activity.js +0 -346
  93. package/src/harness-agent-activity.js.map +0 -1
  94. package/src/inform-ai-error.d.ts +0 -6
  95. package/src/inform-ai-error.js +0 -13
  96. package/src/inform-ai-error.js.map +0 -1
  97. package/src/main-sync-file.d.ts +0 -121
  98. package/src/main-sync-file.js +0 -281
  99. package/src/main-sync-file.js.map +0 -1
  100. package/src/main-sync-status.d.ts +0 -197
  101. package/src/main-sync-status.js +0 -555
  102. package/src/main-sync-status.js.map +0 -1
  103. package/src/merged-branch-verdicts.d.ts +0 -189
  104. package/src/merged-branch-verdicts.js +0 -251
  105. package/src/merged-branch-verdicts.js.map +0 -1
  106. package/src/merged-branches.d.ts +0 -140
  107. package/src/merged-branches.js +0 -521
  108. package/src/merged-branches.js.map +0 -1
  109. package/src/review-identity-stamp.d.ts +0 -82
  110. package/src/review-identity-stamp.js +0 -172
  111. package/src/review-identity-stamp.js.map +0 -1
  112. package/src/state-dir-migration.d.ts +0 -79
  113. package/src/state-dir-migration.js +0 -185
  114. package/src/state-dir-migration.js.map +0 -1
  115. package/src/state-dir.d.ts +0 -209
  116. package/src/state-dir.js +0 -349
  117. package/src/state-dir.js.map +0 -1
  118. package/src/to-error.d.ts +0 -1
  119. package/src/to-error.js +0 -10
  120. package/src/to-error.js.map +0 -1
  121. package/src/worktree-lock-verdicts.d.ts +0 -149
  122. package/src/worktree-lock-verdicts.js +0 -225
  123. package/src/worktree-lock-verdicts.js.map +0 -1
  124. package/src/worktree-reaper.d.ts +0 -116
  125. package/src/worktree-reaper.js +0 -318
  126. package/src/worktree-reaper.js.map +0 -1
  127. package/src/worktrees.d.ts +0 -113
  128. package/src/worktrees.js +0 -260
  129. package/src/worktrees.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"branch-reaper.js","sour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Q,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3E,MAAM,GAAG,GAAG,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1E,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC3D,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;QAChF,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC;IACxD,CAAC;CACJ,CAAA;AA9LY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAMA,uCAAqB;QACxB,uCAAiB;QACpB,gCAAc;GAPpC,YAAY,CA8LxB","sourcesContent":["import { spawnSync } from 'child_process';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport {\n ArchiveResult,\n BranchArchiver,\n BRANCH_RETENTION_ARCHIVE_TAG,\n BRANCH_RETENTION_KEEP,\n} from './branch-archiver';\nimport { BranchMutationEvent, BranchMutationLog, MutationVerb } from './branch-mutation-log';\nimport { DeletableBranch, MergedBranchesCache, MergedBranchesService } from './merged-branches';\n\n/**\n * The EXECUTOR for the dead-branch verdicts that merged-branches.ts computes.\n *\n * WHY this exists: for a long time nothing in the tooling ever deleted a branch. The reap was only\n * ever a `git branch -D a b c` STRING embedded in a guard's fix hint, handed to an AI agent — which\n * reads a raw `-D` as destructive, asks \"may I clean this up?\", and stops. So the verdicts were\n * computed correctly on every hook call and then acted on by nobody, and local branches grew without\n * bound. The fix is not better wording; it is a thing that does the deleting.\n *\n * WHY deleting here is safe: every entry in `deletable` earned its place by one of exactly three\n * proofs — a MERGED PR (the work is in main), a squash-merge BACKUP of a merged branch, or ZERO\n * commits of its own (there is no work). merged-branches.ts also guarantees `main` is never in the\n * list and that a branch checked out in ANY worktree lands in `keep` instead, so we can never delete\n * the branch someone is standing on. On top of that, every delete is logged with the branch's\n * pre-delete SHA and a literal recover command, so no reap is unrecoverable.\n */\n\n// Data-only (per CLAUDE.md, classes for data). One branch and what happened to it.\nexport class ReapedBranch {\n branch: string;\n // The commit the branch pointed at BEFORE deletion — captured first, precisely so a delete is\n // always undoable via `git branch <branch> <sha>`. Empty only if rev-parse itself failed.\n sha: string;\n reason: string;\n pr: number;\n ok: boolean;\n // git's own stderr when ok=false. Kept verbatim: a failed delete is a thing a human must read.\n error: string;\n /**\n * The `archive/<date>/<branch>` tag written immediately BEFORE the delete, or '' when the retention\n * policy is 'delete'. Non-empty means the branch is restorable by NAME rather than by remembering a\n * sha — `git checkout -b <branch> <tag>` restores the exact objects, and the tag survives `gc` and\n * reflog expiry. Field-with-default so every existing `new ReapedBranch(...)` call site still builds.\n */\n archiveTag: string = '';\n /**\n * The branch was ALREADY GONE when we reached it — someone else reaped it first.\n *\n * Not a failure, and the distinction is not cosmetic. `wp-cleanup` and the detached refresher's\n * `auto-reap` both act on their own fresh verdicts, and the hooks kick off the refresher on the\n * same commands a human runs wp-cleanup from, so the two race by design. Observed 2026-08-04:\n * auto-reap deleted both dead branches at 14:30:58.207 and 14:30:59.035, wp-cleanup reached them\n * 300ms later and reported \"⚠️ 2 branch(es) could not be deleted — could not archive it first:\n * unknown revision\", i.e. it announced a failure for the exact outcome it wanted. Whoever wins,\n * the branch is gone, archived and logged by the winner.\n *\n * Field-with-default so every existing `new ReapedBranch(...)` call site still builds.\n */\n alreadyGone: boolean = false;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(branch: string, sha: string, reason: string, pr: number, ok: boolean, error: string) {\n this.branch = branch;\n this.sha = sha;\n this.reason = reason;\n this.pr = pr;\n this.ok = ok;\n this.error = error;\n }\n}\n\n/**\n * The outcome of one reap. `spared` is carried alongside deliberately: a cleanup that silently says\n * nothing about the branches it did NOT touch reads as \"there was nothing else\", when in fact those\n * are exactly the branches only a human can rule on.\n */\nexport class ReapResult {\n reaped: ReapedBranch[];\n failed: ReapedBranch[];\n spared: DeletableBranch[];\n /**\n * Branches a CONCURRENT reaper got to first (see ReapedBranch.alreadyGone). A separate bucket\n * because they belong in neither of the other two: counting them as `reaped` would credit this\n * run with a delete and an archive tag it did not write, and counting them as `failed` is the bug\n * this fixes — a red warning about branches that are, in fact, gone.\n *\n * Optional so every existing `new ReapResult(...)` call site still builds.\n */\n alreadyGone: ReapedBranch[];\n\n constructor(\n reaped: ReapedBranch[],\n failed: ReapedBranch[],\n spared: DeletableBranch[],\n alreadyGone: ReapedBranch[] = [],\n ) {\n this.reaped = reaped;\n this.failed = failed;\n this.spared = spared;\n this.alreadyGone = alreadyGone;\n }\n}\n\n// Result of a captured git invocation. `err` carries stderr so a failed delete can be reported.\ninterface CmdCapture {\n ok: boolean;\n out: string;\n err: string;\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class BranchReaper {\n // Defaulted so the non-DI call sites (the detached refresher in sync-main.ts) can just\n // `new BranchReaper()`, while inversify still injects the singletons when resolved from a\n // container. Mirrors how MergedBranchesService defaults its WorktreeService.\n constructor(\n private readonly mergedBranches: MergedBranchesService = new MergedBranchesService(),\n private readonly mutationLog: BranchMutationLog = new BranchMutationLog(),\n private readonly archiver: BranchArchiver = new BranchArchiver(),\n ) {}\n\n /**\n * Delete every branch the verdicts call dead, one command at a time.\n *\n * `cache` is an ALREADY-FRESH set of verdicts (the refresher just computed them, so re-running\n * the `gh` lookup would be pure waste). Pass nothing — as `wp-cleanup` does — and we recompute\n * from scratch. That distinction is load-bearing: the cache file on disk is DELIBERATELY allowed\n * to go stale, which is fine for blocking a branch creation but is not fine for deleting, since a\n * branch may have gained commits since it was written. Deleting never reads the stale file.\n */\n reap(\n repoRoot: string,\n verb: MutationVerb,\n cache: MergedBranchesCache | null = null,\n retention: string = BRANCH_RETENTION_ARCHIVE_TAG,\n ): ReapResult {\n // `false`: this is the BRANCH reap, and worktree locks are none of its business. Ignoring one\n // would only widen the WORKTREE verdicts it never reads.\n const verdicts = cache ?? this.mergedBranches.computeMergedBranches(repoRoot, false);\n // 'keep' means \"never delete anything\" — the reap becomes a pure report. Everything still lands\n // in `spared` so the human sees exactly what WOULD have been reaped under the other policies.\n if (retention === BRANCH_RETENTION_KEEP) {\n return new ReapResult([], [], [...verdicts.deletable, ...verdicts.keep]);\n }\n return this.reapBranches(repoRoot, verb, verdicts.deletable, retention, verdicts);\n }\n\n /**\n * Delete a CALLER-SUPPLIED list of branches — the branches a human just said yes to at wp-cleanup's\n * classification prompt. Separate from `reap` because these are NOT provably dead: they earned their\n * deletion from an explicit human answer, not from a verdict, so nothing here may ever run unattended.\n * Archiving still happens first, which is precisely what makes that yes low-stakes.\n */\n reapApproved(\n repoRoot: string,\n verb: MutationVerb,\n approved: DeletableBranch[],\n retention: string = BRANCH_RETENTION_ARCHIVE_TAG,\n ): ReapResult {\n if (retention === BRANCH_RETENTION_KEEP) return new ReapResult([], [], approved);\n const reaped: ReapedBranch[] = [];\n const failed: ReapedBranch[] = [];\n const alreadyGone: ReapedBranch[] = [];\n for (const entry of approved) {\n const outcome = this.deleteOne(repoRoot, verb, entry, retention);\n if (outcome.ok) reaped.push(outcome);\n else if (outcome.alreadyGone) alreadyGone.push(outcome);\n else failed.push(outcome);\n }\n return new ReapResult(reaped, failed, [], alreadyGone);\n }\n\n private reapBranches(\n repoRoot: string,\n verb: MutationVerb,\n targets: DeletableBranch[],\n retention: string,\n verdicts: MergedBranchesCache,\n ): ReapResult {\n const reaped: ReapedBranch[] = [];\n const failed: ReapedBranch[] = [];\n const alreadyGone: ReapedBranch[] = [];\n for (const entry of targets) {\n const outcome = this.deleteOne(repoRoot, verb, entry, retention);\n if (outcome.ok) reaped.push(outcome);\n else if (outcome.alreadyGone) alreadyGone.push(outcome);\n else failed.push(outcome);\n }\n\n // Only genuine failures stay in the cache's `deletable`. An already-gone branch is not there\n // to delete on the next pass, and leaving it in would make the cap keep counting a ghost.\n this.rewriteCache(repoRoot, verdicts, failed);\n return new ReapResult(reaped, failed, verdicts.keep, alreadyGone);\n }\n\n /**\n * One branch: ARCHIVE the tip as a tag, then one `git branch -D`. Never the multi-name form the old\n * fix hint used: git aborts the whole command on the first branch it refuses, which would strand\n * every branch after it in the list. One invocation each means one failure costs exactly one branch.\n *\n * The archive comes FIRST and, when it fails, the delete does NOT happen. A branch we could not\n * archive is a branch whose only remaining copy is the reflog, and the entire point of this change is\n * to stop relying on the reflog. Refusing to delete is the fail-safe direction: the worst case is a\n * branch that survives one more cleanup cycle.\n */\n private deleteOne(\n repoRoot: string,\n verb: MutationVerb,\n entry: DeletableBranch,\n retention: string,\n ): ReapedBranch {\n // SHA first — after the delete there is no branch left to resolve, and the whole point of the\n // audit line is that it records what was destroyed while it still exists.\n const resolved = this.capture(repoRoot, ['rev-parse', entry.branch]);\n const sha = resolved.ok ? resolved.out : '';\n\n // It does not resolve ⇒ it is already gone, reaped by whoever won the race (see\n // ReapedBranch.alreadyGone). Report that outcome honestly instead of letting it fall through\n // to the archive, which fails on the same missing ref and calls a successful cleanup a\n // failure. Nothing to archive and nothing to delete: the winner did both, and logged them.\n if (!resolved.ok) return this.alreadyGone(repoRoot, verb, entry);\n\n const archive = retention === BRANCH_RETENTION_ARCHIVE_TAG\n ? this.archiver.archive(repoRoot, entry.branch)\n : new ArchiveResult('', sha, true, '');\n if (!archive.ok) return this.archiveFailed(repoRoot, verb, entry, sha, archive);\n\n const deleted = this.capture(repoRoot, ['branch', '-D', entry.branch]);\n const result = new ReapedBranch(\n entry.branch, sha, entry.reason, entry.pr, deleted.ok, deleted.ok ? '' : deleted.err);\n result.archiveTag = archive.tag;\n\n const event = new BranchMutationEvent(verb, 'REAP');\n event.fromBranch = entry.branch;\n event.sha = sha;\n event.archiveTag = archive.tag;\n event.outcome = deleted.ok ? `deleted (${entry.reason})` : `FAILED (${deleted.err})`;\n this.mutationLog.logBranchMutation(repoRoot, event);\n\n return result;\n }\n\n /**\n * The branch vanished between the verdict and the reap — a concurrent reaper got it.\n *\n * Logged like every other outcome (a mutation nobody logs is a mutation nobody can audit), but\n * as ALREADY_GONE rather than SKIPPED/FAILED, and carried in its own bucket so the report can\n * say \"already gone\" instead of warning about a branch that is exactly as dead as intended.\n */\n private alreadyGone(repoRoot: string, verb: MutationVerb, entry: DeletableBranch): ReapedBranch {\n const event = new BranchMutationEvent(verb, 'REAP');\n event.fromBranch = entry.branch;\n event.outcome = 'ALREADY GONE (a concurrent reap deleted and archived it first)';\n this.mutationLog.logBranchMutation(repoRoot, event);\n\n const result = new ReapedBranch(\n entry.branch, '', entry.reason, entry.pr, false,\n 'already gone — a concurrent reap deleted and archived it first');\n result.alreadyGone = true;\n return result;\n }\n\n // Archiving failed ⇒ the branch is NOT deleted. Reported as a failure with git's own words, so the\n // human sees a branch that survived and why, rather than a silent skip.\n private archiveFailed(\n repoRoot: string, verb: MutationVerb, entry: DeletableBranch, sha: string, archive: ArchiveResult,\n ): ReapedBranch {\n const error = `not deleted — could not archive it first: ${archive.error}`;\n const event = new BranchMutationEvent(verb, 'REAP');\n event.fromBranch = entry.branch;\n event.sha = sha;\n event.outcome = `SKIPPED (${error})`;\n this.mutationLog.logBranchMutation(repoRoot, event);\n return new ReapedBranch(entry.branch, sha, entry.reason, entry.pr, false, error);\n }\n\n /**\n * Write the verdicts back with the reaped branches removed, so the branch-creation-guard's cap\n * sees the post-reap truth on its very next call instead of continuing to block against branches\n * that no longer exist. Anything that FAILED to delete stays in `deletable` — it is still there,\n * and still dead.\n */\n private rewriteCache(repoRoot: string, verdicts: MergedBranchesCache, failed: ReapedBranch[]): void {\n const stillDead = new Set(failed.map((entry: ReapedBranch): string => entry.branch));\n const remaining = verdicts.deletable.filter(\n (entry: DeletableBranch): boolean => stillDead.has(entry.branch));\n this.mergedBranches.writeMergedBranches(\n repoRoot,\n new MergedBranchesCache(verdicts.timestamp, remaining, verdicts.keep, verdicts.worktrees),\n );\n }\n\n // Run a git command capturing trimmed stdout/stderr; ok=false on spawn failure or non-zero exit.\n private capture(repoRoot: string, args: string[]): CmdCapture {\n const result = spawnSync('git', args, { cwd: repoRoot, encoding: 'utf8' });\n const err = typeof result.stderr === 'string' ? result.stderr.trim() : '';\n if (result.status !== 0 || typeof result.stdout !== 'string') {\n return { ok: false, out: '', err: err !== '' ? err : 'git command failed' };\n }\n return { ok: true, out: result.stdout.trim(), err };\n }\n}\n"]}
@@ -1,62 +0,0 @@
1
- /**
2
- * THE ONE PLACE THAT KNOWS WHERE CLAUDE CODE KEEPS ITS ON-DISK STATE.
3
- *
4
- * ─── WHY THIS FILE EXISTS ────────────────────────────────────────────────────────────────────────
5
- * `~/.claude` is a DEFAULT, not the location. Claude Code relocates the whole tree when
6
- * `$CLAUDE_CONFIG_DIR` is set, and three modules in this package read that tree: reviewer provenance
7
- * (`subagent-provenance.ts`), the audit record (`review-provenance.ts`) and the worktree-reap veto
8
- * (`harness-agent-activity.ts`). Only the third one resolved it correctly; the other two joined
9
- * `os.homedir()` with a hardcoded `'.claude'`.
10
- *
11
- * The consequence was not a degraded answer, it was a HARD BLOCK with no user-side workaround: on a
12
- * machine with `CLAUDE_CONFIG_DIR=~/.claude-work`, provenance found zero transcripts — not the
13
- * reviewers', not even the main agent's — so `wp-finish-upsert-pr` refused every PR whose reviewers
14
- * had genuinely run and genuinely passed, and the refusal blamed the reviewers' cwd. The audit record
15
- * it wrote said `mainTranscript: ""`, which is the field that settles it: the main transcript is found
16
- * by session id alone, with no cwd, branch or stamping involved, so an empty one can ONLY mean the
17
- * lookup ROOT was wrong. Re-spawning cannot fix a wrong root, and the only escape was a symlink into
18
- * `~/.claude` — i.e. hand-placing evidence inside a verification gate's own evidence tree.
19
- *
20
- * So the resolution lives here once, and the three modules call it. A second copy is how the first one
21
- * got out of step.
22
- *
23
- * ─── WHY BOTH ROOTS ARE SEARCHED ─────────────────────────────────────────────────────────────────
24
- * `$CLAUDE_CONFIG_DIR` is a property of the PROCESS, and the process that runs `wp-finish-upsert-pr`
25
- * is not the process that wrote the transcripts. A shell launched before the variable was exported —
26
- * or a hook, or a `pnpm` script whose env was sanitized — reads the transcripts of a session that had
27
- * it set while itself having it unset, and vice versa. Resolving to exactly ONE root makes the check
28
- * depend on env agreement between two unrelated processes, which is a fact nobody can verify and
29
- * nobody can repair from inside the flow.
30
- *
31
- * Searching both is cheap (a `readdir` of a directory that usually does not exist) and it only ever
32
- * ADDS candidate trees. It cannot weaken the integrity property either: every root yields the same
33
- * harness-written `spawnDepth` / `isSidechain` / branch evidence, so a transcript found under the
34
- * second root is no more forgeable than one found under the first.
35
- *
36
- * Shaped like {@link ClaudeEnv} in `claude-env.ts` — an injectable class plus one process-wide
37
- * instance — because `no-function-outside-class` is on: module-scope helpers are not a shape this repo
38
- * writes, whatever their arity.
39
- */
40
- /** The env var Claude Code exports when its config tree has been relocated. */
41
- export declare const CLAUDE_CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR";
42
- export declare class ClaudeConfigDir {
43
- /** The raw `$CLAUDE_CONFIG_DIR` value, or '' when it is not set. For DIAGNOSTICS, never for joining. */
44
- configuredDir(): string;
45
- /** Claude Code's config tree: `$CLAUDE_CONFIG_DIR` when set, else `~/.claude`. */
46
- root(): string;
47
- /**
48
- * Every config tree worth searching: the configured one FIRST, then `~/.claude` when it is a
49
- * different directory. See the both-roots note above for why this is a list and not one answer.
50
- */
51
- roots(): string[];
52
- /**
53
- * `<config>/projects` for every root {@link roots} names, in the same order — where per-project
54
- * session state and transcripts live.
55
- *
56
- * There is deliberately NO singular `projectsRoot()` beside this. Searching exactly one root is
57
- * precisely the defect #963 was, so an exported spelling that returns the one-root answer would make
58
- * the broken thing the shorter thing to type, in the one file that exists to prevent it.
59
- */
60
- projectsRoots(): string[];
61
- }
62
- export declare const claudeConfigDir: ClaudeConfigDir;
@@ -1,87 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.claudeConfigDir = exports.ClaudeConfigDir = exports.CLAUDE_CONFIG_DIR_ENV = void 0;
4
- const tslib_1 = require("tslib");
5
- const os = tslib_1.__importStar(require("os"));
6
- const path = tslib_1.__importStar(require("path"));
7
- const inversify_1 = require("inversify");
8
- /**
9
- * THE ONE PLACE THAT KNOWS WHERE CLAUDE CODE KEEPS ITS ON-DISK STATE.
10
- *
11
- * ─── WHY THIS FILE EXISTS ────────────────────────────────────────────────────────────────────────
12
- * `~/.claude` is a DEFAULT, not the location. Claude Code relocates the whole tree when
13
- * `$CLAUDE_CONFIG_DIR` is set, and three modules in this package read that tree: reviewer provenance
14
- * (`subagent-provenance.ts`), the audit record (`review-provenance.ts`) and the worktree-reap veto
15
- * (`harness-agent-activity.ts`). Only the third one resolved it correctly; the other two joined
16
- * `os.homedir()` with a hardcoded `'.claude'`.
17
- *
18
- * The consequence was not a degraded answer, it was a HARD BLOCK with no user-side workaround: on a
19
- * machine with `CLAUDE_CONFIG_DIR=~/.claude-work`, provenance found zero transcripts — not the
20
- * reviewers', not even the main agent's — so `wp-finish-upsert-pr` refused every PR whose reviewers
21
- * had genuinely run and genuinely passed, and the refusal blamed the reviewers' cwd. The audit record
22
- * it wrote said `mainTranscript: ""`, which is the field that settles it: the main transcript is found
23
- * by session id alone, with no cwd, branch or stamping involved, so an empty one can ONLY mean the
24
- * lookup ROOT was wrong. Re-spawning cannot fix a wrong root, and the only escape was a symlink into
25
- * `~/.claude` — i.e. hand-placing evidence inside a verification gate's own evidence tree.
26
- *
27
- * So the resolution lives here once, and the three modules call it. A second copy is how the first one
28
- * got out of step.
29
- *
30
- * ─── WHY BOTH ROOTS ARE SEARCHED ─────────────────────────────────────────────────────────────────
31
- * `$CLAUDE_CONFIG_DIR` is a property of the PROCESS, and the process that runs `wp-finish-upsert-pr`
32
- * is not the process that wrote the transcripts. A shell launched before the variable was exported —
33
- * or a hook, or a `pnpm` script whose env was sanitized — reads the transcripts of a session that had
34
- * it set while itself having it unset, and vice versa. Resolving to exactly ONE root makes the check
35
- * depend on env agreement between two unrelated processes, which is a fact nobody can verify and
36
- * nobody can repair from inside the flow.
37
- *
38
- * Searching both is cheap (a `readdir` of a directory that usually does not exist) and it only ever
39
- * ADDS candidate trees. It cannot weaken the integrity property either: every root yields the same
40
- * harness-written `spawnDepth` / `isSidechain` / branch evidence, so a transcript found under the
41
- * second root is no more forgeable than one found under the first.
42
- *
43
- * Shaped like {@link ClaudeEnv} in `claude-env.ts` — an injectable class plus one process-wide
44
- * instance — because `no-function-outside-class` is on: module-scope helpers are not a shape this repo
45
- * writes, whatever their arity.
46
- */
47
- /** The env var Claude Code exports when its config tree has been relocated. */
48
- exports.CLAUDE_CONFIG_DIR_ENV = 'CLAUDE_CONFIG_DIR';
49
- let ClaudeConfigDir = class ClaudeConfigDir {
50
- /** The raw `$CLAUDE_CONFIG_DIR` value, or '' when it is not set. For DIAGNOSTICS, never for joining. */
51
- configuredDir() {
52
- return (process.env[exports.CLAUDE_CONFIG_DIR_ENV] ?? '').trim();
53
- }
54
- /** Claude Code's config tree: `$CLAUDE_CONFIG_DIR` when set, else `~/.claude`. */
55
- root() {
56
- const configured = this.configuredDir();
57
- return configured !== '' ? configured : path.join(os.homedir(), '.claude');
58
- }
59
- /**
60
- * Every config tree worth searching: the configured one FIRST, then `~/.claude` when it is a
61
- * different directory. See the both-roots note above for why this is a list and not one answer.
62
- */
63
- roots() {
64
- const configured = this.root();
65
- const fallback = path.join(os.homedir(), '.claude');
66
- return path.resolve(configured) === path.resolve(fallback) ? [configured] : [configured, fallback];
67
- }
68
- /**
69
- * `<config>/projects` for every root {@link roots} names, in the same order — where per-project
70
- * session state and transcripts live.
71
- *
72
- * There is deliberately NO singular `projectsRoot()` beside this. Searching exactly one root is
73
- * precisely the defect #963 was, so an exported spelling that returns the one-root answer would make
74
- * the broken thing the shorter thing to type, in the one file that exists to prevent it.
75
- */
76
- projectsRoots() {
77
- return this.roots().map((root) => path.join(root, 'projects'));
78
- }
79
- };
80
- exports.ClaudeConfigDir = ClaudeConfigDir;
81
- exports.ClaudeConfigDir = ClaudeConfigDir = tslib_1.__decorate([
82
- (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton)
83
- ], ClaudeConfigDir);
84
- // Process-wide instance for the many non-DI call sites (hooks, wp-* bins); inversify still injects the
85
- // singleton wherever a container is in play. Same arrangement as `claudeEnv`.
86
- exports.claudeConfigDir = new ClaudeConfigDir();
87
- //# sourceMappingURL=claude-config-dir.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"claude-config-dir.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/claude-config-dir.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,+EAA+E;AAClE,QAAA,qBAAqB,GAAG,mBAAmB,CAAC;AAGlD,IAAM,eAAe,GAArB,MAAM,eAAe;IACxB,wGAAwG;IACxG,aAAa;QACT,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,6BAAqB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,CAAC;IAED,kFAAkF;IAClF,IAAI;QACA,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACxC,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACH,KAAK;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACvG,CAAC;IAED;;;;;;;OAOG;IACH,aAAa;QACT,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IACnF,CAAC;CACJ,CAAA;AAjCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,eAAe,CAiC3B;AAED,uGAAuG;AACvG,8EAA8E;AACjE,QAAA,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC","sourcesContent":["import * as os from 'os';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n/**\n * THE ONE PLACE THAT KNOWS WHERE CLAUDE CODE KEEPS ITS ON-DISK STATE.\n *\n * ─── WHY THIS FILE EXISTS ────────────────────────────────────────────────────────────────────────\n * `~/.claude` is a DEFAULT, not the location. Claude Code relocates the whole tree when\n * `$CLAUDE_CONFIG_DIR` is set, and three modules in this package read that tree: reviewer provenance\n * (`subagent-provenance.ts`), the audit record (`review-provenance.ts`) and the worktree-reap veto\n * (`harness-agent-activity.ts`). Only the third one resolved it correctly; the other two joined\n * `os.homedir()` with a hardcoded `'.claude'`.\n *\n * The consequence was not a degraded answer, it was a HARD BLOCK with no user-side workaround: on a\n * machine with `CLAUDE_CONFIG_DIR=~/.claude-work`, provenance found zero transcripts — not the\n * reviewers', not even the main agent's — so `wp-finish-upsert-pr` refused every PR whose reviewers\n * had genuinely run and genuinely passed, and the refusal blamed the reviewers' cwd. The audit record\n * it wrote said `mainTranscript: \"\"`, which is the field that settles it: the main transcript is found\n * by session id alone, with no cwd, branch or stamping involved, so an empty one can ONLY mean the\n * lookup ROOT was wrong. Re-spawning cannot fix a wrong root, and the only escape was a symlink into\n * `~/.claude` — i.e. hand-placing evidence inside a verification gate's own evidence tree.\n *\n * So the resolution lives here once, and the three modules call it. A second copy is how the first one\n * got out of step.\n *\n * ─── WHY BOTH ROOTS ARE SEARCHED ─────────────────────────────────────────────────────────────────\n * `$CLAUDE_CONFIG_DIR` is a property of the PROCESS, and the process that runs `wp-finish-upsert-pr`\n * is not the process that wrote the transcripts. A shell launched before the variable was exported —\n * or a hook, or a `pnpm` script whose env was sanitized — reads the transcripts of a session that had\n * it set while itself having it unset, and vice versa. Resolving to exactly ONE root makes the check\n * depend on env agreement between two unrelated processes, which is a fact nobody can verify and\n * nobody can repair from inside the flow.\n *\n * Searching both is cheap (a `readdir` of a directory that usually does not exist) and it only ever\n * ADDS candidate trees. It cannot weaken the integrity property either: every root yields the same\n * harness-written `spawnDepth` / `isSidechain` / branch evidence, so a transcript found under the\n * second root is no more forgeable than one found under the first.\n *\n * Shaped like {@link ClaudeEnv} in `claude-env.ts` — an injectable class plus one process-wide\n * instance — because `no-function-outside-class` is on: module-scope helpers are not a shape this repo\n * writes, whatever their arity.\n */\n\n/** The env var Claude Code exports when its config tree has been relocated. */\nexport const CLAUDE_CONFIG_DIR_ENV = 'CLAUDE_CONFIG_DIR';\n\n@injectable(bindingScopeValues.Singleton)\nexport class ClaudeConfigDir {\n /** The raw `$CLAUDE_CONFIG_DIR` value, or '' when it is not set. For DIAGNOSTICS, never for joining. */\n configuredDir(): string {\n return (process.env[CLAUDE_CONFIG_DIR_ENV] ?? '').trim();\n }\n\n /** Claude Code's config tree: `$CLAUDE_CONFIG_DIR` when set, else `~/.claude`. */\n root(): string {\n const configured = this.configuredDir();\n return configured !== '' ? configured : path.join(os.homedir(), '.claude');\n }\n\n /**\n * Every config tree worth searching: the configured one FIRST, then `~/.claude` when it is a\n * different directory. See the both-roots note above for why this is a list and not one answer.\n */\n roots(): string[] {\n const configured = this.root();\n const fallback = path.join(os.homedir(), '.claude');\n return path.resolve(configured) === path.resolve(fallback) ? [configured] : [configured, fallback];\n }\n\n /**\n * `<config>/projects` for every root {@link roots} names, in the same order — where per-project\n * session state and transcripts live.\n *\n * There is deliberately NO singular `projectsRoot()` beside this. Searching exactly one root is\n * precisely the defect #963 was, so an exported spelling that returns the one-root answer would make\n * the broken thing the shorter thing to type, in the one file that exists to prevent it.\n */\n projectsRoots(): string[] {\n return this.roots().map((root: string): string => path.join(root, 'projects'));\n }\n}\n\n// Process-wide instance for the many non-DI call sites (hooks, wp-* bins); inversify still injects the\n// singleton wherever a container is in play. Same arrangement as `claudeEnv`.\nexport const claudeConfigDir = new ClaudeConfigDir();\n"]}
@@ -1,154 +0,0 @@
1
- /**
2
- * THE ONE PLACE THAT KNOWS ANYTHING ABOUT CLAUDE CODE'S ON-DISK STATE.
3
- *
4
- * ─── THE RULE THIS CLASS EXISTS UNDER ────────────────────────────────────────────────────────────
5
- *
6
- * HARNESS STATE MAY ONLY VETO A REAP. IT MAY NEVER LICENSE ONE.
7
- *
8
- * Read that before reading anything else here, because every answer below is shaped by it. The
9
- * licence to remove a worktree comes SOLELY from evidence wp-cleanup already computes and already
10
- * gets right: a merged PR, a snapshot of a ref that still holds the work, a ref identical to
11
- * origin/main, plus a clean `git status --porcelain`. This class answers ONE question — "is somebody
12
- * plausibly still in there?" — and its only power is to STOP a reap that the branch evidence had
13
- * already authorised. No answer it can give turns a spared worktree into a reaped one.
14
- *
15
- * ─── WHY IT EXISTS ───────────────────────────────────────────────────────────────────────────────
16
- * `git worktree lock` reasons written by the Claude Code harness carry a pid, and wp-cleanup used to
17
- * ask the kernel whether that pid was alive. It always is. Subagents are NOT separate OS processes —
18
- * every agent in a session records the SAME pid, the session process — so "is that pid running?"
19
- * reduced to "is the editor still open?", which is true by construction for the whole life of a
20
- * session. Observed in monorepo-nx2: nine worktrees against a cap of five, eight of them reported as
21
- * "that agent is working in here" with one identical pid, exactly ONE agent actually running, and
22
- * several of the others' PRs already merged.
23
- *
24
- * So a veto has to come from somewhere that knows about AGENTS rather than processes. The harness
25
- * does, and it writes it down:
26
- *
27
- * <config>/projects/<project-slug>/<sessionId>/subagents/agent-<id>.meta.json
28
- * <config>/projects/<project-slug>/<sessionId>/subagents/agent-<id>.jsonl
29
- *
30
- * `<config>` is `$CLAUDE_CONFIG_DIR` when set, else `~/.claude`. `agent-<id>` is ONE token, and it is
31
- * the same token in three places: the stem of those two filenames, the basename of the `worktreePath`
32
- * that meta records, and the name in the lock reason `claude agent agent-<id> (pid N …)`. So worktree
33
- * → agent state is an exact lookup, not a heuristic — and nothing here re-derives or re-prefixes that
34
- * token, because a filename built from half of it is how a lookup quietly becomes a miss.
35
- *
36
- * ─── THE SIGNAL: THE SHAPE OF THE LAST RECORD IN THE AGENT'S OWN TRANSCRIPT ──────────────────────
37
- * An agent's loop pauses when the model emits text and asks for no tool. That is the definition of
38
- * the loop, not a correlation with one:
39
- *
40
- * last record is `assistant` with NO `tool_use` block → RETURNED — not currently in a tool loop
41
- * anything else (a `tool_use` block, a `user`/tool_result record) → MID-LOOP
42
- *
43
- * Verified on three agents known to have finished (all `assistant` / `['text']`) and on a live one
44
- * (`assistant` / `['tool_use']`). `thinking` blocks appear alongside `text` and change nothing: the
45
- * criterion is the ABSENCE of `tool_use`, never "exactly one block". A `user` record's content can be
46
- * a plain STRING rather than a list of blocks; that is mid-loop too, and must not throw.
47
- *
48
- * ─── "RETURNED" IS NOT "DONE FOREVER", WHICH IS WHY IT CANNOT LICENSE A REAP ──────────────────────
49
- * Measured: a throwaway agent returned with a text-only record at 17:04:20, and at 17:08:11 a `user`
50
- * record appeared and it ran again, returning a second time at 17:08:13. The harness RE-INVOKES an
51
- * agent when a background child it started completes, and when a parent sends it a message. It holds
52
- * its worktree across that gap. So RETURNED means "not in a tool loop right now" and nothing
53
- * stronger — which is survivable only because of the rule at the top of this file: the reap was
54
- * already authorised by a merged PR and a clean tree, and an agent that briefly resumes into that
55
- * situation has nothing to lose.
56
- *
57
- * ─── WHY MTIME IS ONLY A TIEBREAKER ──────────────────────────────────────────────────────────────
58
- * Freshness of the transcript looks like the obvious liveness signal and is NOT one. Measured: one
59
- * minute after that throwaway agent finished, its mtime was FRESHER than the genuinely live agent's
60
- * had been moments earlier. And a live agent writes nothing at all while it sits inside one long Bash
61
- * call — a `wp-build` is ten minutes of silence — so any threshold safe against that also covers
62
- * every just-finished agent, which is precisely the population wp-cleanup meets. Mtime alone does not
63
- * fix this bug; it re-times it. It earns its place on exactly one case: telling a mid-loop transcript
64
- * that is being written RIGHT NOW (a live agent, veto) from one frozen mid-`tool_use` by a killed
65
- * session (no veto — that is the original "looks live forever" defect).
66
- *
67
- * ─── NEGATIVE RESULT — DO NOT RE-TRY THIS ────────────────────────────────────────────────────────
68
- * The meta records a `toolUseId`, and a `tool_result` for it in the SPAWNER's transcript looks like an
69
- * exact completion marker. It is NOT one: a backgrounded Agent call gets its "launched successfully"
70
- * tool_result IMMEDIATELY, so a running agent already has one, indistinguishable from a finished
71
- * agent's. Measured on a live agent and rejected.
72
- *
73
- * ─── EVERY ANSWER FAILS SAFE ─────────────────────────────────────────────────────────────────────
74
- * A missing config dir, an unreadable file, a meta describing a different worktree, a truncated last
75
- * line — all of them are UNKNOWN. UNKNOWN withholds the veto, which is only ever safe because the
76
- * branch evidence had to authorise the reap first.
77
- *
78
- * THIS IS UNDOCUMENTED HARNESS INTERNALS, deliberately quarantined in one file so a layout change
79
- * breaks exactly here and degrades to "cannot tell" everywhere else.
80
- */
81
- /** Mid-loop and being written to right now. The ONE answer that vetoes a reap. */
82
- export declare const AGENT_ACTIVITY_LIVE = "live";
83
- /** Its transcript ends with the model returning — not in a tool loop. It may still resume. */
84
- export declare const AGENT_ACTIVITY_RETURNED = "returned";
85
- /** No usable evidence, or a mid-loop transcript nobody has touched for a long time. */
86
- export declare const AGENT_ACTIVITY_UNKNOWN = "unknown";
87
- /**
88
- * How long a MID-LOOP transcript may sit untouched before its silence stops vetoing a reap.
89
- *
90
- * Consulted for a mid-loop transcript only — a returned one is recognised by shape, whatever its
91
- * mtime — so this number decides exactly one thing: how long an agent that was KILLED inside a tool
92
- * call goes on vetoing. Generous on purpose, because a live agent writes NOTHING while it is inside
93
- * one long Bash call and a `wp-build` or `nx run … :ci` is routinely ten minutes of that. A threshold
94
- * in seconds would drop the veto on a building agent, which is the one direction that costs work;
95
- * being late costs a directory the next cleanup takes.
96
- */
97
- export declare const AGENT_TRANSCRIPT_QUIET_MS: number;
98
- export declare class AgentActivity {
99
- /** One of the AGENT_ACTIVITY_* constants. */
100
- state: string;
101
- /** Human-readable evidence, printed verbatim into wp-cleanup's spared/overridden reasons. */
102
- detail: string;
103
- constructor(state: string, detail: string);
104
- }
105
- export declare class HarnessAgentActivityReader {
106
- /**
107
- * What the harness says about `agentId`, cross-checked against the worktree we are judging.
108
- *
109
- * `worktreePath` is not decoration: it is what makes this a LOOKUP rather than a guess. If the
110
- * meta we find records a different worktree we have matched the wrong thing, and the answer is
111
- * UNKNOWN — never an answer about somebody else's directory.
112
- */
113
- activityOf(agentId: string, worktreePath: string, now?: number): AgentActivity;
114
- /**
115
- * Did the agent RETURN? True only for an `assistant` record whose content asks for no tool.
116
- *
117
- * A `user` record (a tool result coming back, or a message sent to the agent) is mid-loop by
118
- * definition — and its content may be a plain string, which is why the array check comes first. So
119
- * is an `assistant` record carrying a `tool_use` EVEN ALONGSIDE TEXT: the model narrating before
120
- * it calls something is not a return.
121
- */
122
- private isReturn;
123
- /**
124
- * The agent's own transcript, or the reason there is none — each of the three exits phrased for
125
- * what actually happened. `exists` is asked BEFORE `readMeta` precisely so "not there" and
126
- * "there and unreadable" stay distinguishable; folding them together is what produced the flat
127
- * over-claim this replaced.
128
- */
129
- private locate;
130
- /** Every `<config>/projects/<slug>/<session>/subagents` directory that exists right now. */
131
- private subagentDirs;
132
- /**
133
- * Seam: where the harness keeps its per-project state, delegated to the ONE resolver
134
- * ({@link ClaudeConfigDir}) so this file and the two provenance modules cannot disagree about
135
- * it — they did, and the divergence hard-blocked every PR on a relocated config dir. Specs point
136
- * `$CLAUDE_CONFIG_DIR` at a fixture tree, which exercises the same resolution the field uses.
137
- */
138
- protected projectsRoots(): string[];
139
- private minutesAgo;
140
- private exists;
141
- private readMeta;
142
- /**
143
- * The last complete JSONL record of `transcript`, or null.
144
- *
145
- * Reads only the tail, because these files grow without bound and only the final line matters. A
146
- * window that starts mid-record yields an unparseable fragment and therefore null — "cannot tell"
147
- * — which is exactly what a truncated or half-written last line should also produce.
148
- */
149
- private lastRecord;
150
- private readTail;
151
- private readDir;
152
- private isDirectory;
153
- private mtimeOf;
154
- }