@ornexus/neocortex 4.65.1 → 4.66.1
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.
- package/dist/release-source.json +1 -1
- package/dist/sbom.cdx.json +1206 -1193
- package/install.ps1 +243 -77
- package/install.sh +221 -102
- package/package.json +2 -2
- package/packages/client/dist/adapters/platform-detector.js +1 -1
- package/packages/client/dist/agent/refresh-stubs.d.ts +50 -0
- package/packages/client/dist/agent/refresh-stubs.js +2 -2
- package/packages/client/dist/cli.js +5 -4
- package/packages/client/dist/commands/doctor.d.ts +26 -1
- package/packages/client/dist/commands/doctor.js +2 -2
- package/packages/client/dist/commands/invoke.d.ts +183 -5
- package/packages/client/dist/commands/invoke.js +94 -87
- package/packages/client/dist/commands/planning-qa.d.ts +64 -0
- package/packages/client/dist/commands/planning-qa.js +1 -0
- package/packages/client/dist/commands/refactor-control.js +3 -3
- package/packages/client/dist/commands/story-checkpoint.d.ts +3 -1
- package/packages/client/dist/commands/story-checkpoint.js +1 -1
- package/packages/client/dist/commands/story-worktree.d.ts +1 -1
- package/packages/client/dist/commands/story-worktree.js +1 -1
- package/packages/client/dist/git/direct-yolo-checkpoint.d.ts +64 -1
- package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -3
- package/packages/client/dist/git/epic-lifecycle-evidence.d.ts +184 -0
- package/packages/client/dist/git/epic-lifecycle-evidence.js +6 -0
- package/packages/client/dist/git/git-lifecycle-store.d.ts +23 -0
- package/packages/client/dist/git/git-lifecycle-store.js +9 -8
- package/packages/client/dist/git/governance-runtime-store.d.ts +172 -0
- package/packages/client/dist/git/governance-runtime-store.js +3 -0
- package/packages/client/dist/git/story-worktree-cleanup.js +1 -1
- package/packages/client/dist/git/story-worktree-integration.js +3 -3
- package/packages/client/dist/git/story-worktree-manager.d.ts +39 -0
- package/packages/client/dist/git/story-worktree-manager.js +3 -3
- package/packages/client/dist/git/story-write-set-extension.d.ts +62 -0
- package/packages/client/dist/git/story-write-set-extension.js +1 -1
- package/packages/client/dist/memory/shared-project-memory-types.d.ts +39 -2
- package/packages/client/dist/memory/shared-project-memory-types.js +2 -2
- package/packages/client/dist/policy/subagent-approval-policy.js +1 -1
- package/packages/client/dist/private-execution/codex-executor.d.ts +21 -1
- package/packages/client/dist/private-execution/codex-executor.js +4 -4
- package/packages/client/dist/private-execution/delivery.d.ts +17 -11
- package/packages/client/dist/private-execution/delivery.js +8 -6
- package/packages/client/dist/private-execution/diagnosis-root-review.d.ts +89 -0
- package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -2
- package/packages/client/dist/private-execution/frozen-handoff.js +3 -3
- package/packages/client/dist/private-execution/harness-adapters/antigravity.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/antigravity.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/claude-code.d.ts +8 -0
- package/packages/client/dist/private-execution/harness-adapters/claude-code.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/codex.d.ts +7 -0
- package/packages/client/dist/private-execution/harness-adapters/codex.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/copilot-cli.d.ts +8 -0
- package/packages/client/dist/private-execution/harness-adapters/copilot-cli.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/cursor.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/cursor.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/deepseek.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/deepseek.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/gemini.d.ts +8 -0
- package/packages/client/dist/private-execution/harness-adapters/gemini.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/grok.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/grok.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/index.d.ts +73 -0
- package/packages/client/dist/private-execution/harness-adapters/index.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/kimi.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/kimi.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/openclaw.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/openclaw.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/opencode.d.ts +7 -0
- package/packages/client/dist/private-execution/harness-adapters/opencode.js +1 -0
- package/packages/client/dist/private-execution/harness-ephemeral-home.d.ts +19 -0
- package/packages/client/dist/private-execution/harness-ephemeral-home.js +1 -0
- package/packages/client/dist/private-execution/harness-executor.d.ts +79 -0
- package/packages/client/dist/private-execution/harness-executor.js +1 -0
- package/packages/client/dist/private-execution/harness-process.d.ts +43 -0
- package/packages/client/dist/private-execution/harness-process.js +1 -0
- package/packages/client/dist/private-execution/isolated-admission.js +12 -12
- package/packages/client/dist/private-execution/isolated-workspace.d.ts +16 -1
- package/packages/client/dist/private-execution/isolated-workspace.js +1 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.d.ts +75 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -5
- package/packages/client/dist/private-execution/planning-generation-checkpoint.d.ts +9 -1
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +4 -4
- package/packages/client/dist/private-execution/planning-research-checkpoint.d.ts +9 -1
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -4
- package/packages/client/dist/private-execution/root-memory-request.d.ts +4 -1
- package/packages/client/dist/private-execution/root-memory-request.js +1 -1
- package/packages/client/dist/runner/epic-background-dispatcher.d.ts +3 -1
- package/packages/client/dist/runner/epic-background-dispatcher.js +1 -1
- package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -1
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.d.ts +1 -22
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +6 -10
- package/packages/client/dist/runner/headless/managed-profile.d.ts +20 -0
- package/packages/client/dist/runner/headless/managed-profile.js +1 -1
- package/packages/client/dist/runner/headless/opencode-adapter.js +2 -2
- package/packages/client/dist/runner/headless/run-yoloop.d.ts +40 -0
- package/packages/client/dist/runner/headless/run-yoloop.js +2 -2
- package/packages/client/dist/runner/headless/types.d.ts +20 -0
- package/packages/client/dist/runner/headless/types.js +2 -2
- package/packages/client/dist/state/project-state-snapshot.d.ts +10 -0
- package/packages/client/dist/state/project-state-snapshot.js +1 -1
- package/packages/client/dist/state/structural-dag-projection.d.ts +26 -0
- package/packages/client/dist/state/structural-dag-projection.js +1 -1
- package/packages/client/dist/yoloop/target-normalization.js +1 -1
- package/packages/client/dist/yoloop/yoloop-client-state-store.d.ts +67 -0
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1
- package/packages/shared/dist/compatibility/index.js +96 -0
- package/packages/shared/dist/planning/diagnosis-state.js +105 -1
- package/packages/shared/dist/project-memory-targets.js +36 -5
- package/targets-stubs/antigravity/README.md +1 -1
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/install-antigravity.sh +1 -1
- package/targets-stubs/antigravity/mcp-config.json +0 -3
- package/targets-stubs/antigravity/neocortex.md +25 -13
- package/targets-stubs/antigravity/skill/SKILL.md +4 -4
- package/targets-stubs/claude-code/.mcp.json +0 -4
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +2 -4
- package/targets-stubs/claude-code/neocortex-root.md +33 -43
- package/targets-stubs/claude-code/neocortex-sentinel.md +261 -0
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -3
- package/targets-stubs/claude-code/neocortex.md +61 -84
- package/targets-stubs/codex/AGENTS.md +19 -18
- package/targets-stubs/codex/README.md +1 -1
- package/targets-stubs/codex/config-mcp.toml +0 -3
- package/targets-stubs/codex/neocortex-sentinel.toml +87 -0
- package/targets-stubs/codex/neocortex.toml +23 -44
- package/targets-stubs/cursor/README.md +1 -1
- package/targets-stubs/cursor/agent.md +26 -15
- package/targets-stubs/cursor/mcp.json +0 -3
- package/targets-stubs/deepseek-harness/SKILL.md +11 -8
- package/targets-stubs/gemini-cli/README.md +1 -1
- package/targets-stubs/gemini-cli/agent.md +25 -12
- package/targets-stubs/gemini-cli/agents/neocortex-sentinel.md +75 -0
- package/targets-stubs/gemini-cli/agents/neocortex.md +280 -49
- package/targets-stubs/gemini-cli/settings-mcp.json +0 -3
- package/targets-stubs/grok/SKILL.md +13 -1
- package/targets-stubs/grok/agents/neocortex-sentinel.md +64 -0
- package/targets-stubs/grok/config-mcp.toml +0 -3
- package/targets-stubs/grok/install-grok.sh +51 -1
- package/targets-stubs/kimi/mcp.json +0 -6
- package/targets-stubs/kimi/neocortex.md +21 -8
- package/targets-stubs/lib/managed-config-merge.js +301 -6
- package/targets-stubs/lib/managed-profile.sh +12 -1
- package/targets-stubs/lib/mcp-merge.js +122 -8
- package/targets-stubs/openclaw/SKILL.md +33 -4
- package/targets-stubs/opencode/neocortex-root.md +41 -41
- package/targets-stubs/opencode/neocortex-sentinel.md +115 -0
- package/targets-stubs/opencode/neocortex.md +292 -67
- package/targets-stubs/opencode/opencode-mcp.json +0 -7
- package/targets-stubs/vscode/README.md +1 -1
- package/targets-stubs/vscode/mcp.json +0 -4
- package/targets-stubs/vscode/neocortex.agent.md +29 -18
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readFileSync as
|
|
2
|
-
`),
|
|
1
|
+
import{readFileSync as E,writeFileSync as M,existsSync as c,mkdirSync as q,renameSync as ae,unlinkSync as le,realpathSync as V}from"node:fs";import{join as t,dirname as z,relative as $,isAbsolute as Q}from"node:path";import{homedir as p}from"node:os";import{createRequire as de}from"node:module";import{fileURLToPath as ue}from"node:url";import{setSecureFilePermissions as G}from"../config/secure-config.js";const fe=60,pe=25,Z=de(import.meta.url),xe={"codex:AGENTS.md":"profile-codex-root","codex:neocortex-sentinel.toml":"profile-codex-neocortex-sentinel","codex:neocortex.toml":"profile-codex-neocortex","claude-code:neocortex-sentinel.md":"profile-claude-neocortex-sentinel-agent","claude-code:neocortex.md":"profile-claude-neocortex-agent","claude-code:neocortex-root.md":"profile-claude-neocortex-root-agent"},me={"codex:neocortex-sentinel.toml":"profile-codex-neocortex-sentinel","codex:neocortex.toml":"profile-codex-neocortex","claude-code:neocortex-sentinel.md":"profile-claude-neocortex-sentinel-agent","claude-code:neocortex.md":"profile-claude-neocortex-agent","claude-code:neocortex-root.md":"profile-claude-neocortex-root-agent","opencode:neocortex-sentinel.md":"profile-opencode-neocortex-sentinel","opencode:neocortex.md":"profile-opencode-neocortex","opencode:neocortex-root.md":"profile-opencode-neocortex-root"},ee={"claude-code":"neocortex-sentinel.md",opencode:"neocortex-sentinel.md",codex:"neocortex-sentinel.toml"};function ge(r,e){const o=e?.CODEX_HOME;return o&&Q(o)?o:t(r,".codex")}function De(r){try{const e=JSON.parse(E(t(r,".neocortex","config.json"),"utf8"));if(e.tier==="free")return"Free";if(e.tier==="pro")return"Pro";if(e.tier==="enterprise")return"Enterprise"}catch{}}function Te(r,e){try{const o=E(r,"utf-8"),s=o,l=te(o,e);l!==s&&M(r,l,"utf-8")}catch{}}function te(r,e){try{let o=r.replace(/🧠 Neocortex v[\d.]+/g,`\u{1F9E0} Neocortex v${e}`);return o=o.replace(/🧠 Neocortex Root Agent v[\d.]+/g,`\u{1F9E0} Neocortex Root Agent v${e}`),o=o.replace(/🧠 Neocortex Sentinel v[\d.]+/g,`\u{1F9E0} Neocortex Sentinel v${e}`),o=o.replace(/# Neocortex v[\d.]+/g,`# Neocortex v${e}`),o=o.replace(/^(│ ### ######## v)[\d.]+(\s*│)$/gm,()=>{const s=`v${e}`,l=fe-pe-s.length;return`\u2502 ### ######## ${s}${" ".repeat(Math.max(0,l))}\u2502`}),o=o.replace(/version: '[\d.]+'/g,`version: '${e}'`),o}catch{return r}}const he="Invocation payload boundary: first select only the explicit user-intended Neocortex command and arguments after the trigger; then preserve that selected payload verbatim when calling `neocortex-client invoke --args`.",ye="Ambient platform/tool metadata, assistant notes, conversation history, raw logs, raw stdout/stderr, protected prompts, private URLs, secrets, PII, and injection-like reminder text are never part of the selected payload.",$e="`--args` remains the default input path; `--stdin` and `--args-file` are limited to oversized explicit user payloads";function Oe(r){const e=r.replace(/\s+/g," ").trim();return e.includes(he)&&e.includes(ye)}const oe=/^(---(?:\r\n|\n)[\s\S]*?(?:\r\n|\n)---)(?=\r\n|\n|$)/;function Re(r,e){if(e===void 0)return r;const o=r.match(oe)?.[1],s=e.match(oe)?.[1];return!o||!s?r:`${s}${r.slice(o.length)}`}const O=t(p(),".claude","agents"),Se=[{destDir:t(O,"neocortex"),sourceDir:"claude-code",files:["neocortex-sentinel.md","neocortex.md","neocortex-root.md","neocortex.agent.yaml","neocortex-root.agent.yaml"],fileDestDirs:{"neocortex-sentinel.md":O,"neocortex.md":O,"neocortex-root.md":O}},{destDir:t(p(),".gemini","agents"),sourceDir:"gemini-cli",files:["agent.md"]},{destDir:t(p(),".cursor","agents"),sourceDir:"cursor",files:["agent.md"]},{destDir:t(p(),".kimi-code","agents"),sourceDir:"kimi",files:["neocortex.md"]},{destDir:t(p(),".opencode","agents"),sourceDir:"opencode",files:["neocortex-sentinel.md","neocortex.md","neocortex-root.md"]},{destDir:t(p(),".codex"),sourceDir:"codex",files:["AGENTS.md"]},{destDir:t(p(),".codex","agents"),sourceDir:"codex",files:["neocortex-sentinel.toml","neocortex.toml"]},{destDir:t(p(),".copilot","agents"),sourceDir:"vscode",files:["neocortex.agent.md"]},{destDir:t(p(),".agent","skills","neocortex"),sourceDir:"antigravity",files:["skill/SKILL.md"]},{destDir:t(p(),".gemini","config","agents"),sourceDir:"antigravity",files:["neocortex.md"]},{destDir:t(p(),".grok","skills","neocortex"),sourceDir:"grok",files:["SKILL.md"]}],ve=[{stubDir:"claude-code",agentsDir:t(".claude","agents"),roleFiles:[["neocortex-sentinel.md","project-claude-neocortex-sentinel-agent",!0],["neocortex.md","project-claude-neocortex-agent",!0]],legacyDir:t(".claude","agents","neocortex")},{stubDir:"opencode",agentsDir:t(".opencode","agents"),roleFiles:[["neocortex-sentinel.md","project-opencode-neocortex-sentinel",!0],["neocortex.md","project-opencode-neocortex",!0],["neocortex-root.md","project-opencode-neocortex-root",!1]]},{stubDir:"codex",agentsDir:t(".codex","agents"),roleFiles:[["neocortex-sentinel.toml","project-codex-neocortex-sentinel",!0],["neocortex.toml","project-codex-neocortex",!0]]}];function Ee(){try{const r=ue(import.meta.url);let e=z(r);for(let o=0;o<10;o++){try{if(JSON.parse(E(t(e,"package.json"),"utf-8")).name==="@ornexus/neocortex")return e}catch{}e=z(e)}}catch{}return null}function Ne(r){try{const e=t(r,".version");if(c(e))return E(e,"utf-8").trim()||null}catch{}return null}function Pe(r,e){const o=`${r}.tmp-${process.pid}`;try{M(o,e,"utf8"),G(o),ae(o,r),G(r)}catch(s){try{c(o)&&le(o)}catch{}throw s}}function we(r,e){return be(r,e).refreshed}function re(r,e,o,s,l,u=!0){let x=E(r,"utf8");if(e.endsWith(".md")&&u){const i=c(o)?o:s&&c(s)?s:null,y=i?E(i,"utf8"):void 0;x=Re(x,y)}return(e.endsWith(".md")||e.endsWith(".yaml")||e.endsWith(".yml"))&&(x=te(x,l)),x}function ne(r,e,o){return{id:r.id??e,scope:o,relativePath:r.relativePath??"",action:r.action,reasonCode:r.reasonCode,...r.nextStep?{nextStep:r.nextStep}:{}}}function Ae(r,e){try{return V.native(r)===V.native(e)}catch{return!1}}function Fe(r){const{projectRoot:e,home:o,stubsRoot:s,managed:l,cliVersion:u,dryRun:x,tierLabel:i,targetFilter:y,results:h}=r;if(!Q(e)||!c(e)||Ae(e,o))return;const N=t(e,".neocortex","managed-config-manifest.json");for(const d of ve)if(!(y&&d.stubDir!==y))try{const P=t(s,d.stubDir),A=t(e,d.agentsDir);if(!d.roleFiles.slice(0,2).some(([m])=>c(t(A,m))))continue;const S=ee[d.stubDir],j=!!(S&&c(t(P,S)));for(const[m,n,R]of d.roleFiles){const F=t(P,m),f=t(A,m);if(!c(F)||!R&&!c(f))continue;const g=d.legacyDir?t(e,d.legacyDir,m):null,I=j&&l.agentRoleMigrationPending?.({id:n,destination:f,manifestFile:N,baseDir:e})===!0,w=re(F,m,f,g,u,!I);try{const b=l.applyProfileBytes({id:n,content:w,destination:f,manifestFile:N,baseDir:e,dryRun:x,allowLegacyAdoption:!0,tierLabel:i,adoptExistingOwner:!0,agentRoles:j,legacyCopyPath:g&&c(g)?g:null});h.push(ne(b,n,"project"))}catch(b){const D=b?.reasonCode;h.push({id:n,scope:"project",relativePath:$(e,f).split("\\").join("/"),action:"failed",reasonCode:typeof D=="string"?D:"managed-operation-failed"})}}}catch{}}function be(r,e){const o=[];try{const s=e?.forceCreate??!1,l=e?.targetFilter,u=e?.dryRun??!1,x=p(),i=e?.homeDir??x,y=e?.packageRoot??Ee();if(!y)return{refreshed:0,results:o};const h=t(y,"targets-stubs");if(!c(h))return{refreshed:0,results:o};const N=t(h,"lib","managed-config-merge.js");if(!c(N))return{refreshed:0,results:o};const d=Z(N),P=t(i,".neocortex","managed-config-manifest.json"),A=De(i),U=e?.env??(e?.homeDir?void 0:process.env),S=ge(i,U),j=t(x,".codex");try{d.applyPolicy({configFile:t(i,".neocortex","config.json"),manifestFile:P,baseDir:i,dryRun:u})}catch{}if(e?.projectRoot&&Fe({projectRoot:e.projectRoot,home:i,stubsRoot:h,managed:d,cliVersion:r,dryRun:u,tierLabel:A,targetFilter:l,results:o}),!l||l==="claude-code")try{const n=t(h,"lib","claude-worktree-setting.js");c(n)&&Z(n).ensureClaudeWorktreeBaseRef(i,{dryRun:u})}catch{}let m=0;for(const n of Se)try{const R=n.sourceDir==="codex",F=a=>R?t(S,$(j,a)):e?.homeDir?t(i,$(x,a)):a,f=F(n.destDir);if(l&&n.sourceDir!==l)continue;if(!c(f)){if(s&&!u)q(f,{recursive:!0});else if(!(s&&u))continue}const g=t(h,n.sourceDir),I=a=>{const L=n.fileDestDirs?.[a];return L?t(F(L),a):t(f,a)},w=Ne(f),b=n.files.every(a=>!c(t(g,a))||c(I(a)));if(w===r&&b||!c(g))continue;let D=i;if(R){if(!c(S))continue;D=d.resolveManagedBase(S,i)}const H=D===i?P:t(D,".neocortex","managed-config-manifest.json"),W=ee[n.sourceDir],Y=!!(W&&c(t(g,W)));let B=!1;for(const a of n.files){const L=t(g,a),ce=n.fileDestDirs?.[a],k=I(a),C=ce?t(f,a):null;if(c(L)){const J=$(i,k).split("\\").join("/"),K=`${n.sourceDir}:${a}`,T=xe[K]??`profile-${n.sourceDir}-${J}`,v=me[K],ie=!!v&&Y&&d.agentRoleMigrationPending?.({id:T,agentRoleId:v,destination:k,manifestFile:H,baseDir:D})===!0,se=re(L,a,k,C,r,!ie);try{const _=d.applyProfileBytes({id:T,content:se,destination:k,manifestFile:H,baseDir:D,dryRun:u,allowLegacyAdoption:!0,tierLabel:A,adoptExistingOwner:!0,legacyBaseDir:D===i?null:i,...v?{agentRoles:Y,agentRoleId:v}:{},legacyCopyPath:C&&c(C)?C:null});v&&o.push(ne(_,T,"user")),_.action!=="failed"&&(B=!0)}catch(_){if(v){const X=_?.reasonCode;o.push({id:T,scope:"user",relativePath:J,action:"failed",reasonCode:typeof X=="string"?X:"managed-operation-failed"})}throw _}}}if(B&&!u){const a=t(f,".version");Pe(a,r+`
|
|
2
|
+
`),m++}else B&&m++}catch{}if(m>0&&!u)try{const n=t(i,".neocortex");q(n,{recursive:!0});const R=t(n,".update-check");M(R,"",{flag:"w"}),G(R)}catch{}return{refreshed:m,results:o}}catch{return{refreshed:0,results:o}}}export{me as AGENT_ROLE_IDS,xe as CANONICAL_MANAGED_IDS,ve as PROJECT_ROLE_TARGETS,he as SELECTED_PAYLOAD_BOUNDARY_SNIPPET,ye as SELECTED_PAYLOAD_EXCLUSION_SNIPPET,$e as SELECTED_PAYLOAD_LARGE_INPUT_SNIPPET,Se as STUB_TARGETS,Oe as containsSelectedPayloadBoundary,Ee as findPackageRoot,te as patchVersionInContent,Te as patchVersionInFile,Re as preserveInstalledMarkdownFrontmatter,we as refreshStubs,be as refreshStubsReport};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{getClientVersion as l}from"./version.js";import{spawnSync as v}from"node:child_process";import{COMMAND_REGISTRY_CHECKSUM as p,COMMAND_REGISTRY_VERSION as d}from"./generated/command-registry.generated.js";import{readProjectRegistryIdentity as
|
|
2
|
+
import{getClientVersion as l}from"./version.js";import{spawnSync as v}from"node:child_process";import{COMMAND_REGISTRY_CHECKSUM as p,COMMAND_REGISTRY_VERSION as d}from"./generated/command-registry.generated.js";import{readProjectRegistryIdentity as w,reconcileRegistry as m,RegistryReconciliationError as u,REGISTRY_RECONCILIATION_REASON_CODES as h}from"./registry/registry-reconciliation.js";const f=`
|
|
3
3
|
neocortex-client - Neocortex Client CLI
|
|
4
4
|
|
|
5
5
|
Usage:
|
|
@@ -14,6 +14,7 @@ Commands:
|
|
|
14
14
|
planning-research seal Seal an independently reviewed P02 checkpoint from stdin
|
|
15
15
|
planning-generation <seal|verify> Seal a reviewed P03 or verify its committed evidence from stdin
|
|
16
16
|
planning-memory <seal|verify> Seal reviewed committed memory or reopen its physical receipt
|
|
17
|
+
planning-qa record Record digest-bound QA evidence for an admitted P01-P03 checkpoint from stdin
|
|
17
18
|
private-session <inspect-rejected|discard-rejected|renew-lease|accept-diagnosis|accept-research|accept-specification|accept-tasks|validate-implementation|accept-implementation|accept-refactor-advisory|accept-test-validation|accept-qa|accept-project-memory> Root recovery and phase validation
|
|
18
19
|
story-checkpoint Root-owned direct-*yolo commit/checkpoint boundary
|
|
19
20
|
story-worktree <create|adopt|sync|status|release> P225 temporary story worktree lifecycle (public-safe JSON)
|
|
@@ -220,7 +221,7 @@ Invocation payload boundary:
|
|
|
220
221
|
|
|
221
222
|
License:
|
|
222
223
|
Licensed under BSL-1.1 (Business Source License 1.1)
|
|
223
|
-
`.trim(),
|
|
224
|
+
`.trim(),j=new Set(["pm","install","postinstall","preinstall","prepublish","postpublish","preuninstall","postuninstall","preprepare","prepare","postprepare"]);function y(r,a){const o=r.indexOf(a);return o>=0?r[o+1]:void 0}function g(r){if(r instanceof u){process.stderr.write(`[Neocortex] ${r.reasonCode}: ${r.remediation}
|
|
224
225
|
`);return}process.stderr.write(`[Neocortex] ${h.ARTIFACT_UNAVAILABLE}: registry reconciliation could not be completed safely; no invoke request was sent.
|
|
225
|
-
`)}function x(){return{version:d,checksum:p}}function b(r){const a=
|
|
226
|
-
`),process.exit(0));const o=r.slice(1);switch(a){case"invoke":{const e=k(r,o);if(e!==void 0){process.exitCode=e;break}const{invokeCliHandler:t,flushInvokeCliOutput:
|
|
226
|
+
`)}function x(){return{version:d,checksum:p}}function b(r){const a=w(r);return!a||a.version===d&&a.checksum===p}function k(r,a){const o=y(a,"--project-root")||process.cwd();try{if(process.env.NEOCORTEX_REGISTRY_REEXECUTED==="1"&&!b(o))throw new u(h.ARTIFACT_MISMATCH,"The reinstalled client still does not match the trusted local projection; no invoke request was sent.");if(m({projectRoot:o,installedVersion:l(),installedIdentity:x()}).status!=="updated")return;const t=v(process.execPath,[process.argv[1],...r],{stdio:"inherit",env:{...process.env,NEOCORTEX_REGISTRY_REEXECUTED:"1"},shell:!1});return t.error?1:t.status??1}catch(e){return g(e),1}}async function C(){const r=process.argv.slice(2),a=r[0];a&&j.has(a.toLowerCase())&&process.exit(0),(!a||a==="--help"||a==="-h")&&(console.log(f),process.exit(0)),(a==="--version"||a==="-v")&&(console.log(l()),process.stderr.write(`Licensed under BSL-1.1 (Business Source License 1.1)
|
|
227
|
+
`),process.exit(0));const o=r.slice(1);switch(a){case"invoke":{const e=k(r,o);if(e!==void 0){process.exitCode=e;break}const{invokeCliHandler:t,flushInvokeCliOutput:i}=await import("./commands/invoke.js"),s=await t(o),n=await i();process.exitCode=n?s:1;break}case"reconcile-registry":{const e=y(o,"--project-root")||process.cwd();try{m({projectRoot:e,installedVersion:l(),installedIdentity:x(),checkLatest:o.includes("--check-latest")}),process.exitCode=0}catch(t){g(t),process.exitCode=1}break}case"activate":{const{activate:e}=await import("./commands/activate.js");let t,i,s=!1;for(let n=0;n<o.length;n++){const c=o[n];c==="--server-url"?i=o[++n]:c==="--non-interactive"?s=!0:c==="--help"||c==="-h"?(console.log(f),process.exit(0)):c.startsWith("-")||(t=c)}t||(console.error("Error: License key is required."),console.error("Usage: neocortex-client activate <license-key>"),console.error("Example: neocortex-client activate NX-PRO-ABC-123"),process.exit(1));try{const n=await e({licenseKey:t,serverUrl:i,nonInteractive:s});n.success?(console.log(n.message),process.exit(0)):(console.error(n.message),process.exit(1))}catch(n){const c=n instanceof Error?n.message:String(n);console.error(`Activation failed: ${c}`),process.exit(1)}break}case"cache-status":{console.log("Cache status requires an active client session."),console.log("Use this command within a running Neocortex client context."),process.exit(0);break}case"doctor":{const{doctorCliHandler:e}=await import("./commands/doctor.js"),t=await e(o);process.exit(t);break}case"config":{const{configCliHandler:e}=await import("./commands/config.js"),t=await e(o);process.exit(t);break}case"refresh-memory":{const{refreshMemoryCliHandler:e}=await import("./commands/refresh-memory.js"),t=await e(o);process.exit(t);break}case"architecture-memory":{const{architectureMemoryTerminalCliHandler:e}=await import("./commands/architecture-memory-terminal.js"),t=await e(o);process.exit(t);break}case"planning-diagnosis":{const{planningDiagnosisCliHandler:e}=await import("./commands/planning-diagnosis.js"),t=await e(o);process.exit(t);break}case"planning-research":{const{planningResearchCliHandler:e}=await import("./commands/planning-research.js"),t=await e(o);process.exit(t);break}case"private-session":{const{privateSessionCliHandler:e}=await import("./commands/private-session.js"),t=await e(o);process.exit(t);break}case"planning-memory":{const{planningMemoryCliHandler:e}=await import("./commands/planning-memory.js"),t=await e(o);process.exit(t);break}case"planning-generation":{const{planningGenerationCliHandler:e}=await import("./commands/planning-generation.js"),t=await e(o);process.exit(t);break}case"planning-qa":{const{planningQaCliHandler:e}=await import("./commands/planning-qa.js"),t=await e(o);process.exit(t);break}case"story-checkpoint":{const{storyCheckpointCliHandler:e}=await import("./commands/story-checkpoint.js"),t=await e(o);process.exit(t);break}case"story-worktree":{const{storyWorktreeCliHandler:e}=await import("./commands/story-worktree.js"),t=await e(o);process.exit(t);break}case"legacy-story-branch":{const{legacyStoryBranchCliHandler:e}=await import("./commands/legacy-story-branch.js"),t=await e(o);process.exit(t);break}case"legacy-story-pr":{const{legacyStoryPrCliHandler:e}=await import("./commands/legacy-story-pr.js"),t=await e(o);process.exit(t);break}case"legacy-epic-terminal":{const{legacyEpicTerminalCliHandler:e}=await import("./commands/legacy-epic-terminal.js"),t=await e(o);process.exit(t);break}case"mutation-qa":{const{mutationQaCliHandler:e}=await import("./commands/mutation-qa.js"),t=await e(o);process.exit(t);break}case"property-qa":{const{propertyQaCliHandler:e}=await import("./commands/property-qa.js"),t=await e(o);process.exit(t);break}case"qa-synthetic-backend":{const{syntheticBackendCliHandler:e}=await import("./commands/qa-synthetic-backend.js");process.exitCode=await e(r.slice(1));break}case"qa-scan-review":{const{qaScanReviewCliHandler:e}=await import("./commands/qa-scan-review.js"),t=await e(o);process.exit(t);break}case"qa-root":{const{qaControlCliHandler:e}=await import("./commands/qa-control.js");process.exit(await e(o));break}case"refactor-root":{if(o[0]==="control"){const{refactorControlCliHandler:i}=await import("./commands/refactor-control.js");process.exit(await i(o))}if(o[0]==="characterize"){const{refactorCharacterizationCliHandler:i}=await import("./commands/refactor-characterization.js");process.exit(i(o))}if(o[0]==="review-accept"||o[0]==="review-status"){const{refactorReviewCliHandler:i}=await import("./commands/refactor-review.js");process.exit(await i(o))}if(o[0]?.startsWith("commit-")){const{refactorCommitCliHandler:i}=await import("./commands/refactor-commit.js");process.exit(i(o))}const{refactorRootCliHandler:e}=await import("./commands/refactor-root.js"),t=e(o);process.exit(t);break}case"native-agent":{const{nativeAgentCliHandler:e}=await import("./commands/native-agent.js"),t=await e(o);process.exit(t);break}case"architecture-answers":{const{architectureAnswersCliHandler:e}=await import("./commands/architecture-answers.js"),t=await e(o);process.exit(t);break}case"update":{console.log("To update Neocortex, run:"),console.log(" neocortex update"),console.log(""),console.log("Or manually:"),console.log(" npm install -g @ornexus/neocortex@latest"),process.exit(0);break}default:console.error(`Unknown command: ${a}`),console.error('Run "neocortex-client --help" for usage information.'),process.exit(1)}}C().catch(r=>{console.error(`Fatal error: ${r instanceof Error?r.message:String(r)}`),process.exit(1)});
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* integrated in parallel.
|
|
8
8
|
*/
|
|
9
9
|
import { type ClaudeWorktreeBaseRefState } from '../agent/claude-worktree-base.js';
|
|
10
|
+
import { type PrivateExecutionHostKind } from '../../../shared/dist/compatibility/index.js';
|
|
11
|
+
import { type PrivateHarnessExecutorPortOptions } from '../private-execution/harness-adapters/index.js';
|
|
10
12
|
export declare const DOCTOR_SCHEMA_VERSION: "CompatibilityReleaseDoctor/1.0";
|
|
11
13
|
export declare const DOCTOR_RESPONSE_SCHEMA_VERSION: "CompatibilityDoctorResponse/1.0";
|
|
12
14
|
export declare const DOCTOR_EXIT_CODES: Readonly<{
|
|
@@ -80,7 +82,21 @@ export interface DoctorReport {
|
|
|
80
82
|
readonly dimensions: Readonly<Record<ReleaseDimensionName, DoctorReleaseDimension>>;
|
|
81
83
|
};
|
|
82
84
|
readonly findings: readonly DoctorFinding[];
|
|
85
|
+
/** P229.03 (CON-P229.03-DOCTOR): additive; never affects `overall`/`exitCode`. */
|
|
86
|
+
readonly privateExecutors: readonly DoctorPrivateExecutorStatus[];
|
|
83
87
|
}
|
|
88
|
+
/** P229.03 (DEC-4): per-host private executor status, enums and versions only. */
|
|
89
|
+
/** `not-probed`: library call without an injected probe; no process is spawned (hermetic). */
|
|
90
|
+
export type DoctorPrivateExecutorAvailability = 'available' | 'absent' | 'refused' | 'not-probed';
|
|
91
|
+
export interface DoctorPrivateExecutorProbeResult {
|
|
92
|
+
readonly availability: DoctorPrivateExecutorAvailability;
|
|
93
|
+
readonly version: string | null;
|
|
94
|
+
readonly refusalReasonCode: string | null;
|
|
95
|
+
}
|
|
96
|
+
export interface DoctorPrivateExecutorStatus extends DoctorPrivateExecutorProbeResult {
|
|
97
|
+
readonly hostKind: PrivateExecutionHostKind;
|
|
98
|
+
}
|
|
99
|
+
export type DoctorPrivateExecutorProbe = (hostKind: PrivateExecutionHostKind) => Promise<DoctorPrivateExecutorProbeResult>;
|
|
84
100
|
interface CompatibilityAuthority {
|
|
85
101
|
readonly createCompatibilityOffer: (input: {
|
|
86
102
|
readonly clientVersion: string;
|
|
@@ -113,6 +129,8 @@ export interface DoctorDependencies {
|
|
|
113
129
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
114
130
|
readonly stdout?: (message: string) => void;
|
|
115
131
|
readonly stderr?: (message: string) => void;
|
|
132
|
+
/** P229.03 (DEC-4): injectable per-host private executor probe. */
|
|
133
|
+
readonly probePrivateExecutor?: DoctorPrivateExecutorProbe;
|
|
116
134
|
}
|
|
117
135
|
interface ParsedDoctorArgs {
|
|
118
136
|
readonly mode: DoctorMode;
|
|
@@ -133,7 +151,14 @@ export declare function loadSharedCompatibilityAuthority(): Promise<Compatibilit
|
|
|
133
151
|
export declare function collectLocalReleaseLifecycleContext(projectRoot: string, authority: CompatibilityAuthority): unknown | null;
|
|
134
152
|
/** Test seam: replace the host settings inspector; returns the previous one. */
|
|
135
153
|
export declare function __setDoctorClaudeWorktreeInspector(next: () => ClaudeWorktreeBaseRefState): () => ClaudeWorktreeBaseRefState;
|
|
154
|
+
/**
|
|
155
|
+
* P229.03 (DEC-4) default probe: declared refusal -> `refused`; otherwise the
|
|
156
|
+
* port preflight (`--version` under the core timeout). Headless-unavailable
|
|
157
|
+
* -> `absent`, version-unsupported -> `refused`, any other error -> `absent`.
|
|
158
|
+
* Never throws and never returns paths, argv or stdout.
|
|
159
|
+
*/
|
|
160
|
+
export declare function defaultProbePrivateExecutor(hostKind: string, options?: PrivateHarnessExecutorPortOptions): Promise<DoctorPrivateExecutorProbeResult>;
|
|
136
161
|
export declare function runDoctor(options: ParsedDoctorArgs, dependencies?: DoctorDependencies): Promise<DoctorReport>;
|
|
137
162
|
export declare function renderDoctorReport(report: DoctorReport): string;
|
|
138
|
-
export declare function doctorCliHandler(args: readonly string[],
|
|
163
|
+
export declare function doctorCliHandler(args: readonly string[], injected?: DoctorDependencies): Promise<number>;
|
|
139
164
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Buffer as L}from"node:buffer";import{createHash as k}from"node:crypto";import{execFileSync as P}from"node:child_process";import{readFileSync as Y,statSync as G}from"node:fs";import{join as K,resolve as W}from"node:path";import{COMMAND_REGISTRY_CHECKSUM as A,COMMAND_REGISTRY_VERSION as C}from"../generated/command-registry.generated.js";import{DEFAULT_SERVER_URL as z}from"../constants.js";import{getClientVersion as J}from"../version.js";import{inspectClaudeWorktreeBaseRef as Z}from"../agent/claude-worktree-base.js";const X="CompatibilityReleaseDoctor/1.0",Q="CompatibilityDoctorResponse/1.0",I=Object.freeze({SUCCESS:0,BLOCKED:1,USAGE:2}),n=Object.freeze({HEALTHY:"doctor-healthy",OFFLINE:"doctor-offline",SERVER_UNREACHABLE:"server-unreachable",CLIENT_TOO_OLD:"client-too-old",SERVER_TOO_OLD:"server-too-old",PROTOCOL_MISMATCH:"protocol-mismatch",SCHEMA_MISMATCH:"schema-mismatch",CAPABILITY_MISMATCH:"capability-mismatch",REGISTRY_DRIFT:"registry-drift",MALFORMED_RESPONSE:"malformed-response",AUTHORITY_UNAVAILABLE:"compatibility-authority-unavailable",RELEASE_LIFECYCLE_UNAVAILABLE:"release-lifecycle-unavailable",REQUIRED_DIMENSION_BLOCKED:"required-release-dimension-blocked",CLAUDE_WORKTREE_BASEREF_NOT_HEAD:"claude-worktree-baseref-not-head"}),v=Object.freeze(["implementationComplete","betaOperable","releaseReady","productionPromoted"]),ee=64*1024,re=32,te=5e3,U=/^[a-z][a-z0-9-]{0,63}$/u,D=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,79}$/u,g=/^\d{1,6}\.\d{1,6}\.\d{1,6}(?:[-+][A-Za-z0-9.-]{1,40})?$/u,ie=/^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/u,F=/^[a-f0-9]{64}$/u,oe=/^[A-Za-z0-9][A-Za-z0-9_-]{15,127}$/u,ne=/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u,se=/^(?:local-gate|beta-receipt|release-gate|promotion-receipt|sha256):[a-f0-9]{64}$/u,l=Object.freeze({healthy:"No compatibility remediation is required.",offline:"Rerun without --offline when read-only server evidence is available.",unreachable:"Check read-only server reachability, then rerun doctor.",clientTooOld:"Run a separately authorized client update, then rerun doctor.",serverTooOld:"Ask an authorized server operator to update the server, then rerun doctor.",protocol:"Align client and server protocol releases before invoking protected operations.",schema:"Use a client and server pair that supports the required public schemas.",capability:"Enable no feature here; use a release pair with the required capability set.",registry:"Install an exact release pair with the same command-registry checksum.",malformed:"Contact support with the reason code only; do not attach raw response data.",authority:"Integrate the P223.01 shared compatibility authority, then rerun doctor.",lifecycle:"Obtain bounded physical release evidence through separately authorized operations.",required:"Satisfy and verify the required physical release dimension through a separately authorized operation.",claudeWorktree:'Set Claude Code worktree.baseRef to "head" in ~/.claude/settings.json (neocortex refresh adds it when absent) so v4 story worktrees start from the epic checkout.'}),x=new Map([[n.MALFORMED_RESPONSE,0],[n.AUTHORITY_UNAVAILABLE,1],[n.CLIENT_TOO_OLD,2],[n.SERVER_TOO_OLD,3],[n.PROTOCOL_MISMATCH,4],[n.SCHEMA_MISMATCH,5],[n.CAPABILITY_MISMATCH,6],[n.REGISTRY_DRIFT,7],[n.SERVER_UNREACHABLE,8],[n.OFFLINE,9],[n.RELEASE_LIFECYCLE_UNAVAILABLE,10],[n.REQUIRED_DIMENSION_BLOCKED,11],[n.HEALTHY,100]]);function q(e="release-evidence-unavailable"){const r=()=>Object.freeze({value:"unknown",freshness:"unknown",reasonCodes:Object.freeze([e]),evidenceRefs:Object.freeze([])});return Object.freeze({implementationComplete:r(),betaOperable:r(),releaseReady:r(),productionPromoted:r()})}function ae(e){const r=Object.freeze({implementation:"implementationComplete","implementation-complete":"implementationComplete",beta:"betaOperable","beta-operable":"betaOperable",release:"releaseReady","release-ready":"releaseReady",production:"productionPromoted","production-promoted":"productionPromoted"});return e?r[e]??null:null}function ce(e,r=process.env){let t="online",i=!1,o=r.NEOCORTEX_SERVER_URL??z,c=!1,u=null,f=process.cwd();for(let a=0;a<e.length;a+=1){const s=e[a];if(s==="--offline")t="offline";else if(s==="--json")i=!0;else if(s==="--server-url"){const p=e[a+1];if(!p)throw new Error("doctor-server-url-required");o=p,c=!0,a+=1}else if(s==="--require"){const p=e[a+1],m=ae(p);if(!p||!m)throw new Error("doctor-required-dimension-invalid");u=m,a+=1}else if(s==="--project-root"){const p=e[a+1];if(!p||p.length>4096||p.includes("\0"))throw new Error("doctor-project-root-invalid");f=W(p),a+=1}else throw new Error("doctor-argument-invalid")}if(t==="offline"&&c)throw new Error("doctor-offline-server-url-conflict");if(t==="offline")return Object.freeze({mode:t,json:i,serverUrl:z,requiredDimension:u,projectRoot:f});if(o.length>2048)throw new Error("doctor-server-url-invalid");try{const a=new URL(o);if(a.protocol!=="http:"&&a.protocol!=="https:"||a.username||a.password||a.search||a.hash)throw new Error("url")}catch{throw new Error("doctor-server-url-invalid")}return Object.freeze({mode:t,json:i,serverUrl:o.replace(/\/+$/u,""),requiredDimension:u,projectRoot:f})}function le(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.createCompatibilityOffer=="function"&&typeof r.isCompatibilityResultV1=="function"&&typeof r.validateReleaseLifecycle=="function"}async function de(){const e=["@neocortex/shared/compatibility","../../../shared/dist/compatibility/index.js"];for(const r of e)try{const t=await import(r);if(le(t))return t}catch{}return null}function ue(e,r){if(typeof r.createReleaseLifecycleContext!="function")return null;try{const t=K(e,".neocortex","state.json"),i=G(t);if(!i.isFile()||i.size<=0||i.size>1024*1024)return null;const o=JSON.parse(Y(t,"utf8")),u=(o.config&&typeof o.config=="object"&&!Array.isArray(o.config)?o.config:o.project&&typeof o.project=="object"&&!Array.isArray(o.project)?o.project:null)?.project_id;if(typeof u!="string"||!oe.test(u))return null;const f=P("git",["rev-parse","--verify","HEAD"],{cwd:e,encoding:"utf8",timeout:2e3,maxBuffer:1024,stdio:["ignore","pipe","ignore"]}).trim().toLowerCase();if(!ne.test(f))return null;const a=k("sha256").update("git-lineage-v1\0").update(f).digest("hex"),s=`candidate-${k("sha256").update("release-candidate-v1\0").update(u).update("\0").update(f).digest("hex").slice(0,32)}`;return r.createReleaseLifecycleContext({projectId:u,candidateId:s,lineageSha256:a})}catch{return null}}function d(e,r,t,i,o=null){return Object.freeze({severity:e,reasonCode:r,affectedDimension:t,evidenceRef:o,remediation:i})}function fe(e,r){if(!g.test(e)||!g.test(r))return null;const t=c=>c.split(/[-+]/u,1)[0].split(".").map(Number),i=t(e),o=t(r);for(let c=0;c<3;c+=1)if(i[c]!==o[c])return i[c]<o[c]?-1:1;return 0}function S(e){return Object.freeze([...new Set(e.filter(r=>U.test(r)))].slice(0,8).sort())}function H(e){return Object.freeze([...new Set(e.filter(r=>D.test(r)))].slice(0,32).sort())}function $(e){return Object.freeze([...new Set(e.filter(r=>se.test(r)))].slice(0,8).sort())}function me(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e,t=r.commandRegistry;return!["compatible","degraded","incompatible"].includes(String(r.status))||typeof r.clientVersion!="string"||!g.test(r.clientVersion)||typeof r.serverVersion!="string"||!g.test(r.serverVersion)||!(r.protocolVersion===null||typeof r.protocolVersion=="string"&&D.test(r.protocolVersion))||!Array.isArray(r.schemaVersions)||!r.schemaVersions.every(i=>typeof i=="string")||!Array.isArray(r.capabilityIds)||!r.capabilityIds.every(i=>typeof i=="string")||!Array.isArray(r.reasonCodes)||!r.reasonCodes.every(i=>typeof i=="string")||!t||typeof t.version!="string"||!ie.test(t.version)||typeof t.checksum!="string"||!F.test(t.checksum)||!["matched","mismatched","unknown"].includes(String(t.status))?null:r}function pe(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e;if(typeof r.candidateId!="string"||!D.test(r.candidateId)||typeof r.lineageSha256!="string"||!F.test(r.lineageSha256))return null;for(const t of v){const i=r[t];if(!i||typeof i!="object"||Array.isArray(i))return null;const o=i;if(!(typeof o.value=="boolean"||o.value==="unknown")||!["fresh","stale","unknown"].includes(String(o.freshness))||!Array.isArray(o.reasonCodes)||!o.reasonCodes.every(c=>typeof c=="string")||!Array.isArray(o.evidenceRefs)||!o.evidenceRefs.every(c=>typeof c=="string"))return null}return r}function ye(e){const r={error:0,warning:1,info:2},t=new Map([["compatibility",0],["releaseLifecycle",1],["implementationComplete",2],["betaOperable",3],["releaseReady",4],["productionPromoted",5]]);return Object.freeze([...e].sort((i,o)=>r[i.severity]-r[o.severity]||(x.get(i.reasonCode)??50)-(x.get(o.reasonCode)??50)||(t.get(i.affectedDimension)??99)-(t.get(o.affectedDimension)??99)||i.reasonCode.localeCompare(o.reasonCode)).slice(0,re))}function Ee(e){return Object.freeze({status:"unknown",clientVersion:e,serverVersion:null,protocolVersion:null,schemaVersions:Object.freeze([]),capabilityIds:Object.freeze([]),registry:Object.freeze({localVersion:C,localChecksum:A,remoteVersion:null,remoteChecksum:null,status:"unknown"})})}let T=()=>Z();function Ne(e){const r=T;return T=e,r}function he(){let e;try{e=T()}catch{e="unknown"}return e==="absent"||e==="user-value"||e==="settings-invalid"?[d("warning",n.CLAUDE_WORKTREE_BASEREF_NOT_HEAD,"compatibility",l.claudeWorktree,null)]:[]}function E(e){const r=[...e.findings,...he()],t=e.dimensions??q();let i=e.incompatible;e.requiredDimension&&t[e.requiredDimension].value!==!0&&(i=!0,r.push(d("error",n.REQUIRED_DIMENSION_BLOCKED,e.requiredDimension,l.required,t[e.requiredDimension].evidenceRefs[0]??null)));const o=ye(r),c=i?"incompatible":o.some(u=>u.severity==="warning")?"degraded":"healthy";return Object.freeze({schemaVersion:X,publicSafe:!0,readOnly:!0,mode:e.mode,overall:c,exitCode:i?I.BLOCKED:I.SUCCESS,compatibility:e.compatibility??Ee(e.clientVersion),release:Object.freeze({candidateId:e.candidateId??null,lineageSha256:e.lineageSha256??null,requiredDimension:e.requiredDimension,dimensions:t}),findings:o})}function be(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e;return"compatibility"in r?r.schemaVersion!==void 0&&r.schemaVersion!==Q?null:{compatibility:r.compatibility,...r.releaseLifecycle!==void 0?{releaseLifecycle:r.releaseLifecycle}:{}}:{compatibility:e}}async function Re(e,r,t,i){const o=new AbortController,c=setTimeout(()=>o.abort(),te);try{const u=L.from(JSON.stringify(t),"utf8").toString("base64url");if(u.length>8192)return{kind:"malformed"};const f=i===null?null:L.from(JSON.stringify(i),"utf8").toString("base64url");if(f&&f.length>2048)return{kind:"malformed"};const a=await e(`${r}/api/v1/compatibility`,{method:"GET",headers:Object.freeze({Accept:"application/json","Cache-Control":"no-store","X-Neocortex-Compatibility-Offer":u,...f?{"X-Neocortex-Release-Context":f}:{}}),signal:o.signal});if(a.status===404||a.status===405||a.status===426)return{kind:"server-too-old"};if(!a.ok)return a.status>=500?{kind:"unreachable"}:{kind:"malformed"};const s=await a.text();if(L.byteLength(s,"utf8")>ee)return{kind:"malformed"};try{return{kind:"ok",value:JSON.parse(s)}}catch{return{kind:"malformed"}}}catch{return{kind:"unreachable"}}finally{clearTimeout(c)}}function Oe(e,r){return E({mode:"offline",clientVersion:e,requiredDimension:r,incompatible:!1,findings:[d("warning",n.OFFLINE,"compatibility",l.offline),d("warning",n.RELEASE_LIFECYCLE_UNAVAILABLE,"releaseLifecycle",l.lifecycle)]})}async function Ae(e,r={}){const t=(r.getClientVersion??J)();if(e.mode==="offline")return Oe(t,e.requiredDimension);const i=await(r.loadCompatibilityAuthority??de)();if(!i)return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[d("error",n.AUTHORITY_UNAVAILABLE,"compatibility",l.authority)]});let o;try{o=i.createCompatibilityOffer({clientVersion:t,registryVersion:C,registryChecksum:A})}catch{return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[d("error",n.AUTHORITY_UNAVAILABLE,"compatibility",l.authority)]})}const c=(r.collectReleaseContext??ue)(e.projectRoot,i),u=r.fetch??globalThis.fetch,f=await Re(u,e.serverUrl,o,c);if(f.kind==="unreachable")return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!1,findings:[d("warning",n.SERVER_UNREACHABLE,"compatibility",l.unreachable),d("warning",n.RELEASE_LIFECYCLE_UNAVAILABLE,"releaseLifecycle",l.lifecycle)]});if(f.kind==="server-too-old")return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[d("error",n.SERVER_TOO_OLD,"compatibility",l.serverTooOld),d("warning",n.RELEASE_LIFECYCLE_UNAVAILABLE,"releaseLifecycle",l.lifecycle)]});if(f.kind==="malformed")return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[d("error",n.MALFORMED_RESPONSE,"compatibility",l.malformed)]});const a=be(f.value);if(!a||!i.isCompatibilityResultV1(a.compatibility))return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[d("error",n.MALFORMED_RESPONSE,"compatibility",l.malformed)]});const s=me(a.compatibility);if(!s||s.clientVersion!==t)return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[d("error",n.MALFORMED_RESPONSE,"compatibility",l.malformed)]});const p=Object.freeze({status:s.status,clientVersion:t,serverVersion:s.serverVersion,protocolVersion:s.protocolVersion,schemaVersions:H(s.schemaVersions),capabilityIds:H(s.capabilityIds),registry:Object.freeze({localVersion:C,localChecksum:A,remoteVersion:s.commandRegistry.version,remoteChecksum:s.commandRegistry.checksum,status:s.commandRegistry.status})}),m=[],b=S(s.reasonCodes),w=fe(t,s.serverVersion);if(s.status==="incompatible"&&w===-1?m.push(d("error",n.CLIENT_TOO_OLD,"compatibility",l.clientTooOld,`client-version:${t}`)):s.status==="incompatible"&&w===1&&m.push(d("error",n.SERVER_TOO_OLD,"compatibility",l.serverTooOld,`server-version:${s.serverVersion}`)),b.some(y=>y.includes("protocol"))&&m.push(d("error",n.PROTOCOL_MISMATCH,"compatibility",l.protocol)),b.some(y=>y.includes("schema"))&&m.push(d("error",n.SCHEMA_MISMATCH,"compatibility",l.schema)),b.some(y=>y.includes("capability"))&&m.push(d("error",n.CAPABILITY_MISMATCH,"compatibility",l.capability)),(s.commandRegistry.status==="mismatched"||s.commandRegistry.version!==C||s.commandRegistry.checksum!==A)&&m.push(d("error",n.REGISTRY_DRIFT,"compatibility",l.registry,`sha256:${s.commandRegistry.checksum}`)),s.status==="incompatible"&&m.length===0)m.push(d("error",n.MALFORMED_RESPONSE,"compatibility",l.malformed));else if(s.status==="degraded")for(const y of b)m.push(d("warning",y,"compatibility",l.lifecycle));let N=q(),V=null,j=null,M=!1;if(a.releaseLifecycle===void 0)m.push(d("warning",n.RELEASE_LIFECYCLE_UNAVAILABLE,"releaseLifecycle",l.lifecycle));else{const y=i.validateReleaseLifecycle(a.releaseLifecycle),R=y.accepted?pe(y.projection):null;if(R){V=R.candidateId,j=R.lineageSha256;const O={};for(const _ of v){const h=R[_];if(O[_]=Object.freeze({value:h.value,freshness:h.freshness,reasonCodes:S(h.reasonCodes),evidenceRefs:$(h.evidenceRefs)}),h.value!==!0||h.freshness!=="fresh")for(const B of S(h.reasonCodes))m.push(d("warning",B,_,l.lifecycle,$(h.evidenceRefs)[0]??null))}N=Object.freeze(O)}else{M=!0,m.push(d("error",n.MALFORMED_RESPONSE,"releaseLifecycle",l.malformed));for(const O of S(y.reasonCodes))m.push(d("error",O,"releaseLifecycle",l.lifecycle))}}return m.length===0&&m.push(d("info",n.HEALTHY,"compatibility",l.healthy)),E({mode:"online",clientVersion:t,compatibility:p,dimensions:N,candidateId:V,lineageSha256:j,requiredDimension:e.requiredDimension,findings:m,incompatible:s.status==="incompatible"||M})}function Ce(e){const r=["Neocortex compatibility and release doctor (read-only)",`Result: ${e.overall} (exit ${e.exitCode})`,`Mode: ${e.mode}`,`Compatibility: ${e.compatibility.status}`,`Client: ${e.compatibility.clientVersion}`,`Server: ${e.compatibility.serverVersion??"unknown"}`,`Registry: ${e.compatibility.registry.status}`,"","Release lifecycle:"];for(const t of v){const i=e.release.dimensions[t];r.push(` ${t}: ${String(i.value)} (${i.freshness}) [${i.reasonCodes.join(",")||"none"}]`)}r.push("","Ordered findings:");for(const t of e.findings)r.push(` ${t.severity.toUpperCase()} ${t.reasonCode} dimension=${t.affectedDimension} evidence=${t.evidenceRef??"none"}`),r.push(` ${t.remediation}`);return r.push("","Doctor made no repairs or state changes."),r.join(`
|
|
2
|
-
`)}async function
|
|
1
|
+
import{Buffer as I}from"node:buffer";import{createHash as x}from"node:crypto";import{execFileSync as J}from"node:child_process";import{readFileSync as Z,statSync as K}from"node:fs";import{join as Q,resolve as ee}from"node:path";import{COMMAND_REGISTRY_CHECKSUM as A,COMMAND_REGISTRY_VERSION as C}from"../generated/command-registry.generated.js";import{DEFAULT_SERVER_URL as U}from"../constants.js";import{getClientVersion as re}from"../version.js";import{inspectClaudeWorktreeBaseRef as te}from"../agent/claude-worktree-base.js";import{PRIVATE_EXECUTION_HOST_KINDS as oe}from"../../../shared/dist/compatibility/index.js";import{createPrivateHarnessExecutorPort as ie,resolvePrivateHarnessDecision as P}from"../private-execution/harness-adapters/index.js";const ne="CompatibilityReleaseDoctor/1.0",se="CompatibilityDoctorResponse/1.0",L=Object.freeze({SUCCESS:0,BLOCKED:1,USAGE:2}),s=Object.freeze({HEALTHY:"doctor-healthy",OFFLINE:"doctor-offline",SERVER_UNREACHABLE:"server-unreachable",CLIENT_TOO_OLD:"client-too-old",SERVER_TOO_OLD:"server-too-old",PROTOCOL_MISMATCH:"protocol-mismatch",SCHEMA_MISMATCH:"schema-mismatch",CAPABILITY_MISMATCH:"capability-mismatch",REGISTRY_DRIFT:"registry-drift",MALFORMED_RESPONSE:"malformed-response",AUTHORITY_UNAVAILABLE:"compatibility-authority-unavailable",RELEASE_LIFECYCLE_UNAVAILABLE:"release-lifecycle-unavailable",REQUIRED_DIMENSION_BLOCKED:"required-release-dimension-blocked",CLAUDE_WORKTREE_BASEREF_NOT_HEAD:"claude-worktree-baseref-not-head"}),D=Object.freeze(["implementationComplete","betaOperable","releaseReady","productionPromoted"]),ae=64*1024,ce=32,le=5e3,T=/^[a-z][a-z0-9-]{0,63}$/u,V=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,79}$/u,v=/^\d{1,6}\.\d{1,6}\.\d{1,6}(?:[-+][A-Za-z0-9.-]{1,40})?$/u,ue=/^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/u,F=/^[a-f0-9]{64}$/u,de=/^[A-Za-z0-9][A-Za-z0-9_-]{15,127}$/u,fe=/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u,me=/^(?:local-gate|beta-receipt|release-gate|promotion-receipt|sha256):[a-f0-9]{64}$/u,l=Object.freeze({healthy:"No compatibility remediation is required.",offline:"Rerun without --offline when read-only server evidence is available.",unreachable:"Check read-only server reachability, then rerun doctor.",clientTooOld:"Run a separately authorized client update, then rerun doctor.",serverTooOld:"Ask an authorized server operator to update the server, then rerun doctor.",protocol:"Align client and server protocol releases before invoking protected operations.",schema:"Use a client and server pair that supports the required public schemas.",capability:"Enable no feature here; use a release pair with the required capability set.",registry:"Install an exact release pair with the same command-registry checksum.",malformed:"Contact support with the reason code only; do not attach raw response data.",authority:"Integrate the P223.01 shared compatibility authority, then rerun doctor.",lifecycle:"Obtain bounded physical release evidence through separately authorized operations.",required:"Satisfy and verify the required physical release dimension through a separately authorized operation.",claudeWorktree:'Set Claude Code worktree.baseRef to "head" in ~/.claude/settings.json (neocortex refresh adds it when absent) so v4 story worktrees start from the epic checkout.'}),H=new Map([[s.MALFORMED_RESPONSE,0],[s.AUTHORITY_UNAVAILABLE,1],[s.CLIENT_TOO_OLD,2],[s.SERVER_TOO_OLD,3],[s.PROTOCOL_MISMATCH,4],[s.SCHEMA_MISMATCH,5],[s.CAPABILITY_MISMATCH,6],[s.REGISTRY_DRIFT,7],[s.SERVER_UNREACHABLE,8],[s.OFFLINE,9],[s.RELEASE_LIFECYCLE_UNAVAILABLE,10],[s.REQUIRED_DIMENSION_BLOCKED,11],[s.HEALTHY,100]]);function $(e="release-evidence-unavailable"){const r=()=>Object.freeze({value:"unknown",freshness:"unknown",reasonCodes:Object.freeze([e]),evidenceRefs:Object.freeze([])});return Object.freeze({implementationComplete:r(),betaOperable:r(),releaseReady:r(),productionPromoted:r()})}function pe(e){const r=Object.freeze({implementation:"implementationComplete","implementation-complete":"implementationComplete",beta:"betaOperable","beta-operable":"betaOperable",release:"releaseReady","release-ready":"releaseReady",production:"productionPromoted","production-promoted":"productionPromoted"});return e?r[e]??null:null}function ye(e,r=process.env){let t="online",o=!1,i=r.NEOCORTEX_SERVER_URL??U,c=!1,m=null,d=process.cwd();for(let n=0;n<e.length;n+=1){const a=e[n];if(a==="--offline")t="offline";else if(a==="--json")o=!0;else if(a==="--server-url"){const p=e[n+1];if(!p)throw new Error("doctor-server-url-required");i=p,c=!0,n+=1}else if(a==="--require"){const p=e[n+1],f=pe(p);if(!p||!f)throw new Error("doctor-required-dimension-invalid");m=f,n+=1}else if(a==="--project-root"){const p=e[n+1];if(!p||p.length>4096||p.includes("\0"))throw new Error("doctor-project-root-invalid");d=ee(p),n+=1}else throw new Error("doctor-argument-invalid")}if(t==="offline"&&c)throw new Error("doctor-offline-server-url-conflict");if(t==="offline")return Object.freeze({mode:t,json:o,serverUrl:U,requiredDimension:m,projectRoot:d});if(i.length>2048)throw new Error("doctor-server-url-invalid");try{const n=new URL(i);if(n.protocol!=="http:"&&n.protocol!=="https:"||n.username||n.password||n.search||n.hash)throw new Error("url")}catch{throw new Error("doctor-server-url-invalid")}return Object.freeze({mode:t,json:o,serverUrl:i.replace(/\/+$/u,""),requiredDimension:m,projectRoot:d})}function Ee(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.createCompatibilityOffer=="function"&&typeof r.isCompatibilityResultV1=="function"&&typeof r.validateReleaseLifecycle=="function"}async function be(){const e=["@neocortex/shared/compatibility","../../../shared/dist/compatibility/index.js"];for(const r of e)try{const t=await import(r);if(Ee(t))return t}catch{}return null}function he(e,r){if(typeof r.createReleaseLifecycleContext!="function")return null;try{const t=Q(e,".neocortex","state.json"),o=K(t);if(!o.isFile()||o.size<=0||o.size>1024*1024)return null;const i=JSON.parse(Z(t,"utf8")),m=(i.config&&typeof i.config=="object"&&!Array.isArray(i.config)?i.config:i.project&&typeof i.project=="object"&&!Array.isArray(i.project)?i.project:null)?.project_id;if(typeof m!="string"||!de.test(m))return null;const d=J("git",["rev-parse","--verify","HEAD"],{cwd:e,encoding:"utf8",timeout:2e3,maxBuffer:1024,stdio:["ignore","pipe","ignore"]}).trim().toLowerCase();if(!fe.test(d))return null;const n=x("sha256").update("git-lineage-v1\0").update(d).digest("hex"),a=`candidate-${x("sha256").update("release-candidate-v1\0").update(m).update("\0").update(d).digest("hex").slice(0,32)}`;return r.createReleaseLifecycleContext({projectId:m,candidateId:a,lineageSha256:n})}catch{return null}}function u(e,r,t,o,i=null){return Object.freeze({severity:e,reasonCode:r,affectedDimension:t,evidenceRef:i,remediation:o})}function Re(e,r){if(!v.test(e)||!v.test(r))return null;const t=c=>c.split(/[-+]/u,1)[0].split(".").map(Number),o=t(e),i=t(r);for(let c=0;c<3;c+=1)if(o[c]!==i[c])return o[c]<i[c]?-1:1;return 0}function g(e){return Object.freeze([...new Set(e.filter(r=>T.test(r)))].slice(0,8).sort())}function q(e){return Object.freeze([...new Set(e.filter(r=>V.test(r)))].slice(0,32).sort())}function B(e){return Object.freeze([...new Set(e.filter(r=>me.test(r)))].slice(0,8).sort())}function Oe(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e,t=r.commandRegistry;return!["compatible","degraded","incompatible"].includes(String(r.status))||typeof r.clientVersion!="string"||!v.test(r.clientVersion)||typeof r.serverVersion!="string"||!v.test(r.serverVersion)||!(r.protocolVersion===null||typeof r.protocolVersion=="string"&&V.test(r.protocolVersion))||!Array.isArray(r.schemaVersions)||!r.schemaVersions.every(o=>typeof o=="string")||!Array.isArray(r.capabilityIds)||!r.capabilityIds.every(o=>typeof o=="string")||!Array.isArray(r.reasonCodes)||!r.reasonCodes.every(o=>typeof o=="string")||!t||typeof t.version!="string"||!ue.test(t.version)||typeof t.checksum!="string"||!F.test(t.checksum)||!["matched","mismatched","unknown"].includes(String(t.status))?null:r}function Ae(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e;if(typeof r.candidateId!="string"||!V.test(r.candidateId)||typeof r.lineageSha256!="string"||!F.test(r.lineageSha256))return null;for(const t of D){const o=r[t];if(!o||typeof o!="object"||Array.isArray(o))return null;const i=o;if(!(typeof i.value=="boolean"||i.value==="unknown")||!["fresh","stale","unknown"].includes(String(i.freshness))||!Array.isArray(i.reasonCodes)||!i.reasonCodes.every(c=>typeof c=="string")||!Array.isArray(i.evidenceRefs)||!i.evidenceRefs.every(c=>typeof c=="string"))return null}return r}function Ce(e){const r={error:0,warning:1,info:2},t=new Map([["compatibility",0],["releaseLifecycle",1],["implementationComplete",2],["betaOperable",3],["releaseReady",4],["productionPromoted",5]]);return Object.freeze([...e].sort((o,i)=>r[o.severity]-r[i.severity]||(H.get(o.reasonCode)??50)-(H.get(i.reasonCode)??50)||(t.get(o.affectedDimension)??99)-(t.get(i.affectedDimension)??99)||o.reasonCode.localeCompare(i.reasonCode)).slice(0,ce))}function ve(e){return Object.freeze({status:"unknown",clientVersion:e,serverVersion:null,protocolVersion:null,schemaVersions:Object.freeze([]),capabilityIds:Object.freeze([]),registry:Object.freeze({localVersion:C,localChecksum:A,remoteVersion:null,remoteChecksum:null,status:"unknown"})})}let w=()=>te();function Be(e){const r=w;return w=e,r}function ge(){let e;try{e=w()}catch{e="unknown"}return e==="absent"||e==="user-value"||e==="settings-invalid"?[u("warning",s.CLAUDE_WORKTREE_BASEREF_NOT_HEAD,"compatibility",l.claudeWorktree,null)]:[]}function E(e){const r=[...e.findings,...ge()],t=e.dimensions??$();let o=e.incompatible;e.requiredDimension&&t[e.requiredDimension].value!==!0&&(o=!0,r.push(u("error",s.REQUIRED_DIMENSION_BLOCKED,e.requiredDimension,l.required,t[e.requiredDimension].evidenceRefs[0]??null)));const i=Ce(r),c=o?"incompatible":i.some(m=>m.severity==="warning")?"degraded":"healthy";return Object.freeze({schemaVersion:ne,publicSafe:!0,readOnly:!0,mode:e.mode,overall:c,exitCode:o?L.BLOCKED:L.SUCCESS,compatibility:e.compatibility??ve(e.clientVersion),release:Object.freeze({candidateId:e.candidateId??null,lineageSha256:e.lineageSha256??null,requiredDimension:e.requiredDimension,dimensions:t}),findings:i})}function Se(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e;return"compatibility"in r?r.schemaVersion!==void 0&&r.schemaVersion!==se?null:{compatibility:r.compatibility,...r.releaseLifecycle!==void 0?{releaseLifecycle:r.releaseLifecycle}:{}}:{compatibility:e}}async function _e(e,r,t,o){const i=new AbortController,c=setTimeout(()=>i.abort(),le);try{const m=I.from(JSON.stringify(t),"utf8").toString("base64url");if(m.length>8192)return{kind:"malformed"};const d=o===null?null:I.from(JSON.stringify(o),"utf8").toString("base64url");if(d&&d.length>2048)return{kind:"malformed"};const n=await e(`${r}/api/v1/compatibility`,{method:"GET",headers:Object.freeze({Accept:"application/json","Cache-Control":"no-store","X-Neocortex-Compatibility-Offer":m,...d?{"X-Neocortex-Release-Context":d}:{}}),signal:i.signal});if(n.status===404||n.status===405||n.status===426)return{kind:"server-too-old"};if(!n.ok)return n.status>=500?{kind:"unreachable"}:{kind:"malformed"};const a=await n.text();if(I.byteLength(a,"utf8")>ae)return{kind:"malformed"};try{return{kind:"ok",value:JSON.parse(a)}}catch{return{kind:"malformed"}}}catch{return{kind:"unreachable"}}finally{clearTimeout(c)}}function Ie(e,r){return E({mode:"offline",clientVersion:e,requiredDimension:r,incompatible:!1,findings:[u("warning",s.OFFLINE,"compatibility",l.offline),u("warning",s.RELEASE_LIFECYCLE_UNAVAILABLE,"releaseLifecycle",l.lifecycle)]})}const Y="private-executor-headless-unavailable",G="private-executor-version-unsupported",X=/^\d{1,9}\.\d{1,9}\.\d{1,9}$/u,S=Object.freeze({availability:"absent",version:null,refusalReasonCode:null});async function Le(e,r={}){try{const o=P(e)?.kind==="adapter"?ie(e,r):void 0;if(o===void 0)return Object.freeze({availability:"refused",version:null,refusalReasonCode:Y});const i=await o.preflight();return X.test(i.hostVersion)?Object.freeze({availability:"available",version:i.hostVersion,refusalReasonCode:null}):S}catch(t){return t instanceof Error&&t.message===G?Object.freeze({availability:"refused",version:null,refusalReasonCode:G}):S}}function De(e){if(!e||typeof e!="object"||Array.isArray(e))return S;const r=e,t=r.version,o=r.refusalReasonCode;return r.availability==="available"&&typeof t=="string"&&X.test(t)&&o===null?Object.freeze({availability:"available",version:t,refusalReasonCode:null}):r.availability==="refused"&&t===null&&typeof o=="string"&&T.test(o)?Object.freeze({availability:"refused",version:null,refusalReasonCode:o}):S}async function Te(e,r){const t=r.probePrivateExecutor,o=await Promise.all(oe.map(async i=>{if(t===void 0)return Object.freeze({hostKind:i,...P(i)?.kind==="refusal"?{availability:"refused",version:null,refusalReasonCode:Y}:{availability:"not-probed",version:null,refusalReasonCode:null}});let c;try{c=await t(i)}catch{c=void 0}return Object.freeze({hostKind:i,...De(c)})}));return Object.freeze(o)}async function Ve(e,r={}){const[t,o]=await Promise.all([we(e,r),Te(e.projectRoot,r)]);return Object.freeze({...t,privateExecutors:o})}async function we(e,r){const t=(r.getClientVersion??re)();if(e.mode==="offline")return Ie(t,e.requiredDimension);const o=await(r.loadCompatibilityAuthority??be)();if(!o)return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[u("error",s.AUTHORITY_UNAVAILABLE,"compatibility",l.authority)]});let i;try{i=o.createCompatibilityOffer({clientVersion:t,registryVersion:C,registryChecksum:A})}catch{return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[u("error",s.AUTHORITY_UNAVAILABLE,"compatibility",l.authority)]})}const c=(r.collectReleaseContext??he)(e.projectRoot,o),m=r.fetch??globalThis.fetch,d=await _e(m,e.serverUrl,i,c);if(d.kind==="unreachable")return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!1,findings:[u("warning",s.SERVER_UNREACHABLE,"compatibility",l.unreachable),u("warning",s.RELEASE_LIFECYCLE_UNAVAILABLE,"releaseLifecycle",l.lifecycle)]});if(d.kind==="server-too-old")return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[u("error",s.SERVER_TOO_OLD,"compatibility",l.serverTooOld),u("warning",s.RELEASE_LIFECYCLE_UNAVAILABLE,"releaseLifecycle",l.lifecycle)]});if(d.kind==="malformed")return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[u("error",s.MALFORMED_RESPONSE,"compatibility",l.malformed)]});const n=Se(d.value);if(!n||!o.isCompatibilityResultV1(n.compatibility))return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[u("error",s.MALFORMED_RESPONSE,"compatibility",l.malformed)]});const a=Oe(n.compatibility);if(!a||a.clientVersion!==t)return E({mode:"online",clientVersion:t,requiredDimension:e.requiredDimension,incompatible:!0,findings:[u("error",s.MALFORMED_RESPONSE,"compatibility",l.malformed)]});const p=Object.freeze({status:a.status,clientVersion:t,serverVersion:a.serverVersion,protocolVersion:a.protocolVersion,schemaVersions:q(a.schemaVersions),capabilityIds:q(a.capabilityIds),registry:Object.freeze({localVersion:C,localChecksum:A,remoteVersion:a.commandRegistry.version,remoteChecksum:a.commandRegistry.checksum,status:a.commandRegistry.status})}),f=[],h=g(a.reasonCodes),j=Re(t,a.serverVersion);if(a.status==="incompatible"&&j===-1?f.push(u("error",s.CLIENT_TOO_OLD,"compatibility",l.clientTooOld,`client-version:${t}`)):a.status==="incompatible"&&j===1&&f.push(u("error",s.SERVER_TOO_OLD,"compatibility",l.serverTooOld,`server-version:${a.serverVersion}`)),h.some(y=>y.includes("protocol"))&&f.push(u("error",s.PROTOCOL_MISMATCH,"compatibility",l.protocol)),h.some(y=>y.includes("schema"))&&f.push(u("error",s.SCHEMA_MISMATCH,"compatibility",l.schema)),h.some(y=>y.includes("capability"))&&f.push(u("error",s.CAPABILITY_MISMATCH,"compatibility",l.capability)),(a.commandRegistry.status==="mismatched"||a.commandRegistry.version!==C||a.commandRegistry.checksum!==A)&&f.push(u("error",s.REGISTRY_DRIFT,"compatibility",l.registry,`sha256:${a.commandRegistry.checksum}`)),a.status==="incompatible"&&f.length===0)f.push(u("error",s.MALFORMED_RESPONSE,"compatibility",l.malformed));else if(a.status==="degraded")for(const y of h)f.push(u("warning",y,"compatibility",l.lifecycle));let N=$(),M=null,z=null,k=!1;if(n.releaseLifecycle===void 0)f.push(u("warning",s.RELEASE_LIFECYCLE_UNAVAILABLE,"releaseLifecycle",l.lifecycle));else{const y=o.validateReleaseLifecycle(n.releaseLifecycle),R=y.accepted?Ae(y.projection):null;if(R){M=R.candidateId,z=R.lineageSha256;const O={};for(const _ of D){const b=R[_];if(O[_]=Object.freeze({value:b.value,freshness:b.freshness,reasonCodes:g(b.reasonCodes),evidenceRefs:B(b.evidenceRefs)}),b.value!==!0||b.freshness!=="fresh")for(const W of g(b.reasonCodes))f.push(u("warning",W,_,l.lifecycle,B(b.evidenceRefs)[0]??null))}N=Object.freeze(O)}else{k=!0,f.push(u("error",s.MALFORMED_RESPONSE,"releaseLifecycle",l.malformed));for(const O of g(y.reasonCodes))f.push(u("error",O,"releaseLifecycle",l.lifecycle))}}return f.length===0&&f.push(u("info",s.HEALTHY,"compatibility",l.healthy)),E({mode:"online",clientVersion:t,compatibility:p,dimensions:N,candidateId:M,lineageSha256:z,requiredDimension:e.requiredDimension,findings:f,incompatible:a.status==="incompatible"||k})}function je(e){const r=["Neocortex compatibility and release doctor (read-only)",`Result: ${e.overall} (exit ${e.exitCode})`,`Mode: ${e.mode}`,`Compatibility: ${e.compatibility.status}`,`Client: ${e.compatibility.clientVersion}`,`Server: ${e.compatibility.serverVersion??"unknown"}`,`Registry: ${e.compatibility.registry.status}`,"","Release lifecycle:"];for(const t of D){const o=e.release.dimensions[t];r.push(` ${t}: ${String(o.value)} (${o.freshness}) [${o.reasonCodes.join(",")||"none"}]`)}r.push("","Ordered findings:");for(const t of e.findings)r.push(` ${t.severity.toUpperCase()} ${t.reasonCode} dimension=${t.affectedDimension} evidence=${t.evidenceRef??"none"}`),r.push(` ${t.remediation}`);r.push("","Private executors:");for(const t of e.privateExecutors)r.push(` ${t.hostKind}: ${t.availability} version=${t.version??"unknown"} refusal=${t.refusalReasonCode??"none"}`);return r.push("","Doctor made no repairs or state changes."),r.join(`
|
|
2
|
+
`)}async function Ye(e,r){const t=r??{},o=t.stdout??console.log,i=t.stderr??console.error;let c;try{c=ye(e,t.env??process.env)}catch(n){const a=n instanceof Error&&T.test(n.message)?n.message:"doctor-argument-invalid";return i(`Error: ${a}`),L.USAGE}const m=c.projectRoot,d=await Ve(c,r===void 0?{...t,probePrivateExecutor:n=>Le(n,{cwd:m})}:t);return o(c.json?JSON.stringify(d,null,2):je(d)),d.exitCode}export{L as DOCTOR_EXIT_CODES,s as DOCTOR_REASON_CODES,se as DOCTOR_RESPONSE_SCHEMA_VERSION,ne as DOCTOR_SCHEMA_VERSION,Be as __setDoctorClaudeWorktreeInspector,he as collectLocalReleaseLifecycleContext,Le as defaultProbePrivateExecutor,Ye as doctorCliHandler,be as loadSharedCompatibilityAuthority,ye as parseDoctorArgs,je as renderDoctorReport,Ve as runDoctor};
|
|
@@ -14,7 +14,7 @@ import type { ProjectManifestProjectionAttachment } from '../../../shared/dist/p
|
|
|
14
14
|
import { type ReleaseGateRequestV1 } from '../../../shared/dist/yoloop/release-blocked.js';
|
|
15
15
|
import { type InvokeEffectContext, type StrictReadOnlyInvokeEnvelope } from '../../../shared/dist/strict-readonly.js';
|
|
16
16
|
import { type ExplicitIntentRecoveryBindingV1, type ExplicitIntentRecoveryResultV1, type InvokeInputEvidenceV1, type InvokeInputEnvelopeV2, type InvokeInputSourceV2, type InvocationMalformedInputReasonV1, type InvocationAdmissionResultV1, type ProjectIdentityMigrationRequestV1 } from '../../../shared/dist/invocation/index.js';
|
|
17
|
-
import { type CompatibilityOfferV1, type CompatibilityResultV1 } from '../../../shared/dist/compatibility/index.js';
|
|
17
|
+
import { COMPATIBILITY_CAPABILITIES, type CompatibilityOfferV1, type CompatibilityResultV1, type PrivateExecutionHostKind } from '../../../shared/dist/compatibility/index.js';
|
|
18
18
|
import { type P205TransientExecutionAuthority } from '../git/git-lifecycle-store.js';
|
|
19
19
|
/**
|
|
20
20
|
* P226.04: the collector may fail with the bounded per-field frontmatter code
|
|
@@ -73,9 +73,78 @@ export interface InvokeOptions {
|
|
|
73
73
|
readonly onPrivateExecutionWorkspaceFailure?: (observation: import('../private-execution/codex-executor.js').PrivateCodexWorkspaceEffectFailureV1) => void;
|
|
74
74
|
/** Test-only parent for root-owned private YOLO/planning clones; CLI leaves unset. */
|
|
75
75
|
readonly privateExecutionWorkspaceParent?: string;
|
|
76
|
+
/** P229.05 test seam for the host-neutral executor port; the CLI leaves it unset. */
|
|
77
|
+
readonly privateHostExecutorLoader?: PrivateHostExecutorLoaderV1;
|
|
76
78
|
/** Explicit typed P223 release gate input from an authorized local producer. */
|
|
77
79
|
readonly releaseGate?: ReleaseGateRequestV1;
|
|
78
80
|
}
|
|
81
|
+
/** P229.02 port: `cwd` is bound at creation; material enters only through `run`. */
|
|
82
|
+
export interface PrivateHostExecutionPortV1 {
|
|
83
|
+
readonly hostKind: string;
|
|
84
|
+
preflight(): Promise<unknown>;
|
|
85
|
+
run(material: string): Promise<unknown>;
|
|
86
|
+
}
|
|
87
|
+
export type PrivateHostExecutorLoaderV1 = (hostKind: string, options: {
|
|
88
|
+
readonly cwd: string;
|
|
89
|
+
}) => Promise<PrivateHostExecutionPortV1 | undefined>;
|
|
90
|
+
/** Validated core preflight; `cwd` is never part of it and is never serialized. */
|
|
91
|
+
export interface PrivateHostPreflightV1 {
|
|
92
|
+
readonly hostKind: string;
|
|
93
|
+
readonly hostVersion: string;
|
|
94
|
+
readonly os: 'linux' | 'darwin' | 'win32';
|
|
95
|
+
readonly observedAtMs: number;
|
|
96
|
+
}
|
|
97
|
+
/** P229.04 exact v7 executor proof sent for every port host (`isPrivateExecutorProofV7`). */
|
|
98
|
+
export type PrivateHostExecutorProofV7 = {
|
|
99
|
+
readonly schemaVersion: 7;
|
|
100
|
+
readonly preflight: 'passed';
|
|
101
|
+
readonly hostVersion: 'passed';
|
|
102
|
+
readonly stdinOnly: 'passed';
|
|
103
|
+
readonly ephemeralHome: 'passed';
|
|
104
|
+
readonly nativeNoPersistence: 'passed';
|
|
105
|
+
readonly os: 'passed';
|
|
106
|
+
};
|
|
107
|
+
/** Routing (P229-CON-EXECUTOR): only `codex-cli` on Linux keeps the v6 executor. */
|
|
108
|
+
export declare function usesPrivateCodexV6Executor(hostKind: string | undefined, platform: string): boolean;
|
|
109
|
+
/** Default loader: the P229.02 adapter registry; hosts without an adapter yield `undefined`. */
|
|
110
|
+
export declare function defaultPrivateHostExecutorLoader(hostKind: string, options: {
|
|
111
|
+
readonly cwd: string;
|
|
112
|
+
}): Promise<PrivateHostExecutionPortV1 | undefined>;
|
|
113
|
+
/** One port per `cwd`; a missing, throwing or mismatched port is `private-executor-headless-unavailable`. */
|
|
114
|
+
export declare function loadPrivateHostExecutionPort(hostKind: string, cwd: string, loader?: PrivateHostExecutorLoaderV1): Promise<PrivateHostExecutionPortV1>;
|
|
115
|
+
export declare function validatePrivateHostPreflight(value: unknown, hostKind: string): PrivateHostPreflightV1;
|
|
116
|
+
/** Exactly the 10 keys of `PrivateHarnessExecutionReceiptV2`; the receipt is returned unchanged. */
|
|
117
|
+
export declare function sanitizePrivateHostReceiptV2(value: unknown, hostKind: string): import('../private-execution/harness-executor.js').PrivateHarnessExecutionReceiptV2;
|
|
118
|
+
/** P229-CON-ADMISSION request for a port host, built only from a validated preflight. */
|
|
119
|
+
export declare function buildPrivateHostExecutionRequest(preflight: PrivateHostPreflightV1): {
|
|
120
|
+
readonly schemaVersion: 1;
|
|
121
|
+
readonly hostKind: PrivateExecutionHostKind;
|
|
122
|
+
readonly hostVersion: string;
|
|
123
|
+
readonly executorProof: PrivateHostExecutorProofV7;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Material goes only to `port.run`. A non-success outcome fails with the outcome itself;
|
|
127
|
+
* coded port errors pass, others become `private-executor-run-failed`. With
|
|
128
|
+
* `requireWorkspaceEffect` the Codex checkout check is replicated around the run.
|
|
129
|
+
*/
|
|
130
|
+
export declare function runPrivateHostExecutionStep(port: PrivateHostExecutionPortV1, material: string, options: {
|
|
131
|
+
readonly hostKind: string;
|
|
132
|
+
readonly workspaceRoot: string;
|
|
133
|
+
readonly requireWorkspaceEffect: boolean;
|
|
134
|
+
readonly expectedExecutionBranch?: string;
|
|
135
|
+
}): Promise<import('../private-execution/harness-executor.js').PrivateHarnessExecutionReceiptV2>;
|
|
136
|
+
/**
|
|
137
|
+
* P229.05 AC2/AC3: `create-epic` private material by descriptor write-set. Both runtimes
|
|
138
|
+
* accept only P01 (diagnosis) inside a create-epic envelope: the Codex v6 executor refuses
|
|
139
|
+
* the rest with the root protocol, the port with `private-execution-planning-step-unsupported`.
|
|
140
|
+
* P02/P03 run through the standalone *idea-research / *generate-epic step commands, the
|
|
141
|
+
* only place their predecessor-bound preflights exist.
|
|
142
|
+
*/
|
|
143
|
+
export declare function classifyPrivateCreateEpicPlanningPhase(input: {
|
|
144
|
+
readonly codexV6: boolean;
|
|
145
|
+
readonly writeSetId: unknown;
|
|
146
|
+
readonly stepId: unknown;
|
|
147
|
+
}): 'diagnosis';
|
|
79
148
|
/**
|
|
80
149
|
* Normalize the project root received from wrappers/CLI flags.
|
|
81
150
|
*
|
|
@@ -546,11 +615,17 @@ interface InvokeRequestBodyBase {
|
|
|
546
615
|
readonly nativeHostAttestation?: ReturnType<typeof detectNativeHostAttestation>;
|
|
547
616
|
/** Advisory numbers-only host capacity, attached to `*yoloop` only. */
|
|
548
617
|
readonly hostCapacity?: YoloopHostCapacityV1;
|
|
618
|
+
/**
|
|
619
|
+
* P228.18: `hostKind` is the closed shared host enum; `sandboxProof` is a
|
|
620
|
+
* Codex-host attribute sent only for `codex-cli` on Linux (v6 executor).
|
|
621
|
+
* P229.05: every other host carries the exact P229.04 v7 `executorProof`.
|
|
622
|
+
*/
|
|
549
623
|
readonly privateExecution?: {
|
|
550
624
|
readonly schemaVersion: 1;
|
|
551
|
-
readonly hostKind:
|
|
625
|
+
readonly hostKind: PrivateExecutionHostKind;
|
|
552
626
|
readonly hostVersion: string;
|
|
553
|
-
readonly
|
|
627
|
+
readonly executorProof?: PrivateHostExecutorProofV7;
|
|
628
|
+
readonly sandboxProof?: {
|
|
554
629
|
readonly schemaVersion: 6;
|
|
555
630
|
readonly trust: 'client-self-attested';
|
|
556
631
|
readonly credentialKind: 'chatgpt-subscription';
|
|
@@ -649,11 +724,16 @@ export declare function detectStateSchemaDrift(stateData: unknown): SchemaDriftI
|
|
|
649
724
|
* Exported for tests only; not part of the public API.
|
|
650
725
|
*/
|
|
651
726
|
export declare function __resetSchemaDriftWarnedForTests(): void;
|
|
727
|
+
/**
|
|
728
|
+
* P228.03 (CON-PB-03): exact public counts only. The 1.0 bucket shape is no
|
|
729
|
+
* longer emitted; servers keep accepting it from older clients.
|
|
730
|
+
*/
|
|
652
731
|
export interface CreateEpicPlanningProjectionDiagnosticV1 {
|
|
653
|
-
readonly schemaVersion: 'CreateEpicPlanningProjectionDiagnostic/1.
|
|
732
|
+
readonly schemaVersion: 'CreateEpicPlanningProjectionDiagnostic/1.1';
|
|
654
733
|
readonly outcome: 'omitted';
|
|
655
734
|
readonly reasonCode: 'budget-omitted';
|
|
656
|
-
readonly
|
|
735
|
+
readonly byteLength: number;
|
|
736
|
+
readonly maxBytes: number;
|
|
657
737
|
readonly publicSafe: true;
|
|
658
738
|
}
|
|
659
739
|
/**
|
|
@@ -674,6 +754,8 @@ export interface StateSnapshotCollectionOptions {
|
|
|
674
754
|
readonly verifyPlanningGeneration?: boolean;
|
|
675
755
|
/** Process-local proof keyed by story; never read from or written to JSON. */
|
|
676
756
|
readonly p205Authorities?: Readonly<Record<string, P205TransientExecutionAuthority>>;
|
|
757
|
+
/** P230.07: count-only P205 order diagnostics projected on the affected epic. */
|
|
758
|
+
readonly p205AuthorityDiagnostics?: readonly P205AuthorityEpicDiagnostic[];
|
|
677
759
|
}
|
|
678
760
|
export declare class StateSnapshotIntegrityError extends Error {
|
|
679
761
|
readonly reasonCode: string;
|
|
@@ -705,7 +787,21 @@ export interface StoryWorktreeReadinessV1 {
|
|
|
705
787
|
* only on the epic branch are present in every worktree.
|
|
706
788
|
*/
|
|
707
789
|
readonly executionBases?: readonly StoryWorktreeExecutionBaseV1[];
|
|
790
|
+
/**
|
|
791
|
+
* P228.26 (R12, DEC-09): emitted only when `.neocortex/state.json` is not
|
|
792
|
+
* tracked (`runtime-store` or `ambiguous`), always with the in-band
|
|
793
|
+
* capability id. `tracked` readiness stays byte-identical (AC5).
|
|
794
|
+
*/
|
|
795
|
+
readonly governanceMode?: 'runtime-store' | 'ambiguous';
|
|
796
|
+
readonly governanceCapability?: typeof COMPATIBILITY_CAPABILITIES.STORY_GOVERNANCE_RUNTIME_STORE;
|
|
708
797
|
}
|
|
798
|
+
/**
|
|
799
|
+
* P228.26 (DEC-05): from the root checkout of a `runtime-store` project, mirror
|
|
800
|
+
* the local `.neocortex/state.json` read-only into the governance store so
|
|
801
|
+
* story worktrees can read it. Never writes the local file; a failure only
|
|
802
|
+
* leaves the previous mirror and is reported by reason code.
|
|
803
|
+
*/
|
|
804
|
+
export declare function mirrorRuntimeStoreProjectState(projectRoot: string): void;
|
|
709
805
|
/** Epic targeted by `*yoloop @docs/epics/epic-P…md` or `*yolo @docs/stories/P….NN.story.md`. */
|
|
710
806
|
export declare function storyWorktreeReadinessTargetEpic(args: string): string | undefined;
|
|
711
807
|
/** Undefined outside a Git work tree or when Git cannot answer. */
|
|
@@ -730,7 +826,73 @@ export declare function boundedP222PremergeCheckpointPositions(projectRoot: stri
|
|
|
730
826
|
* The projection itself stays fail-closed regardless of the reason.
|
|
731
827
|
*/
|
|
732
828
|
export declare function invokeP205ProjectionReasonCode(error: unknown): string;
|
|
829
|
+
export declare const P205_AUTHORITY_EPIC_ORDER_MISMATCH: "p205-authority-epic-order-mismatch";
|
|
830
|
+
export interface EpicCheckpointOrderCandidate {
|
|
831
|
+
readonly storyId: string;
|
|
832
|
+
/** First-parent position (bounded P222 premerge positions may be negative). */
|
|
833
|
+
readonly position: number;
|
|
834
|
+
/** Effective `depends_on` of the story. */
|
|
835
|
+
readonly dependsOn: readonly string[];
|
|
836
|
+
}
|
|
837
|
+
export interface EpicCheckpointOrderCounts {
|
|
838
|
+
readonly listed: number;
|
|
839
|
+
readonly physical: number;
|
|
840
|
+
readonly missing: number;
|
|
841
|
+
readonly extra: number;
|
|
842
|
+
readonly duplicates: number;
|
|
843
|
+
readonly dependencyViolations: number;
|
|
844
|
+
}
|
|
845
|
+
export type EpicCheckpointOrderDecision = {
|
|
846
|
+
readonly ok: true;
|
|
847
|
+
readonly order: readonly string[];
|
|
848
|
+
} | {
|
|
849
|
+
readonly ok: false;
|
|
850
|
+
readonly reasonCode: typeof P205_AUTHORITY_EPIC_ORDER_MISMATCH;
|
|
851
|
+
readonly counts: EpicCheckpointOrderCounts;
|
|
852
|
+
};
|
|
853
|
+
/** Public, count-only diagnostic for an epic whose checkpoint order was refused. */
|
|
854
|
+
export interface P205AuthorityEpicDiagnostic {
|
|
855
|
+
readonly epicId: string;
|
|
856
|
+
readonly reasonCode: typeof P205_AUTHORITY_EPIC_ORDER_MISMATCH;
|
|
857
|
+
readonly counts: EpicCheckpointOrderCounts;
|
|
858
|
+
}
|
|
859
|
+
export interface InvokeP205AuthorityProjection {
|
|
860
|
+
readonly authorities: Readonly<Record<string, P205TransientExecutionAuthority>>;
|
|
861
|
+
readonly diagnostics: readonly P205AuthorityEpicDiagnostic[];
|
|
862
|
+
/**
|
|
863
|
+
* P230.07 AC3: `finalize-epic` only -- authority minted by the same single
|
|
864
|
+
* P205 run for the target epic's current graph revision (exact for the
|
|
865
|
+
* aggregate receipt). Process-local; never serialized.
|
|
866
|
+
*/
|
|
867
|
+
readonly epicAuthorities: Readonly<Record<string, P205TransientExecutionAuthority>>;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* P230.07 (P230-CON-P205-FINALIZE): the physical first-parent order is the
|
|
871
|
+
* canonical claim order when the listed checkpoint set is exactly the physical
|
|
872
|
+
* set (no duplicates) and every in-group dependency lands physically earlier.
|
|
873
|
+
* Anything else is a typed, count-only mismatch. Pure and deterministic.
|
|
874
|
+
*/
|
|
875
|
+
export declare function canonicalizeEpicCheckpointOrder(listed: readonly string[], candidates: readonly EpicCheckpointOrderCandidate[]): EpicCheckpointOrderDecision;
|
|
733
876
|
export declare function collectInvokeP205Authorities(projectRoot: string, args: string, commandId: string | null | undefined): Promise<Readonly<Record<string, P205TransientExecutionAuthority>>>;
|
|
877
|
+
export declare function collectInvokeP205AuthorityProjection(projectRoot: string, args: string, commandId: string | null | undefined): Promise<InvokeP205AuthorityProjection>;
|
|
878
|
+
/** Bounded `finalize-epic` target: `epic-P<n>.md` or an isolated `P<n>` token. */
|
|
879
|
+
export declare function finalizeEpicTargetId(args: string): string | undefined;
|
|
880
|
+
/**
|
|
881
|
+
* P230.07 AC3 (P230-CON-P205-FINALIZE): `finalize-epic` through the invoke
|
|
882
|
+
* produces the missing aggregate QA and head reconciliation receipts with the
|
|
883
|
+
* same producer as the headless runner, reusing the exact in-process P205
|
|
884
|
+
* authority. It never switches the operator checkout. Failures are typed and
|
|
885
|
+
* public; the projection then simply carries no receipt (fail-closed).
|
|
886
|
+
* Returns `undefined` when not applicable.
|
|
887
|
+
*/
|
|
888
|
+
export declare function produceFinalizeEpicLifecycleEvidence(input: {
|
|
889
|
+
readonly projectRoot: string;
|
|
890
|
+
readonly args: string;
|
|
891
|
+
readonly commandId: string | null | undefined;
|
|
892
|
+
/** `InvokeP205AuthorityProjection.epicAuthorities`; the only P205 authority this path may use. */
|
|
893
|
+
readonly epicAuthorities: Readonly<Record<string, P205TransientExecutionAuthority>>;
|
|
894
|
+
readonly nowIso?: string;
|
|
895
|
+
}): Promise<Awaited<ReturnType<typeof import('../git/epic-lifecycle-evidence.js').produceEpicLifecycleEvidence>> | undefined>;
|
|
734
896
|
export declare function createFullStateSnapshotScope(trigger: string, snapshot: Pick<StateSnapshot, 'stories' | 'epics'>): FullStateSnapshotScope;
|
|
735
897
|
interface SendResult {
|
|
736
898
|
readonly ok: boolean;
|
|
@@ -799,6 +961,15 @@ export declare function sendEpicClaimAcknowledgement(serverUrl: string, authToke
|
|
|
799
961
|
readonly snapshot: Record<string, unknown>;
|
|
800
962
|
};
|
|
801
963
|
}, retryOptions?: InvokePhysicalRetryOptions): Promise<boolean>;
|
|
964
|
+
/**
|
|
965
|
+
* P230.01 (P230-CON-CONTINUATION C2): at a `*yoloop` re-invocation, records the
|
|
966
|
+
* typed `yoloop-round-refused-before-setup` receipt when the single pending
|
|
967
|
+
* authority's round left no setup evidence, then returns the re-read state so
|
|
968
|
+
* the request carries it. Any derivation or recording failure keeps the state
|
|
969
|
+
* unchanged (no receipt, legacy replay path); only a bounded reason code is
|
|
970
|
+
* written to stderr.
|
|
971
|
+
*/
|
|
972
|
+
export declare function recordRefusedYoloopRoundIfAny(projectRoot: string, stateSnapshot: Pick<StateSnapshot, 'epics' | 'stories'>, yoloopState: YoloopPersistedState): Promise<YoloopPersistedState>;
|
|
802
973
|
export declare function acknowledgeMaterializedPendingEpicClaims(projectRoot: string, stateSnapshot: StateSnapshot, serverUrl: string, authToken: string, projectId: string | undefined, retryOptions?: InvokePhysicalRetryOptions): Promise<number>;
|
|
803
974
|
export type YoloopInvalidatedSessionRecoveryResultV1 = {
|
|
804
975
|
readonly outcome: 'applied';
|
|
@@ -841,6 +1012,13 @@ export interface StoryWorktreeBarrierPollingOptions {
|
|
|
841
1012
|
* phase-1 prompt, which resumes at C05.
|
|
842
1013
|
*/
|
|
843
1014
|
export declare function pollStoryWorktreeSpecBarrier(args: string, attempt: (args: string) => Promise<InvokeResult>, options?: StoryWorktreeBarrierPollingOptions): Promise<InvokeResult>;
|
|
1015
|
+
/**
|
|
1016
|
+
* P228.24 (AM-03): the server returns the v1 acceptance and, beside it, the
|
|
1017
|
+
* story's current `specInputDigest`. A valid digest upgrades the record to v2
|
|
1018
|
+
* (closed five keys); anything else keeps the record as the server sent it,
|
|
1019
|
+
* so the closed store validator still decides. The client never computes it.
|
|
1020
|
+
*/
|
|
1021
|
+
export declare function composeStoryWorktreeSpecAcceptance(acceptance: unknown, specInputDigest: unknown): unknown;
|
|
844
1022
|
/**
|
|
845
1023
|
* 4.61.4: persist the server-returned C04 spec acceptance and phase-one receipt
|
|
846
1024
|
* into the shared runtime evidence (git common dir), so the server can see
|