@ornexus/neocortex 4.60.63 → 4.60.65

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 (136) hide show
  1. package/dist/release-source.json +1 -1
  2. package/dist/sbom.cdx.json +31 -38
  3. package/install.js +1 -0
  4. package/install.ps1 +34 -3
  5. package/install.sh +35 -3
  6. package/package.json +5 -3
  7. package/packages/client/dist/cli.js +8 -3
  8. package/packages/client/dist/commands/activate.js +8 -8
  9. package/packages/client/dist/commands/architecture-memory-terminal.js +4 -2
  10. package/packages/client/dist/commands/architecture-non-ui-continuation.d.ts +3 -0
  11. package/packages/client/dist/commands/architecture-non-ui-continuation.js +1 -0
  12. package/packages/client/dist/commands/invoke.d.ts +19 -16
  13. package/packages/client/dist/commands/invoke.js +80 -75
  14. package/packages/client/dist/commands/mutation-qa-run.js +2 -2
  15. package/packages/client/dist/commands/planning-generation.js +1 -1
  16. package/packages/client/dist/commands/planning-memory.d.ts +1 -0
  17. package/packages/client/dist/commands/planning-memory.js +1 -0
  18. package/packages/client/dist/commands/private-session.d.ts +1 -0
  19. package/packages/client/dist/commands/private-session.js +1 -0
  20. package/packages/client/dist/commands/qa-control.d.ts +4 -0
  21. package/packages/client/dist/commands/qa-control.js +1 -0
  22. package/packages/client/dist/commands/qa-scan-browser-launch.d.ts +8 -0
  23. package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -0
  24. package/packages/client/dist/commands/qa-scan-browser-route.d.ts +3 -0
  25. package/packages/client/dist/commands/qa-scan-browser-route.js +1 -0
  26. package/packages/client/dist/commands/qa-scan-capture.d.ts +43 -0
  27. package/packages/client/dist/commands/qa-scan-capture.js +5 -5
  28. package/packages/client/dist/commands/qa-scan-discovery.d.ts +7 -0
  29. package/packages/client/dist/commands/qa-scan-discovery.js +3 -3
  30. package/packages/client/dist/commands/qa-scan-review.d.ts +8 -1
  31. package/packages/client/dist/commands/qa-scan-review.js +5 -5
  32. package/packages/client/dist/commands/qa-synthetic-backend-capture.d.ts +62 -0
  33. package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -0
  34. package/packages/client/dist/commands/qa-synthetic-backend-review.d.ts +104 -0
  35. package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -0
  36. package/packages/client/dist/commands/qa-synthetic-backend.d.ts +52 -0
  37. package/packages/client/dist/commands/qa-synthetic-backend.js +7 -0
  38. package/packages/client/dist/commands/qa-synthetic-broker-port.d.ts +30 -0
  39. package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -0
  40. package/packages/client/dist/commands/qa-synthetic-browser.d.ts +1 -0
  41. package/packages/client/dist/commands/qa-synthetic-browser.js +1 -0
  42. package/packages/client/dist/commands/refactor-characterization.d.ts +4 -2
  43. package/packages/client/dist/commands/refactor-characterization.js +21 -12
  44. package/packages/client/dist/commands/refactor-control.d.ts +9 -0
  45. package/packages/client/dist/commands/refactor-control.js +3 -0
  46. package/packages/client/dist/commands/refactor-cpp-assertions.d.ts +4 -0
  47. package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -0
  48. package/packages/client/dist/commands/refactor-review.js +5 -5
  49. package/packages/client/dist/commands/refactor-root.d.ts +8 -1
  50. package/packages/client/dist/commands/refactor-root.js +7 -7
  51. package/packages/client/dist/commands/refresh-memory.d.ts +1 -0
  52. package/packages/client/dist/commands/refresh-memory.js +3 -3
  53. package/packages/client/dist/commands/shared-architecture-non-ui.d.ts +18 -0
  54. package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -0
  55. package/packages/client/dist/errors/error-messages.js +1 -1
  56. package/packages/client/dist/git/direct-yolo-checkpoint.d.ts +5 -1
  57. package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -4
  58. package/packages/client/dist/git/git-lifecycle-store.d.ts +2 -0
  59. package/packages/client/dist/git/git-lifecycle-store.js +9 -8
  60. package/packages/client/dist/license/license-client.d.ts +3 -1
  61. package/packages/client/dist/license/license-client.js +1 -1
  62. package/packages/client/dist/memory/project-memory-path-scope.d.ts +4 -0
  63. package/packages/client/dist/memory/project-memory-path-scope.js +1 -0
  64. package/packages/client/dist/memory/project-memory-writer.d.ts +4 -1
  65. package/packages/client/dist/memory/project-memory-writer.js +16 -16
  66. package/packages/client/dist/private-execution/codex-executor.d.ts +24 -4
  67. package/packages/client/dist/private-execution/codex-executor.js +4 -2
  68. package/packages/client/dist/private-execution/codex-host-runtime.d.ts +10 -0
  69. package/packages/client/dist/private-execution/codex-host-runtime.js +1 -0
  70. package/packages/client/dist/private-execution/codex-lifecycle-guard.d.ts +4 -0
  71. package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -0
  72. package/packages/client/dist/private-execution/codex-scoped-permissions.d.ts +8 -0
  73. package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -0
  74. package/packages/client/dist/private-execution/delivery.d.ts +17 -1
  75. package/packages/client/dist/private-execution/delivery.js +11 -3
  76. package/packages/client/dist/private-execution/diagnosis-root-review.d.ts +112 -0
  77. package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -0
  78. package/packages/client/dist/private-execution/frozen-handoff.d.ts +2 -0
  79. package/packages/client/dist/private-execution/frozen-handoff.js +6 -0
  80. package/packages/client/dist/private-execution/implementation-validation.d.ts +15 -0
  81. package/packages/client/dist/private-execution/implementation-validation.js +2 -0
  82. package/packages/client/dist/private-execution/isolated-admission.d.ts +11 -7
  83. package/packages/client/dist/private-execution/isolated-admission.js +17 -10
  84. package/packages/client/dist/private-execution/isolated-session.d.ts +68 -0
  85. package/packages/client/dist/private-execution/isolated-session.js +5 -2
  86. package/packages/client/dist/private-execution/pact-test-source.d.ts +1 -1
  87. package/packages/client/dist/private-execution/pact-test-source.js +1 -1
  88. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.d.ts +2 -0
  89. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -5
  90. package/packages/client/dist/private-execution/planning-generation-checkpoint.d.ts +13 -0
  91. package/packages/client/dist/private-execution/planning-generation-checkpoint.js +4 -3
  92. package/packages/client/dist/private-execution/planning-memory-checkpoint.d.ts +32 -0
  93. package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -0
  94. package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -4
  95. package/packages/client/dist/private-execution/root-checkpoint.js +1 -1
  96. package/packages/client/dist/private-execution/root-memory-git-evidence.d.ts +30 -0
  97. package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -0
  98. package/packages/client/dist/private-execution/root-memory-recovery.d.ts +16 -0
  99. package/packages/client/dist/private-execution/root-memory-recovery.js +1 -0
  100. package/packages/client/dist/private-execution/root-memory-request.d.ts +28 -0
  101. package/packages/client/dist/private-execution/root-memory-request.js +1 -0
  102. package/packages/client/dist/private-execution/root-memory-scope.d.ts +28 -0
  103. package/packages/client/dist/private-execution/root-memory-scope.js +1 -0
  104. package/packages/client/dist/private-execution/root-memory-writer.d.ts +22 -0
  105. package/packages/client/dist/private-execution/root-memory-writer.js +1 -0
  106. package/packages/client/dist/private-execution/session-lease.d.ts +19 -0
  107. package/packages/client/dist/private-execution/session-lease.js +1 -0
  108. package/packages/client/dist/private-execution/shared-private-admission-types.d.ts +34 -0
  109. package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -0
  110. package/packages/client/dist/private-execution/shared-project-validation.d.ts +17 -0
  111. package/packages/client/dist/private-execution/shared-project-validation.js +1 -0
  112. package/packages/client/dist/private-execution/shared-root-memory-types.d.ts +37 -0
  113. package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -0
  114. package/packages/client/dist/runner/binary.d.ts +1 -1
  115. package/packages/client/dist/runner/binary.js +1 -1
  116. package/packages/client/dist/runner/headless/opencode-adapter.js +2 -2
  117. package/packages/client/dist/yolo/change-evidence-collector.d.ts +2 -2
  118. package/packages/client/dist/yolo/change-evidence-collector.js +1 -1
  119. package/packages/client/dist/yolo/spec-envelope-collector.js +2 -2
  120. package/packages/shared/dist/planning/diagnosis-state.js +5 -2
  121. package/packages/shared/dist/project-memory-targets.js +243 -0
  122. package/packages/shared/dist/yolo/change-evidence.js +35 -0
  123. package/packages/shared/dist/yoloop/branch-unit.js +10 -1
  124. package/packages/shared/dist/yoloop/root-memory-effect.js +57 -0
  125. package/targets-stubs/antigravity/gemini.md +1 -1
  126. package/targets-stubs/antigravity/skill/SKILL.md +1 -1
  127. package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
  128. package/targets-stubs/claude-code/neocortex-root.md +2 -2
  129. package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
  130. package/targets-stubs/claude-code/neocortex.md +2 -2
  131. package/targets-stubs/codex/AGENTS.md +1 -1
  132. package/targets-stubs/cursor/agent.md +2 -2
  133. package/targets-stubs/deepseek-harness/SKILL.md +64 -0
  134. package/targets-stubs/gemini-cli/agent.md +2 -2
  135. package/targets-stubs/opencode/neocortex-root.md +1 -1
  136. package/targets-stubs/vscode/neocortex.agent.md +2 -2
@@ -1 +1 @@
1
- import{execFileSync as f}from"node:child_process";import{createHash as l}from"node:crypto";import{resolve as I}from"node:path";import{beginDirectYoloStoryCommit as v,finalizeDirectYoloStoryCheckpoint as m,issueDirectYoloSetupLeaseHandoff as E}from"../git/direct-yolo-checkpoint.js";import{verifyPrivateYoloCleanBaseline as y}from"./clean-baseline.js";import{stagePrivateYoloIsolatedSessionBundle as g}from"./isolated-session.js";const _="step-5ce2a8c7";function n(a,e){const t={...process.env};for(const i of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES"])delete t[i];return f("git",[...e],{cwd:a,env:t,stdio:["ignore","pipe","pipe"],timeout:3e4,maxBuffer:16*1024*1024})}async function b(a,e){const t=I(a);if(e.schemaVersion!==1||e.action!=="checkpoint-epic-story"||!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(e.storyId)||!/^[a-f0-9]{64}$/.test(e.graphRevision)||e.stepId!==_||!/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(e.executionBranch)||e.executionBranch.includes("..")||e.publicSafe!==!0)throw new Error("private-execution-root-checkpoint-invalid");await y(t,e.storyId,e.executionBranch,e.graphRevision);const i=await g(t,e.storyId,e.graphRevision),c=await E({projectRoot:t,storyId:e.storyId});if(!c.ok||c.value.bundleDigest!==i.bundleSha256)throw new Error("private-execution-root-checkpoint-handoff-denied");const o=await v({projectRoot:t,storyId:e.storyId});if(!o.ok)throw new Error("private-execution-root-checkpoint-begin-denied");if(o.value.graphRevision!==e.graphRevision||o.value.executionBranch!==e.executionBranch)throw new Error("private-execution-root-checkpoint-authority-drift");try{const r=n(t,["rev-parse","HEAD"]).toString("utf8").trim(),h=n(t,["symbolic-ref","--quiet","--short","HEAD"]).toString("utf8").trim(),u=n(t,["diff","--cached","--binary","--full-index"]),d=l("sha256").update(u).digest("hex");if(r!==o.value.baseSha||h!==o.value.executionBranch||d!==o.value.bundleDigest||d!==i.bundleSha256)throw new Error("private-execution-root-checkpoint-bundle-drift");n(t,["commit","-m",`fix(${e.storyId}): checkpoint direct yolo`,...o.value.trailers.flatMap(p=>["-m",p])])}catch(r){throw r instanceof Error&&r.message==="private-execution-root-checkpoint-bundle-drift"?r:new Error("private-execution-root-checkpoint-commit-failed")}const s=await m({projectRoot:t,storyId:e.storyId,push:!0});if(!s.ok)throw new Error("private-execution-root-checkpoint-finalize-denied");return Object.freeze({schemaVersion:1,outcome:"checkpoint-validated",storyId:e.storyId,headSha:s.value.headSha,publicSafe:!0})}export{b as runPrivateYoloRootCheckpoint};
1
+ import{execFileSync as f}from"node:child_process";import{createHash as l}from"node:crypto";import{resolve as I}from"node:path";import{beginDirectYoloStoryCommit as v,finalizeDirectYoloStoryCheckpoint as m,issueDirectYoloSetupLeaseHandoff as E}from"../git/direct-yolo-checkpoint.js";import{verifyPrivateYoloCleanBaseline as y}from"./clean-baseline.js";import{stagePrivateYoloIsolatedSessionBundle as g}from"./isolated-session.js";const w="step-5ce2a8c7";function a(c,e){const o={...process.env};for(const i of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES"])delete o[i];return f("git",[...e],{cwd:c,env:o,stdio:["ignore","pipe","pipe"],timeout:3e4,maxBuffer:16*1024*1024})}async function b(c,e){const o=I(c);if(e.schemaVersion!==1||e.action!=="checkpoint-epic-story"||!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(e.storyId)||!/^[a-f0-9]{64}$/.test(e.graphRevision)||e.stepId!==w||!/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(e.executionBranch)||e.executionBranch.includes("..")||e.publicSafe!==!0)throw new Error("private-execution-root-checkpoint-invalid");await y(o,e.storyId,e.executionBranch,e.graphRevision);const i=await g(o,e.storyId,e.graphRevision),n=await E({projectRoot:o,storyId:e.storyId});if(!n.ok||n.value.bundleDigest!==i.bundleSha256)throw new Error("private-execution-root-checkpoint-handoff-denied",{cause:new Error(n.ok?"private-execution-root-checkpoint-handoff-bundle-mismatch":n.reasonCode)});const t=await v({projectRoot:o,storyId:e.storyId});if(!t.ok)throw new Error("private-execution-root-checkpoint-begin-denied");if(t.value.graphRevision!==e.graphRevision||t.value.executionBranch!==e.executionBranch)throw new Error("private-execution-root-checkpoint-authority-drift");try{const r=a(o,["rev-parse","HEAD"]).toString("utf8").trim(),h=a(o,["symbolic-ref","--quiet","--short","HEAD"]).toString("utf8").trim(),u=a(o,["diff","--cached","--binary","--full-index"]),d=l("sha256").update(u).digest("hex");if(r!==t.value.baseSha||h!==t.value.executionBranch||d!==t.value.bundleDigest||d!==i.bundleSha256)throw new Error("private-execution-root-checkpoint-bundle-drift");a(o,["commit","-m",`fix(${e.storyId}): checkpoint direct yolo`,...t.value.trailers.flatMap(p=>["-m",p])])}catch(r){throw r instanceof Error&&r.message==="private-execution-root-checkpoint-bundle-drift"?r:new Error("private-execution-root-checkpoint-commit-failed")}const s=await m({projectRoot:o,storyId:e.storyId,push:!0});if(!s.ok)throw new Error("private-execution-root-checkpoint-finalize-denied");return Object.freeze({schemaVersion:1,outcome:"checkpoint-validated",storyId:e.storyId,headSha:s.value.headSha,publicSafe:!0})}export{b as runPrivateYoloRootCheckpoint};
@@ -0,0 +1,30 @@
1
+ import { type RootMemoryFileState, type RootProjectMemoryEffect } from './shared-root-memory-types.js';
2
+ /** Hash Git blobs without following links, using the same link-byte hash as the writer. */
3
+ export declare function rootMemoryGitFileState(root: string, sha: string, path: string): RootMemoryFileState;
4
+ export interface RootMemoryGitBinding {
5
+ readonly storyId: string;
6
+ readonly graphRevision: string;
7
+ readonly childClaimRevision: string;
8
+ readonly setupSessionId: string;
9
+ readonly sourceHeadSha: string;
10
+ readonly executionBranch: string;
11
+ }
12
+ /**
13
+ * Prove that the recorded root range contains exactly the registered memory delta.
14
+ * The caller must separately verify the private producer receipt and live session.
15
+ * A JSON effect plus this inspection alone is never an execution authority.
16
+ */
17
+ export declare function verifyRootMemoryEffectGitEvidence(root: string, effect: unknown, binding: RootMemoryGitBinding): RootProjectMemoryEffect;
18
+ export declare function rootMemoryEffectDigest(effect: RootProjectMemoryEffect): string;
19
+ /**
20
+ * Verify only physical ownership and bytes in the staged/committed C08 bundle.
21
+ * Selection must come from private producer custody or an already accepted typed
22
+ * checkpoint. This inspector alone does not grant QA, review or commit authority.
23
+ */
24
+ export declare function verifyRootMemoryPhysicalWriteSet(root: string, candidate: unknown, binding: {
25
+ readonly storyId: string;
26
+ readonly executionBranch: string;
27
+ readonly baseSha: string;
28
+ readonly headRef: string;
29
+ readonly childPaths: readonly string[];
30
+ }): RootProjectMemoryEffect;
@@ -0,0 +1,3 @@
1
+ import{execFileSync as S}from"node:child_process";import{createHash as R}from"node:crypto";import{isDeepStrictEqual as f}from"node:util";import{canonicalRootMemoryEffectJson as x,getProjectMemoryTarget as d,listProjectMemoryTargets as E,isRootProjectMemoryEffect as p,rootProjectMemoryPaths as P}from"./shared-root-memory-types.js";import{shouldUseManagedWrapper as g}from"../memory/project-memory-writer.js";const u=o=>R("sha256").update(o).digest("hex"),i=()=>{throw new Error("private-root-memory-git-evidence-unverified")};function l(o,t){return S("git",[...t],{cwd:o,stdio:["ignore","pipe","ignore"],env:{...Object.fromEntries(Object.entries(process.env).filter(([e])=>!e.startsWith("GIT_"))),GIT_NO_REPLACE_OBJECTS:"1"},timeout:3e4,maxBuffer:2*1024*1024})}function m(o,t,e){if(t!==":"&&!/^[a-f0-9]{40,64}$/.test(t)||!P().includes(e))return i();const h=l(o,t===":"?["ls-files","--stage","-z","--",e]:["ls-tree","-z",t,"--",e]).toString("utf8");if(!h)return{kind:"absent",sha256:null};const s=(t===":"?/^(100644|120000) ([a-f0-9]{40,64}) 0\t([^\0]+)\0$/:/^(100644|120000) blob ([a-f0-9]{40,64})\t([^\0]+)\0$/).exec(h);if(!s||s[3]!==e)return i();const c=l(o,["cat-file","blob",s[2]]);return c.byteLength>512*1024?i():s[1]==="120000"?{kind:"symlink",sha256:u(c),linkTarget:c.toString("utf8")}:{kind:"regular",sha256:u(c)}}function $(o,t,e){try{if(!p(t)||!e||["storyId","graphRevision","childClaimRevision","setupSessionId","sourceHeadSha","executionBranch"].some(s=>t[s]!==e[s]))return i();l(o,["merge-base","--is-ancestor",t.sourceHeadSha,t.sourceSnapshotSha]),l(o,["merge-base","--is-ancestor",t.sourceSnapshotSha,t.memorySnapshotSha]);const h=l(o,["diff","--name-only","--no-renames","--no-ext-diff","--no-textconv","-z",t.sourceSnapshotSha,t.memorySnapshotSha]).toString("utf8").split("\0").filter(Boolean).sort();if(!f(h,t.files.map(s=>s.path).sort()))return i();for(const s of t.files){const c=m(o,t.sourceSnapshotSha,s.path),r=m(o,t.memorySnapshotSha,s.path);if(!f(c,s.before)||!f(r,s.after)||f(c,r))return i()}return y(o,t.memorySnapshotSha,t),t}catch{return i()}}function y(o,t,e){const h=m(o,t,"NEOCORTEX.md");if(h.kind!=="regular"||h.sha256!==e.canonicalSha256)return i();const s=new Map;for(const r of[d("canonical"),...E()])for(const a of[r.primaryFile,...r.targetId==="canonical"?[]:r.secondaryFiles.filter(n=>n.scope==="project").map(n=>n.path)])s.has(a)||s.set(a,r.targetId==="canonical"?"canonical":g(r,a)?"managed-wrapper":"semantic-symlink");const c=[...s].sort(([r],[a])=>r<a?-1:r>a?1:0).map(([r,a])=>{const n=m(o,t,r);return n.kind==="absent"||a!=="semantic-symlink"&&n.kind!=="regular"||a==="semantic-symlink"&&(n.kind!=="symlink"||n.linkTarget!=="../".repeat(r.split("/").length-1)+"NEOCORTEX.md")?i():`${r}:${a}:${n.kind==="symlink"?h.sha256:n.sha256}`});if(e.projectionFileCount!==c.length||e.projectionSha256!==u(Buffer.from(c.join(`
2
+ `))))return i()}function k(o){return u(Buffer.from(x(o)))}function C(o,t,e){try{if(!p(t)||!e||t.storyId!==e.storyId||t.executionBranch!==e.executionBranch||t.sourceHeadSha!==e.baseSha||!/^[a-f0-9]{40,64}$/.test(e.baseSha)||e.headRef!==":"&&!/^[a-f0-9]{40,64}$/.test(e.headRef)||!Array.isArray(e.childPaths)||e.childPaths.length<1||e.childPaths.length>1024||e.childPaths.some(r=>typeof r!="string"||!r||r.startsWith("/")||/[\\\x00-\x1f\x7f]/.test(r)||r.split("/").includes("..")||r.split("/").includes(".git"))||new Set(e.childPaths).size!==e.childPaths.length||t.childClaimRevision!==u(Buffer.from([...e.childPaths].sort().join("\0"))))return i();const h=r=>e.childPaths.some(a=>a===r||a.endsWith("/")&&r.startsWith(a)),s=l(o,["diff",...e.headRef===":"?["--cached"]:[],"--name-only","--no-renames","--no-ext-diff","--no-textconv","-z",e.baseSha,...e.headRef===":"?[]:[e.headRef]]).toString("utf8").split("\0").filter(Boolean),c=t.files.map(r=>r.path).sort();if(!f(s.filter(r=>!h(r)).sort(),c)||t.files.some(r=>h(r.path)))return i();for(const r of t.files){const a=m(o,e.baseSha,r.path),n=m(o,e.headRef,r.path);if(!f(a,r.before)||!f(n,r.after)||f(a,n))return i()}if(y(o,e.headRef,t),e.headRef!==":"){const a=l(o,["show","--no-patch","--format=%B",e.headRef]).toString("utf8").split(`
3
+ `).filter(n=>n.startsWith("Neocortex-Root-Memory-Effect:"));if(a.length!==1||a[0]!==`Neocortex-Root-Memory-Effect: ${k(t)}`)return i()}return t}catch{return i()}}export{k as rootMemoryEffectDigest,m as rootMemoryGitFileState,$ as verifyRootMemoryEffectGitEvidence,C as verifyRootMemoryPhysicalWriteSet};
@@ -0,0 +1,16 @@
1
+ import type { PrivateYoloIsolatedSessionV1 } from './isolated-session.js';
2
+ import type { PrivateRootMemoryRequest } from './root-memory-request.js';
3
+ export declare function rootMemoryOperationJournalName(current: PrivateYoloIsolatedSessionV1, request: PrivateRootMemoryRequest): string;
4
+ export declare function readVerifiedPreparedRootMemory(input: {
5
+ readonly projectRoot: string;
6
+ readonly parent: string;
7
+ readonly current: PrivateYoloIsolatedSessionV1;
8
+ readonly request: PrivateRootMemoryRequest;
9
+ readonly childPaths: readonly string[];
10
+ }): Promise<{
11
+ receipt: any;
12
+ effect: import("./shared-root-memory-types.js").RootProjectMemoryEffect;
13
+ patch: Buffer<ArrayBufferLike>;
14
+ sourceAlreadyApplied: boolean;
15
+ journalPath: string;
16
+ }>;
@@ -0,0 +1 @@
1
+ import{createHash as x}from"node:crypto";import{execFileSync as M}from"node:child_process";import{existsSync as O,lstatSync as m,readFileSync as P,realpathSync as A}from"node:fs";import{join as l}from"node:path";import{isDeepStrictEqual as d}from"node:util";import{isRootProjectMemoryEffect as D,rootProjectMemoryPaths as H}from"./shared-root-memory-types.js";import{assertGitLifecyclePrivateFile as B}from"../git/git-lifecycle-store.js";import{privateYoloSourceFileMatchesSnapshot as F}from"./isolated-admission.js";import{rootMemoryGitFileState as I,verifyRootMemoryEffectGitEvidence as J}from"./root-memory-git-evidence.js";import{rootMemoryFileState as N}from"./root-memory-writer.js";const S=s=>x("sha256").update(s).digest("hex"),n=()=>{throw new Error("private-root-memory-prepared-recovery-unverified")},b=(s,e)=>Object.keys(s).sort().join("|")===[...e].sort().join("|");function c(s,e){return M("git",[...e],{cwd:s,stdio:["ignore","pipe","ignore"],env:{...Object.fromEntries(Object.entries(process.env).filter(([t])=>!t.startsWith("GIT_"))),GIT_NO_REPLACE_OBJECTS:"1"},timeout:3e4,maxBuffer:16*1024*1024})}function G(s,e){return`memory-operation-${S(JSON.stringify([s.storyId,s.setupSessionId,s.graphRevision,e.review.snapshotSha,e.review.proposalSha256,e.review.sourceStateSha256,e.review.rootQaReceiptId,S(JSON.stringify(e.review.notes))]))}.json`}async function U(s){try{const{projectRoot:e,current:t,request:g,childPaths:f}=s,{review:h,directive:u}=g,y=l(s.parent,G(t,g));await B(y,s.parent);const w=P(y);if(w.length>256*1024)return n();const p=JSON.parse(w.toString("utf8"));if(!p||!b(p,["schemaVersion","kind","previousSession","receipt","patchSha256"])||p.schemaVersion!==1||p.kind!=="prepared-root-memory-effect"||!d(p.previousSession,t)||t.rootMemoryEffect!==void 0)return n();const r=p.receipt,a=r?.rootMemoryEffect;if(!r||!b(r,["schemaVersion","kind","storyId","graphRevision","sourceHeadSha","snapshotSha","proposalSha256","notesSha256","sourceStateSha256","checks","reviewedAt","rootMemoryEffect","independentStoryQaAccepted","terminalAccepted"])||!D(a)||r.schemaVersion!==1||r.kind!=="private-project-memory-root-review"||r.storyId!==t.storyId||r.graphRevision!==t.graphRevision||r.sourceHeadSha!==t.workspace.baseSha||r.snapshotSha!==a.memorySnapshotSha||r.proposalSha256!==h.proposalSha256||r.sourceStateSha256!==h.sourceStateSha256||r.notesSha256!==S(JSON.stringify(h.notes))||r.notesSha256!==a.proposalSha256||!d(r.checks,h.checks)||r.reviewedAt!==a.recordedAt||a.sourceSnapshotSha!==t.snapshotSha||a.rootQaReceiptId!==h.rootQaReceiptId||r.independentStoryQaAccepted!==!1||r.terminalAccepted!==!1)return n();const o=t.workspace.workspacePath;if(A(e)!==e||A(o)!==o||!m(o).isDirectory()||m(o).uid!==process.getuid?.()||(m(o).mode&63)!==0||!m(l(o,".git")).isDirectory()||m(l(o,".git")).isSymbolicLink()||O(l(o,".git/objects/info/alternates"))||c(o,["rev-parse","--show-toplevel"]).toString().trim()!==o||c(e,["rev-parse","--show-toplevel"]).toString().trim()!==e||c(e,["rev-parse","HEAD"]).toString().trim()!==t.workspace.baseSha||c(e,["symbolic-ref","--short","HEAD"]).toString().trim()!==u.executionBranch||c(o,["rev-parse","HEAD"]).toString().trim()!==a.memorySnapshotSha||c(o,["symbolic-ref","--short","HEAD"]).toString().trim()!==u.executionBranch||c(o,["status","--porcelain=v1","-z","--untracked-files=all","--ignored=matching"]).length!==0||c(e,["diff","--cached","--name-only","-z"]).length!==0||(J(o,a,{storyId:t.storyId,graphRevision:t.graphRevision,childClaimRevision:S([...f].sort().join("\0")),setupSessionId:t.setupSessionId,sourceHeadSha:t.workspace.baseSha,executionBranch:u.executionBranch}),f.some(i=>!F(e,o,t.snapshotSha,i))))return n();const k=a.files.map(i=>i.path);if(c(e,["status","--porcelain=v1","-z","--untracked-files=all"]).toString("utf8").split("\0").filter(Boolean).some(i=>![" M"," D","??"," T"].includes(i.slice(0,2))||!f.includes(i.slice(3))&&!k.includes(i.slice(3))||i.slice(0,2)===" T"&&!k.includes(i.slice(3))))return n();let E=!0,v=!0;for(const i of H()){if(f.includes(i))return n();const R=N(e,i);E&&=d(R,I(o,t.snapshotSha,i)),v&&=d(R,I(o,a.memorySnapshotSha,i))}if(!E&&!v)return n();const j=c(o,["diff","--binary","--full-index",t.snapshotSha,a.memorySnapshotSha]);return S(j)!==p.patchSha256?n():{receipt:r,effect:a,patch:j,sourceAlreadyApplied:v,journalPath:y}}catch{return n()}}export{U as readVerifiedPreparedRootMemory,G as rootMemoryOperationJournalName};
@@ -0,0 +1,28 @@
1
+ export declare const ROOT_MEMORY_STEP_DIGEST = "638cc25234b6a507841c889ad7f5c8c1e33bd38aa20ca7818b0f21c4a3e9030e";
2
+ export declare const ROOT_MEMORY_REVIEW_CHECKS: string[];
3
+ export interface PrivateRootMemoryRequest {
4
+ readonly schemaVersion: 'PrivateYoloProjectMemoryAcceptance/1';
5
+ readonly executorStopped: true;
6
+ readonly directive: {
7
+ readonly schemaVersion: 1;
8
+ readonly action: 'review-project-memory-candidate';
9
+ readonly storyId: string;
10
+ readonly executionBranch: string;
11
+ readonly graphRevision: string;
12
+ readonly stepId: 'step-638cc252';
13
+ readonly publicSafe: true;
14
+ };
15
+ readonly review: {
16
+ readonly reviewer: 'root';
17
+ readonly decision: 'approve-project-memory';
18
+ readonly snapshotSha: string;
19
+ readonly proposalSha256: string;
20
+ readonly sourceStateSha256: string;
21
+ readonly rootQaReceiptId: string;
22
+ readonly rawStepId: string;
23
+ readonly reviewedAt: string;
24
+ readonly notes: readonly string[];
25
+ readonly checks: Readonly<Record<string, true>>;
26
+ };
27
+ }
28
+ export declare function parsePrivateRootMemoryRequest(value: unknown): PrivateRootMemoryRequest;
@@ -0,0 +1 @@
1
+ import{createHash as h}from"node:crypto";const v="638cc25234b6a507841c889ad7f5c8c1e33bd38aa20ca7818b0f21c4a3e9030e",c=["canonicalUpdateReviewed","acceptedQaReviewed","scopeReviewed","unresolvedGatesPreserved","platformTargetsReviewed","wrapperPreservationReviewed","mandatoryRequirementsResolved","noImplementationChange"];function u(n){const p=()=>{throw new Error("private-root-memory-review-unverified")},s=t=>t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0,a=(t,d)=>Object.keys(t).sort().join("|")===d.sort().join("|"),o=s(n),r=s(o?.directive),e=s(o?.review),i=s(e?.checks);return!o||!r||!e||!i||!a(o,["schemaVersion","executorStopped","directive","review"])||o.schemaVersion!=="PrivateYoloProjectMemoryAcceptance/1"||o.executorStopped!==!0||!a(r,["schemaVersion","action","storyId","executionBranch","graphRevision","stepId","publicSafe"])||r.schemaVersion!==1||r.action!=="review-project-memory-candidate"||r.stepId!=="step-638cc252"||r.publicSafe!==!0||typeof r.storyId!="string"||!/^P[1-9][0-9]*\.[0-9]+$/.test(r.storyId)||r.executionBranch!==`epic/${r.storyId.split(".")[0]}`||typeof r.graphRevision!="string"||!/^[a-f0-9]{64}$/.test(r.graphRevision)||!a(e,["reviewer","decision","snapshotSha","proposalSha256","sourceStateSha256","rootQaReceiptId","rawStepId","reviewedAt","notes","checks"])||e.reviewer!=="root"||e.decision!=="approve-project-memory"||typeof e.snapshotSha!="string"||!/^[a-f0-9]{40,64}$/.test(e.snapshotSha)||["proposalSha256","sourceStateSha256","rootQaReceiptId"].some(t=>typeof e[t]!="string"||!/^[a-f0-9]{64}$/.test(e[t]))||typeof e.rawStepId!="string"||h("sha256").update(e.rawStepId).digest("hex")!==v||typeof e.reviewedAt!="string"||!Number.isFinite(Date.parse(e.reviewedAt))||Date.parse(e.reviewedAt)>Date.now()||Date.now()-Date.parse(e.reviewedAt)>10*6e4||!Array.isArray(e.notes)||e.notes.length<1||e.notes.length>8||e.notes.some(t=>typeof t!="string"||Buffer.byteLength(t)<1||Buffer.byteLength(t)>512)||!a(i,[...c])||c.some(t=>i[t]!==!0)?p():structuredClone(n)}export{c as ROOT_MEMORY_REVIEW_CHECKS,v as ROOT_MEMORY_STEP_DIGEST,u as parsePrivateRootMemoryRequest};
@@ -0,0 +1,28 @@
1
+ import { type RootProjectMemoryEffect } from './shared-root-memory-types.js';
2
+ export interface PrivateRootMemoryScope {
3
+ readonly __rootMemoryScope: never;
4
+ }
5
+ /** Absence means no extra scope; malformed or mismatched existing evidence fails closed. */
6
+ export declare function readPrivateRootMemoryScope(input: {
7
+ readonly projectRoot: string;
8
+ readonly storyId: string;
9
+ readonly snapshotRoot: string;
10
+ readonly snapshotSha: string;
11
+ readonly sourceHeadSha: string;
12
+ readonly executionBranch: string;
13
+ readonly graphRevision: string;
14
+ readonly setupSessionId: string;
15
+ readonly childPaths: readonly string[];
16
+ }): Promise<PrivateRootMemoryScope | undefined>;
17
+ /** A caller-provided object never supplies extra source or agent permissions. */
18
+ export declare function privateRootMemoryEffect(scope: PrivateRootMemoryScope): RootProjectMemoryEffect;
19
+ export declare function privateRootMemorySourceMatches(scope: PrivateRootMemoryScope, root: string, snapshotRoot?: string, snapshotSha?: string): boolean;
20
+ export declare function privateRootMemorySourceMatchReason(scope: PrivateRootMemoryScope, root: string, snapshotRoot?: string, snapshotSha?: string): string;
21
+ /** C08 selection comes from actual private custody, never caller-supplied JSON. */
22
+ export declare function readRootMemoryEffectForCheckpoint(input: {
23
+ readonly projectRoot: string;
24
+ readonly storyId: string;
25
+ readonly graphRevision: string;
26
+ readonly executionBranch: string;
27
+ readonly childPaths: readonly string[];
28
+ }): Promise<RootProjectMemoryEffect | undefined>;
@@ -0,0 +1 @@
1
+ import{createHash as S}from"node:crypto";import{execFileSync as A}from"node:child_process";import{existsSync as B,readFileSync as l}from"node:fs";import{join as g,resolve as w}from"node:path";import{isDeepStrictEqual as u}from"node:util";import{isRootProjectMemoryEffect as _}from"./shared-root-memory-types.js";import{assertGitLifecyclePrivateFile as R,ensureGitLifecyclePrivateChildDirectory as k,gitLifecycleRuntimeDirectory as P,readGitLifecycleRuntime as H}from"../git/git-lifecycle-store.js";import{rootMemoryGitFileState as I,verifyRootMemoryEffectGitEvidence as C,verifyRootMemoryPhysicalWriteSet as $}from"./root-memory-git-evidence.js";import{rootMemoryFileState as G}from"./root-memory-writer.js";import{ROOT_MEMORY_REVIEW_CHECKS as b,ROOT_MEMORY_STEP_DIGEST as T}from"./root-memory-request.js";import{parseRefreshMemoryArgs as q,verifyProjectMemoryTargets as F}from"../commands/refresh-memory.js";const j=new WeakMap,n=()=>{throw new Error("private-root-memory-scope-unverified")};function m(e,o){return A("git",[...o],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],env:{...Object.fromEntries(Object.entries(process.env).filter(([h])=>!h.startsWith("GIT_"))),GIT_NO_REPLACE_OBJECTS:"1"},timeout:3e4,maxBuffer:2*1024*1024})}async function J(e){let o="pin";try{const h=w(e.projectRoot);if(!/^P[1-9][0-9]*\.[0-9]+$/.test(e.storyId))return n();const r=await k(await P(h),"private-execution"),a=g(r,`session-${S("sha256").update(e.storyId).digest("hex")}.json`);await R(a,r);const i=l(a);if(i.length>128*1024)return n();const s=JSON.parse(i.toString("utf8"));if(o="binding",s.storyId!==e.storyId||s.graphRevision!==e.graphRevision||s.setupSessionId!==e.setupSessionId||s.snapshotSha!==e.snapshotSha||s.workspace?.sourceRoot!==h||s.workspace?.workspacePath!==e.snapshotRoot||s.workspace?.baseSha!==e.sourceHeadSha||s.workspace?.executionBranch!==e.executionBranch)return n();if(s.rootMemoryEffect===void 0)return;const t=s.rootMemoryEffect;if(!_(t)||!Array.isArray(s.graphHistory)||!s.graphHistory.includes(t.graphRevision))return n();o="producer-receipt";const d=f=>S("sha256").update(f).digest("hex"),y=g(r,`memory-review-${d(JSON.stringify(t))}.json`);await R(y,r);const x=l(y);if(x.length>128*1024)return n();const c=JSON.parse(x.toString("utf8"));if(Object.keys(c).sort().join("|")!==["schemaVersion","kind","storyId","graphRevision","sourceHeadSha","snapshotSha","proposalSha256","notesSha256","sourceStateSha256","checks","reviewedAt","rootMemoryEffect","independentStoryQaAccepted","terminalAccepted"].sort().join("|")||c.schemaVersion!==1||c.kind!=="private-project-memory-root-review"||c.storyId!==e.storyId||c.graphRevision!==t.graphRevision||c.sourceHeadSha!==e.sourceHeadSha||c.snapshotSha!==t.memorySnapshotSha||c.notesSha256!==t.proposalSha256||c.reviewedAt!==t.recordedAt||c.independentStoryQaAccepted!==!1||c.terminalAccepted!==!1||!u(c.rootMemoryEffect,t)||!c.checks||Object.keys(c.checks).sort().join("|")!==[...b].sort().join("|")||b.some(f=>c.checks[f]!==!0)||c.proposalSha256!==d(Buffer.from(m(e.snapshotRoot,["show",`${t.sourceSnapshotSha}:.neocortex/stories/${e.storyId}/validation-evidence.md`])))||c.sourceStateSha256!==d(Buffer.from(m(e.snapshotRoot,["show",`${t.sourceSnapshotSha}:.neocortex/state.json`]))))return n();const E=g(r,`qa-review-${t.rootQaReceiptId}.json`);await R(E,r);const v=l(E);if(v.length>16384||d(v)!==t.rootQaReceiptId)return n();const p=JSON.parse(v.toString("utf8"));if(p.kind!=="private-qa-root-review"||p.storyId!==e.storyId||p.sourceHeadSha!==e.sourceHeadSha||p.precommitQaAccepted!==!0||p.independentStoryQaAccepted!==!1||p.terminalAccepted!==!1||(m(e.snapshotRoot,["merge-base","--is-ancestor",p.snapshotSha,t.sourceSnapshotSha]),o="git-evidence",C(e.snapshotRoot,t,{storyId:e.storyId,executionBranch:e.executionBranch,sourceHeadSha:e.sourceHeadSha,graphRevision:t.graphRevision,setupSessionId:e.setupSessionId,childClaimRevision:S("sha256").update([...e.childPaths].sort().join("\0")).digest("hex")}),o="range",m(e.snapshotRoot,["merge-base","--is-ancestor",t.memorySnapshotSha,e.snapshotSha]),m(e.snapshotRoot,["diff","--name-only","--no-renames","--no-ext-diff","--no-textconv","-z",e.sourceHeadSha,e.snapshotSha]).split("\0").filter(Boolean).some(f=>!e.childPaths.includes(f)&&!t.files.some(O=>O.path===f))))return n();o="files";for(const f of t.files)if(e.childPaths.includes(f.path)||!u(I(e.snapshotRoot,e.sourceHeadSha,f.path),f.before)||!u(I(e.snapshotRoot,e.snapshotSha,f.path),f.after))return n();const M=Object.freeze(Object.create(null));return j.set(M,Object.freeze({effect:structuredClone(t),root:h,snapshotRoot:e.snapshotRoot})),M}catch{throw new Error(`private-root-memory-scope-${o}-unverified`)}}function N(e){const o=j.get(e);return o?structuredClone(o.effect):n()}function Q(e,o,h,r){return L(e,o,h,r)==="matched"}function L(e,o,h,r){const a=j.get(e);if(!a||a.root!==w(o)||h!==void 0&&h!==a.snapshotRoot)return"scope-binding";let i="snapshot-ancestry";try{if(r&&(m(a.snapshotRoot,["merge-base","--is-ancestor",a.effect.memorySnapshotSha,r]),i="snapshot-content",a.effect.files.some(t=>!u(I(a.snapshotRoot,r,t.path),t.after)))||(i="source-content",!a.effect.files.every(t=>u(G(o,t.path),t.after))))return i;i="source-projection";const s=F(q(["--project-root",o,"--verify"]));return s.canonicalSha256===a.effect.canonicalSha256&&s.projectionSha256===a.effect.projectionSha256&&s.fileCount===a.effect.projectionFileCount?"matched":i}catch{return i+"-unsafe"}}async function re(e){try{const o=w(e.projectRoot),h=await H(o,{required:!0}),r=h.stories[e.storyId]?.checkpoint;if(r?.rootMemoryEffect!==void 0)return r.storyId!==e.storyId||r.branch!==e.executionBranch||typeof r.baseSha!="string"||typeof r.headSha!="string"?n():structuredClone($(o,r.rootMemoryEffect,{storyId:e.storyId,executionBranch:e.executionBranch,baseSha:r.baseSha,headRef:r.headSha,childPaths:e.childPaths}));if(!/^P[1-9][0-9]*\.[0-9]+$/.test(e.storyId))return;const a=await k(await P(o),"private-execution"),i=g(a,`session-${S("sha256").update(e.storyId).digest("hex")}.json`);if(!B(i))return;await R(i,a);const s=l(i);if(s.length>128*1024)return n();const t=JSON.parse(s.toString("utf8"));if(t.rootMemoryEffect===void 0)return;const d=h.stories[e.storyId];if(d?.status!=="memory-updated"||typeof d.last_step!="string"||S("sha256").update(d.last_step).digest("hex")!==T||!Array.isArray(d.steps_completed)||d.steps_completed.at(-1)!==d.last_step)return n();const y=await J({projectRoot:o,storyId:e.storyId,snapshotRoot:t.workspace?.workspacePath,snapshotSha:t.snapshotSha,sourceHeadSha:t.workspace?.baseSha,executionBranch:e.executionBranch,graphRevision:e.graphRevision,setupSessionId:t.setupSessionId,childPaths:e.childPaths});return!y||!Q(y,o,t.workspace?.workspacePath,t.snapshotSha)?n():N(y)}catch{return n()}}export{N as privateRootMemoryEffect,L as privateRootMemorySourceMatchReason,Q as privateRootMemorySourceMatches,J as readPrivateRootMemoryScope,re as readRootMemoryEffectForCheckpoint};
@@ -0,0 +1,22 @@
1
+ import { type RootMemoryFileEffect, type RootMemoryFileState } from './shared-root-memory-types.js';
2
+ import { type ProjectMemoryVerification } from '../commands/refresh-memory.js';
3
+ export interface RootMemoryWriterAuthority {
4
+ readonly __rootMemoryWriter?: never;
5
+ }
6
+ export interface RootMemoryWriterExecution {
7
+ readonly snapshotRoot: string;
8
+ readonly sourceSnapshotSha: string;
9
+ readonly notesSha256: string;
10
+ readonly files: readonly RootMemoryFileEffect[];
11
+ readonly verification: ProjectMemoryVerification;
12
+ }
13
+ export declare function rootMemoryFileState(root: string, path: string): RootMemoryFileState;
14
+ export declare function executeRootMemoryWriter(input: {
15
+ readonly snapshotRoot: string;
16
+ readonly expectedSnapshotSha: string;
17
+ readonly notes: readonly string[];
18
+ readonly backupDirectory: string;
19
+ }): RootMemoryWriterAuthority;
20
+ export declare function projectRootMemoryWriterExecution(authority: RootMemoryWriterAuthority): RootMemoryWriterExecution | undefined;
21
+ /** Recheck the actual writer output immediately before source admission. */
22
+ export declare function verifyRootMemoryWriterExecution(authority: RootMemoryWriterAuthority): RootMemoryWriterExecution;
@@ -0,0 +1 @@
1
+ import{execFileSync as z}from"node:child_process";import{createHash as N}from"node:crypto";import{lstatSync as y,readFileSync as E,readlinkSync as D,realpathSync as v}from"node:fs";import{join as O,resolve as l}from"node:path";import{rootProjectMemoryPaths as j}from"./shared-root-memory-types.js";import{parseRefreshMemoryArgs as x,refreshProjectMemoryTargets as M,verifyProjectMemoryTargets as J}from"../commands/refresh-memory.js";import{assertProjectMemoryPaths as w}from"../memory/project-memory-path-scope.js";import{classifyProjectMemoryUpdate as P}from"../memory/project-memory-writer.js";const d=r=>N("sha256").update(r).digest("hex"),h=new WeakMap,n=()=>{throw new Error("private-root-memory-writer-unverified")};function c(r,...e){return z("git",e,{cwd:r,encoding:"utf8",stdio:["ignore","pipe","ignore"],env:Object.fromEntries(Object.entries(process.env).filter(([i])=>!i.startsWith("GIT_"))),timeout:3e4,maxBuffer:2*1024*1024})}function m(r,e){if(!j().includes(e))return n();w(r,[e]);const i=O(r,e);let o;try{o=y(i)}catch(a){return a.code==="ENOENT"?{kind:"absent",sha256:null}:n()}if(o.uid!==process.getuid?.()||o.nlink!==1||(o.mode&18)!==0&&!o.isSymbolicLink())return n();if(o.isSymbolicLink()){const a=D(i);return l(r,e,"..",a)!==O(l(r),"NEOCORTEX.md")?n():{kind:"symlink",sha256:d(a),linkTarget:a}}return!o.isFile()||o.size>512*1024?n():{kind:"regular",sha256:d(E(i))}}function G(r){const e=l(r.snapshotRoot),i=l(r.backupDirectory),o=y(e),a=y(i);if(!o.isDirectory()||o.uid!==process.getuid?.()||(o.mode&63)!==0||v(e)!==e||!a.isDirectory()||a.isSymbolicLink()||a.uid!==process.getuid?.()||(a.mode&63)!==0||v(i)!==i||i===e||i.startsWith(e+"/")||!/^[a-f0-9]{40,64}$/.test(r.expectedSnapshotSha)||!Array.isArray(r.notes)||r.notes.length<1||r.notes.length>8||r.notes.some(t=>typeof t!="string"||Buffer.byteLength(t)<1||Buffer.byteLength(t)>512)||c(e,"rev-parse","HEAD").trim()!==r.expectedSnapshotSha||c(e,"status","--porcelain=v1","--untracked-files=all").length!==0)return n();for(const t of r.notes)P(t);const f=j(),g=new Map(f.map(t=>[t,m(e,t)])),S=x(["--project-root",e,...r.notes.flatMap(t=>["--note",t])]);if(M({...S,dryRun:!0}).some(t=>t.files.some(s=>s.fallbackReason||s.remediationDebt||s.mode==="compatibility-materialized-fallback"||!f.includes(s.relativeFile))))return n();for(const[t,s]of g)if(JSON.stringify(m(e,t))!==JSON.stringify(s))return n();if(M({...S,backupDirectory:i}).some(t=>t.files.some(s=>s.fallbackReason||s.remediationDebt||s.mode==="compatibility-materialized-fallback"||!f.includes(s.relativeFile))))return n();const R=J(x(["--project-root",e,"--verify"])),u=c(e,"status","--porcelain=v1","-z","--untracked-files=all").split("\0").filter(Boolean).map(t=>t.slice(3));if(u.some(t=>!f.includes(t))||c(e,"rev-parse","HEAD").trim()!==r.expectedSnapshotSha)return n();const p=f.flatMap(t=>{const s=g.get(t),k=m(e,t);return JSON.stringify(s)===JSON.stringify(k)?[]:[Object.freeze({path:t,before:Object.freeze(s),after:Object.freeze(k)})]});if(p.some(t=>!u.includes(t.path))||u.some(t=>!p.some(s=>s.path===t)))return n();const b=Object.freeze(Object.create(null));return h.set(b,Object.freeze({snapshotRoot:e,sourceSnapshotSha:r.expectedSnapshotSha,notesSha256:d(JSON.stringify(r.notes)),files:Object.freeze(p),verification:Object.freeze(R)})),b}function U(r){return h.get(r)}function X(r){const e=h.get(r);if(!e||c(e.snapshotRoot,"rev-parse","HEAD").trim()!==e.sourceSnapshotSha)return n();const i=c(e.snapshotRoot,"status","--porcelain=v1","-z","--untracked-files=all").split("\0").filter(Boolean).map(o=>o.slice(3)).sort();return JSON.stringify(i)!==JSON.stringify(e.files.map(o=>o.path).sort())||e.files.some(o=>JSON.stringify(m(e.snapshotRoot,o.path))!==JSON.stringify(o.after))?n():e}export{G as executeRootMemoryWriter,U as projectRootMemoryWriterExecution,m as rootMemoryFileState,X as verifyRootMemoryWriterExecution};
@@ -0,0 +1,19 @@
1
+ export declare function renewPrivateYoloSessionLease(projectRoot: string, storyId: string, graphRevision: string, input: {
2
+ readonly executorStopped: true;
3
+ readonly expectedSnapshotSha: string;
4
+ readonly expiresAt: string;
5
+ }): Promise<{
6
+ schemaVersion: "PrivateYoloSessionLeaseRenewal/1";
7
+ storyId: string;
8
+ graphRevision: string;
9
+ snapshotSha: string;
10
+ sourceHead: string;
11
+ previousExpiresAt: string;
12
+ expiresAt: string;
13
+ revision: number;
14
+ reused: boolean;
15
+ sessionPinPreserved: true;
16
+ originPreserved: true;
17
+ checkpointAccepted: false;
18
+ publicSafe: true;
19
+ }>;
@@ -0,0 +1 @@
1
+ import{resolve as g}from"node:path";import{acquireGitLifecyclePhysicalIntegrationLock as b,mutateGitLifecycleRuntime as A,readGitLifecycleRuntime as D,releaseGitLifecyclePhysicalIntegrationLock as k}from"../git/git-lifecycle-store.js";import{resumePrivateYoloIsolatedSession as m}from"./isolated-session.js";async function P(y,r,s,t){const n=g(y),c=Date.now(),i=Date.parse(t.expiresAt);if(t.executorStopped!==!0||!/^[a-f0-9]{40,64}$/.test(t.expectedSnapshotSha)||!Number.isFinite(i)||i<=c||i>c+3600*1e3)throw new Error("private-execution-session-renewal-input-invalid");const h=await D(n,{required:!0}),S=r.split(".")[0],p=h.epics[S],w=p?.branch_lease,e=w&&typeof w=="object"&&!Array.isArray(w)?w:void 0;if(!e||e.schemaVersion!==1||e.ownerStoryId!==r||e.sessionId!==e.idempotencyKey||typeof e.sessionId!="string"||p?.graph_revision!==s||typeof e.expiresAt!="string"||!Number.isFinite(Date.parse(e.expiresAt))||Date.parse(e.expiresAt)<=c||i<Date.parse(e.expiresAt)||!p.origin_binding)throw new Error("private-execution-session-renewal-authority-invalid");const l=e.sessionId,u=e.expiresAt,f=await b(n,{kind:"direct",storyId:r,sessionId:l,idempotencyKey:l,expiresAt:new Date(c+5*6e4).toISOString(),persistent:!1});if(!f.ok)throw new Error("private-execution-session-renewal-backpressure");try{const o=await m(n,r,s);if(o.snapshotSha!==t.expectedSnapshotSha||o.setupSessionId!==l||o.workspace.baseSha!==e.setupHeadSha)throw new Error("private-execution-session-renewal-pin-invalid");const x=new Date(i).toISOString();let v=h.revision;return Date.parse(u)!==i&&(v=(await A(n,d=>{const a=d.epics[S];if(!a||JSON.stringify(a.origin_binding)!==JSON.stringify(p.origin_binding)||JSON.stringify(a.branch_lease)!==JSON.stringify(e)||a.graph_revision!==s)throw new Error("private-execution-session-renewal-raced");a.branch_lease={...e,expiresAt:x}},{expectedRevision:h.revision,preCommit:async()=>{if(Date.parse(u)<=Date.now())throw new Error("private-execution-session-renewal-expired");const d=await m(n,r,s);if(d.snapshotSha!==t.expectedSnapshotSha||d.setupSessionId!==l)throw new Error("private-execution-session-renewal-raced")}})).document.revision),{schemaVersion:"PrivateYoloSessionLeaseRenewal/1",storyId:r,graphRevision:s,snapshotSha:o.snapshotSha,sourceHead:o.workspace.baseSha,previousExpiresAt:u,expiresAt:x,revision:v,reused:Date.parse(u)===i,sessionPinPreserved:!0,originPreserved:!0,checkpointAccepted:!1,publicSafe:!0}}finally{if(!await k(f.path,f.owner))throw new Error("private-execution-session-renewal-lock-unverified")}}export{P as renewPrivateYoloSessionLease};
@@ -0,0 +1,34 @@
1
+ export interface PrivateYoloSkippedPredecessor {
2
+ readonly stepId: 'step-a8ce5c64';
3
+ readonly featureFlagId: 'property-testing';
4
+ readonly enabled: boolean;
5
+ readonly tier: 'free' | 'pro' | 'enterprise';
6
+ readonly publicSafe: true;
7
+ }
8
+ export interface PrivateQaTierSkippedPredecessor {
9
+ readonly stepId: 'step-b2fe7cb5';
10
+ readonly featureGate: 'validate-tests';
11
+ readonly reason: 'subscription-tier';
12
+ readonly tier: 'free';
13
+ readonly publicSafe: true;
14
+ }
15
+ export type PrivateQaSkippedPredecessor = PrivateYoloSkippedPredecessor | PrivateQaTierSkippedPredecessor;
16
+ export interface PrivateQaStructuralAdmission {
17
+ readonly schemaVersion: 1;
18
+ readonly kind: 'server-private-qa-structural-admission';
19
+ readonly stepId: 'step-8721319d';
20
+ readonly generationId: string;
21
+ readonly graphRevision: string;
22
+ readonly topologyGenerationId: string;
23
+ readonly tier: 'free' | 'pro' | 'enterprise';
24
+ readonly checks: {
25
+ readonly classifiedAssetDelivery: true;
26
+ readonly licensedCommandAdmission: true;
27
+ readonly registeredStatusMapping: true;
28
+ readonly prerequisiteStateAdmitted: true;
29
+ };
30
+ readonly publicSafe: true;
31
+ }
32
+ export declare function isPrivateYoloSkippedPredecessors(value: unknown): value is readonly PrivateYoloSkippedPredecessor[];
33
+ export declare function isPrivateQaSkippedPredecessors(value: unknown): value is readonly PrivateQaSkippedPredecessor[];
34
+ export declare function isPrivateQaStructuralAdmission(value: unknown): value is PrivateQaStructuralAdmission;
@@ -0,0 +1 @@
1
+ const i="step-a8ce5c64",o="step-b2fe7cb5",n="step-8721319d";function a(t){return Array.isArray(t)&&t.length<=1&&t.every(e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return Object.keys(r).sort().join("|")===["stepId","featureFlagId","enabled","tier","publicSafe"].sort().join("|")&&r.stepId===i&&r.featureFlagId==="property-testing"&&typeof r.enabled=="boolean"&&["free","pro","enterprise"].includes(String(r.tier))&&(r.enabled===!1||r.tier==="free")&&r.publicSafe===!0})}function p(t){if(!Array.isArray(t)||t.length>2)return!1;const e=[];for(const r of t){if(a([r])){e.push(r.stepId);continue}if(!r||typeof r!="object"||Array.isArray(r))return!1;const s=r;if(Object.keys(s).sort().join("|")!==["stepId","featureGate","reason","tier","publicSafe"].sort().join("|")||s.stepId!==o||s.featureGate!=="validate-tests"||s.reason!=="subscription-tier"||s.tier!=="free"||s.publicSafe!==!0)return!1;e.push(s.stepId)}return new Set(e).size===e.length&&(t.length<2||e[0]===i&&e[1]===o&&t[0].tier==="free")}function c(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t,r=e.checks;return Object.keys(e).sort().join("|")===["schemaVersion","kind","stepId","generationId","graphRevision","topologyGenerationId","tier","checks","publicSafe"].sort().join("|")&&e.schemaVersion===1&&e.kind==="server-private-qa-structural-admission"&&e.stepId===n&&typeof e.generationId=="string"&&/^sha256:[a-f0-9]{64}$/.test(e.generationId)&&typeof e.graphRevision=="string"&&/^[a-f0-9]{64}$/.test(e.graphRevision)&&typeof e.topologyGenerationId=="string"&&/^sha256:[a-f0-9]{64}$/.test(e.topologyGenerationId)&&["free","pro","enterprise"].includes(String(e.tier))&&e.publicSafe===!0&&!!r&&typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).sort().join("|")===["classifiedAssetDelivery","licensedCommandAdmission","registeredStatusMapping","prerequisiteStateAdmitted"].sort().join("|")&&Object.values(r).every(s=>s===!0)}export{p as isPrivateQaSkippedPredecessors,c as isPrivateQaStructuralAdmission,a as isPrivateYoloSkippedPredecessors};
@@ -0,0 +1,17 @@
1
+ /** Standalone-client shadow of bounded project validation declarations. */
2
+ export declare const PROJECT_VALIDATION_KINDS: readonly ["unit", "integration", "contract", "bdd-example", "e2e"];
3
+ export type ProjectValidationKind = typeof PROJECT_VALIDATION_KINDS[number];
4
+ export interface ProjectValidationSource {
5
+ readonly path: string;
6
+ readonly content: string;
7
+ }
8
+ export interface ProjectValidationDeclaration {
9
+ readonly kind: ProjectValidationKind;
10
+ readonly command: string;
11
+ readonly sourcePaths: readonly string[];
12
+ }
13
+ export declare function readProjectValidationCommands(storyId: string, sources: readonly ProjectValidationSource[]): {
14
+ declared: boolean;
15
+ invalid: boolean;
16
+ commands: readonly ProjectValidationDeclaration[];
17
+ };
@@ -0,0 +1 @@
1
+ const P=["unit","integration","contract","bdd-example","e2e"];function x(p,a){const o=new Map;let c=!1,t=!1;const h=new Set(["story","spec","tasks"].map(e=>`docs/stories/${p}.${e}.md`));if(a.length>3||new Set(a.map(e=>e.path)).size!==a.length)return{declared:!0,invalid:!0,commands:[]};for(const e of a){if(!h.has(e.path)||Buffer.byteLength(e.content)>131072){t=!0,c=!0;continue}let n=!1,d=!1,m=0,r=0;for(const g of e.content.split(/\r?\n/)){const i=g.trim();if(/^(?:```|~~~)/.test(i)){d=!d;continue}if(d)continue;if(/^##\s+/.test(i)){n&&r===0&&(t=!0),n=i==="## Validation Commands",n&&(c=!0,m++,r=0,m>1&&(t=!0));continue}if(!n||!i)continue;const l=/^- (unit|integration|contract|bdd-example|e2e): `([^`]{1,220})`$/.exec(i);if(!l){t=!0;continue}const f=l[1],s=l[2];if(!/^[A-Za-z0-9_./-]+(?: [A-Za-z0-9_./:@%+=,-]+)*$/.test(s)||/(?:token|password|license_key|secret|credential)=|(?:https?|ssh):\/\/|@[^ /]+\.[A-Za-z]/i.test(s)||s.split(" ").some(w=>w.split("/").includes(".."))){t=!0;continue}r++;const u=o.get(f);if(u&&u.command!==s||u?.sourcePaths.includes(e.path)){t=!0;continue}o.set(f,{kind:f,command:s,sourcePaths:[...u?.sourcePaths??[],e.path]})}n&&r===0&&(t=!0)}return c&&!o.has("unit")&&(t=!0),{declared:c,invalid:t,commands:[...o.values()]}}export{P as PROJECT_VALIDATION_KINDS,x as readProjectValidationCommands};
@@ -0,0 +1,37 @@
1
+ /** Standalone-client shadow of the public root-memory effect contract. */
2
+ import { getProjectMemoryTarget, listProjectMemoryTargets } from '../memory/shared-project-memory-types.js';
3
+ export { getProjectMemoryTarget, listProjectMemoryTargets };
4
+ export interface RootMemoryFileState {
5
+ readonly kind: 'absent' | 'regular' | 'symlink';
6
+ readonly sha256: string | null;
7
+ readonly linkTarget?: string;
8
+ }
9
+ export interface RootMemoryFileEffect {
10
+ readonly path: string;
11
+ readonly before: RootMemoryFileState;
12
+ readonly after: RootMemoryFileState;
13
+ }
14
+ export interface RootProjectMemoryEffect {
15
+ readonly schemaVersion: 'RootProjectMemoryEffect/1';
16
+ readonly producer: 'root-project-memory';
17
+ readonly storyId: string;
18
+ readonly epicId: string;
19
+ readonly executionBranch: string;
20
+ readonly sourceHeadSha: string;
21
+ readonly sourceSnapshotSha: string;
22
+ readonly memorySnapshotSha: string;
23
+ readonly graphRevision: string;
24
+ readonly childClaimRevision: string;
25
+ readonly setupSessionId: string;
26
+ readonly rootQaReceiptId: string;
27
+ readonly proposalSha256: string;
28
+ readonly canonicalSha256: string;
29
+ readonly projectionSha256: string;
30
+ readonly projectionFileCount: number;
31
+ readonly files: readonly RootMemoryFileEffect[];
32
+ readonly recordedAt: string;
33
+ readonly publicSafe: true;
34
+ }
35
+ export declare function canonicalRootMemoryEffectJson(effect: RootProjectMemoryEffect): string;
36
+ export declare function rootProjectMemoryPaths(): readonly string[];
37
+ export declare function isRootProjectMemoryEffect(value: unknown): value is RootProjectMemoryEffect;
@@ -0,0 +1 @@
1
+ import{getProjectMemoryTarget as u,listProjectMemoryTargets as l}from"../memory/shared-project-memory-types.js";function S(n){const s=e=>Array.isArray(e)?e.map(s):e!==null&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(i=>[i,s(e[i])])):e;return JSON.stringify(s(n))}function y(){return[...new Set(["NEOCORTEX.md",...l().flatMap(n=>[n.primaryFile,...n.secondaryFiles.filter(s=>s.scope==="project").map(s=>s.path)])])].sort()}function g(n){const s=t=>t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0,e=s(n),i=["schemaVersion","producer","storyId","epicId","executionBranch","sourceHeadSha","sourceSnapshotSha","memorySnapshotSha","graphRevision","childClaimRevision","setupSessionId","rootQaReceiptId","proposalSha256","canonicalSha256","projectionSha256","projectionFileCount","files","recordedAt","publicSafe"];if(!e||Object.keys(e).sort().join("|")!==i.sort().join("|")||e.schemaVersion!=="RootProjectMemoryEffect/1"||e.producer!=="root-project-memory"||e.publicSafe!==!0||typeof e.storyId!="string"||!/^P[1-9][0-9]*\.[0-9]+$/.test(e.storyId)||e.epicId!==e.storyId.split(".")[0]||e.executionBranch!==`epic/${e.epicId}`||["sourceHeadSha","sourceSnapshotSha","memorySnapshotSha"].some(t=>typeof e[t]!="string"||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(e[t]))||["graphRevision","childClaimRevision","rootQaReceiptId","proposalSha256","canonicalSha256","projectionSha256"].some(t=>typeof e[t]!="string"||!/^[a-f0-9]{64}$/.test(e[t]))||typeof e.setupSessionId!="string"||!/^setup-[a-f0-9]{64}$/.test(e.setupSessionId)||typeof e.recordedAt!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(e.recordedAt)||!Number.isFinite(Date.parse(e.recordedAt))||new Date(e.recordedAt).toISOString()!==e.recordedAt||!Number.isSafeInteger(e.projectionFileCount)||e.projectionFileCount<1||e.projectionFileCount>128||!Array.isArray(e.files)||e.files.length>128)return!1;const d=new Set(y()),a=new Set,c=(t,o,p)=>{const r=s(t);if(!r||!["absent","regular","symlink"].includes(String(r.kind))||Object.keys(r).sort().join("|")!==["kind","sha256",...r.kind==="symlink"?["linkTarget"]:[]].sort().join("|"))return!1;if(r.kind==="absent")return!p&&r.sha256===null;if(typeof r.sha256!="string"||!/^[a-f0-9]{64}$/.test(r.sha256)||o==="NEOCORTEX.md"&&r.kind!=="regular")return!1;const f="../".repeat(o.split("/").length-1)+"NEOCORTEX.md";return r.kind!=="symlink"||typeof r.linkTarget=="string"&&r.linkTarget.length<=1024&&(p?r.linkTarget===f:r.linkTarget.split("/").filter(h=>h!==".").join("/")===f)};return e.files.every(t=>{const o=s(t);return!o||Object.keys(o).sort().join("|")!=="after|before|path"||typeof o.path!="string"||!d.has(o.path)||a.has(o.path)||!c(o.before,o.path,!1)||!c(o.after,o.path,!0)?!1:(a.add(o.path),!0)})}export{S as canonicalRootMemoryEffectJson,u as getProjectMemoryTarget,g as isRootProjectMemoryEffect,l as listProjectMemoryTargets,y as rootProjectMemoryPaths};
@@ -77,7 +77,7 @@ export interface HeadlessRuntimeBinaryCheckOptions {
77
77
  readonly commandLocator?: (commandName: string, env?: NodeJS.ProcessEnv) => string | undefined;
78
78
  readonly realpathBasenamePolicy?: HeadlessRuntimeRealpathBasenamePolicy;
79
79
  }
80
- export type HeadlessRuntimeRealpathBasenamePolicy = 'strict' | 'claude-code-versioned';
80
+ export type HeadlessRuntimeRealpathBasenamePolicy = 'strict' | 'claude-code-versioned' | 'opencode-npm-native';
81
81
  export type HeadlessRuntimeBinaryCheckResult = {
82
82
  readonly ok: true;
83
83
  readonly trusted: true;
@@ -1 +1 @@
1
- import{existsSync as g,readFileSync as j,realpathSync as z,statSync as M}from"node:fs";import{basename as P,delimiter as K,dirname as p,isAbsolute as k,join as B,relative as X,resolve as E,sep as F,win32 as Z}from"node:path";const o=Object.freeze({OK:"continuity-ok",MISSING:"runner-binary-missing",AMBIGUOUS:"runner-binary-ambiguous",NON_EXECUTABLE:"runner-binary-non-executable",VERSION_MISMATCHED:"runner-binary-version-mismatched",UNTRUSTED:"runner-binary-untrusted"}),m=Object.freeze({OK:"continuity-ok",UNAVAILABLE:"headless-adapter-unavailable",UNTRUSTED:"headless-runtime-untrusted"}),y=new Set(["@ornexus/neocortex","@neocortex/client"]),v=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function re(e={}){const t=J(e);if(!t)return b(o.MISSING,"Runner binary resolution did not receive a usable start path.");const r=w(t);if(!r)return b(o.AMBIGUOUS,"Runner binary was not inside an accepted Neocortex package.");const{packageRoot:n,pkg:c}=r,a=typeof c.name=="string"?c.name:void 0,i=typeof c.version=="string"?c.version:void 0,u=G(n,a);if(!a||!y.has(a))return b(o.AMBIGUOUS,"Runner package identity was not accepted.",{packageName:a,packageVersion:i,packageRoot:n,provenance:u});if(!i||!v.test(i))return b(o.VERSION_MISMATCHED,"Runner package version was missing or invalid.",{packageName:a,packageVersion:i,packageRoot:n,provenance:u});const s=_(c,a);if(!s)return b(o.MISSING,"Runner package did not declare an accepted runner bin target.",{packageName:a,packageVersion:i,packageRoot:n,provenance:u});const d=D(n,s),l=R(d);if(!l||!g(l))return b(o.MISSING,"Runner package bin target was not present.",{packageName:a,packageVersion:i,packageRoot:n,expectedRelativePath:s,provenance:u});const S=A(l,e.platform,e.requireExecutable);return S?b(S,N(S),{packageName:a,packageVersion:i,packageRoot:n,executablePath:l,expectedRelativePath:s,provenance:u}):V(n,a,i)?b(o.VERSION_MISMATCHED,"Runner package version did not match the development workspace root.",{packageName:a,packageVersion:i,packageRoot:n,executablePath:l,expectedRelativePath:s,provenance:u}):{ok:!0,trusted:!0,command:l,args:[],executablePath:l,packageName:a,packageVersion:i,packageRoot:n,expectedRelativePath:s,provenance:u,reasonCodes:[o.OK],publicSummary:`Resolved trusted ${u} runner for ${a}.`,publicSafe:!0}}function ae(e,t={}){const r=I(e);if(!r)return f(o.MISSING,"Runner executable path was missing.");const n=R(r);if(!n||!g(n))return f(o.MISSING,"Runner executable was not present.",{executablePath:r});const c=w(p(n));if(!c)return f(o.AMBIGUOUS,"Runner executable was not inside an accepted Neocortex package.",{executablePath:n});const{packageRoot:a,pkg:i}=c,u=typeof i.name=="string"?i.name:void 0,s=typeof i.version=="string"?i.version:void 0,d=G(a,u);if(!u||!y.has(u))return f(o.AMBIGUOUS,"Runner package identity was not accepted.",{executablePath:n,packageName:u,packageVersion:s,packageRoot:a,provenance:d});if(!s||!v.test(s))return f(o.VERSION_MISMATCHED,"Runner package version was missing or invalid.",{executablePath:n,packageName:u,packageVersion:s,packageRoot:a,provenance:d});const l=_(i,u);if(!l)return f(o.MISSING,"Runner package did not declare an accepted runner bin target.",{executablePath:n,packageName:u,packageVersion:s,packageRoot:a,provenance:d});const S=R(D(a,l));if(!S||!g(S))return f(o.MISSING,"Runner package bin target was not present.",{executablePath:n,packageName:u,packageVersion:s,packageRoot:a,expectedRelativePath:l,provenance:d});if(S!==n)return f(o.AMBIGUOUS,"Runner executable did not match the package-declared bin target.",{executablePath:n,packageName:u,packageVersion:s,packageRoot:a,expectedRelativePath:l,provenance:d});const x=A(n,t.platform,t.requireExecutable);return x?f(x,N(x),{executablePath:n,packageName:u,packageVersion:s,packageRoot:a,expectedRelativePath:l,provenance:d}):V(a,u,s)?f(o.VERSION_MISMATCHED,"Runner package version did not match the development workspace root.",{executablePath:n,packageName:u,packageVersion:s,packageRoot:a,expectedRelativePath:l,provenance:d}):{trusted:!0,packageName:u,packageVersion:s,packageRoot:a,executablePath:n,expectedRelativePath:l,provenance:d,reasonCodes:[o.OK],publicSummary:`Trusted ${d} runner for ${u}.`,publicSafe:!0}}function ce(e,t){return H(e)||H(t)?Z.relative(e,t).split("\\").join("/"):X(e,t).split("\\").join("/")}function oe(e){const t=e.commandName,r=e.realpathBasenamePolicy??"strict";if(!U(t))return h(m.UNTRUSTED,"Headless runtime command name was not allowlisted by adapter code.",t,"commandName","unsafe_key");const c=(e.commandLocator??q)(t,e.env);if(!c)return h(m.UNAVAILABLE,"Headless runtime command was not found on PATH.",t,"runtimeBinary","missing");if(!$(c,t,e.platform))return h(m.UNTRUSTED,"Headless runtime executable path did not match adapter-owned command constraints.",t,"runtimeBinary","executable_path");const a=R(c);if(!a||!g(a))return h(m.UNAVAILABLE,"Headless runtime executable was not present.",t,"runtimeBinary","missing");if(!Q(a,t,e.platform,r))return h(m.UNTRUSTED,"Headless runtime executable realpath did not match adapter-owned command constraints.",t,"runtimeBinary","executable_path");const i=A(a,e.platform,e.requireExecutable??!0);if(i)return h(i===o.NON_EXECUTABLE||i===o.MISSING?m.UNAVAILABLE:m.UNTRUSTED,N(i),t,"runtimeBinary",i);const u={ok:!0,trusted:!0,commandName:t,reasonCodes:[m.OK],publicSummary:`Trusted headless runtime command ${t} is available.`,redactionSummary:[],publicSafe:!0};return Object.defineProperty(u,"executablePath",{value:a,enumerable:!1,configurable:!1}),u}function q(e,t=process.env){if(!U(e))return;const r=t.PATH??"",n=process.platform==="win32"?(t.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean):[""];for(const c of r.split(K))if(!(!c||/[\r\n\0]/.test(c)))for(const a of n){const i=E(c,`${e}${a}`);if(g(i))return i}}function J(e){if(e.packageRoot)return I(e.packageRoot);const t=I(e.from??process.argv[1]);if(!t)return null;const r=R(t);if(r)try{return M(r).isDirectory()?r:p(r)}catch{return p(r)}return p(t)}function I(e){if(!e||/[\r\n\0]/.test(e))return null;const t=k(e)?e:E(e);return k(t)?t:null}function R(e){try{return z(e)}catch{return null}}function w(e){let t=e;for(let r=0;r<10;r++){const n=C(B(t,"package.json"));if(n&&typeof n.name=="string"&&y.has(n.name))return{packageRoot:t,pkg:n};const c=p(t);if(c===t)break;t=c}return null}function O(e){let t=e;for(let r=0;r<10;r++){const n=C(B(t,"package.json"));if(n?.name==="@ornexus/neocortex")return{packageRoot:t,pkg:n};const c=p(t);if(c===t)break;t=c}return null}function C(e){try{return JSON.parse(j(e,"utf8"))}catch{return null}}function _(e,t){const r=W(e.bin)?e.bin["neocortex-runner"]:void 0;if(typeof r!="string"||r.length===0)return null;const n=Y(r);return t==="@ornexus/neocortex"&&n!=="packages/client/dist/runner-cli.js"||t==="@neocortex/client"&&n!=="dist/runner-cli.js"?null:n}function Y(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"")}function D(e,t){return E(e,...t.split("/").filter(Boolean))}function G(e,t){return t==="@ornexus/neocortex"?"published-root-package":t!=="@neocortex/client"?"published-client-package":O(p(e))?"development-workspace":"published-client-package"}function V(e,t,r){if(t!=="@neocortex/client")return!1;const n=O(p(e));return!!(n&&n.pkg.version!==r)}function A(e,t=process.platform,r=!0){try{const n=M(e);return n.isFile()?r&&t!=="win32"&&(n.mode&73)===0?o.NON_EXECUTABLE:null:o.AMBIGUOUS}catch{return o.MISSING}}function b(e,t,r={}){const n=L(r);return{ok:!1,trusted:!1,reasonCode:e,reasonCodes:[e],publicSummary:T(t),publicSafe:!0,...n}}function f(e,t,r={}){const n=L(r);return{trusted:!1,reasonCode:e,reasonCodes:[e],publicSummary:T(t),publicSafe:!0,...n}}function L(e){return{...e.packageName?{packageName:e.packageName}:{},...e.packageVersion?{packageVersion:e.packageVersion}:{},...e.expectedRelativePath?{expectedRelativePath:e.expectedRelativePath}:{},...e.provenance?{provenance:e.provenance}:{}}}function N(e){switch(e){case o.MISSING:return"Runner package bin target was not present.";case o.AMBIGUOUS:return"Runner binary candidate was ambiguous.";case o.NON_EXECUTABLE:return"Runner package bin target was not executable.";case o.VERSION_MISMATCHED:return"Runner package version did not match the development workspace root.";default:return"Runner binary trust check failed."}}function T(e){return e.length<=180?e:`${e.slice(0,180)}\u2026[TRUNCATED:${e.length-180}]`}function H(e){return/^[A-Za-z]:[\\/]/.test(e)||e.includes("\\")||F==="\\"}function W(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function U(e){return/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(e)&&!/[\\/\s;&|`$<>\r\n\0]/.test(e)}function $(e,t,r=process.platform){if(!e||/[\r\n\0]/.test(e)||!k(e))return!1;const n=P(e).toLowerCase(),c=t.toLowerCase();return r==="win32"?n===c||[".exe",".cmd",".bat",".com"].some(a=>n===`${c}${a}`):n===c}function Q(e,t,r=process.platform,n="strict"){return $(e,t,r)?!0:n!=="claude-code-versioned"||t!=="claude"||!e||/[\r\n\0]/.test(e)||!k(e)?!1:ee(P(e),r)}function ee(e,t=process.platform){const r=e.toLowerCase(),n=t==="win32"?r.replace(/\.(?:exe|cmd|bat|com)$/i,""):r;return/^(?:(?:claude|claude-code)[._-])?v?\d+\.\d+\.\d+(?:[-+][0-9a-z][0-9a-z.-]*)?(?:\.(?:js|mjs|cjs))?$/.test(n)}function h(e,t,r,n,c){return{ok:!1,trusted:!1,...r&&U(r)?{commandName:r}:{},reasonCode:e,reasonCodes:[e],publicSummary:T(t),redactionSummary:[{field:n,reason:c,evidence:"value-denied",publicSafe:!0}],publicSafe:!0}}export{m as HEADLESS_RUNTIME_BINARY_REASON_CODES,o as RUNNER_BINARY_REASON_CODES,ae as checkRunnerBinaryTrust,oe as checkTrustedHeadlessRuntimeBinary,q as defaultHeadlessRuntimeCommandLocator,re as resolveTrustedRunnerBinary,ce as runnerTrustRelativePath};
1
+ import{existsSync as g,readFileSync as j,realpathSync as z,statSync as P}from"node:fs";import{basename as E,delimiter as K,dirname as p,isAbsolute as R,join as B,relative as X,resolve as y,sep as F,win32 as Z}from"node:path";const o=Object.freeze({OK:"continuity-ok",MISSING:"runner-binary-missing",AMBIGUOUS:"runner-binary-ambiguous",NON_EXECUTABLE:"runner-binary-non-executable",VERSION_MISMATCHED:"runner-binary-version-mismatched",UNTRUSTED:"runner-binary-untrusted"}),m=Object.freeze({OK:"continuity-ok",UNAVAILABLE:"headless-adapter-unavailable",UNTRUSTED:"headless-runtime-untrusted"}),I=new Set(["@ornexus/neocortex","@neocortex/client"]),w=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function re(e={}){const t=J(e);if(!t)return b(o.MISSING,"Runner binary resolution did not receive a usable start path.");const r=v(t);if(!r)return b(o.AMBIGUOUS,"Runner binary was not inside an accepted Neocortex package.");const{packageRoot:n,pkg:c}=r,a=typeof c.name=="string"?c.name:void 0,u=typeof c.version=="string"?c.version:void 0,i=G(n,a);if(!a||!I.has(a))return b(o.AMBIGUOUS,"Runner package identity was not accepted.",{packageName:a,packageVersion:u,packageRoot:n,provenance:i});if(!u||!w.test(u))return b(o.VERSION_MISMATCHED,"Runner package version was missing or invalid.",{packageName:a,packageVersion:u,packageRoot:n,provenance:i});const s=_(c,a);if(!s)return b(o.MISSING,"Runner package did not declare an accepted runner bin target.",{packageName:a,packageVersion:u,packageRoot:n,provenance:i});const d=D(n,s),l=x(d);if(!l||!g(l))return b(o.MISSING,"Runner package bin target was not present.",{packageName:a,packageVersion:u,packageRoot:n,expectedRelativePath:s,provenance:i});const S=N(l,e.platform,e.requireExecutable);return S?b(S,T(S),{packageName:a,packageVersion:u,packageRoot:n,executablePath:l,expectedRelativePath:s,provenance:i}):L(n,a,u)?b(o.VERSION_MISMATCHED,"Runner package version did not match the development workspace root.",{packageName:a,packageVersion:u,packageRoot:n,executablePath:l,expectedRelativePath:s,provenance:i}):{ok:!0,trusted:!0,command:l,args:[],executablePath:l,packageName:a,packageVersion:u,packageRoot:n,expectedRelativePath:s,provenance:i,reasonCodes:[o.OK],publicSummary:`Resolved trusted ${i} runner for ${a}.`,publicSafe:!0}}function ae(e,t={}){const r=A(e);if(!r)return f(o.MISSING,"Runner executable path was missing.");const n=x(r);if(!n||!g(n))return f(o.MISSING,"Runner executable was not present.",{executablePath:r});const c=v(p(n));if(!c)return f(o.AMBIGUOUS,"Runner executable was not inside an accepted Neocortex package.",{executablePath:n});const{packageRoot:a,pkg:u}=c,i=typeof u.name=="string"?u.name:void 0,s=typeof u.version=="string"?u.version:void 0,d=G(a,i);if(!i||!I.has(i))return f(o.AMBIGUOUS,"Runner package identity was not accepted.",{executablePath:n,packageName:i,packageVersion:s,packageRoot:a,provenance:d});if(!s||!w.test(s))return f(o.VERSION_MISMATCHED,"Runner package version was missing or invalid.",{executablePath:n,packageName:i,packageVersion:s,packageRoot:a,provenance:d});const l=_(u,i);if(!l)return f(o.MISSING,"Runner package did not declare an accepted runner bin target.",{executablePath:n,packageName:i,packageVersion:s,packageRoot:a,provenance:d});const S=x(D(a,l));if(!S||!g(S))return f(o.MISSING,"Runner package bin target was not present.",{executablePath:n,packageName:i,packageVersion:s,packageRoot:a,expectedRelativePath:l,provenance:d});if(S!==n)return f(o.AMBIGUOUS,"Runner executable did not match the package-declared bin target.",{executablePath:n,packageName:i,packageVersion:s,packageRoot:a,expectedRelativePath:l,provenance:d});const k=N(n,t.platform,t.requireExecutable);return k?f(k,T(k),{executablePath:n,packageName:i,packageVersion:s,packageRoot:a,expectedRelativePath:l,provenance:d}):L(a,i,s)?f(o.VERSION_MISMATCHED,"Runner package version did not match the development workspace root.",{executablePath:n,packageName:i,packageVersion:s,packageRoot:a,expectedRelativePath:l,provenance:d}):{trusted:!0,packageName:i,packageVersion:s,packageRoot:a,executablePath:n,expectedRelativePath:l,provenance:d,reasonCodes:[o.OK],publicSummary:`Trusted ${d} runner for ${i}.`,publicSafe:!0}}function ce(e,t){return H(e)||H(t)?Z.relative(e,t).split("\\").join("/"):X(e,t).split("\\").join("/")}function oe(e){const t=e.commandName,r=e.realpathBasenamePolicy??"strict";if(!M(t))return h(m.UNTRUSTED,"Headless runtime command name was not allowlisted by adapter code.",t,"commandName","unsafe_key");const c=(e.commandLocator??q)(t,e.env);if(!c)return h(m.UNAVAILABLE,"Headless runtime command was not found on PATH.",t,"runtimeBinary","missing");if(!$(c,t,e.platform))return h(m.UNTRUSTED,"Headless runtime executable path did not match adapter-owned command constraints.",t,"runtimeBinary","executable_path");const a=x(c);if(!a||!g(a))return h(m.UNAVAILABLE,"Headless runtime executable was not present.",t,"runtimeBinary","missing");if(!Q(a,t,e.platform,r))return h(m.UNTRUSTED,"Headless runtime executable realpath did not match adapter-owned command constraints.",t,"runtimeBinary","executable_path");const u=N(a,e.platform,e.requireExecutable??!0);if(u)return h(u===o.NON_EXECUTABLE||u===o.MISSING?m.UNAVAILABLE:m.UNTRUSTED,T(u),t,"runtimeBinary",u);const i={ok:!0,trusted:!0,commandName:t,reasonCodes:[m.OK],publicSummary:`Trusted headless runtime command ${t} is available.`,redactionSummary:[],publicSafe:!0};return Object.defineProperty(i,"executablePath",{value:a,enumerable:!1,configurable:!1}),i}function q(e,t=process.env){if(!M(e))return;const r=t.PATH??"",n=process.platform==="win32"?(t.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean):[""];for(const c of r.split(K))if(!(!c||/[\r\n\0]/.test(c)))for(const a of n){const u=y(c,`${e}${a}`);if(g(u))return u}}function J(e){if(e.packageRoot)return A(e.packageRoot);const t=A(e.from??process.argv[1]);if(!t)return null;const r=x(t);if(r)try{return P(r).isDirectory()?r:p(r)}catch{return p(r)}return p(t)}function A(e){if(!e||/[\r\n\0]/.test(e))return null;const t=R(e)?e:y(e);return R(t)?t:null}function x(e){try{return z(e)}catch{return null}}function v(e){let t=e;for(let r=0;r<10;r++){const n=O(B(t,"package.json"));if(n&&typeof n.name=="string"&&I.has(n.name))return{packageRoot:t,pkg:n};const c=p(t);if(c===t)break;t=c}return null}function C(e){let t=e;for(let r=0;r<10;r++){const n=O(B(t,"package.json"));if(n?.name==="@ornexus/neocortex")return{packageRoot:t,pkg:n};const c=p(t);if(c===t)break;t=c}return null}function O(e){try{return JSON.parse(j(e,"utf8"))}catch{return null}}function _(e,t){const r=W(e.bin)?e.bin["neocortex-runner"]:void 0;if(typeof r!="string"||r.length===0)return null;const n=Y(r);return t==="@ornexus/neocortex"&&n!=="packages/client/dist/runner-cli.js"||t==="@neocortex/client"&&n!=="dist/runner-cli.js"?null:n}function Y(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"")}function D(e,t){return y(e,...t.split("/").filter(Boolean))}function G(e,t){return t==="@ornexus/neocortex"?"published-root-package":t!=="@neocortex/client"?"published-client-package":C(p(e))?"development-workspace":"published-client-package"}function L(e,t,r){if(t!=="@neocortex/client")return!1;const n=C(p(e));return!!(n&&n.pkg.version!==r)}function N(e,t=process.platform,r=!0){try{const n=P(e);return n.isFile()?r&&t!=="win32"&&(n.mode&73)===0?o.NON_EXECUTABLE:null:o.AMBIGUOUS}catch{return o.MISSING}}function b(e,t,r={}){const n=V(r);return{ok:!1,trusted:!1,reasonCode:e,reasonCodes:[e],publicSummary:U(t),publicSafe:!0,...n}}function f(e,t,r={}){const n=V(r);return{trusted:!1,reasonCode:e,reasonCodes:[e],publicSummary:U(t),publicSafe:!0,...n}}function V(e){return{...e.packageName?{packageName:e.packageName}:{},...e.packageVersion?{packageVersion:e.packageVersion}:{},...e.expectedRelativePath?{expectedRelativePath:e.expectedRelativePath}:{},...e.provenance?{provenance:e.provenance}:{}}}function T(e){switch(e){case o.MISSING:return"Runner package bin target was not present.";case o.AMBIGUOUS:return"Runner binary candidate was ambiguous.";case o.NON_EXECUTABLE:return"Runner package bin target was not executable.";case o.VERSION_MISMATCHED:return"Runner package version did not match the development workspace root.";default:return"Runner binary trust check failed."}}function U(e){return e.length<=180?e:`${e.slice(0,180)}\u2026[TRUNCATED:${e.length-180}]`}function H(e){return/^[A-Za-z]:[\\/]/.test(e)||e.includes("\\")||F==="\\"}function W(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function M(e){return/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(e)&&!/[\\/\s;&|`$<>\r\n\0]/.test(e)}function $(e,t,r=process.platform){if(!e||/[\r\n\0]/.test(e)||!R(e))return!1;const n=E(e).toLowerCase(),c=t.toLowerCase();return r==="win32"?n===c||[".exe",".cmd",".bat",".com"].some(a=>n===`${c}${a}`):n===c}function Q(e,t,r=process.platform,n="strict"){return $(e,t,r)?!0:n==="opencode-npm-native"&&t==="opencode"?!e||/[\r\n\0]/.test(e)||!R(e)?!1:E(e).toLowerCase()==="opencode.exe":n!=="claude-code-versioned"||t!=="claude"||!e||/[\r\n\0]/.test(e)||!R(e)?!1:ee(E(e),r)}function ee(e,t=process.platform){const r=e.toLowerCase(),n=t==="win32"?r.replace(/\.(?:exe|cmd|bat|com)$/i,""):r;return/^(?:(?:claude|claude-code)[._-])?v?\d+\.\d+\.\d+(?:[-+][0-9a-z][0-9a-z.-]*)?(?:\.(?:js|mjs|cjs))?$/.test(n)}function h(e,t,r,n,c){return{ok:!1,trusted:!1,...r&&M(r)?{commandName:r}:{},reasonCode:e,reasonCodes:[e],publicSummary:U(t),redactionSummary:[{field:n,reason:c,evidence:"value-denied",publicSafe:!0}],publicSafe:!0}}export{m as HEADLESS_RUNTIME_BINARY_REASON_CODES,o as RUNNER_BINARY_REASON_CODES,ae as checkRunnerBinaryTrust,oe as checkTrustedHeadlessRuntimeBinary,q as defaultHeadlessRuntimeCommandLocator,re as resolveTrustedRunnerBinary,ce as runnerTrustRelativePath};
@@ -1,2 +1,2 @@
1
- import{checkTrustedHeadlessRuntimeBinary as _}from"../binary.js";import{HEADLESS_REASON_CODES as s,adapterAvailabilityFailure as m,adapterAvailabilitySuccess as R,createRejectedExecutionResult as E,createUnavailableExecutionResult as I,hashPublicValue as f,normalizeHeadlessCommandResult as p,redaction as A,runHeadlessCommand as v,validateHeadlessAdapterExecutionInput as b}from"./types.js";import{governedPreflightFailureResult as h,preflightManagedHeadlessProfile as y,withGovernedHeadlessEvidence as c}from"./managed-profile.js";const r="opencode",d="opencode",S="neocortex",T=2e3,C=2e3,O=/(https?:\/\/\S+|(?:^|\s)(?:\/(?:home|Users|media|mnt|tmp|var|etc|private)\/\S+|[A-Za-z]:\\\S+)|ghp_[A-Za-z0-9_]+|sk-[A-Za-z0-9_-]+|-----BEGIN [A-Z ]*PRIVATE KEY-----|authorization\s*:|password\s*=|token\s*=|api[_-]?key\s*=|license[_-]?key\s*=|raw[_-]?(?:logs?)\s*[:=]|transcript|stack\s*trace|stderr:|stdout:|system prompt|workflow body|step body|PROTECTED_|PRIVATE_INTERNALS|CUSTOMER_PII|\bPII\b|VENDOR_CORPUS|\bPRIVATE\b)/i,P=/\b(?:Claude\s+Code|claude-code|@anthropic-ai\/claude-code)\b/i,k=/\bv?\d+\.\d+\.\d+(?:[-+][0-9A-Za-z][0-9A-Za-z.-]*)?\b/;function w(){return{id:r,displayName:"OpenCode Headless Adapter",async checkAvailability(n={}){return N(r,d,n)},buildInvocation(n){const e=b(n,r);return e.ok?{ok:!0,invocation:{adapterId:r,commandName:d,args:V(e.prompt,e.input.modelId),promptHash:e.promptHash,...e.input.modelId?{modelId:e.input.modelId}:{},timeoutMs:e.input.timeoutMs??600*1e3,publicSafe:!0},publicSafe:!0}:e},async execute(n,e={}){const t=b(n,r);if(!t.ok)return E(r,r,t);const a=y(r,e);if(!a.ok)return h(r,t.input,a);if(e.signal?.aborted)return c(p(r,t.input,{exitCode:null,signal:"SIGTERM",timedOut:!1,cancelled:!0,durationMs:0,stdout:"",stderr:"",stdoutBytes:0,stderrBytes:0}));const i=await this.checkAvailability(e);if(!i.ok)return c(I(r,t.input,i));const o=this.buildInvocation(t.input);if(!o.ok)return E(r,r,o);const u=await(e.commandRunner??v)(i.executablePath??d,o.invocation.args,{cwd:e.cwd,env:e.env,timeoutMs:o.invocation.timeoutMs,maxOutputBytes:e.maxOutputBytes,signal:e.signal,...t.input.receipt?.jobId?{localConsole:{projectRoot:e.cwd,jobId:t.input.receipt.jobId,attemptId:t.input.receipt.attemptId,executionId:t.input.receipt.executionId,publicSafe:!0}}:{}});return c(p(r,t.input,u))}}}async function N(n,e,t,a={}){const i=_({commandName:e,env:t.env,platform:t.platform,commandLocator:t.commandLocator,realpathBasenamePolicy:a.realpathBasenamePolicy});if(!i.ok)return m(n,e,i.reasonCode===s.ADAPTER_UNAVAILABLE?s.ADAPTER_UNAVAILABLE:s.RUNTIME_UNTRUSTED,i.publicSummary,i.redactionSummary);const l=await(t.versionRunner??t.commandRunner??v)(i.executablePath,["--version"],{env:t.env,timeoutMs:5e3,maxOutputBytes:2e3}),u=g(l,a.versionEvidence??"generic-public");return u.ok?R(n,e,D(e,a.versionEvidence),{executablePath:i.executablePath,versionText:u.versionText}):m(n,e,s.ADAPTER_UNAVAILABLE,u.publicSummary,u.redactionSummary)}function g(n,e){const t=x(`${n.stdout}
2
- ${n.stderr}`.trim()),a=t?[A("runtimeVersion","raw_log",f(t))]:[A("runtimeVersion","missing","value-denied")];return n.timedOut||n.exitCode!==0||t.length===0||t.length>T||n.stdoutBytes+n.stderrBytes>C||O.test(t)?{ok:!1,publicSummary:"Headless runtime version check did not return a bounded public result.",redactionSummary:a}:e==="claude-code"&&(!P.test(t)||!k.test(t))?{ok:!1,publicSummary:"Headless runtime version check did not return bounded Claude Code product/version evidence.",redactionSummary:a}:{ok:!0,versionText:t}}function x(n){return n.replace(/\s+/g," ").trim()}function D(n,e){return e==="claude-code"?`Trusted ${n} runtime is available with bounded Claude Code version evidence.`:`Trusted ${n} runtime is available.`}function V(n,e){const t=["run","--agent",S,"--auto"];return e&&t.push("--model",e),t.push("--",n),t}export{N as checkRuntimeAvailability,w as createOpenCodeHeadlessAdapter};
1
+ import{checkTrustedHeadlessRuntimeBinary as _}from"../binary.js";import{HEADLESS_REASON_CODES as s,adapterAvailabilityFailure as m,adapterAvailabilitySuccess as R,createRejectedExecutionResult as p,createUnavailableExecutionResult as I,hashPublicValue as f,normalizeHeadlessCommandResult as E,redaction as A,runHeadlessCommand as v,validateHeadlessAdapterExecutionInput as b}from"./types.js";import{governedPreflightFailureResult as h,preflightManagedHeadlessProfile as y,withGovernedHeadlessEvidence as c}from"./managed-profile.js";const r="opencode",d="opencode",S="neocortex",T=2e3,C=2e3,P=/(https?:\/\/\S+|(?:^|\s)(?:\/(?:home|Users|media|mnt|tmp|var|etc|private)\/\S+|[A-Za-z]:\\\S+)|ghp_[A-Za-z0-9_]+|sk-[A-Za-z0-9_-]+|-----BEGIN [A-Z ]*PRIVATE KEY-----|authorization\s*:|password\s*=|token\s*=|api[_-]?key\s*=|license[_-]?key\s*=|raw[_-]?(?:logs?)\s*[:=]|transcript|stack\s*trace|stderr:|stdout:|system prompt|workflow body|step body|PROTECTED_|PRIVATE_INTERNALS|CUSTOMER_PII|\bPII\b|VENDOR_CORPUS|\bPRIVATE\b)/i,O=/\b(?:Claude\s+Code|claude-code|@anthropic-ai\/claude-code)\b/i,k=/\bv?\d+\.\d+\.\d+(?:[-+][0-9A-Za-z][0-9A-Za-z.-]*)?\b/;function w(){return{id:r,displayName:"OpenCode Headless Adapter",async checkAvailability(n={}){return N(r,d,n,{realpathBasenamePolicy:"opencode-npm-native"})},buildInvocation(n){const e=b(n,r);return e.ok?{ok:!0,invocation:{adapterId:r,commandName:d,args:V(e.prompt,e.input.modelId),promptHash:e.promptHash,...e.input.modelId?{modelId:e.input.modelId}:{},timeoutMs:e.input.timeoutMs??600*1e3,publicSafe:!0},publicSafe:!0}:e},async execute(n,e={}){const t=b(n,r);if(!t.ok)return p(r,r,t);const a=y(r,e);if(!a.ok)return h(r,t.input,a);if(e.signal?.aborted)return c(E(r,t.input,{exitCode:null,signal:"SIGTERM",timedOut:!1,cancelled:!0,durationMs:0,stdout:"",stderr:"",stdoutBytes:0,stderrBytes:0}));const i=await this.checkAvailability(e);if(!i.ok)return c(I(r,t.input,i));const o=this.buildInvocation(t.input);if(!o.ok)return p(r,r,o);const u=await(e.commandRunner??v)(i.executablePath??d,o.invocation.args,{cwd:e.cwd,env:e.env,timeoutMs:o.invocation.timeoutMs,maxOutputBytes:e.maxOutputBytes,signal:e.signal,...t.input.receipt?.jobId?{localConsole:{projectRoot:e.cwd,jobId:t.input.receipt.jobId,attemptId:t.input.receipt.attemptId,executionId:t.input.receipt.executionId,publicSafe:!0}}:{}});return c(E(r,t.input,u))}}}async function N(n,e,t,a={}){const i=_({commandName:e,env:t.env,platform:t.platform,commandLocator:t.commandLocator,realpathBasenamePolicy:a.realpathBasenamePolicy});if(!i.ok)return m(n,e,i.reasonCode===s.ADAPTER_UNAVAILABLE?s.ADAPTER_UNAVAILABLE:s.RUNTIME_UNTRUSTED,i.publicSummary,i.redactionSummary);const l=await(t.versionRunner??t.commandRunner??v)(i.executablePath,["--version"],{env:t.env,timeoutMs:5e3,maxOutputBytes:2e3}),u=g(l,a.versionEvidence??"generic-public");return u.ok?R(n,e,D(e,a.versionEvidence),{executablePath:i.executablePath,versionText:u.versionText}):m(n,e,s.ADAPTER_UNAVAILABLE,u.publicSummary,u.redactionSummary)}function g(n,e){const t=x(`${n.stdout}
2
+ ${n.stderr}`.trim()),a=t?[A("runtimeVersion","raw_log",f(t))]:[A("runtimeVersion","missing","value-denied")];return n.timedOut||n.exitCode!==0||t.length===0||t.length>T||n.stdoutBytes+n.stderrBytes>C||P.test(t)?{ok:!1,publicSummary:"Headless runtime version check did not return a bounded public result.",redactionSummary:a}:e==="claude-code"&&(!O.test(t)||!k.test(t))?{ok:!1,publicSummary:"Headless runtime version check did not return bounded Claude Code product/version evidence.",redactionSummary:a}:{ok:!0,versionText:t}}function x(n){return n.replace(/\s+/g," ").trim()}function D(n,e){return e==="claude-code"?`Trusted ${n} runtime is available with bounded Claude Code version evidence.`:`Trusted ${n} runtime is available.`}function V(n,e){const t=["run","--standalone","--agent",S,"--auto"];return e&&t.push("--model",e),t.push("--",n),t}export{N as checkRuntimeAvailability,w as createOpenCodeHeadlessAdapter};
@@ -1,4 +1,4 @@
1
- import { type YoloChangeEvidenceV1 } from '../../../shared/dist/yolo/change-evidence.js';
1
+ import { type YoloChangeEvidence } from '../../../shared/dist/yolo/change-evidence.js';
2
2
  /** Reacquire only an expired setup lease for this exact story through P207's CAS boundary. */
3
3
  export declare function reconcileYoloChangeEvidenceLease(options: {
4
4
  readonly projectRoot: string;
@@ -11,4 +11,4 @@ export declare function collectYoloChangeEvidence(options: {
11
11
  readonly expectedHeadSha: string;
12
12
  readonly storyId?: string;
13
13
  readonly epicId?: string;
14
- }): YoloChangeEvidenceV1;
14
+ }): YoloChangeEvidence;
@@ -1 +1 @@
1
- import{execFileSync as p}from"node:child_process";import{realpathSync as f}from"node:fs";import{createYoloChangeEvidenceV1 as w}from"../../../shared/dist/yolo/change-evidence.js";import{readGitLifecycleRuntimeSync as u}from"../git/git-lifecycle-store.js";async function j(e){let r;try{r=u(e.projectRoot,{required:!0}).epics[e.epicId]?.branch_lease}catch(c){if(c instanceof Error&&c.message==="git-lifecycle-runtime-missing")return;throw new Error("yolo-change-evidence-unavailable")}if(r==null)return;if(typeof r!="object"||Array.isArray(r)||r.ownerStoryId!==e.storyId||typeof r.expiresAt!="string")throw new Error("yolo-change-evidence-unavailable");const n=Date.parse(r.expiresAt);if(!Number.isFinite(n))throw new Error("yolo-change-evidence-unavailable");if(n>Date.now())return;if(typeof r.sessionId!="string"||!/^setup-[a-f0-9]{64}$/.test(r.sessionId)||r.idempotencyKey!==r.sessionId)throw new Error("yolo-change-evidence-unavailable");const{prepareDirectYoloSetup:o}=await import("../git/direct-yolo-checkpoint.js"),i=await o(e);if(!i.ok||i.value.storyId!==e.storyId||i.value.epicId!==e.epicId||Date.parse(i.value.leaseExpiresAt)<=Date.now())throw new Error("yolo-change-evidence-unavailable")}function t(e,r){try{return p("git",["-C",e,...r],{encoding:"utf8",timeout:3e3,maxBuffer:1024*1024,stdio:["ignore","pipe","ignore"]})}catch{throw new Error("yolo-change-evidence-unavailable")}}function x(e){if(!/^[A-Za-z0-9][A-Za-z0-9_./-]{0,119}$/.test(e.defaultBranch)||e.defaultBranch.includes(".."))throw new Error("yolo-change-evidence-unavailable");const r=t(e.projectRoot,["rev-parse","--show-toplevel"]).trim();if(f(r)!==f(e.projectRoot))throw new Error("yolo-change-evidence-unavailable");const n=t(e.projectRoot,["rev-parse","HEAD"]).trim();if(n!==e.expectedHeadSha)throw new Error("yolo-change-evidence-stale");let o,i=!1,c=null;if(e.storyId&&e.epicId)try{const a=u(e.projectRoot).epics[e.epicId],l=a?.branch_lease,h=t(e.projectRoot,["symbolic-ref","--quiet","--short","HEAD"]).trim();if(a?.branch_mode==="epic"&&a.execution_branch===h&&(c=h),l&&typeof l=="object"&&!Array.isArray(l)){const d=l;if(d.ownerStoryId!==e.storyId||typeof d.expiresAt!="string"||Date.parse(d.expiresAt)<=Date.now()||c===null)throw new Error("yolo-change-evidence-unavailable");i=!0}}catch{throw new Error("yolo-change-evidence-unavailable")}if(i)o=n;else{const s=c===null?"":t(e.projectRoot,["ls-remote","--heads","origin",`refs/heads/${c}`]).trim();if(s){const a=/^([a-f0-9]{40})\trefs\/heads\/([^\n]+)$/.exec(s);if(!a||a[2]!==c||t(e.projectRoot,["merge-base","HEAD",a[1]]).trim()!==a[1])throw new Error("yolo-change-evidence-unavailable");o=a[1]}else try{o=t(e.projectRoot,["merge-base","HEAD",e.defaultBranch]).trim()}catch{o=t(e.projectRoot,["merge-base","HEAD",`refs/remotes/origin/${e.defaultBranch}`]).trim()}}const y=t(e.projectRoot,["diff","--name-only","-z",o,"--"]).split("\0").filter(Boolean),m=t(e.projectRoot,["ls-files","--others","--exclude-standard","-z"]).split("\0").filter(Boolean),v=w({baseSha:o,headSha:n,changedPaths:[...y,...m]});if(t(e.projectRoot,["rev-parse","HEAD"]).trim()!==n)throw new Error("yolo-change-evidence-stale");return v}export{x as collectYoloChangeEvidence,j as reconcileYoloChangeEvidenceLease};
1
+ import{execFileSync as p}from"node:child_process";import{realpathSync as f}from"node:fs";import{createYoloChangeEvidence as w}from"../../../shared/dist/yolo/change-evidence.js";import{readGitLifecycleRuntimeSync as u}from"../git/git-lifecycle-store.js";async function j(e){let r;try{r=u(e.projectRoot,{required:!0}).epics[e.epicId]?.branch_lease}catch(c){if(c instanceof Error&&c.message==="git-lifecycle-runtime-missing")return;throw new Error("yolo-change-evidence-unavailable")}if(r==null)return;if(typeof r!="object"||Array.isArray(r)||r.ownerStoryId!==e.storyId||typeof r.expiresAt!="string")throw new Error("yolo-change-evidence-unavailable");const n=Date.parse(r.expiresAt);if(!Number.isFinite(n))throw new Error("yolo-change-evidence-unavailable");if(n>Date.now())return;if(typeof r.sessionId!="string"||!/^setup-[a-f0-9]{64}$/.test(r.sessionId)||r.idempotencyKey!==r.sessionId)throw new Error("yolo-change-evidence-unavailable");const{prepareDirectYoloSetup:o}=await import("../git/direct-yolo-checkpoint.js"),i=await o(e);if(!i.ok||i.value.storyId!==e.storyId||i.value.epicId!==e.epicId||Date.parse(i.value.leaseExpiresAt)<=Date.now())throw new Error("yolo-change-evidence-unavailable")}function t(e,r){try{return p("git",["-C",e,...r],{encoding:"utf8",timeout:3e3,maxBuffer:1024*1024,stdio:["ignore","pipe","ignore"]})}catch{throw new Error("yolo-change-evidence-unavailable")}}function x(e){if(!/^[A-Za-z0-9][A-Za-z0-9_./-]{0,119}$/.test(e.defaultBranch)||e.defaultBranch.includes(".."))throw new Error("yolo-change-evidence-unavailable");const r=t(e.projectRoot,["rev-parse","--show-toplevel"]).trim();if(f(r)!==f(e.projectRoot))throw new Error("yolo-change-evidence-unavailable");const n=t(e.projectRoot,["rev-parse","HEAD"]).trim();if(n!==e.expectedHeadSha)throw new Error("yolo-change-evidence-stale");let o,i=!1,c=null;if(e.storyId&&e.epicId)try{const a=u(e.projectRoot).epics[e.epicId],l=a?.branch_lease,h=t(e.projectRoot,["symbolic-ref","--quiet","--short","HEAD"]).trim();if(a?.branch_mode==="epic"&&a.execution_branch===h&&(c=h),l&&typeof l=="object"&&!Array.isArray(l)){const d=l;if(d.ownerStoryId!==e.storyId||typeof d.expiresAt!="string"||Date.parse(d.expiresAt)<=Date.now()||c===null)throw new Error("yolo-change-evidence-unavailable");i=!0}}catch{throw new Error("yolo-change-evidence-unavailable")}if(i)o=n;else{const s=c===null?"":t(e.projectRoot,["ls-remote","--heads","origin",`refs/heads/${c}`]).trim();if(s){const a=/^([a-f0-9]{40})\trefs\/heads\/([^\n]+)$/.exec(s);if(!a||a[2]!==c||t(e.projectRoot,["merge-base","HEAD",a[1]]).trim()!==a[1])throw new Error("yolo-change-evidence-unavailable");o=a[1]}else try{o=t(e.projectRoot,["merge-base","HEAD",e.defaultBranch]).trim()}catch{o=t(e.projectRoot,["merge-base","HEAD",`refs/remotes/origin/${e.defaultBranch}`]).trim()}}const y=t(e.projectRoot,["diff","--name-only","-z",o,"--"]).split("\0").filter(Boolean),m=t(e.projectRoot,["ls-files","--others","--exclude-standard","-z"]).split("\0").filter(Boolean),v=w({baseSha:o,headSha:n,changedPaths:[...y,...m]});if(t(e.projectRoot,["rev-parse","HEAD"]).trim()!==n)throw new Error("yolo-change-evidence-stale");return v}export{x as collectYoloChangeEvidence,j as reconcileYoloChangeEvidenceLease};
@@ -1,5 +1,5 @@
1
- import{execFileSync as L}from"node:child_process";import{existsSync as S,readFileSync as T,realpathSync as w,statSync as E}from"node:fs";import{join as y,sep as b}from"node:path";import{createYoloSpecEnvelopeV1 as x,YOLO_SPEC_ARTIFACT_LIMIT_BYTES as C,YOLO_SPEC_MAX_ARTIFACTS as R,YOLO_SPEC_TOTAL_LIMIT_BYTES as g}from"../../../shared/dist/yolo/spec-envelope.js";import{inspectFrontmatterContext as $}from"../../../shared/dist/frontmatter-context-contract.js";const O=["core/templates/specs/feature-spec-template.md","core/templates/specs/architecture-spec-template.md","core/templates/specs/contract-spec-template.md","core/templates/specs/story-spec-template.md","core/templates/specs/traceability-matrix-template.md"],W=/(?:^|[\s([`'";])((?:docs\/(?:stories|epics|specs|architecture|examples)\/|core\/templates\/specs\/)[A-Za-z0-9_./-]+\.(?:md|mdx|feature))(?:$|[\s)\]`'",;])/gm;function I(e){return e.startsWith("core/templates/")?"template":e.startsWith("docs/epics/")?"epic":e.startsWith("docs/stories/")&&e.endsWith(".story.md")?"story":e.toLowerCase().includes("adr")?"adr":e.toLowerCase().includes("contract")?"contract":e.toLowerCase().includes("nfr")?"nfr":e.endsWith(".feature")?"bdd":e.toLowerCase().includes("traceability")?"traceability":e.startsWith("docs/examples/")?"example":"spec"}function P(e){return[...new Set([...e.matchAll(W)].map(r=>r[1]).filter(r=>!!r))].sort()}function i(e,r){const c=w(e);let o;try{o=w(y(c,r))}catch{throw new Error("yolo-spec-envelope-required")}if(!o.startsWith(`${c}${b}`))throw new Error("yolo-spec-envelope-path-out-of-scope");if(!E(o).isFile())throw new Error("yolo-spec-envelope-unsafe");if(E(o).size>C)throw new Error("yolo-spec-envelope-too-large");return T(o,"utf8")}function f(e,r){const o=$(e,{context:r==="story"?"story-target":"epic-target",explicitlySelected:!0});if(o.status==="malformed"||o.status==="oversized")throw new Error("yolo-spec-envelope-unsafe");if(o.status==="absent")return e;const a=e.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n/);if(!a)throw new Error("yolo-spec-envelope-unsafe");return`---
1
+ import{execFileSync as L}from"node:child_process";import{existsSync as S,readFileSync as T,realpathSync as w,statSync as E}from"node:fs";import{join as f,sep as b}from"node:path";import{createYoloSpecEnvelopeV1 as x,YOLO_SPEC_ARTIFACT_LIMIT_BYTES as C,YOLO_SPEC_MAX_ARTIFACTS as R,YOLO_SPEC_TOTAL_LIMIT_BYTES as g}from"../../../shared/dist/yolo/spec-envelope.js";import{inspectFrontmatterContext as $}from"../../../shared/dist/frontmatter-context-contract.js";const O=["core/templates/specs/feature-spec-template.md","core/templates/specs/architecture-spec-template.md","core/templates/specs/contract-spec-template.md","core/templates/specs/story-spec-template.md","core/templates/specs/traceability-matrix-template.md"],W=/(?:^|[\s([`'";])((?:docs\/(?:stories|epics|specs|architecture|examples)\/|core\/templates\/specs\/)[A-Za-z0-9_./-]+\.(?:md|mdx|feature))(?:$|[\s)\]`'",;])/gm;function I(e){return e.startsWith("core/templates/")?"template":e.startsWith("docs/epics/")?"epic":e.startsWith("docs/stories/")&&e.endsWith(".story.md")?"story":e.endsWith(".rtm.md")?"traceability":e.toLowerCase().includes("adr")?"adr":e.toLowerCase().includes("contract")?"contract":e.toLowerCase().includes("nfr")?"nfr":e.endsWith(".feature")?"bdd":e.toLowerCase().includes("traceability")?"traceability":e.startsWith("docs/examples/")?"example":"spec"}function P(e){return[...new Set([...e.matchAll(W)].map(r=>r[1]).filter(r=>!!r))].sort()}function i(e,r){const c=w(e);let o;try{o=w(f(c,r))}catch{throw new Error("yolo-spec-envelope-required")}if(!o.startsWith(`${c}${b}`))throw new Error("yolo-spec-envelope-path-out-of-scope");if(!E(o).isFile())throw new Error("yolo-spec-envelope-unsafe");if(E(o).size>C)throw new Error("yolo-spec-envelope-too-large");return T(o,"utf8")}function m(e,r){const o=$(e,{context:r==="story"?"story-target":"epic-target",explicitlySelected:!0});if(o.status==="malformed"||o.status==="oversized")throw new Error("yolo-spec-envelope-unsafe");if(o.status==="absent")return e;const a=e.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n/);if(!a)throw new Error("yolo-spec-envelope-unsafe");return`---
2
2
  ${Object.entries(o.metadata).map(([s,l])=>`${s}: ${JSON.stringify(l)}`).join(`
3
3
  `)}
4
4
  ---
5
- ${e.slice(a[0].length)}`}function v(e){try{return L("git",["-C",e,"rev-parse","HEAD"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).trim()}catch{throw new Error("yolo-spec-envelope-stale")}}function M(e){const r=`docs/stories/${e.storyId}.story.md`,c=`docs/epics/epic-${e.epicId}.md`,o=e.headSha??v(e.projectRoot),a=f(i(e.projectRoot,r),"story"),m=f(i(e.projectRoot,c),"epic"),s=[{kind:"story",path:r,content:a},{kind:"epic",path:c,content:m}],l=P(a),u=new Set([`docs/stories/${e.storyId}.spec.md`,`docs/stories/${e.storyId}.tasks.md`,`docs/stories/${e.storyId}.rtm.md`]),_=[...l.filter(t=>u.has(t)),...l.filter(t=>!u.has(t))];let p=s.reduce((t,n)=>t+Buffer.byteLength(n.content,"utf8"),0),h=0;for(const t of _){if(t===r||t===c||!S(y(e.projectRoot,t)))continue;if(t.startsWith("docs/stories/")&&t.endsWith(".story.md")||t.startsWith("docs/epics/"))throw new Error("yolo-spec-envelope-target-mismatch");const n=i(e.projectRoot,t),d=Buffer.byteLength(n,"utf8");if(s.length>=R||p+d>g){if(u.has(t))throw new Error("yolo-spec-envelope-too-large");h+=1;continue}s.push({kind:I(t),path:t,content:n}),p+=d}h&&e.onOmittedReferences?.(h);for(const t of O){if(t===r||t===c||l.includes(t)||!S(y(e.projectRoot,t)))continue;const n=i(e.projectRoot,t),d=Buffer.byteLength(n,"utf8");s.length>=R||p+d>g||(s.push({kind:I(t),path:t,content:n}),p+=d)}const j=x({storyId:e.storyId,epicId:e.epicId,targetPath:r,inputSha256:e.inputSha256,headSha:o,collectedAt:e.collectedAt??new Date().toISOString(),artifacts:s}),A=e.headSha??v(e.projectRoot);if(o!==A||f(i(e.projectRoot,r),"story")!==a||f(i(e.projectRoot,c),"epic")!==m||s.some(t=>t.kind!=="story"&&t.kind!=="epic"&&i(e.projectRoot,t.path)!==t.content))throw new Error("yolo-spec-envelope-stale");return j}export{M as collectYoloSpecEnvelope};
5
+ ${e.slice(a[0].length)}`}function j(e){try{return L("git",["-C",e,"rev-parse","HEAD"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).trim()}catch{throw new Error("yolo-spec-envelope-stale")}}function M(e){const r=`docs/stories/${e.storyId}.story.md`,c=`docs/epics/epic-${e.epicId}.md`,o=e.headSha??j(e.projectRoot),a=m(i(e.projectRoot,r),"story"),u=m(i(e.projectRoot,c),"epic"),s=[{kind:"story",path:r,content:a},{kind:"epic",path:c,content:u}],l=new Set([`docs/stories/${e.storyId}.spec.md`,`docs/stories/${e.storyId}.tasks.md`,`docs/stories/${e.storyId}.rtm.md`]),h=[...new Set([...P(a),...[...l].filter(t=>S(f(e.projectRoot,t)))])].sort(),v=[...h.filter(t=>l.has(t)),...h.filter(t=>!l.has(t))];let p=s.reduce((t,n)=>t+Buffer.byteLength(n.content,"utf8"),0),y=0;for(const t of v){if(t===r||t===c||!S(f(e.projectRoot,t)))continue;if(t.startsWith("docs/stories/")&&t.endsWith(".story.md")||t.startsWith("docs/epics/"))throw new Error("yolo-spec-envelope-target-mismatch");const n=i(e.projectRoot,t),d=Buffer.byteLength(n,"utf8");if(s.length>=R||p+d>g){if(l.has(t))throw new Error("yolo-spec-envelope-too-large");y+=1;continue}s.push({kind:I(t),path:t,content:n}),p+=d}y&&e.onOmittedReferences?.(y);for(const t of O){if(t===r||t===c||h.includes(t)||!S(f(e.projectRoot,t)))continue;const n=i(e.projectRoot,t),d=Buffer.byteLength(n,"utf8");s.length>=R||p+d>g||(s.push({kind:I(t),path:t,content:n}),p+=d)}const _=x({storyId:e.storyId,epicId:e.epicId,targetPath:r,inputSha256:e.inputSha256,headSha:o,collectedAt:e.collectedAt??new Date().toISOString(),artifacts:s}),A=e.headSha??j(e.projectRoot);if(o!==A||m(i(e.projectRoot,r),"story")!==a||m(i(e.projectRoot,c),"epic")!==u||s.some(t=>t.kind!=="story"&&t.kind!=="epic"&&i(e.projectRoot,t.path)!==t.content))throw new Error("yolo-spec-envelope-stale");return _}export{M as collectYoloSpecEnvelope};
@@ -9,6 +9,8 @@ function record(value) {
9
9
  return value !== null && typeof value === 'object' && !Array.isArray(value);
10
10
  }
11
11
  const SCALARS = ['goal', 'problem', 'desiredOutcome', 'rawIntent'];
12
+ /** Original selected input is preserved; ordinary summary fields stay at 512. */
13
+ export const PLANNING_RAW_INTENT_MAX_CHARS = 4096;
12
14
  const LISTS = ['context', 'users', 'surfaces', 'constraints', 'assumptions', 'risks', 'nonGoals',
13
15
  'validationExpectations', 'debtRefs', 'repositoryEvidencePaths', 'journeyIds', 'screenIds',
14
16
  'storybookStoryIds', 'backendContractIds', 'featureBlockerIds', 'remediationRefs'];
@@ -39,8 +41,9 @@ export function canonicalPlanningIntake(value) {
39
41
  allowedKeys(value, [...SCALARS, ...LISTS, ...BOOLEANS, 'examples', 'contracts']);
40
42
  const result = {};
41
43
  for (const key of SCALARS)
42
- if (value[key] !== undefined)
43
- result[key] = safeText(value[key]);
44
+ if (value[key] !== undefined) {
45
+ result[key] = safeText(value[key], key === 'rawIntent' ? PLANNING_RAW_INTENT_MAX_CHARS : 512);
46
+ }
44
47
  for (const key of LISTS)
45
48
  if (value[key] !== undefined) {
46
49
  const entries = value[key];