@ornexus/neocortex 4.61.5 → 4.62.0

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 (279) hide show
  1. package/dist/release-source.json +1 -1
  2. package/dist/sbom.cdx.json +1193 -1193
  3. package/install.ps1 +31 -34
  4. package/install.sh +1 -1
  5. package/package.json +5 -2
  6. package/packages/client/dist/adapters/adapter-registry.js +1 -108
  7. package/packages/client/dist/adapters/antigravity-adapter.js +2 -77
  8. package/packages/client/dist/adapters/claude-code-adapter.js +3 -79
  9. package/packages/client/dist/adapters/codex-adapter.js +2 -80
  10. package/packages/client/dist/adapters/cursor-adapter.js +4 -115
  11. package/packages/client/dist/adapters/gemini-adapter.js +2 -71
  12. package/packages/client/dist/adapters/grok-adapter.js +2 -42
  13. package/packages/client/dist/adapters/index.js +1 -22
  14. package/packages/client/dist/adapters/platform-detector.js +1 -220
  15. package/packages/client/dist/adapters/target-adapter.js +0 -12
  16. package/packages/client/dist/adapters/vscode-adapter.js +2 -72
  17. package/packages/client/dist/agent/refresh-stubs.js +2 -443
  18. package/packages/client/dist/agent/update-agent-yaml.js +1 -102
  19. package/packages/client/dist/agent/update-description.d.ts +8 -1
  20. package/packages/client/dist/agent/update-description.js +2 -260
  21. package/packages/client/dist/cache/crypto-utils.js +1 -78
  22. package/packages/client/dist/cache/encrypted-cache.js +1 -338
  23. package/packages/client/dist/cache/in-memory-asset-cache.js +1 -73
  24. package/packages/client/dist/cache/index.js +1 -13
  25. package/packages/client/dist/cache/protected-pi-boundary.js +1 -44
  26. package/packages/client/dist/checkpoint/checkpoint-client-reader.js +2 -127
  27. package/packages/client/dist/checkpoint/index.js +1 -11
  28. package/packages/client/dist/checkpoint/shared-checkpoint-types.js +1 -32
  29. package/packages/client/dist/cli.js +5 -364
  30. package/packages/client/dist/commands/activate.js +8 -394
  31. package/packages/client/dist/commands/architecture-answers.js +7 -274
  32. package/packages/client/dist/commands/architecture-memory-terminal.js +4 -253
  33. package/packages/client/dist/commands/architecture-non-ui-continuation.js +1 -100
  34. package/packages/client/dist/commands/architecture-root-binding.js +1 -51
  35. package/packages/client/dist/commands/cache-status.js +2 -112
  36. package/packages/client/dist/commands/config.js +1 -88
  37. package/packages/client/dist/commands/doctor.js +2 -635
  38. package/packages/client/dist/commands/invoke.d.ts +17 -0
  39. package/packages/client/dist/commands/invoke.js +148 -7822
  40. package/packages/client/dist/commands/legacy-epic-terminal.js +1 -71
  41. package/packages/client/dist/commands/legacy-story-branch.js +1 -96
  42. package/packages/client/dist/commands/legacy-story-pr.js +1 -276
  43. package/packages/client/dist/commands/mutation-qa-checkpoint.js +5 -285
  44. package/packages/client/dist/commands/mutation-qa-gate.js +1 -54
  45. package/packages/client/dist/commands/mutation-qa-git.js +1 -41
  46. package/packages/client/dist/commands/mutation-qa-policy.js +1 -102
  47. package/packages/client/dist/commands/mutation-qa-run.js +3 -219
  48. package/packages/client/dist/commands/mutation-qa-verdict.js +1 -149
  49. package/packages/client/dist/commands/mutation-qa.js +1 -220
  50. package/packages/client/dist/commands/native-agent.js +2 -136
  51. package/packages/client/dist/commands/planning-diagnosis.js +1 -43
  52. package/packages/client/dist/commands/planning-generation.js +1 -53
  53. package/packages/client/dist/commands/planning-memory.js +1 -40
  54. package/packages/client/dist/commands/planning-research.js +1 -42
  55. package/packages/client/dist/commands/private-session.js +1 -75
  56. package/packages/client/dist/commands/property-qa.js +1 -139
  57. package/packages/client/dist/commands/qa-control.js +1 -16
  58. package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -55
  59. package/packages/client/dist/commands/qa-scan-browser-route.js +1 -28
  60. package/packages/client/dist/commands/qa-scan-capture.js +5 -663
  61. package/packages/client/dist/commands/qa-scan-discovery.js +3 -376
  62. package/packages/client/dist/commands/qa-scan-review.js +5 -826
  63. package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -266
  64. package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -297
  65. package/packages/client/dist/commands/qa-synthetic-backend.js +2 -340
  66. package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -85
  67. package/packages/client/dist/commands/qa-synthetic-browser.js +1 -39
  68. package/packages/client/dist/commands/refactor-characterization.js +21 -671
  69. package/packages/client/dist/commands/refactor-commit.js +13 -399
  70. package/packages/client/dist/commands/refactor-control.js +3 -142
  71. package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -93
  72. package/packages/client/dist/commands/refactor-review.js +5 -283
  73. package/packages/client/dist/commands/refactor-root.js +7 -588
  74. package/packages/client/dist/commands/refresh-memory.js +3 -174
  75. package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -24
  76. package/packages/client/dist/commands/story-checkpoint.d.ts +5 -1
  77. package/packages/client/dist/commands/story-checkpoint.js +1 -203
  78. package/packages/client/dist/commands/story-worktree.js +5 -258
  79. package/packages/client/dist/config/host-auth-broker.js +1 -60
  80. package/packages/client/dist/config/host-auth-reference.js +1 -93
  81. package/packages/client/dist/config/profile-directory.js +1 -13
  82. package/packages/client/dist/config/resolver-selection.js +1 -278
  83. package/packages/client/dist/config/secure-config.js +12 -281
  84. package/packages/client/dist/config.js +2 -224
  85. package/packages/client/dist/constants.js +1 -25
  86. package/packages/client/dist/context/context-collector.js +2 -222
  87. package/packages/client/dist/context/context-sanitizer.js +1 -145
  88. package/packages/client/dist/continuity/autonomous-governance.js +1 -285
  89. package/packages/client/dist/continuity/continuity-client-state-store.js +1 -1587
  90. package/packages/client/dist/continuity/invoke-hooks.js +1 -129
  91. package/packages/client/dist/continuity/migrations/001-initial-schema.js +2 -12
  92. package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +2 -12
  93. package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +2 -12
  94. package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +2 -12
  95. package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +2 -12
  96. package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +2 -10
  97. package/packages/client/dist/continuity/native-agent-store.js +1 -69
  98. package/packages/client/dist/continuity/native-agent-types.js +1 -105
  99. package/packages/client/dist/continuity/outbox.js +1 -117
  100. package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -172
  101. package/packages/client/dist/continuity/sqlite-store.js +81 -2612
  102. package/packages/client/dist/effects/invoke-effect-gateways.js +1 -62
  103. package/packages/client/dist/errors/error-messages.js +2 -258
  104. package/packages/client/dist/errors/frontmatter-diagnostics.d.ts +10 -1
  105. package/packages/client/dist/errors/frontmatter-diagnostics.js +1 -125
  106. package/packages/client/dist/evidence/collector.js +1 -347
  107. package/packages/client/dist/evidence/index.js +1 -1
  108. package/packages/client/dist/evidence/types.js +0 -2
  109. package/packages/client/dist/fs/atomic-state-replace.js +1 -152
  110. package/packages/client/dist/generated/command-registry.generated.js +1 -4076
  111. package/packages/client/dist/generated/public-projections.generated.js +1 -149
  112. package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -138
  113. package/packages/client/dist/git/direct-yolo-checkpoint.d.ts +94 -9
  114. package/packages/client/dist/git/direct-yolo-checkpoint.js +3 -1592
  115. package/packages/client/dist/git/epic-operational-state.js +2 -672
  116. package/packages/client/dist/git/git-lifecycle-step-ids.js +1 -14
  117. package/packages/client/dist/git/git-lifecycle-store.d.ts +88 -0
  118. package/packages/client/dist/git/git-lifecycle-store.js +9 -2529
  119. package/packages/client/dist/git/legacy-story-branch-checkpoint.js +9 -259
  120. package/packages/client/dist/git/legacy-story-branch-setup.js +4 -348
  121. package/packages/client/dist/git/legacy-story-pr.js +70 -3538
  122. package/packages/client/dist/git/neocortex-trailers.js +2 -53
  123. package/packages/client/dist/git/release-gate-env.d.ts +62 -0
  124. package/packages/client/dist/git/release-gate-env.js +1 -0
  125. package/packages/client/dist/git/secure-filesystem-boundary.d.ts +24 -0
  126. package/packages/client/dist/git/secure-filesystem-boundary.js +20 -186
  127. package/packages/client/dist/git/story-worktree-cleanup.js +4 -1058
  128. package/packages/client/dist/git/story-worktree-integration.d.ts +62 -0
  129. package/packages/client/dist/git/story-worktree-integration.js +3 -603
  130. package/packages/client/dist/git/story-worktree-manager.js +3 -843
  131. package/packages/client/dist/git/story-worktree-paths.js +1 -150
  132. package/packages/client/dist/git/story-write-set-extension.d.ts +44 -0
  133. package/packages/client/dist/git/story-write-set-extension.js +1 -0
  134. package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -284
  135. package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -237
  136. package/packages/client/dist/i18n/first-run.js +2 -60
  137. package/packages/client/dist/index.js +1 -50
  138. package/packages/client/dist/invocation/invoke-input.js +1 -24
  139. package/packages/client/dist/license/host-auth-recovery.js +1 -401
  140. package/packages/client/dist/license/index.js +1 -5
  141. package/packages/client/dist/license/license-client.js +1 -337
  142. package/packages/client/dist/machine/fingerprint.js +2 -163
  143. package/packages/client/dist/machine/index.js +1 -5
  144. package/packages/client/dist/memory/project-memory-path-scope.js +1 -62
  145. package/packages/client/dist/memory/project-memory-writer.js +41 -1117
  146. package/packages/client/dist/memory/shared-project-memory-types.js +2 -259
  147. package/packages/client/dist/migrations/epic-lifecycle-backfill.js +3 -1060
  148. package/packages/client/dist/migrations/project-identity-capability.js +1 -50
  149. package/packages/client/dist/migrations/project-identity.js +7 -493
  150. package/packages/client/dist/migrations/state-json.js +4 -393
  151. package/packages/client/dist/policy/architecture-policy.js +2 -184
  152. package/packages/client/dist/policy/index.js +1 -7
  153. package/packages/client/dist/policy/shared-policy-types.js +0 -38
  154. package/packages/client/dist/policy/subagent-approval-policy.js +1 -57
  155. package/packages/client/dist/private-execution/clean-baseline.js +2 -279
  156. package/packages/client/dist/private-execution/codex-executor.js +4 -574
  157. package/packages/client/dist/private-execution/codex-host-runtime.js +1 -137
  158. package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -97
  159. package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -128
  160. package/packages/client/dist/private-execution/delivery.js +13 -410
  161. package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -294
  162. package/packages/client/dist/private-execution/frozen-handoff.js +6 -19
  163. package/packages/client/dist/private-execution/implementation-validation.js +2 -106
  164. package/packages/client/dist/private-execution/isolated-admission.js +23 -1432
  165. package/packages/client/dist/private-execution/isolated-session.js +5 -725
  166. package/packages/client/dist/private-execution/isolated-workspace.js +1 -122
  167. package/packages/client/dist/private-execution/pact-consumer-runtime.js +3 -409
  168. package/packages/client/dist/private-execution/pact-test-source.js +1 -258
  169. package/packages/client/dist/private-execution/pact-toolchain.js +3 -290
  170. package/packages/client/dist/private-execution/pact-write-set.js +1 -172
  171. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -406
  172. package/packages/client/dist/private-execution/planning-generation-checkpoint.js +5 -462
  173. package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -139
  174. package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -325
  175. package/packages/client/dist/private-execution/private-report-store.js +1 -42
  176. package/packages/client/dist/private-execution/property-test-candidate.js +1 -103
  177. package/packages/client/dist/private-execution/property-test-choices.js +3 -147
  178. package/packages/client/dist/private-execution/property-test-plan.js +7 -271
  179. package/packages/client/dist/private-execution/property-test-review.js +4 -258
  180. package/packages/client/dist/private-execution/property-test-runtime.js +9 -372
  181. package/packages/client/dist/private-execution/property-test-source.js +1 -139
  182. package/packages/client/dist/private-execution/root-checkpoint.js +1 -80
  183. package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -135
  184. package/packages/client/dist/private-execution/root-memory-recovery.js +1 -93
  185. package/packages/client/dist/private-execution/root-memory-request.js +1 -29
  186. package/packages/client/dist/private-execution/root-memory-scope.js +1 -178
  187. package/packages/client/dist/private-execution/root-memory-writer.js +1 -102
  188. package/packages/client/dist/private-execution/session-lease.js +1 -63
  189. package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -50
  190. package/packages/client/dist/private-execution/shared-project-validation.js +1 -66
  191. package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -61
  192. package/packages/client/dist/private-execution/ux-source-validation.js +1 -372
  193. package/packages/client/dist/private-execution/ux-write-set.js +2 -191
  194. package/packages/client/dist/registry/registry-reconciliation.js +1 -234
  195. package/packages/client/dist/resilience/circuit-breaker.js +1 -170
  196. package/packages/client/dist/resilience/degradation-manager.js +1 -164
  197. package/packages/client/dist/resilience/freshness-indicator.js +1 -100
  198. package/packages/client/dist/resilience/index.js +1 -8
  199. package/packages/client/dist/resilience/recovery-detector.js +1 -74
  200. package/packages/client/dist/resolvers/asset-resolver.js +0 -13
  201. package/packages/client/dist/resolvers/local-resolver.js +8 -255
  202. package/packages/client/dist/resolvers/remote-resolver.js +1 -233
  203. package/packages/client/dist/runner/binary.js +1 -404
  204. package/packages/client/dist/runner/cli.js +17 -1571
  205. package/packages/client/dist/runner/epic-background-dispatcher.js +1 -124
  206. package/packages/client/dist/runner/headless/adapters.js +1 -49
  207. package/packages/client/dist/runner/headless/background-root.js +1 -85
  208. package/packages/client/dist/runner/headless/child-env.d.ts +92 -0
  209. package/packages/client/dist/runner/headless/child-env.js +1 -0
  210. package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -79
  211. package/packages/client/dist/runner/headless/continuous-story-workspace.js +11 -1776
  212. package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +1 -69
  213. package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +2 -111
  214. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.d.ts +1 -0
  215. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +10 -1464
  216. package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +2 -357
  217. package/packages/client/dist/runner/headless/fake-adapter.js +1 -62
  218. package/packages/client/dist/runner/headless/managed-environment-cleanup.js +1 -274
  219. package/packages/client/dist/runner/headless/managed-profile.js +1 -149
  220. package/packages/client/dist/runner/headless/opencode-adapter.js +2 -145
  221. package/packages/client/dist/runner/headless/prepared-story-bundle.js +1 -43
  222. package/packages/client/dist/runner/headless/resolver.js +1 -231
  223. package/packages/client/dist/runner/headless/run-yolo.js +1 -886
  224. package/packages/client/dist/runner/headless/run-yoloop.js +2 -2657
  225. package/packages/client/dist/runner/headless/types.js +2 -575
  226. package/packages/client/dist/runner/host-capacity.js +1 -59
  227. package/packages/client/dist/runner/local-console.js +13 -396
  228. package/packages/client/dist/runner/portal-sync-worker.js +1 -1487
  229. package/packages/client/dist/runner/project-identity.js +1 -106
  230. package/packages/client/dist/runner/scheduler.js +7 -995
  231. package/packages/client/dist/runner-cli.js +2 -18
  232. package/packages/client/dist/state/invocation-shape.js +1 -13
  233. package/packages/client/dist/state/project-state-snapshot.js +1 -1754
  234. package/packages/client/dist/state/state-json-repair.js +3 -785
  235. package/packages/client/dist/state/structural-dag-projection.js +1 -118
  236. package/packages/client/dist/telemetry/index.js +1 -5
  237. package/packages/client/dist/telemetry/offline-queue.js +1 -131
  238. package/packages/client/dist/tier/index.js +1 -5
  239. package/packages/client/dist/tier/tier-aware-client.js +1 -405
  240. package/packages/client/dist/types/index.js +1 -38
  241. package/packages/client/dist/version.js +1 -27
  242. package/packages/client/dist/yolo/change-evidence-collector.d.ts +10 -0
  243. package/packages/client/dist/yolo/change-evidence-collector.js +1 -262
  244. package/packages/client/dist/yolo/invoke-envelope-capability.d.ts +2 -0
  245. package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -65
  246. package/packages/client/dist/yolo/project-manifest-projection-collector.d.ts +28 -0
  247. package/packages/client/dist/yolo/project-manifest-projection-collector.js +1 -0
  248. package/packages/client/dist/yolo/spec-envelope-collector.d.ts +9 -0
  249. package/packages/client/dist/yolo/spec-envelope-collector.js +5 -184
  250. package/packages/client/dist/yoloop/discovery-hook.js +2 -300
  251. package/packages/client/dist/yoloop/index.js +1 -8
  252. package/packages/client/dist/yoloop/invoke-hooks.js +12 -669
  253. package/packages/client/dist/yoloop/shared-discover-epics.d.ts +16 -0
  254. package/packages/client/dist/yoloop/shared-discover-epics.js +1 -1007
  255. package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -33
  256. package/packages/client/dist/yoloop/target-normalization.js +1 -180
  257. package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1920
  258. package/packages/shared/dist/frontmatter-context-contract.js +164 -52
  259. package/packages/shared/dist/project-manifest-projection.js +199 -0
  260. package/packages/shared/dist/project-validation-commands.js +14 -6
  261. package/packages/shared/dist/yolo/spec-envelope-rules.js +85 -0
  262. package/packages/shared/dist/yolo/spec-envelope.js +33 -7
  263. package/packages/shared/dist/yoloop/epic-terminal-git.js +94 -6
  264. package/packages/shared/dist/yoloop/story-write-scope.js +212 -0
  265. package/targets-stubs/antigravity/gemini.md +1 -1
  266. package/targets-stubs/antigravity/install-antigravity.sh +13 -4
  267. package/targets-stubs/antigravity/skill/SKILL.md +1 -1
  268. package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
  269. package/targets-stubs/claude-code/neocortex-root.md +2 -2
  270. package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
  271. package/targets-stubs/claude-code/neocortex.md +5 -5
  272. package/targets-stubs/codex/AGENTS.md +1 -1
  273. package/targets-stubs/cursor/agent.md +2 -2
  274. package/targets-stubs/gemini-cli/agent.md +2 -2
  275. package/targets-stubs/lib/managed-config-merge.js +77 -1
  276. package/targets-stubs/lib/managed-profile.sh +7 -0
  277. package/targets-stubs/opencode/neocortex-root.md +1 -1
  278. package/targets-stubs/vscode/install-vscode.sh +21 -0
  279. package/targets-stubs/vscode/neocortex.agent.md +2 -2
@@ -1,69 +1 @@
1
- export const GIT_INVENTORY_REF_LIMIT = 2048;
2
- /** Maximum PRs related to managed branches, independent of repository history size. */
3
- export const GIT_INVENTORY_PR_LIMIT = 1000;
4
- export function collectGitResourceOwnership(state) {
5
- const claims = new Map();
6
- const origins = new Set();
7
- const epics = Object.entries(state.epics ?? {});
8
- const stories = Object.entries(state.stories ?? {});
9
- if (epics.length + stories.length > 10000)
10
- throw new Error('git-reconciliation-state-inventory-limit');
11
- const add = (claim) => {
12
- if (!claim.branch || !claim.origin)
13
- return;
14
- claims.set(claim.branch, [...(claims.get(claim.branch) ?? []), claim]);
15
- };
16
- for (const [epicId, epic] of epics) {
17
- const branch = str(epic.execution_branch), origin = str(epic.origin_branch);
18
- if (origin)
19
- origins.add(origin);
20
- const receipt = record(epic.terminal_git_receipt);
21
- const receiptMatches = receipt?.physicalStatus === 'pushed' && receipt.epicId === epicId
22
- && receipt.executionBranch === branch && receipt.originBranch === origin
23
- && sha(receipt.executionHeadSha) && sha(receipt.mergeSha) && sha(receipt.pushedSha);
24
- // A receipt-only orphan can be reconciled; an explicitly resumed lifecycle
25
- // or live writer always wins over an older terminal receipt.
26
- const active = liveLease(epic.branch_lease)
27
- || (epic.status === undefined ? !receiptMatches : !terminal(epic.status));
28
- add({ epicId, branch, origin, active,
29
- proofs: receiptMatches ? [{ head: str(receipt.executionHeadSha),
30
- evidence: ['terminal_receipt', 'canonical_convention', 'managed_metadata'],
31
- mergeSha: str(receipt.mergeSha), pushedSha: str(receipt.pushedSha) }] : [],
32
- prNumbers: prNumber(epic.pr_number), });
33
- }
34
- for (const [storyId, story] of stories) {
35
- const epicId = str(story.epic_id) || storyId.split('.')[0];
36
- const epic = state.epics?.[epicId];
37
- const checkpoint = record(story.checkpoint);
38
- const branch = str(story.branch_name) || str(checkpoint?.branch);
39
- if (!epic || branch === str(epic.execution_branch))
40
- continue;
41
- const proofMatches = checkpoint?.branch === branch && sha(checkpoint.headSha);
42
- add({ epicId, branch, origin: str(epic.origin_branch),
43
- active: !terminal(story.status) || liveLease(story.branch_lease),
44
- proofs: proofMatches ? [{ head: str(checkpoint.headSha),
45
- evidence: ['state_reference', 'canonical_convention', 'managed_metadata'] }] : [],
46
- prNumbers: prNumber(story.pr_number), });
47
- }
48
- // Convention is corroboration, never authority; validate it against the
49
- // recorded owner rather than accepting a similar branch prefix.
50
- for (const [branch, entries] of claims) {
51
- claims.set(branch, entries.map((entry) => ({ ...entry, proofs: entry.proofs.map((proof) => ({
52
- ...proof, evidence: proof.evidence.filter((item) => item !== 'canonical_convention'
53
- || branch === `epic/${entry.epicId}` || branch.startsWith(`epic/${entry.epicId}/`)
54
- || branch.startsWith(`story/${entry.epicId}.`) || branch.startsWith(`story/${entry.epicId}/`)),
55
- })) })));
56
- }
57
- return { claims, origins };
58
- }
59
- function str(value) { return typeof value === 'string' ? value : ''; }
60
- function record(value) {
61
- return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
62
- }
63
- function sha(value) { return typeof value === 'string' && /^[a-f0-9]{40,64}$/.test(value); }
64
- function terminal(value) { return ['done', 'completed', 'merged', 'superseded', 'cancelled', 'archived', 'rolled-back'].includes(str(value)); }
65
- function liveLease(value) {
66
- const lease = record(value);
67
- return Boolean(lease && Date.parse(str(lease.expiresAt)) > Date.now());
68
- }
69
- function prNumber(value) { return Number.isSafeInteger(value) && Number(value) > 0 ? [Number(value)] : []; }
1
+ const I=2048,S=1e3;function N(e){const s=new Map,u=new Set,f=Object.entries(e.epics??{}),b=Object.entries(e.stories??{});if(f.length+b.length>1e4)throw new Error("git-reconciliation-state-inventory-limit");const _=t=>{!t.branch||!t.origin||s.set(t.branch,[...s.get(t.branch)??[],t])};for(const[t,r]of f){const i=c(r.execution_branch),o=c(r.origin_branch);o&&u.add(o);const n=d(r.terminal_git_receipt),a=n?.physicalStatus==="pushed"&&n.epicId===t&&n.executionBranch===i&&n.originBranch===o&&p(n.executionHeadSha)&&p(n.mergeSha)&&p(n.pushedSha),h=m(r.branch_lease)||(r.status===void 0?!a:!g(r.status));_({epicId:t,branch:i,origin:o,active:h,proofs:a?[{head:c(n.executionHeadSha),evidence:["terminal_receipt","canonical_convention","managed_metadata"],mergeSha:c(n.mergeSha),pushedSha:c(n.pushedSha)}]:[],prNumbers:l(r.pr_number)})}for(const[t,r]of b){const i=c(r.epic_id)||t.split(".")[0],o=e.epics?.[i],n=d(r.checkpoint),a=c(r.branch_name)||c(n?.branch);if(!o||a===c(o.execution_branch))continue;const h=n?.branch===a&&p(n.headSha);_({epicId:i,branch:a,origin:c(o.origin_branch),active:!g(r.status)||m(r.branch_lease),proofs:h?[{head:c(n.headSha),evidence:["state_reference","canonical_convention","managed_metadata"]}]:[],prNumbers:l(r.pr_number)})}for(const[t,r]of s)s.set(t,r.map(i=>({...i,proofs:i.proofs.map(o=>({...o,evidence:o.evidence.filter(n=>n!=="canonical_convention"||t===`epic/${i.epicId}`||t.startsWith(`epic/${i.epicId}/`)||t.startsWith(`story/${i.epicId}.`)||t.startsWith(`story/${i.epicId}/`))}))})));return{claims:s,origins:u}}function c(e){return typeof e=="string"?e:""}function d(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function p(e){return typeof e=="string"&&/^[a-f0-9]{40,64}$/.test(e)}function g(e){return["done","completed","merged","superseded","cancelled","archived","rolled-back"].includes(c(e))}function m(e){const s=d(e);return!!(s&&Date.parse(c(s.expiresAt))>Date.now())}function l(e){return Number.isSafeInteger(e)&&Number(e)>0?[Number(e)]:[]}export{S as GIT_INVENTORY_PR_LIMIT,I as GIT_INVENTORY_REF_LIMIT,N as collectGitResourceOwnership};
@@ -1,62 +1,4 @@
1
- /** Canonical P205 execution on an isolated, branchless combined merge tree. */
2
- import { execFile } from 'node:child_process';
3
- import { createHash, randomBytes } from 'node:crypto';
4
- import { join } from 'node:path';
5
- import { promisify } from 'node:util';
6
- import { P205_RELEASE_GATE_BUDGETS, } from '../../../../shared/dist/yoloop/epic-terminal-git.js';
7
- import { assertGitLifecyclePrivateDirectory, ensureGitLifecyclePrivateChildDirectory, executeP205TransientAuthority, gitLifecycleRuntimeDirectory, P205_COMPLETE_COMMAND, p205TransientAuthorityMatchesAggregate, projectP205TransientExecutionEvidence, removeGitLifecyclePrivateDirectory, } from '../../git/git-lifecycle-store.js';
8
- import { anchoredCreateDirectory, anchoredDirectoryIdentity, anchoredExecuteGit, anchoredExecuteNode, anchoredExecuteNpm, secureFilesystemBoundaryAvailable, } from '../../git/secure-filesystem-boundary.js';
9
- const exec = promisify(execFile);
10
- const AUTHORITIES = new WeakMap();
11
- export function verifiedEpicMergeCandidateReceipt(authority, binding) {
12
- const record = authority && AUTHORITIES.get(authority);
13
- if (!record || !p205TransientAuthorityMatchesAggregate(record.p205, binding.mergeSha, binding.graphRevision))
14
- return undefined;
15
- const age = Date.now() - record.acceptedAt;
16
- if (age < 0 || age > P205_RELEASE_GATE_BUDGETS.aggregateValidityMs)
17
- return undefined;
18
- const receipt = record.receipt;
19
- return receipt.originHeadSha === binding.originHeadSha && receipt.executionHeadSha === binding.executionHeadSha
20
- && receipt.mergeSha === binding.mergeSha && receipt.graphRevision === binding.graphRevision ? receipt : undefined;
21
- }
22
- export async function executeEpicMergeCandidateQa(projectRoot, binding, nowIso = new Date().toISOString()) {
23
- if (!secureFilesystemBoundaryAvailable())
24
- throw new Error('epic-merge-candidate-platform-unsupported');
25
- if (![binding.originHeadSha, binding.executionHeadSha, binding.mergeSha].every((sha) => /^[a-f0-9]{40,64}$/.test(sha))
26
- || !/^[a-f0-9]{64}$/.test(binding.graphRevision))
27
- throw new Error('epic-merge-candidate-binding-invalid');
28
- const rootGit = async (...args) => String((await exec('git', args, { cwd: projectRoot, encoding: 'utf8' })).stdout).trim();
29
- const parents = (await rootGit('rev-list', '--parents', '-n', '1', binding.mergeSha)).split(/\s+/);
30
- if (parents.length !== 3 || parents[1] !== binding.originHeadSha || parents[2] !== binding.executionHeadSha) {
31
- throw new Error('epic-merge-candidate-parents-invalid');
32
- }
33
- const treeSha = await rootGit('rev-parse', `${binding.mergeSha}^{tree}`);
34
- const runtime = await gitLifecycleRuntimeDirectory(projectRoot);
35
- const parent = await ensureGitLifecyclePrivateChildDirectory(runtime, 'merge-candidates');
36
- const name = `${binding.mergeSha.slice(0, 16)}-${randomBytes(8).toString('hex')}`;
37
- const identity = await anchoredCreateDirectory(parent, name);
38
- const workspace = join(parent, name);
39
- const git = async (...args) => (await anchoredExecuteGit(parent, name, identity, args)).toString('utf8').trim();
40
- let p205;
41
- try {
42
- await git('init', '--quiet', '--template=');
43
- await git('fetch', '--quiet', '--no-tags', projectRoot, binding.mergeSha);
44
- await git('checkout', '--quiet', '--detach', 'FETCH_HEAD');
45
- if (await git('rev-parse', 'HEAD') !== binding.mergeSha || await git('rev-parse', 'HEAD^{tree}') !== treeSha) {
46
- throw new Error('epic-merge-candidate-checkout-invalid');
47
- }
48
- // Inspect committed entry modes before any filesystem read or npm effect:
49
- // a symlinked manifest/lock/config can redirect install outside this tree.
50
- const dependencyEntries = (await git('ls-files', '--stage', '-z', '--', 'package.json', '*/package.json', 'package-lock.json', '*/package-lock.json', 'npm-shrinkwrap.json', '*/npm-shrinkwrap.json', '.npmrc', '*/.npmrc')).split('\0').filter(Boolean);
51
- if (dependencyEntries.length > 1024 || dependencyEntries.some((entry) => !/^100(?:644|755) [a-f0-9]{40,64} 0\t/.test(entry))) {
52
- throw new Error('epic-merge-candidate-dependency-entry-unsafe');
53
- }
54
- // Each lockfile is installed into the candidate itself. No source
55
- // node_modules symlink/copy can make QA test the wrong dependency graph.
56
- const lockfiles = (await git('ls-files', '-z', '--', 'package-lock.json', '*/package-lock.json', 'npm-shrinkwrap.json', '*/npm-shrinkwrap.json')).split('\0').filter(Boolean);
57
- if (lockfiles.length > 32)
58
- throw new Error('epic-merge-candidate-dependency-limit');
59
- const dependencies = JSON.parse((await anchoredExecuteNode(parent, name, identity, ['-e', `
1
+ import{execFile as D}from"node:child_process";import{createHash as x,randomBytes as A}from"node:crypto";import{join as H}from"node:path";import{promisify as j}from"node:util";import{P205_RELEASE_GATE_BUDGETS as O}from"../../../../shared/dist/yoloop/epic-terminal-git.js";import{assertGitLifecyclePrivateDirectory as L,ensureGitLifecyclePrivateChildDirectory as P,executeP205TransientAuthority as C,gitLifecycleRuntimeDirectory as R,P205_COMPLETE_COMMAND as _,p205TransientAuthorityMatchesAggregate as M,projectP205TransientExecutionEvidence as T,removeGitLifecyclePrivateDirectory as q}from"../../git/git-lifecycle-store.js";import{anchoredCreateDirectory as I,anchoredDirectoryIdentity as y,anchoredExecuteGit as N,anchoredExecuteNode as G,anchoredExecuteNpm as $,secureFilesystemBoundaryAvailable as z}from"../../git/secure-filesystem-boundary.js";const B=j(D),S=new WeakMap;function K(c,e){const s=c&&S.get(c);if(!s||!M(s.p205,e.mergeSha,e.graphRevision))return;const h=Date.now()-s.acceptedAt;if(h<0||h>O.aggregateValidityMs)return;const r=s.receipt;return r.originHeadSha===e.originHeadSha&&r.executionHeadSha===e.executionHeadSha&&r.mergeSha===e.mergeSha&&r.graphRevision===e.graphRevision?r:void 0}async function X(c,e,s=new Date().toISOString()){if(!z())throw new Error("epic-merge-candidate-platform-unsupported");if(![e.originHeadSha,e.executionHeadSha,e.mergeSha].every(a=>/^[a-f0-9]{40,64}$/.test(a))||!/^[a-f0-9]{64}$/.test(e.graphRevision))throw new Error("epic-merge-candidate-binding-invalid");const h=async(...a)=>String((await B("git",a,{cwd:c,encoding:"utf8"})).stdout).trim(),r=(await h("rev-list","--parents","-n","1",e.mergeSha)).split(/\s+/);if(r.length!==3||r[1]!==e.originHeadSha||r[2]!==e.executionHeadSha)throw new Error("epic-merge-candidate-parents-invalid");const f=await h("rev-parse",`${e.mergeSha}^{tree}`),v=await R(c),n=await P(v,"merge-candidates"),p=`${e.mergeSha.slice(0,16)}-${A(8).toString("hex")}`,o=await I(n,p),u=H(n,p),t=async(...a)=>(await N(n,p,o,a)).toString("utf8").trim();let w;try{if(await t("init","--quiet","--template="),await t("fetch","--quiet","--no-tags",c,e.mergeSha),await t("checkout","--quiet","--detach","FETCH_HEAD"),await t("rev-parse","HEAD")!==e.mergeSha||await t("rev-parse","HEAD^{tree}")!==f)throw new Error("epic-merge-candidate-checkout-invalid");const a=(await t("ls-files","--stage","-z","--","package.json","*/package.json","package-lock.json","*/package-lock.json","npm-shrinkwrap.json","*/npm-shrinkwrap.json",".npmrc","*/.npmrc")).split("\0").filter(Boolean);if(a.length>1024||a.some(l=>!/^100(?:644|755) [a-f0-9]{40,64} 0\t/.test(l)))throw new Error("epic-merge-candidate-dependency-entry-unsafe");const m=(await t("ls-files","-z","--","package-lock.json","*/package-lock.json","npm-shrinkwrap.json","*/npm-shrinkwrap.json")).split("\0").filter(Boolean);if(m.length>32)throw new Error("epic-merge-candidate-dependency-limit");const d=JSON.parse((await G(n,p,o,["-e",`
60
2
  const fs=require('node:fs'); const path=require('node:path'); const locks=JSON.parse(process.argv[1]);
61
3
  // npm-shrinkwrap wins over package-lock in the same installation root.
62
4
  // Validate every selected root, not only the repository's top-level lock.
@@ -83,55 +25,4 @@ export async function executeEpicMergeCandidateQa(projectRoot, binding, nowIso =
83
25
  }
84
26
  process.stdout.write(JSON.stringify({unsafeLinks,roots:[...selected.keys()]
85
27
  .filter(p=>!workspacePaths.has(p)).sort((a,b)=>a.length-b.length)}));
86
- `, JSON.stringify(lockfiles)])).toString('utf8'));
87
- if (dependencies.unsafeLinks)
88
- throw new Error('epic-merge-candidate-dependency-link-unsafe');
89
- if (dependencies.roots.length > 16)
90
- throw new Error('epic-merge-candidate-dependency-limit');
91
- for (const dependencyRoot of dependencies.roots) {
92
- if (dependencyRoot !== '.' && !/^[A-Za-z0-9_.\/-]+$/.test(dependencyRoot)
93
- || dependencyRoot.split('/').includes('..'))
94
- throw new Error('epic-merge-candidate-dependency-path-invalid');
95
- await anchoredExecuteNpm(parent, name, identity, ['--prefix', dependencyRoot, 'ci', '--include=dev', '--no-audit', '--no-fund']);
96
- }
97
- if (await git('status', '--porcelain', '--untracked-files=normal'))
98
- throw new Error('epic-merge-candidate-dirty');
99
- p205 = await executeP205TransientAuthority(workspace, {
100
- headSha: binding.mergeSha, graphRevision: binding.graphRevision, nowIso,
101
- anchoredWorkspace: { parent, name, identity },
102
- });
103
- if (await git('status', '--porcelain', '--untracked-files=normal')
104
- || await git('rev-parse', 'HEAD') !== binding.mergeSha || await git('rev-parse', 'HEAD^{tree}') !== treeSha) {
105
- throw new Error('epic-merge-candidate-raced');
106
- }
107
- }
108
- finally {
109
- // Cleanup is identity-checked; a substituted directory is never removed.
110
- await assertGitLifecyclePrivateDirectory(workspace, parent);
111
- const current = await anchoredDirectoryIdentity(workspace);
112
- if (current.dev !== identity.dev || current.ino !== identity.ino)
113
- throw new Error('epic-merge-candidate-cleanup-owner-raced');
114
- if (!(await removeGitLifecyclePrivateDirectory(workspace, parent, async (renamed) => {
115
- const moved = await anchoredDirectoryIdentity(renamed);
116
- return moved.dev === identity.dev && moved.ino === identity.ino;
117
- })))
118
- throw new Error('epic-merge-candidate-cleanup-unverified');
119
- }
120
- const evidence = projectP205TransientExecutionEvidence(p205);
121
- if (!evidence || evidence.executionHeadSha !== binding.mergeSha)
122
- throw new Error('epic-merge-candidate-authority-missing');
123
- const receiptRef = `merge-qa:${createHash('sha256').update([
124
- 'epic-merge-candidate-qa-v1', binding.originHeadSha, binding.executionHeadSha, binding.mergeSha,
125
- treeSha, binding.graphRevision, evidence.manifestDigest, evidence.resultDigest, evidence.gateIds.join(','),
126
- ].join('\0')).digest('hex')}`;
127
- const candidateQa = Object.freeze({ schemaVersion: 1,
128
- kind: 'epic_merge_candidate_qa', contract: 'P205-CI-02', command: P205_COMPLETE_COMMAND,
129
- ...binding, treeSha, manifestDigest: evidence.manifestDigest, resultDigest: evidence.resultDigest,
130
- gateIds: Object.freeze([...evidence.gateIds]), checkedAt: evidence.executedAt, receiptRef,
131
- });
132
- const candidateAuthority = Object.freeze(Object.create(null));
133
- // Freshness is process-local evidence captured after QA, not a caller's
134
- // serialized timestamp. Clock rollback or expiry requires new execution.
135
- AUTHORITIES.set(candidateAuthority, { receipt: candidateQa, p205: p205, acceptedAt: Date.now() });
136
- return { candidateQa, candidateAuthority };
137
- }
28
+ `,JSON.stringify(m)])).toString("utf8"));if(d.unsafeLinks)throw new Error("epic-merge-candidate-dependency-link-unsafe");if(d.roots.length>16)throw new Error("epic-merge-candidate-dependency-limit");for(const l of d.roots){if(l!=="."&&!/^[A-Za-z0-9_.\/-]+$/.test(l)||l.split("/").includes(".."))throw new Error("epic-merge-candidate-dependency-path-invalid");await $(n,p,o,["--prefix",l,"ci","--include=dev","--no-audit","--no-fund"])}if(await t("status","--porcelain","--untracked-files=normal"))throw new Error("epic-merge-candidate-dirty");if(w=await C(u,{headSha:e.mergeSha,graphRevision:e.graphRevision,nowIso:s,anchoredWorkspace:{parent:n,name:p,identity:o}}),await t("status","--porcelain","--untracked-files=normal")||await t("rev-parse","HEAD")!==e.mergeSha||await t("rev-parse","HEAD^{tree}")!==f)throw new Error("epic-merge-candidate-raced")}finally{await L(u,n);const a=await y(u);if(a.dev!==o.dev||a.ino!==o.ino)throw new Error("epic-merge-candidate-cleanup-owner-raced");if(!await q(u,n,async m=>{const d=await y(m);return d.dev===o.dev&&d.ino===o.ino}))throw new Error("epic-merge-candidate-cleanup-unverified")}const i=T(w);if(!i||i.executionHeadSha!==e.mergeSha)throw new Error("epic-merge-candidate-authority-missing");const E=`merge-qa:${x("sha256").update(["epic-merge-candidate-qa-v1",e.originHeadSha,e.executionHeadSha,e.mergeSha,f,e.graphRevision,i.manifestDigest,i.resultDigest,i.gateIds.join(",")].join("\0")).digest("hex")}`,g=Object.freeze({schemaVersion:1,kind:"epic_merge_candidate_qa",contract:"P205-CI-02",command:_,...e,treeSha:f,manifestDigest:i.manifestDigest,resultDigest:i.resultDigest,gateIds:Object.freeze([...i.gateIds]),checkedAt:i.executedAt,receiptRef:E}),k=Object.freeze(Object.create(null));return S.set(k,{receipt:g,p205:w,acceptedAt:Date.now()}),{candidateQa:g,candidateAuthority:k}}export{X as executeEpicMergeCandidateQa,K as verifiedEpicMergeCandidateReceipt};
@@ -12,3 +12,4 @@ export interface CliEpicTerminalGitAdapterOptions {
12
12
  readonly now?: () => string;
13
13
  }
14
14
  export declare function createCliEpicTerminalGitAdapter(projectRoot: string, options?: CliEpicTerminalGitAdapterOptions): EpicTerminalGitAdapter;
15
+ export declare function publicLifecycleEvidenceCause(error: unknown): string | undefined;