@ornexus/neocortex 4.66.0 → 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 +1 -1
- package/install.sh +2 -2
- package/package.json +2 -2
- 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 +149 -1
- package/packages/client/dist/commands/invoke.js +88 -83
- package/packages/client/dist/commands/planning-qa.d.ts +57 -0
- package/packages/client/dist/commands/planning-qa.js +1 -1
- package/packages/client/dist/commands/story-checkpoint.d.ts +2 -0
- 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 +51 -0
- 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 +9 -0
- package/packages/client/dist/git/git-lifecycle-store.js +9 -8
- 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/private-execution/codex-executor.d.ts +13 -0
- package/packages/client/dist/private-execution/codex-executor.js +4 -4
- 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/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/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/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 +28 -0
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/skill/SKILL.md +1 -1
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex-root.md +2 -2
- package/targets-stubs/claude-code/neocortex-sentinel.md +1 -1
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex.md +2 -2
- package/targets-stubs/codex/AGENTS.md +1 -1
- package/targets-stubs/cursor/agent.md +2 -2
- package/targets-stubs/gemini-cli/agent.md +2 -2
- package/targets-stubs/gemini-cli/agents/neocortex.md +2 -2
- package/targets-stubs/grok/SKILL.md +3 -3
- package/targets-stubs/grok/agents/{neocortex.md → neocortex-sentinel.md} +2 -2
- package/targets-stubs/grok/install-grok.sh +45 -8
- package/targets-stubs/lib/managed-config-merge.js +21 -1
- package/targets-stubs/lib/mcp-merge.js +12 -3
- package/targets-stubs/opencode/neocortex-root.md +1 -1
- package/targets-stubs/opencode/neocortex.md +1 -1
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
package/install.ps1
CHANGED
package/install.sh
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Development Orchestrator
|
|
5
5
|
|
|
6
6
|
# Versao do instalador
|
|
7
|
-
VERSION="4.66.
|
|
7
|
+
VERSION="4.66.1"
|
|
8
8
|
|
|
9
9
|
# Flags
|
|
10
10
|
MIGRATION_DETECTED=false
|
|
@@ -1081,7 +1081,7 @@ show_target_resolution_dry_run() {
|
|
|
1081
1081
|
;;
|
|
1082
1082
|
grok)
|
|
1083
1083
|
info "Dry-run Skill target=grok file=${GROK_HOME:-$HOME/.grok}/skills/neocortex/SKILL.md project=.grok/skills/neocortex/SKILL.md"
|
|
1084
|
-
info "Dry-run Agent target=grok file=${GROK_HOME:-$HOME/.grok}/agents/neocortex.md project=.grok/agents/neocortex.md action=managed-non-overwrite"
|
|
1084
|
+
info "Dry-run Agent target=grok file=${GROK_HOME:-$HOME/.grok}/agents/neocortex-sentinel.md project=.grok/agents/neocortex-sentinel.md action=managed-non-overwrite legacy=retire-if-managed-hash"
|
|
1085
1085
|
info "Dry-run MCP target=grok file=${GROK_HOME:-$HOME/.grok}/config.toml root=mcp_servers managed=playwright,browser_use,figma,shadcn,chrome-devtools action=replace-managed-sections-preserve-unknown"
|
|
1086
1086
|
;;
|
|
1087
1087
|
opencode)
|
package/package.json
CHANGED
|
@@ -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};
|
|
@@ -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
|
*
|
|
@@ -548,12 +617,14 @@ interface InvokeRequestBodyBase {
|
|
|
548
617
|
readonly hostCapacity?: YoloopHostCapacityV1;
|
|
549
618
|
/**
|
|
550
619
|
* P228.18: `hostKind` is the closed shared host enum; `sandboxProof` is a
|
|
551
|
-
* Codex-host attribute sent only for `codex-cli
|
|
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`.
|
|
552
622
|
*/
|
|
553
623
|
readonly privateExecution?: {
|
|
554
624
|
readonly schemaVersion: 1;
|
|
555
625
|
readonly hostKind: PrivateExecutionHostKind;
|
|
556
626
|
readonly hostVersion: string;
|
|
627
|
+
readonly executorProof?: PrivateHostExecutorProofV7;
|
|
557
628
|
readonly sandboxProof?: {
|
|
558
629
|
readonly schemaVersion: 6;
|
|
559
630
|
readonly trust: 'client-self-attested';
|
|
@@ -683,6 +754,8 @@ export interface StateSnapshotCollectionOptions {
|
|
|
683
754
|
readonly verifyPlanningGeneration?: boolean;
|
|
684
755
|
/** Process-local proof keyed by story; never read from or written to JSON. */
|
|
685
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[];
|
|
686
759
|
}
|
|
687
760
|
export declare class StateSnapshotIntegrityError extends Error {
|
|
688
761
|
readonly reasonCode: string;
|
|
@@ -753,7 +826,73 @@ export declare function boundedP222PremergeCheckpointPositions(projectRoot: stri
|
|
|
753
826
|
* The projection itself stays fail-closed regardless of the reason.
|
|
754
827
|
*/
|
|
755
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;
|
|
756
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>;
|
|
757
896
|
export declare function createFullStateSnapshotScope(trigger: string, snapshot: Pick<StateSnapshot, 'stories' | 'epics'>): FullStateSnapshotScope;
|
|
758
897
|
interface SendResult {
|
|
759
898
|
readonly ok: boolean;
|
|
@@ -822,6 +961,15 @@ export declare function sendEpicClaimAcknowledgement(serverUrl: string, authToke
|
|
|
822
961
|
readonly snapshot: Record<string, unknown>;
|
|
823
962
|
};
|
|
824
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>;
|
|
825
973
|
export declare function acknowledgeMaterializedPendingEpicClaims(projectRoot: string, stateSnapshot: StateSnapshot, serverUrl: string, authToken: string, projectId: string | undefined, retryOptions?: InvokePhysicalRetryOptions): Promise<number>;
|
|
826
974
|
export type YoloopInvalidatedSessionRecoveryResultV1 = {
|
|
827
975
|
readonly outcome: 'applied';
|