@ornexus/neocortex 4.60.65 → 4.60.66
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 +23 -23
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +9 -2
- package/packages/client/dist/commands/architecture-root-binding.js +1 -1
- package/packages/client/dist/commands/invoke.d.ts +1 -1
- package/packages/client/dist/commands/invoke.js +79 -78
- 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/git/direct-yolo-c01-retry.d.ts +21 -0
- package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -0
- package/packages/client/dist/git/direct-yolo-checkpoint.d.ts +1 -5
- package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -4
- package/packages/client/dist/git/git-lifecycle-store.d.ts +0 -2
- package/packages/client/dist/git/git-lifecycle-store.js +8 -9
- package/packages/client/dist/private-execution/clean-baseline.d.ts +2 -3
- package/packages/client/dist/private-execution/clean-baseline.js +2 -2
- package/packages/client/dist/private-execution/isolated-admission.d.ts +2 -0
- package/packages/client/dist/private-execution/isolated-admission.js +16 -11
- package/packages/client/dist/yolo/invoke-envelope-capability.d.ts +16 -0
- package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -0
- package/packages/client/dist/yolo/spec-envelope-collector.d.ts +7 -0
- package/packages/client/dist/yolo/spec-envelope-collector.js +3 -3
- package/packages/shared/dist/architecture-non-ui-scope.js +22 -0
- package/packages/shared/dist/architecture-public-topology.js +11 -0
- package/packages/shared/dist/invocation/index.js +4 -2
- package/packages/shared/dist/private-qa-structural-admission.js +14 -0
- package/packages/shared/dist/private-yolo-predecessor-decision.js +32 -0
- package/packages/shared/dist/project-validation-commands.js +74 -0
- package/packages/shared/dist/yolo/spec-envelope.js +2 -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.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/opencode/neocortex-root.md +1 -1
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import{execFileSync as Nt,spawnSync as wt}from"node:child_process";import{createHash as F}from"node:crypto";import{existsSync as
|
|
2
|
-
`)])));if(
|
|
1
|
+
import{execFileSync as Nt,spawnSync as wt}from"node:child_process";import{createHash as F}from"node:crypto";import{existsSync as nt,lstatSync as x,readFileSync as m,realpathSync as ht,writeFileSync as mt}from"node:fs";import{isAbsolute as ot,join as a,relative as dt,sep as vt}from"node:path";import{isDeepStrictEqual as S}from"node:util";import{readPrivateYoloFrozenWriteSet as Dt,verifyPrivateYoloCandidateWriteSet as Ft,verifyPrivateYoloCleanBaseline as Bt}from"./clean-baseline.js";import{PRIVATE_EPIC_PENDING_SIDECAR as et}from"./isolated-workspace.js";import{loadPactPrivateAnswers as Ct}from"../commands/architecture-answers.js";import{derivePactWriteSet as _t}from"./pact-write-set.js";import{deriveUxCandidateWriteSet as zt,deriveUxWriteSet as Lt}from"./ux-write-set.js";import{validateUxCandidateSource as Ht}from"./ux-source-validation.js";import{validatePactTestSource as Jt}from"./pact-test-source.js";import{classifyProjectMemoryUpdate as Mt}from"../memory/project-memory-writer.js";import{privateRootMemoryEffect as yt,privateRootMemorySourceMatches as qt,privateRootMemorySourceMatchReason as Gt}from"./root-memory-scope.js";import{inspectPactToolchain as Yt,planPactToolchainManifest as Ut}from"./pact-toolchain.js";import{acceptedPlanningDiagnosisPredecessor as Wt,planningPendingSidecarDigest as bt}from"./planning-diagnosis-checkpoint.js";import{acceptedPlanningResearchPredecessor as Vt}from"./planning-research-checkpoint.js";import{confirmPropertyTestPlan as xt,renderPropertyTestConfiguration as Xt}from"./property-test-plan.js";import{validatePropertyTestTypeScriptSource as Kt}from"./property-test-source.js";const Z=16*1024*1024,st=1024,ut="acd455ed0e39d98b90fb57391db75e366e4c5604db043e03a89a20e33d643c3c",Zt="81f50aaa801c1660eabe46e645501acbfb3e9873410c991e1496c014ca75c369",Rt="fa2194f89c01f07e225fd6f39e98e679f628e072239b6cd0af3ee527f0722518",Qt="8636f22ec5950410902448ee1e9cb4947359ac98df518742bddbbb367468e3ae";function tt(t,r){return typeof t=="string"&&t.length<=128&&F("sha256").update(t).digest("hex")===r}function Et(){const t={...process.env};for(const r of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES"])delete t[r];return t}function G(t,r){return Nt("git",[...r],{cwd:t,env:Et(),stdio:["ignore","pipe","pipe"],timeout:3e4,maxBuffer:Z})}function J(t,r){return G(t,r).toString("utf8").trim()}function B(t,r=!1){return G(t,["status","--porcelain=v1","-z","--untracked-files=all",...r?["--ignored=matching"]:[]])}function rt(t){return!!t&&!ot(t)&&!t.includes("\\")&&!t.includes("\0")&&!t.split("/").some(r=>!r||r==="."||r===".."||r===".git")}function P(t,r){const e=r.split("/");let n=t;for(const o of e.slice(0,-1)){n=a(n,o);try{const i=x(n);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("path-boundary")}catch(i){if(i.code==="ENOENT")return;throw i}}try{const o=x(a(t,r));if(!o.isFile()||o.isSymbolicLink()||o.size>Z)throw new Error("path-boundary")}catch(o){if(o.code!=="ENOENT")throw o}}function At(t){const r=[...t.matchAll(/\/\/\s*arch:keep-start[^\n]*\n[\s\S]*?\/\/\s*arch:keep-end[^\n]*/g)].map(o=>o[0]),e=(t.match(/arch:keep-start/g)??[]).length,n=(t.match(/arch:keep-end/g)??[]).length;if(e!==n||e!==r.length)throw new Error("architecture-keep-marker-invalid");return r}function M(t,r=!1,e=!1,n=[]){const o=[],i=[];for(const s of t.toString("utf8").split("\0").filter(Boolean)){if(s.length<4||s[2]!==" ")throw new Error("status-invalid");const d=s.slice(0,2),l=s.slice(3);if(!rt(l)||d!=="??"&&d!==" M"&&d!==" D"&&!(d===" T"&&n.includes(l))&&!(e&&d==="!!"&&l===et))throw new Error("status-invalid");o.push(l),d==="??"&&i.push(l)}if(!r&&o.length===0||o.length>st||new Set(o).size!==o.length)throw new Error("status-invalid");return{paths:o.sort(),untracked:i.sort()}}function lt(t,r,e,n){const o=G(r,["ls-tree","-z",e,"--",n]).toString("utf8");if(!o)try{return x(a(t,n)),!1}catch(s){return s.code==="ENOENT"}const i=/^([0-7]{6}) blob [a-f0-9]{40,64}\t([^\0]+)\0$/.exec(o);if(!i||i[2]!==n||!["100644","100755"].includes(i[1]))return!1;try{const s=x(a(t,n));return!s.isFile()||s.isSymbolicLink()||s.size>Z||!!(s.mode&73)!=(i[1]==="100755")?!1:m(a(t,n)).equals(G(r,["show",`${e}:${n}`]))}catch{return!1}}function ve(t,r,e,n){return rt(n)&&/^[a-f0-9]{40,64}$/.test(e)&<(t,r,e,n)}function it(t,r){try{const e=a(t,et),n=x(a(t,".neocortex")),o=x(e);return n.isDirectory()&&!n.isSymbolicLink()&&n.uid===process.getuid?.()&&(n.mode&18)===0&&o.isFile()&&!o.isSymbolicLink()&&o.uid===process.getuid?.()&&(o.mode&63)===0&&o.size>0&&o.size<=128*1024&&F("sha256").update(m(e)).digest("hex")===r}catch{return!1}}function ft(t,r,e,n,o,i){const s=new Set(n),d=i?yt(i).files.map(f=>f.path):[],l=M(B(t),!0,!!o,d),c=i?Gt(i,t,r,e):"matched";if(c!=="matched")throw new Error(`root-memory-${c}`);if(!l.paths.every(f=>s.has(f)||d.includes(f)||f===et&&!!o&&it(t,o)))throw new Error("source-unclaimed-delta");if(!n.every(f=>lt(t,r,e,f)))throw new Error("source-frozen-mismatch");return!o||it(t,o)}function kt(t,r){const e=wt("git",["diff","--no-index","--binary","--no-ext-diff","--","/dev/null",r],{cwd:t,env:Et(),encoding:"buffer",timeout:3e4,maxBuffer:Z});if(e.error||e.status!==1||!Buffer.isBuffer(e.stdout)||e.stdout.byteLength===0)throw new Error("patch-invalid");return e.stdout}function St(t,r,e){const n=wt("git",["apply",...e?["--check"]:[],"--binary","-"],{cwd:t,env:Et(),input:r,encoding:"buffer",timeout:3e4,maxBuffer:Z});if(n.error||n.status!==0)throw new Error("apply-failed")}function pt(t,r,e){const n=a(t,e),o=a(r,e);try{const i=x(n),s=x(o);return i.isFile()&&s.isFile()&&(i.mode&73)===(s.mode&73)&&m(n).equals(m(o))}catch(i){if(i.code!=="ENOENT")return!1;try{return x(n),!1}catch(s){if(s.code!=="ENOENT")return!1}try{return x(o),!1}catch(s){return s.code==="ENOENT"}}}function _e(t,r,e,n){$t(t,r,e,!0,n)}function be(t,r,e,n){if($t(t,r,e,!1,n),G(t.workspacePath,["diff","--cached","--name-only"]).byteLength!==0)throw new Error("private-execution-isolated-snapshot-unverified")}function $t(t,r,e,n,o){try{if(process.platform!=="linux"||t.schemaVersion!==1||!ot(t.sourceRoot)||!ot(t.workspacePath)||ht(t.sourceRoot)!==t.sourceRoot||ht(t.workspacePath)!==t.workspacePath||!x(t.workspacePath).isDirectory()||(x(t.workspacePath).mode&63)!==0||dt(t.sourceRoot,t.workspacePath)===""||dt(t.sourceRoot,t.workspacePath).split(vt)[0]!==".."||!/^[a-f0-9]{40,64}$/.test(t.baseSha)||!/^[a-f0-9]{40,64}$/.test(e)||J(t.sourceRoot,["rev-parse","--show-toplevel"])!==t.sourceRoot||J(t.workspacePath,["rev-parse","--show-toplevel"])!==t.workspacePath||J(t.sourceRoot,["rev-parse","HEAD"])!==t.baseSha||J(t.workspacePath,["rev-parse","HEAD"])!==e||J(t.sourceRoot,["symbolic-ref","--short","HEAD"])!==t.executionBranch||J(t.workspacePath,["symbolic-ref","--short","HEAD"])!==t.executionBranch||nt(a(t.workspacePath,".git","objects","info","alternates"))||n&&B(t.workspacePath,!0).byteLength!==0||r.length===0||r.length>st||r.some(i=>!rt(i))||new Set(r).size!==r.length)throw new Error("boundary-invalid");if(G(t.workspacePath,["merge-base","--is-ancestor",t.baseSha,e]),!ft(t.sourceRoot,t.workspacePath,e,r,void 0,o))throw new Error("boundary-raced")}catch(i){const s=i instanceof Error&&(["boundary-invalid","boundary-raced","status-invalid","source-unclaimed-delta","source-frozen-mismatch"].includes(i.message)||/^root-memory-(scope-binding|snapshot-ancestry|snapshot-content|source-content|source-projection)(-unsafe)?$/.test(i.message))?i.message:"physical-inspection-failed";throw new Error("private-execution-isolated-snapshot-unverified",{cause:new Error(s)})}}function Y(t,r,e,n,o,i=[],s){try{if(process.platform!=="linux"||t.schemaVersion!==1||!ot(t.sourceRoot)||!ot(t.workspacePath)||ht(t.sourceRoot)!==t.sourceRoot||ht(t.workspacePath)!==t.workspacePath||!x(t.workspacePath).isDirectory()||(x(t.workspacePath).mode&63)!==0||dt(t.sourceRoot,t.workspacePath)===""||dt(t.sourceRoot,t.workspacePath).split(vt)[0]!==".."||J(t.sourceRoot,["rev-parse","--show-toplevel"])!==t.sourceRoot||J(t.workspacePath,["rev-parse","--show-toplevel"])!==t.workspacePath||J(t.sourceRoot,["rev-parse","HEAD"])!==t.baseSha||!/^[a-f0-9]{40,64}$/.test(e)||J(t.workspacePath,["rev-parse","HEAD"])!==e||J(t.sourceRoot,["symbolic-ref","--short","HEAD"])!==t.executionBranch||J(t.workspacePath,["symbolic-ref","--short","HEAD"])!==t.executionBranch||r.length===0||r.length>st||r.some(g=>!rt(g))||new Set(r).size!==r.length)throw new Error("authority-invalid");if(G(t.workspacePath,["merge-base","--is-ancestor",t.baseSha,e]),!ft(t.sourceRoot,t.workspacePath,e,r,n,s))throw new Error("source-snapshot-mismatch");const d=B(t.workspacePath,!0),l=M(d),c=new Set(r);if(l.paths.some(g=>!c.has(g)||i.includes(g)))throw new Error("path-unclaimed");if(o&&!o())throw new Error("candidate-raced");for(const g of l.paths)P(t.workspacePath,g),P(t.sourceRoot,g);const h=[G(t.workspacePath,["diff","--binary","--no-ext-diff","--no-textconv","HEAD","--"]),...l.untracked.map(g=>kt(t.workspacePath,g))],p=Buffer.concat(h.map(g=>Buffer.concat([g,Buffer.from(`
|
|
2
|
+
`)])));if(p.byteLength===0||p.byteLength>Z||!B(t.workspacePath,!0).equals(d)||o&&!o()||!ft(t.sourceRoot,t.workspacePath,e,r,n,s))throw new Error("patch-raced");if(St(t.sourceRoot,p,!0),!B(t.workspacePath,!0).equals(d)||o&&!o()||!ft(t.sourceRoot,t.workspacePath,e,r,n,s))throw new Error("patch-raced");St(t.sourceRoot,p,!1);const v=s?yt(s).files.map(g=>g.path):[];if(M(B(t.sourceRoot),!0,!!n,v).paths.some(g=>!c.has(g)&&!v.includes(g)&&g!==et)||s&&!qt(s,t.sourceRoot)||n&&!it(t.sourceRoot,n)||r.some(g=>!pt(t.workspacePath,t.sourceRoot,g))||J(t.sourceRoot,["rev-parse","HEAD"])!==t.baseSha||J(t.sourceRoot,["symbolic-ref","--short","HEAD"])!==t.executionBranch)throw new Error("admission-raced");return Object.freeze({schemaVersion:1,outcome:"admitted-unverified",baseSha:t.baseSha,executionBranch:t.executionBranch,changedPaths:Object.freeze([...l.paths]),patchSha256:F("sha256").update(p).digest("hex")})}catch{throw new Error("private-execution-isolated-admission-unverified")}}async function xe(t,r,e,n=t.baseSha,o=!1,i){try{const s=await Dt(t.sourceRoot,r,t.executionBranch,e);if(i){const f=yt(i);if(f.storyId!==r||f.childClaimRevision!==F("sha256").update([...s].sort().join("\0")).digest("hex"))throw new Error("root-memory-claim-mismatch")}const d=a(t.workspacePath,".neocortex","state.json"),l=x(d);if(!l.isFile()||l.isSymbolicLink()||l.size>Z)throw new Error("candidate-state-invalid");Ft(m(d,"utf8"),r,s);const c=Y(t,s,n,void 0,void 0,o?[".neocortex/state.json"]:[],i);return await Bt(t.sourceRoot,r,t.executionBranch,e),c}catch{throw new Error("private-execution-isolated-admission-unverified")}}const It=new Set(["id","epic_id","title","description","status","steps_completed","last_step","branch_name","estimated_hours","complexity","priority","type","depends_on","created_at","updated_at","acceptance_criteria"]),te=new Set(["id","title","description","status","stories","total_stories","completed_stories","estimated_hours","complexity","priority","created_at","updated_at","last_updated","source","tags"]);function Ot(t){return["title","description","complexity","priority","type","created_at","updated_at","last_updated","source"].some(e=>t[e]!==void 0&&typeof t[e]!="string")||t.estimated_hours!==void 0&&(typeof t.estimated_hours!="number"||!Number.isFinite(t.estimated_hours)||t.estimated_hours<0)?!1:["depends_on","acceptance_criteria","tags"].every(e=>t[e]===void 0||Array.isArray(t[e])&&t[e].length<=256&&t[e].every(n=>typeof n=="string"))}function ee(t){return Object.keys(t).every(r=>It.has(r))&&t.status==="backlog"&&Ot(t)&&(t.steps_completed===void 0||Array.isArray(t.steps_completed)&&t.steps_completed.length===0)&&(t.last_step===void 0||t.last_step===null)&&(t.branch_name===void 0||t.branch_name===null)}function Re(t,r,e,n,o){try{if(!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(r)||!/^P[1-9][0-9]*$/.test(e)||!/^[a-f0-9]{64}$/.test(n)||!/^[a-f0-9]{64}$/.test(o)||!it(t.sourceRoot,o))throw new Error("claim-invalid");const i=JSON.parse(m(a(t.sourceRoot,et),"utf8")),s=i&&typeof i=="object"&&!Array.isArray(i)?i.operations?.[n]:void 0;if(!s||typeof s!="object"||Array.isArray(s)||s.claimId!==r||s.epicId!==e)throw new Error("claim-sidecar-mismatch");const d=M(B(t.workspacePath,!0)),l=`docs/epics/epic-${e}.md`,c=".neocortex/state.json",f=new RegExp(`^docs/stories/${e}\\.[0-9]{2}\\.story\\.md$`),h=d.paths.filter(E=>f.test(E));if(!d.paths.includes(l)||!d.paths.includes(c)||h.length===0||h.length>99||d.paths.some(E=>E!==l&&E!==c&&E!=="NEOCORTEX.md"&&!f.test(E)))throw new Error("artifact-scope-invalid");const p=h.map(E=>E.slice(13,-9)).sort();if(p.some((E,T)=>E!==`${e}.${String(T+1).padStart(2,"0")}`))throw new Error("story-sequence-invalid");for(const E of[l,...h])try{throw x(a(t.sourceRoot,E)),new Error("artifact-already-exists")}catch(T){if(T.code!=="ENOENT")throw T}const v=(E,T)=>{P(t.workspacePath,E);const K=m(a(t.workspacePath,E),"utf8");return Buffer.byteLength(K)>Z?null:/^---\r?\n([\s\S]{1,8192}?)\r?\n---(?:\r?\n|$)/.exec(K)?.[1]?.split(/\r?\n/).find(ct=>ct.startsWith(`${T}:`))?.slice(T.length+1).trim()?.replace(/^(["'])(.*)\1$/,"$2")??null};if(v(l,"id")!==e||h.some((E,T)=>v(E,"id")!==p[T]||v(E,"epic_id")!==e))throw new Error("artifact-id-invalid");P(t.workspacePath,c);const u=JSON.parse(m(a(t.workspacePath,c),"utf8"));if(!u||typeof u!="object"||Array.isArray(u))throw new Error("state-invalid");const g=u,_=g.epics,j=g.stories,b=_?.[e],N=g.epic_id_ledger;if(g.schema_version!==1||!b||b.id!==e||b.status!=="memory-updated"||Object.keys(b).some(E=>!te.has(E))||!Ot(b)||b.completed_stories!==void 0&&b.completed_stories!==0||b.total_stories!==void 0&&b.total_stories!==p.length||!Array.isArray(b.stories)||b.stories.length!==p.length||b.stories.some((E,T)=>E!==p[T])||!j||p.some(E=>{const T=j[E];return!T||T.id!==E||T.epic_id!==e||!ee(T)})||!N||!Array.isArray(N.reserved_ids)||!N.reserved_ids.includes(e))throw new Error("state-claim-mismatch");P(t.sourceRoot,c);const y=JSON.parse(m(a(t.sourceRoot,c),"utf8")),A=y.epics,R=y.stories;if(!A||!R||A[e]!==void 0||p.some(E=>R[E]!==void 0))throw new Error("state-claim-conflict");const{[e]:U,...L}=_,$={...j};for(const E of p)delete $[E];const{epic_id_ledger:q,last_updated:C,...z}=y,{epic_id_ledger:V,last_updated:X,...Q}=g;if(!S(L,A)||!S($,R)||!S({...Q,epics:void 0,stories:void 0},{...z,epics:void 0,stories:void 0}))throw new Error("state-unrelated-drift");const O=y.epic_id_ledger&&typeof y.epic_id_ledger=="object"?y.epic_id_ledger.reserved_ids:void 0,{reserved_ids:W,...w}=N,D=y.epic_id_ledger&&typeof y.epic_id_ledger=="object"?y.epic_id_ledger:{schema_version:1},{reserved_ids:H,...k}=D;if(O!==void 0&&(!Array.isArray(O)||O.some(E=>typeof E!="string"||!/^P[1-9][0-9]*$/.test(E))||new Set(O).size!==O.length))throw new Error("ledger-drift");const I=[...Array.isArray(O)?O:[]];if(I.includes(e)||I.push(e),!S(N.reserved_ids,I)||!S(w,k))throw new Error("ledger-drift");return Y(t,d.paths,t.baseSha,o)}catch{throw new Error("private-execution-epic-claim-admission-unverified")}}function Ae(t,r,e,n,o,i){try{if(!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(r)||!/^P[1-9][0-9]{0,11}$/.test(e)||!/^[a-f0-9]{64}$/.test(n)||!/^[a-f0-9]{64}$/.test(o)||typeof i!="string"||!i.trim()||i.length>16384||!it(t.sourceRoot,o))throw new Error("planning-claim-invalid");const s=JSON.parse(m(a(t.sourceRoot,et),"utf8")),d=s&&typeof s=="object"&&!Array.isArray(s)?s.operations?.[n]:void 0;if(!d||typeof d!="object"||Array.isArray(d)||d.claimId!==r||d.epicId!==e)throw new Error("planning-claim-sidecar-mismatch");const l=`.neocortex/planning/epic-${e}`,c=`${l}/idea.json`,f=`${l}/diagnosis.md`,h=`${l}/enriched-prompt.md`,p=".neocortex/planning/planning.json",v=[c,f,h,p],u=M(B(t.workspacePath,!0));if(u.paths.length!==v.length||u.paths.some(E=>!v.includes(E)))throw new Error("planning-artifact-scope-invalid");for(const E of[c,f,h]){P(t.workspacePath,E);try{throw x(a(t.sourceRoot,E)),new Error("planning-artifact-already-exists")}catch(T){if(T.code!=="ENOENT")throw T}}const g=(E,T)=>{const K=x(a(t.workspacePath,E));if(!K.isFile()||K.isSymbolicLink()||K.size<1||K.size>T)throw new Error("planning-artifact-invalid");return m(a(t.workspacePath,E),"utf8")},_=JSON.parse(g(c,32*1024));if(!_||typeof _!="object"||Array.isArray(_)||_.epic_id!==e||_.status!=="diagnosed"||typeof _.raw_input!="string"||_.raw_input!==i)throw new Error("planning-idea-invalid");const j=g(f,256*1024),b=g(h,256*1024),N=(E,T)=>{const K=/^---\n([\s\S]{1,8192}?)\n---\n/.exec(E.replace(/\r\n/g,`
|
|
3
3
|
`))?.[1];if(!K)return!1;const Pt=K.split(`
|
|
4
|
-
`),
|
|
5
|
-
`))?.[1],y=O=>{const
|
|
6
|
-
`).filter(w=>w.startsWith(`${O}:`))??[];return
|
|
4
|
+
`),at=gt=>{const ct=Pt.filter(jt=>jt.startsWith(`${gt}:`));return ct.length===1?ct[0].slice(gt.length+1).trim().replace(/^(?:"(.*)"|'(.*)')$/,"$1$2"):void 0};return at("epic_id")===e&&tt(at("step"),T)&&at("status")==="completed"};if(!N(j,ut)||!N(b,Zt))throw new Error("planning-document-identity-invalid");P(t.workspacePath,p),P(t.sourceRoot,p);const y=JSON.parse(g(p,128*1024)),A=nt(a(t.sourceRoot,p))?JSON.parse(m(a(t.sourceRoot,p),"utf8")):void 0;if(!y||typeof y!="object"||Array.isArray(y)||!("epics"in y)||!y.epics||typeof y.epics!="object"||Array.isArray(y.epics)||A!==void 0&&(!A||typeof A!="object"||Array.isArray(A)||!("epics"in A)||!A.epics||typeof A.epics!="object"||Array.isArray(A.epics)))throw new Error("planning-index-invalid");const R=y,U=R.epics,L=U[e],$=L,q=$?.output_files;if(!L||typeof L!="object"||Array.isArray(L)||$?.id!==e||$.status!=="diagnosed"||$.idea!==_.raw_input||!Array.isArray($.steps_completed)||$.steps_completed.length!==1||!tt($.steps_completed[0],ut)||typeof $.created_at!="string"||!Number.isFinite(Date.parse($.created_at))||$.completed_at!==null||!q||typeof q!="object"||Array.isArray(q)||!S(q,{diagnosis:`${l}/diagnosis.md`})||!S(Object.keys($).sort(),["id","idea","status","steps_completed","created_at","completed_at","output_files"].sort()))throw new Error("planning-index-epic-invalid");const{last_scan:C,epics:z,...V}=R,X=A,Q=X?.epics,{last_scan:O,epics:W,...w}=X??{},{[e]:D,...H}=U;if(Q?.[e]!==void 0||!S(H,Q??{})||X!==void 0&&!S(V,w)||X===void 0&&(Object.keys(U).length!==1||!S(Object.keys(R).sort(),["version","next_epic_id","last_scan","existing_epics_discovered","epics"].sort())||R.version!=="1.0.0"||R.next_epic_id!==1||!S(R.existing_epics_discovered,[]))||typeof R.last_scan!="string"||!Number.isFinite(Date.parse(R.last_scan)))throw new Error("planning-index-drift");const k=v.map(E=>F("sha256").update(m(a(t.workspacePath,E))).digest("hex")),I=()=>v.every((E,T)=>{try{return P(t.workspacePath,E),F("sha256").update(m(a(t.workspacePath,E))).digest("hex")===k[T]}catch{return!1}});return Y(t,v,t.baseSha,o,I)}catch{throw new Error("private-execution-planning-diagnosis-admission-unverified")}}function Se(t,r,e,n,o,i){try{if(!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(r)||!/^P[1-9][0-9]{0,11}$/.test(e)||!/^[a-f0-9]{64}$/.test(n)||!/^[a-f0-9]{64}$/.test(o)||!/^[a-f0-9]{64}$/.test(i))throw new Error("planning-research-binding-invalid");const s=".neocortex/state.json",d=".neocortex/planning/planning.json",l=`.neocortex/planning/epic-${e}`,c=`${l}/research.md`;if(P(t.sourceRoot,s),P(t.workspacePath,s),P(t.sourceRoot,d),P(t.workspacePath,d),P(t.sourceRoot,c),P(t.workspacePath,c),x(a(t.sourceRoot,s)).size>8*1024*1024||x(a(t.workspacePath,s)).size>8*1024*1024||x(a(t.sourceRoot,d)).size>128*1024||x(a(t.workspacePath,d)).size>128*1024)throw new Error("planning-research-source-size-invalid");const f=m(a(t.sourceRoot,s));if(F("sha256").update(f).digest("hex")!==i||!f.equals(m(a(t.workspacePath,s))))throw new Error("planning-research-state-drift");const h=JSON.parse(f.toString("utf8")),p=Wt(h,r,e);if(p.diagnosisReceiptId!==n||p.intakeRevision!==o)throw new Error("planning-research-predecessor-mismatch");const u=h.epics[e].createEpicPlanningPhysical.artifactDigests;for(const[O,W]of Object.entries({idea:`${l}/idea.json`,diagnosis:`${l}/diagnosis.md`,enrichment:`${l}/enriched-prompt.md`,index:d}))if(P(t.sourceRoot,W),F("sha256").update(m(a(t.sourceRoot,W))).digest("hex")!==u[O])throw new Error("planning-research-source-artifact-drift");try{throw x(a(t.sourceRoot,c)),new Error("planning-research-already-exists")}catch(O){if(O.code!=="ENOENT")throw O}const g=[c,d],_=M(B(t.workspacePath,!0));if(_.paths.length!==g.length||_.paths.some(O=>!g.includes(O)))throw new Error("planning-research-write-scope-invalid");const j=x(a(t.workspacePath,c));if(!j.isFile()||j.isSymbolicLink()||j.size<64||j.size>256*1024)throw new Error("planning-research-document-invalid");const b=m(a(t.workspacePath,c),"utf8"),N=/^---\n([\s\S]{1,8192}?)\n---\n/.exec(b.replace(/\r\n/g,`
|
|
5
|
+
`))?.[1],y=O=>{const W=N?.split(`
|
|
6
|
+
`).filter(w=>w.startsWith(`${O}:`))??[];return W.length===1?W[0].slice(O.length+1).trim().replace(/^(?:"(.*)"|'(.*)')$/,"$1$2"):void 0};if(!N||y("epic_id")!==e||y("status")!=="completed"||!tt(y("step"),Rt)||!b.slice(N.length+8).trim())throw new Error("planning-research-document-identity-invalid");const A=JSON.parse(m(a(t.sourceRoot,d),"utf8")),R=JSON.parse(m(a(t.workspacePath,d),"utf8"));if(!A||typeof A!="object"||Array.isArray(A)||!R||typeof R!="object"||Array.isArray(R))throw new Error("planning-research-index-invalid");const U=A,L=R,$=U.epics,q=L.epics,C=$?.[e];if(!$||Array.isArray($)||!q||Array.isArray(q)||!C||Array.isArray(C)||C.id!==e||C.idea!==p.rawIntent||C.status!=="diagnosed"||!Array.isArray(C.steps_completed)||C.steps_completed.length!==1||!tt(C.steps_completed[0],ut)||!S(C.output_files,{diagnosis:`${l}/diagnosis.md`})||typeof L.last_scan!="string"||!Number.isFinite(Date.parse(L.last_scan)))throw new Error("planning-research-index-predecessor-invalid");const z={...C,status:"researched",steps_completed:[...C.steps_completed,y("step")],output_files:{diagnosis:`${l}/diagnosis.md`,research:c}},V={...U,last_scan:L.last_scan,epics:{...$,[e]:z}};if(!S(L,V))throw new Error("planning-research-index-drift");const X=g.map(O=>F("sha256").update(m(a(t.workspacePath,O))).digest("hex")),Q=()=>g.every((O,W)=>{try{return P(t.workspacePath,O),F("sha256").update(m(a(t.workspacePath,O))).digest("hex")===X[W]}catch{return!1}});return Y(t,g,t.baseSha,bt(t.sourceRoot),Q)}catch{throw new Error("private-execution-planning-research-admission-unverified")}}function $e(t,r,e,n,o,i,s){try{if(!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(r)||!/^P[1-9][0-9]{0,11}$/.test(e)||[n,o,i,s].some(w=>!/^[a-f0-9]{64}$/.test(w)))throw new Error("planning-generation-binding-invalid");const d=".neocortex/state.json",l=".neocortex/planning/planning.json",c=`.neocortex/planning/epic-${e}`,f=`docs/epics/epic-${e}.md`;for(const w of[d,l,`${c}/idea.json`,`${c}/diagnosis.md`,`${c}/enriched-prompt.md`,`${c}/research.md`]){P(t.sourceRoot,w),P(t.workspacePath,w);const D=m(a(t.sourceRoot,w));if(w!==l&&!D.equals(m(a(t.workspacePath,w)))||!D.equals(G(t.sourceRoot,["show",`HEAD:${w}`])))throw new Error("planning-generation-predecessor-uncommitted")}const h=m(a(t.sourceRoot,d));if(h.byteLength>8*1024*1024||F("sha256").update(h).digest("hex")!==s)throw new Error("planning-generation-state-drift");const p=JSON.parse(h.toString("utf8")),v=Vt(p,r,e);if(v.diagnosisReceiptId!==n||v.researchReceiptId!==o||v.intakeRevision!==i)throw new Error("planning-generation-predecessor-mismatch");const u=p.epics[e],g=u.createEpicPlanningPhysical.artifactDigests,_=u.createEpicPlanningResearchPhysical.artifactDigests,j={idea:`${c}/idea.json`,diagnosis:`${c}/diagnosis.md`,enrichment:`${c}/enriched-prompt.md`,research:`${c}/research.md`};for(const[w,D]of Object.entries(j)){const H=w==="research"?_.research:g[w];if(F("sha256").update(m(a(t.sourceRoot,D))).digest("hex")!==H)throw new Error("planning-generation-artifact-drift")}if(F("sha256").update(m(a(t.sourceRoot,l))).digest("hex")!==_.index)throw new Error("planning-generation-index-drift");const b=M(B(t.workspacePath,!0)),N=new RegExp(`^docs/stories/${e}\\.([0-9]{2})\\.story\\.md$`),y=b.paths.filter(w=>N.test(w)).sort((w,D)=>Number(N.exec(w)[1])-Number(N.exec(D)[1]));if(y.length<1||y.length>24||y.some((w,D)=>N.exec(w)[1]!==String(D+1).padStart(2,"0"))||b.paths.length!==y.length+2||b.paths.some(w=>w!==f&&w!==l&&!N.test(w)))throw new Error("planning-generation-write-scope-invalid");const A=[f,l,...y];for(const w of[f,...y]){P(t.sourceRoot,w),P(t.workspacePath,w);try{throw x(a(t.sourceRoot,w)),new Error("planning-generation-path-collision")}catch(H){if(H.code!=="ENOENT")throw H}const D=x(a(t.workspacePath,w));if(!D.isFile()||D.isSymbolicLink()||D.size<128||D.size>(w===f?512:128)*1024)throw new Error("planning-generation-document-invalid")}const R=(w,D)=>{const k=/^---\n([\s\S]{1,8192}?)\n---\n/.exec(w.replace(/\r\n/g,`
|
|
7
7
|
`))?.[1]?.split(`
|
|
8
|
-
`).filter(I=>I.startsWith(`${D}:`))??[];return k.length===1?k[0].slice(D.length+1).trim().replace(/^(?:"(.*)"|'(.*)')$/,"$1$2"):void 0},U=
|
|
9
|
-
`))?.[1]??"";if(R(H,"id")!==`${e}.${String(w+1).padStart(2,"0")}`||R(H,"epic_id")!==e||/^\s*epic\s*:/m.test(k)||R(H,"status")!=="backlog"||!H.includes("## Acceptance Criteria")||!/\bGiven\b[\s\S]*\bWhen\b[\s\S]*\bThen\b/.test(H))throw new Error("planning-generation-story-invalid")}const L=JSON.parse(
|
|
8
|
+
`).filter(I=>I.startsWith(`${D}:`))??[];return k.length===1?k[0].slice(D.length+1).trim().replace(/^(?:"(.*)"|'(.*)')$/,"$1$2"):void 0},U=m(a(t.workspacePath,f),"utf8");if(R(U,"id")!==e||R(U,"stories_count")!==String(y.length)||!U.includes("## Stories"))throw new Error("planning-generation-epic-invalid");for(const[w,D]of y.entries()){const H=m(a(t.workspacePath,D),"utf8"),k=/^---\n([\s\S]{1,8192}?)\n---\n/.exec(H.replace(/\r\n/g,`
|
|
9
|
+
`))?.[1]??"";if(R(H,"id")!==`${e}.${String(w+1).padStart(2,"0")}`||R(H,"epic_id")!==e||/^\s*epic\s*:/m.test(k)||R(H,"status")!=="backlog"||!H.includes("## Acceptance Criteria")||!/\bGiven\b[\s\S]*\bWhen\b[\s\S]*\bThen\b/.test(H))throw new Error("planning-generation-story-invalid")}const L=JSON.parse(m(a(t.sourceRoot,l),"utf8")),$=JSON.parse(m(a(t.workspacePath,l),"utf8")),q=L.epics,C=$.epics,z=q?.[e],V=C?.[e];if(!q||!C||!z||!V||z.id!==e||z.status!=="researched"||!Array.isArray(z.steps_completed)||z.steps_completed.length!==2||!tt(z.steps_completed[0],ut)||!tt(z.steps_completed[1],Rt)||!S(z.output_files,{diagnosis:`${c}/diagnosis.md`,research:`${c}/research.md`})||typeof $.last_scan!="string"||!Number.isFinite(Date.parse($.last_scan))||typeof V.completed_at!="string"||!Number.isFinite(Date.parse(V.completed_at)))throw new Error("planning-generation-index-predecessor-invalid");const X=V.steps_completed?.[2];if(!tt(X,Qt))throw new Error("planning-generation-index-transition-invalid");const Q={...L,last_scan:$.last_scan,epics:{...q,[e]:{...z,status:"generated",steps_completed:[...z.steps_completed,X],completed_at:V.completed_at,output_files:{...z.output_files,epic:f,stories:y}}}};if(!S($,Q))throw new Error("planning-generation-index-transition-invalid");const O=A.map(w=>F("sha256").update(m(a(t.workspacePath,w))).digest("hex")),W=()=>A.every((w,D)=>{try{return P(t.workspacePath,w),F("sha256").update(m(a(t.workspacePath,w))).digest("hex")===O[D]}catch{return!1}});return Y(t,A,t.baseSha,bt(t.sourceRoot),W)}catch{throw new Error("private-execution-planning-generation-admission-unverified")}}function Oe(t,r,e){try{if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(e))throw new Error("story-id-invalid");const n=".neocortex/state.json";P(r.sourceRoot,n),P(r.workspacePath,n);const o=m(a(r.sourceRoot,n));if(!o.equals(m(a(r.workspacePath,n))))throw new Error("state-drift");const i=JSON.parse(o.toString("utf8")),s=i?.stories?.[e],d=s?.files_to_modify;if(i?.schema_version!==1||s?.id!==e||!Array.isArray(d)||d.length<1||d.length>st||d.some(f=>typeof f!="string"||!rt(f)||f.length>1024||/[\r\n]/.test(f))||new Set(d).size!==d.length)throw new Error("write-set-invalid");const l=d,c=l.filter(f=>{if(!f.startsWith("docs/stories/")||!f.endsWith(".story.md"))return!1;P(r.sourceRoot,f),P(r.workspacePath,f);const h=m(a(r.sourceRoot,f));if(!h.equals(m(a(r.workspacePath,f))))throw new Error("story-drift");const v=/^---\r?\n([\s\S]{1,8192}?)\r?\n---(?:\r?\n|$)/.exec(h.toString("utf8"))?.[1]?.split(/\r?\n/).filter(u=>u.startsWith("id:"))??[];return v.length===1&&v[0].slice(3).trim().replace(/^(["'])(.*)\1$/,"$2")===e});if(c.length!==1)throw new Error("story-target-ambiguous");return`${t}
|
|
10
|
+
|
|
11
|
+
Private story handoff (local only):
|
|
12
|
+
${JSON.stringify({storyId:e,storyPath:c[0],allowedPaths:[...l].sort()})}
|
|
13
|
+
Work from this isolated checkout's current directory. Use the exact storyPath above for the delivered current step; do not use an unresolved story-file placeholder or infer a filename. Persist the current step's actual result in the declared files; a final chat response alone is not a saved candidate. Modify only allowedPaths and preserve story identity and the write set. Do not operate Git, change unrelated stories, grant root QA/checkpoint authority, or declare the story, epic or pipeline complete. If required inputs are unavailable, report failure without inventing evidence or completion.
|
|
14
|
+
`}catch{throw new Error("private-execution-state-step-handoff-unverified")}}function Te(t,r){try{if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(r))throw new Error("story-id-invalid");const e=".neocortex/state.json";P(t.sourceRoot,e),P(t.workspacePath,e);const n=JSON.parse(m(a(t.sourceRoot,e),"utf8")),o=JSON.parse(m(a(t.workspacePath,e),"utf8"));if(!n||typeof n!="object"||Array.isArray(n)||!o||typeof o!="object"||Array.isArray(o))throw new Error("state-invalid");const i=n,s=o,d=i.stories,l=s.stories,c=d?.[r],f=l?.[r],h=c?.files_to_modify;if(i.schema_version!==1||s.schema_version!==1||!d||!l||!c||!f||c.id!==r||f.id!==r||f.epic_id!==c.epic_id||!Array.isArray(h)||h.length===0||h.length>st||h.some(R=>typeof R!="string"||!rt(R)||R.length>1024)||new Set(h).size!==h.length||!S(f.files_to_modify,h))throw new Error("write-set-invalid");const{[r]:p,...v}=d,{[r]:u,...g}=l,{stories:_,last_updated:j,...b}=i,{stories:N,last_updated:y,...A}=s;if(!S(g,v)||!S(A,b))throw new Error("state-unrelated-drift");return Y(t,[...h].sort(),t.baseSha)}catch{throw new Error("private-execution-state-step-admission-unverified")}}function je(t,r,e){if(r==="chaos-plan"&&e==="chaos-quarterly-v1")try{const o=new Date,i=`Q${Math.floor(o.getUTCMonth()/3)+1}-${o.getUTCFullYear()}`,s=M(B(t.workspacePath,!0)).paths,d=`tools/chaos/${i}-plan.md`,l=`.neocortex/chaos-history/${i}.md`,c=s.filter(u=>u.startsWith("tools/chaos/experiments/")),f=c.map(u=>/^tools\/chaos\/experiments\/(chaos-mesh|litmus|aws-fis)-(?:PodKill|NetworkChaos|IOChaos|StressChaos|TimeChaos|pod-kill|network-chaos|io-chaos|stress-chaos|time-chaos)-([a-z0-9]+(?:-[a-z0-9]+)*)\.yaml$/.exec(u));if(!s.includes(d)||!s.includes(l)||c.length<5||c.length>10||s.length!==c.length+2||f.some(u=>!u)||new Set(f.map(u=>u[1])).size!==1)throw new Error("chaos-write-set-invalid");for(const u of s)if(P(t.workspacePath,u),x(a(t.workspacePath,u)).size===0)throw new Error("chaos-empty-artifact");const h=m(a(t.workspacePath,l),"utf8");if(!h.includes(i)||!/\bPLANNED\b/.test(h))throw new Error("chaos-history-invalid");const v=G(t.workspacePath,["ls-tree","-z","HEAD","--",l]).length>0?G(t.workspacePath,["show",`HEAD:${l}`]).toString("utf8"):"";if(v&&!h.startsWith(v))throw new Error("chaos-history-not-append-only");return Y(t,s,t.baseSha)}catch{throw new Error("private-execution-project-step-admission-unverified")}const n=r==="sync-openapi"&&e==="sync-openapi-contract-v1"?["docs/architecture/api-contracts.md","docs/api/openapi.yaml"]:r==="tech-debt"&&e==="tech-debt-registry-v1"?[".neocortex/tech-debt-registry.json"]:void 0;if(!n)throw new Error("private-execution-project-step-admission-unverified");try{if(r==="tech-debt"){const o=".neocortex/tech-debt-registry.json";P(t.workspacePath,o);const i=JSON.parse(m(a(t.workspacePath,o),"utf8"));if(!i||typeof i!="object"||Array.isArray(i))throw new Error("registry-invalid");const s=i;if(s.schema_version!==2||s.version!==void 0&&s.version!==2||!Array.isArray(s.items))throw new Error("registry-invalid")}return Y(t,n,t.baseSha)}catch{throw new Error("private-execution-project-step-admission-unverified")}}function Tt(t,r){const e=t==="arch-prd"&&r==="arch-prd-docs-v1"?["docs/architecture/prd.md","docs/architecture/product-experience.md"]:t==="arch-architecture"&&r==="arch-architecture-doc-v1"?["docs/architecture/architecture.md"]:t==="arch-fitness-functions"&&r==="arch-fitness-tools-v1"?["tools/architecture/dependency-cruiser.config.js","tools/architecture/archunit-test.ts","tools/architecture/.eslintrc.boundaries.js"]:t==="arch-api-contracts"&&r==="arch-api-contracts-docs-v1"?["docs/architecture/api-contracts.md","docs/api/openapi.yaml"]:t==="arch-api-integrations"&&r==="arch-api-integrations-doc-v1"?["docs/architecture/api-integrations.md"]:t==="arch-database"&&r==="arch-database-doc-v1"?["docs/architecture/database-schema.md"]:t==="arch-security"&&r==="arch-security-doc-v1"?["docs/architecture/cyber-security.md"]:t==="arch-design-system"&&r==="arch-design-system-doc-v1"?["docs/architecture/atomic-design-system.md"]:t==="arch-performance"&&r==="arch-performance-doc-v1"?["docs/architecture/performance-strategy.md"]:t==="arch-testing"&&r==="arch-testing-doc-v1"?["docs/architecture/testing-strategy.md"]:t==="arch-infrastructure"&&r==="arch-infrastructure-doc-v1"?["docs/architecture/infrastructure-deploy.md"]:t==="arch-review"&&r==="arch-review-doc-v1"?["docs/architecture/review-consolidation.md"]:t==="update-memory"&&r==="arch-memory-canonical-v1"?["NEOCORTEX.md"]:null;return e===null?null:Object.freeze(e)}function Ne(t,r,e,n="all"){const o=Tt(r,e);if(!o)throw new Error("private-execution-architecture-admission-unverified");return`${t}
|
|
10
15
|
|
|
11
16
|
Private architecture handoff (local only):
|
|
12
|
-
${JSON.stringify({allowedPaths:
|
|
13
|
-
${
|
|
17
|
+
${JSON.stringify({allowedPaths:o})}
|
|
18
|
+
${n==="non-ui"?`The server admitted a signed non-UI scope for this snapshot. Preserve the backend-only scope: design-system and UX phases are not applicable. Do not require or generate interface artifacts.
|
|
14
19
|
`:""}Write exactly the listed nonempty artifacts inside this isolated clone. Existing compliant listed artifacts may remain unchanged; all listed artifacts must exist after execution. Place any necessary scope notes inside those artifacts. Do not edit README, package files, other documents, state, Git, QA records or configuration outside the listed paths. Do not install dependencies, use network, deploy or continue to another stage. Preserve existing arch:keep blocks byte-for-byte. Do not add new arch:keep markers. For managed memory, preserve all bytes outside its existing managed block. Root independently reviews artifacts and owns continuation, Git and acceptance.
|
|
15
|
-
`}function
|
|
20
|
+
`}function De(t,r,e,n,o){const i=Tt(r,e);if(!i||!/^P[1-9][0-9]{0,11}$/.test(n)||!/^[a-f0-9]{64}$/.test(o))throw new Error("private-execution-architecture-admission-unverified");try{P(t.workspacePath,".neocortex/state.json");const s=JSON.parse(m(a(t.workspacePath,".neocortex/state.json"),"utf8"));if(!s||typeof s!="object"||Array.isArray(s))throw new Error("state-invalid");const d=s,c=d.archPlan?.execution,f=d.epics;if(!c||c.currentStageCommand!==r||c.targetEpicId!==n||c.graphRevision!==o||!f||!Object.hasOwn(f,n))throw new Error("state-binding-mismatch");if(r==="update-memory"){if(c.continuationState!=="delegate"||c.reviewDecision?.decision!=="approved")throw new Error("memory-root-review-missing");const h="NEOCORTEX.md";if(!M(B(t.workspacePath,!0)).paths.includes(h))throw new Error("memory-effect-missing");P(t.sourceRoot,h),P(t.workspacePath,h);const p=m(a(t.sourceRoot,h),"utf8"),v=m(a(t.workspacePath,h),"utf8"),u="<!-- NEOCORTEX-MEMORY-START -->",g="<!-- NEOCORTEX-MEMORY-END -->",_=y=>{if(y.split(u).length!==2||y.split(g).length!==2||y.indexOf(u)>=y.indexOf(g))throw new Error("memory-markers-invalid");const A=y.indexOf(u)+u.length,R=y.indexOf(g);return{before:y.slice(0,A),body:y.slice(A,R),after:y.slice(R)}},j=_(p),b=_(v);if(j.before!==b.before||j.after!==b.after||j.body===b.body||Buffer.byteLength(v,"utf8")>32768||v.split(`
|
|
16
21
|
`).length>240)throw new Error("memory-managed-block-invalid");const N=new Set(j.body.split(`
|
|
17
22
|
`));for(const y of b.body.split(`
|
|
18
|
-
`))N.has(y)||Mt(y)}if(r==="arch-prd"){const h="docs/architecture/prd.md";if(!M(
|
|
23
|
+
`))N.has(y)||Mt(y)}if(r==="arch-prd"){const h="docs/architecture/prd.md";if(!M(B(t.workspacePath,!0)).paths.includes(h))throw new Error("prd-effect-missing");if(P(t.workspacePath,h),x(a(t.workspacePath,h)).size===0)throw new Error("prd-empty")}if(r==="arch-api-contracts"||r==="arch-fitness-functions"||r==="arch-api-integrations"||r==="arch-database"||r==="arch-security"||r==="arch-design-system"||r==="arch-performance"||r==="arch-testing"||r==="arch-infrastructure"||r==="arch-review"){const h=M(B(t.workspacePath,!0)).paths;for(const p of i){if(!h.includes(p)&&G(t.workspacePath,["cat-file","-t",`${t.baseSha}:${p}`]).toString("utf8").trim()!=="blob")throw new Error("architecture-required-effect-missing");if(P(t.workspacePath,p),x(a(t.workspacePath,p)).size===0)throw new Error("architecture-required-effect-empty");if(r==="arch-fitness-functions"){P(t.sourceRoot,p);const v=nt(a(t.sourceRoot,p))?m(a(t.sourceRoot,p),"utf8"):"",u=m(a(t.workspacePath,p),"utf8"),g=At(v),_=At(u);if(!S(_,g))throw new Error("architecture-keep-marker-changed")}}}return Y(t,i,t.baseSha)}catch{throw new Error("private-execution-architecture-admission-unverified")}}function Fe(t,r,e,n){try{if(!/^P[1-9][0-9]{0,11}$/.test(r)||!/^[a-f0-9]{64}$/.test(e)||n.schemaVersion!==1||n.targetEpicId!==r)throw new Error("binding-invalid");const o=Lt(t.sourceRoot,r),i=zt(t.workspacePath,r);if(!S(o,n)||!S(i,n))throw new Error("write-set-invalid");P(t.workspacePath,".neocortex/state.json");const s=JSON.parse(m(a(t.workspacePath,".neocortex/state.json"),"utf8"));if(!s||typeof s!="object"||Array.isArray(s))throw new Error("state-invalid");const d=s,c=d.archPlan?.execution,f=d.epics;if(!c||c.currentStageCommand!=="arch-ux-design"||c.continuationState!=="delegate"||c.targetEpicId!==r||c.graphRevision!==e||!f||!Object.hasOwn(f,r))throw new Error("stage-invalid");const h=M(B(t.workspacePath,!0)).paths;if(h.length!==n.pathCount||h.some(p=>!n.paths.includes(p)))throw new Error("agent-path-unclaimed");for(const p of n.paths){P(t.sourceRoot,p),P(t.workspacePath,p);const v=x(a(t.workspacePath,p));if(!v.isFile()||v.isSymbolicLink()||v.size<1)throw new Error("effect-empty");const u=new TextDecoder("utf-8",{fatal:!0}).decode(m(a(t.workspacePath,p)));if(!u.trim()||u.includes("\0"))throw new Error("effect-invalid")}return Ht(t.workspacePath,n),Y(t,n.paths,t.baseSha)}catch{throw new Error("private-execution-ux-admission-unverified")}}function Be(t,r,e,n,o,i){try{if(!/^P[1-9][0-9]{0,11}$/.test(r)||!/^[a-f0-9]{64}$/.test(e)||n.targetEpicId!==r||n.graphRevision!==e||o.schemaVersion!==1)throw new Error("binding-invalid");const s=Ct(t.sourceRoot);if(!s||!S(s.receipt,n))throw new Error("answers-invalid");const d=_t(t.sourceRoot,s.answers.generateProvider),l=_t(t.workspacePath,s.answers.generateProvider);if(d.outcome!=="ready"||l.outcome!=="ready"||!S(d.writeSet,o)||!S(l.writeSet,o))throw new Error("write-set-invalid");const c=M(B(t.workspacePath,!0)).paths;if(c.some(u=>!o.paths.includes(u)))throw new Error("agent-path-unclaimed");let f=0,h=0;for(const u of o.paths){if(P(t.sourceRoot,u),nt(a(t.sourceRoot,u))||!c.includes(u))throw new Error("effect-missing-or-overwrite");P(t.workspacePath,u);const g=x(a(t.workspacePath,u));if(!g.isFile()||g.size<1)throw new Error("effect-empty");const _=new TextDecoder("utf-8",{fatal:!0}).decode(m(a(t.workspacePath,u))),j=o.interactions.find(N=>N.filePath===u);if(u!==o.providerPath&&!j)throw new Error("private-execution-pact-interaction-missing");const b=Jt(u,_,s.answers.brokerUrl,j,t.workspacePath,s.answers.matchersAggressive);b.consumerBinding==="app-import-candidate"&&f++,b.consumerBinding==="mock-only-scaffold"&&h++}let p=o.paths;if(i){const u=Ut(t.sourceRoot,s.answers.generateProvider),g=_=>F("sha256").update(_).digest("hex");if(i.schemaVersion!==1||i.outcome!=="candidate-unverified"||i.executionVerified!==!1||i.sourceManifestSha256!==g(u.sourceText)||i.sourceLockSha256!==(u.sourceLockText===null?null:g(u.sourceLockText))||i.manifestText!==u.candidateText||!lt(t.sourceRoot,t.workspacePath,t.baseSha,"package.json")||!lt(t.sourceRoot,t.workspacePath,t.baseSha,"package-lock.json"))throw new Error("toolchain-binding-invalid");for(const _ of["package.json","package-lock.json"]){P(t.sourceRoot,_),P(t.workspacePath,_);const j=_==="package.json"?u.sourceText:u.sourceLockText,b=nt(a(t.workspacePath,_))?m(a(t.workspacePath,_),"utf8"):null;if(j!==b)throw new Error("toolchain-clone-raced")}if(mt(a(t.workspacePath,"package.json"),i.manifestText),mt(a(t.workspacePath,"package-lock.json"),i.lockText),Yt(t.workspacePath,s.answers.generateProvider).outcome!=="manifest-aligned")throw new Error("toolchain-candidate-invalid");p=[...o.paths,"package.json","package-lock.json"]}const v=Y(t,p,t.baseSha);return Object.freeze({...v,consumerBindingCandidateCount:f,consumerScaffoldCount:h})}catch{throw new Error("private-execution-pact-admission-unverified")}}function Ce(t,r,e,n=new Date().toISOString()){try{const o=xt(t.sourceRoot,r);if(!S(o,e)||!pt(t.sourceRoot,t.workspacePath,e.prdPath)||e.aggregates.some(h=>!pt(t.sourceRoot,t.workspacePath,h.implementationFile))||e.writeSet.length===0)throw new Error("plan-drift");const i=M(B(t.workspacePath,!0)).paths;if(!S(i,e.writeSet))throw new Error("agent-path-unclaimed");const s=new Map;for(const h of e.aggregates){P(t.sourceRoot,h.testFile),P(t.workspacePath,h.testFile);const p=x(a(t.workspacePath,h.testFile));if(!p.isFile()||p.isSymbolicLink()||p.size<1||p.size>Z)throw new Error("test-invalid");const v=m(a(t.workspacePath,h.testFile)),u=new TextDecoder("utf-8",{fatal:!0}).decode(v),g=e.language==="typescript"?(u.match(/\b(?:it|test)\s*\(/g)??[]).length:(u.match(/^def\s+test_[A-Za-z0-9_]+\s*\(/gm)??[]).length;if(!u.trim()||u.includes("\0")||g<h.invariantCount||/\b(?:it|test|describe)\s*\.\s*(?:skip|todo|only)\s*\(/.test(u)||!u.includes(String(e.numRuns)))throw new Error("test-invalid");e.language==="typescript"&&Kt({source:u,testFile:h.testFile,implementationFile:h.implementationFile,invariantCount:h.invariantCount,numRuns:e.numRuns}),s.set(h.testFile,F("sha256").update(v).digest("hex"))}P(t.sourceRoot,e.prdPath),P(t.workspacePath,e.prdPath);const d=m(a(t.workspacePath,e.prdPath)),l=new TextDecoder("utf-8",{fatal:!0}).decode(d),c=Xt(l,e,n);mt(a(t.workspacePath,e.prdPath),c);const f=F("sha256").update(c).digest("hex");return Y(t,[...e.writeSet,e.prdPath],t.baseSha,void 0,()=>{try{return!S(xt(t.sourceRoot,r),e)||e.aggregates.some(h=>!pt(t.sourceRoot,t.workspacePath,h.implementationFile))||F("sha256").update(m(a(t.workspacePath,e.prdPath))).digest("hex")!==f?!1:[...s].every(([h,p])=>F("sha256").update(m(a(t.workspacePath,h))).digest("hex")===p)}catch{return!1}})}catch{throw new Error("private-execution-property-admission-unverified")}}export{De as admitPrivateArchitectureStageWorkspace,Re as admitPrivateEpicClaimWorkspace,$e as admitPrivateGenerateEpicWorkspace,Ae as admitPrivateIdeaDiagnosisWorkspace,Se as admitPrivateIdeaResearchWorkspace,Be as admitPrivatePactWorkspace,je as admitPrivateProjectStepWorkspace,Ce as admitPrivatePropertyTestWorkspace,Te as admitPrivateStateBoundStepWorkspace,Fe as admitPrivateUxWorkspace,xe as admitPrivateYoloFrozenWorkspace,Ne as appendPrivateArchitectureHandoff,Oe as appendPrivateStateBoundStepHandoff,Tt as privateArchitectureStagePaths,ve as privateYoloSourceFileMatchesSnapshot,be as verifyPrivateYoloRejectedCandidateOrigin,_e as verifyPrivateYoloSnapshotBoundary};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { YOLO_INVOKE_ENVELOPE_CAPABILITY } from '../../../shared/dist/yolo/spec-envelope.js';
|
|
2
|
+
export type YoloInvokeEnvelopeCapabilityReason = 'supported' | 'fetch-unavailable' | 'request-failed' | 'http-rejected' | 'response-too-large' | 'response-invalid' | 'capability-missing';
|
|
3
|
+
export interface YoloInvokeEnvelopeCapabilityProbe {
|
|
4
|
+
readonly supported: boolean;
|
|
5
|
+
readonly capability: typeof YOLO_INVOKE_ENVELOPE_CAPABILITY;
|
|
6
|
+
readonly reason: YoloInvokeEnvelopeCapabilityReason;
|
|
7
|
+
readonly serverVersion?: string;
|
|
8
|
+
readonly publicSafe: true;
|
|
9
|
+
}
|
|
10
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Pick<Response, 'ok' | 'text'>>;
|
|
11
|
+
/**
|
|
12
|
+
* Non-mutating, fail-closed compatibility probe for targeted YOLO requests.
|
|
13
|
+
* Older strict servers must be rejected before local release-gate execution.
|
|
14
|
+
*/
|
|
15
|
+
export declare function probeYoloInvokeEnvelopeCapability(serverUrl: string, fetcher?: FetchLike | undefined): Promise<YoloInvokeEnvelopeCapabilityProbe>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{YOLO_INVOKE_ENVELOPE_CAPABILITY as u}from"../../../shared/dist/yolo/spec-envelope.js";const y=16*1024,b=/^[0-9]{1,6}\.[0-9]{1,6}\.[0-9]{1,6}(?:-[A-Za-z0-9.-]{1,40})?$/;function e(n,a,t){return Object.freeze({supported:n,capability:u,reason:a,...t&&b.test(t)?{serverVersion:t}:{},publicSafe:!0})}async function h(n,a=globalThis.fetch){if(!a)return e(!1,"fetch-unavailable");const t=new AbortController,l=setTimeout(()=>t.abort(),5e3);l.unref?.();try{const c=await a(`${n.replace(/\/+$/,"")}/api/v1/health`,{method:"GET",headers:{accept:"application/json"},signal:t.signal});if(!c.ok)return e(!1,"http-rejected");const f=await c.text();if(Buffer.byteLength(f,"utf8")>y)return e(!1,"response-too-large");let r;try{r=JSON.parse(f)}catch{return e(!1,"response-invalid")}if(!r||typeof r!="object"||Array.isArray(r))return e(!1,"response-invalid");const i=r,s=i.capabilities,o=typeof i.version=="string"?i.version:void 0;return!Array.isArray(s)||s.some(p=>typeof p!="string"||p.length>80)?e(!1,"response-invalid",o):s.includes(u)?e(!0,"supported",o):e(!1,"capability-missing",o)}catch{return e(!1,"request-failed")}finally{clearTimeout(l)}}export{h as probeYoloInvokeEnvelopeCapability};
|
|
@@ -10,4 +10,11 @@ export interface CollectYoloSpecEnvelopeOptions {
|
|
|
10
10
|
/** Public-safe count only; omitted supporting refs never silently imply coverage. */
|
|
11
11
|
readonly onOmittedReferences?: (count: number) => void;
|
|
12
12
|
}
|
|
13
|
+
/** Resolve only an explicit story target. Inline YOLO text intentionally has no match. */
|
|
14
|
+
export declare function extractTargetedYoloStoryId(args: string): string | null;
|
|
13
15
|
export declare function collectYoloSpecEnvelope(options: CollectYoloSpecEnvelopeOptions): YoloSpecEnvelopeV1;
|
|
16
|
+
/**
|
|
17
|
+
* Reissue a precollected physical snapshot with a fresh bounded transport time.
|
|
18
|
+
* The caller still performs the final disk/HEAD collection and digest comparison.
|
|
19
|
+
*/
|
|
20
|
+
export declare function refreshPrecollectedYoloSpecEnvelope(envelope: YoloSpecEnvelopeV1, collectedAt?: string): YoloSpecEnvelopeV1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{execFileSync as L}from"node:child_process";import{existsSync as S,readFileSync as
|
|
2
|
-
${Object.entries(o.metadata).map(([
|
|
1
|
+
import{execFileSync as L}from"node:child_process";import{existsSync as S,readFileSync as $,realpathSync as w,statSync as R}from"node:fs";import{join as f,sep as b}from"node:path";import{createYoloSpecEnvelopeV1 as E,YOLO_SPEC_ARTIFACT_LIMIT_BYTES as O,YOLO_SPEC_MAX_ARTIFACTS as g,YOLO_SPEC_TOTAL_LIMIT_BYTES as I}from"../../../shared/dist/yolo/spec-envelope.js";import{inspectFrontmatterContext as v}from"../../../shared/dist/frontmatter-context-contract.js";const C=["core/templates/specs/feature-spec-template.md","core/templates/specs/architecture-spec-template.md","core/templates/specs/contract-spec-template.md","core/templates/specs/story-spec-template.md","core/templates/specs/traceability-matrix-template.md"],P=/(?:^|[\s([`'";])((?:docs\/(?:stories|epics|specs|architecture|examples)\/|core\/templates\/specs\/)[A-Za-z0-9_./-]+\.(?:md|mdx|feature))(?:$|[\s)\]`'",;])/gm,W=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function Z(e){const r=[...e.matchAll(/(?:^|\s)@?docs\/stories\/([A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+)\.story\.md(?=\s|$)/g)].map(c=>c[1]),s=e.trim().split(/\s+/).slice(1).map(c=>c.replace(/^@/,"")).filter(c=>W.test(c)),o=[...new Set([...r,...s])];return o.length===1?o[0]:null}function A(e){return e.startsWith("core/templates/")?"template":e.startsWith("docs/epics/")?"epic":e.startsWith("docs/stories/")&&e.endsWith(".story.md")?"story":e.endsWith(".rtm.md")?"traceability":e.toLowerCase().includes("adr")?"adr":e.toLowerCase().includes("contract")?"contract":e.toLowerCase().includes("nfr")?"nfr":e.endsWith(".feature")?"bdd":e.toLowerCase().includes("traceability")?"traceability":e.startsWith("docs/examples/")?"example":"spec"}function z(e){return[...new Set([...e.matchAll(P)].map(r=>r[1]).filter(r=>!!r))].sort()}function a(e,r){const s=w(e);let o;try{o=w(f(s,r))}catch{throw new Error("yolo-spec-envelope-required")}if(!o.startsWith(`${s}${b}`))throw new Error("yolo-spec-envelope-path-out-of-scope");if(!R(o).isFile())throw new Error("yolo-spec-envelope-unsafe");if(R(o).size>O)throw new Error("yolo-spec-envelope-too-large");return $(o,"utf8")}function m(e,r){const o=v(e,{context:r==="story"?"story-target":"epic-target",explicitlySelected:!0});if(o.status==="malformed"||o.status==="oversized")throw new Error("yolo-spec-envelope-unsafe");if(o.status==="absent")return e;const c=e.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n/);if(!c)throw new Error("yolo-spec-envelope-unsafe");return`---
|
|
2
|
+
${Object.entries(o.metadata).map(([n,l])=>`${n}: ${JSON.stringify(l)}`).join(`
|
|
3
3
|
`)}
|
|
4
4
|
---
|
|
5
|
-
${e.slice(
|
|
5
|
+
${e.slice(c[0].length)}`}function _(e){try{return L("git",["-C",e,"rev-parse","HEAD"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).trim()}catch{throw new Error("yolo-spec-envelope-stale")}}function H(e){const r=`docs/stories/${e.storyId}.story.md`,s=`docs/epics/epic-${e.epicId}.md`,o=e.headSha??_(e.projectRoot),c=m(a(e.projectRoot,r),"story"),u=m(a(e.projectRoot,s),"epic"),n=[{kind:"story",path:r,content:c},{kind:"epic",path:s,content:u}],l=new Set([`docs/stories/${e.storyId}.spec.md`,`docs/stories/${e.storyId}.tasks.md`,`docs/stories/${e.storyId}.rtm.md`]),h=[...new Set([...z(c),...[...l].filter(t=>S(f(e.projectRoot,t)))])].sort(),T=[...h.filter(t=>l.has(t)),...h.filter(t=>!l.has(t))];let p=n.reduce((t,i)=>t+Buffer.byteLength(i.content,"utf8"),0),y=0;for(const t of T){if(t===r||t===s||!S(f(e.projectRoot,t)))continue;if(t.startsWith("docs/stories/")&&t.endsWith(".story.md")||t.startsWith("docs/epics/"))throw new Error("yolo-spec-envelope-target-mismatch");const i=a(e.projectRoot,t),d=Buffer.byteLength(i,"utf8");if(n.length>=g||p+d>I){if(l.has(t))throw new Error("yolo-spec-envelope-too-large");y+=1;continue}n.push({kind:A(t),path:t,content:i}),p+=d}y&&e.onOmittedReferences?.(y);for(const t of C){if(t===r||t===s||h.includes(t)||!S(f(e.projectRoot,t)))continue;const i=a(e.projectRoot,t),d=Buffer.byteLength(i,"utf8");n.length>=g||p+d>I||(n.push({kind:A(t),path:t,content:i}),p+=d)}const j=E({storyId:e.storyId,epicId:e.epicId,targetPath:r,inputSha256:e.inputSha256,headSha:o,collectedAt:e.collectedAt??new Date().toISOString(),artifacts:n}),x=e.headSha??_(e.projectRoot);if(o!==x||m(a(e.projectRoot,r),"story")!==c||m(a(e.projectRoot,s),"epic")!==u||n.some(t=>t.kind!=="story"&&t.kind!=="epic"&&a(e.projectRoot,t.path)!==t.content))throw new Error("yolo-spec-envelope-stale");return j}function D(e,r=new Date().toISOString()){return E({storyId:e.storyId,epicId:e.epicId,targetPath:e.targetPath,inputSha256:e.inputSha256,headSha:e.sourceRevision.headSha,collectedAt:r,artifacts:e.artifacts.map(({kind:s,path:o,content:c})=>({kind:s,path:o,content:c}))})}export{H as collectYoloSpecEnvelope,Z as extractTargetedYoloStoryId,D as refreshPrecollectedYoloSpecEnvelope};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Public syntax only. Authenticity is checked exclusively by the server. */
|
|
2
|
+
const NON_UI_EXCLUDED_STAGE_COMMANDS = Object.freeze([
|
|
3
|
+
'arch-design-system',
|
|
4
|
+
'arch-ux-design',
|
|
5
|
+
]);
|
|
6
|
+
export function parseArchitectureNonUiScopeReceipt(value) {
|
|
7
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
8
|
+
return undefined;
|
|
9
|
+
const v = value;
|
|
10
|
+
if (Object.keys(v).sort().join(',') !== ['schemaVersion', 'kind', 'licenseHash', 'projectHash', 'targetEpicId',
|
|
11
|
+
'graphRevision', 'rootInputSha256', 'accountingId', 'applicability', 'excludedStageCommands', 'macSha256', 'publicSafe'].sort().join(',')
|
|
12
|
+
|| v.schemaVersion !== 1 || v.kind !== 'ArchitectureNonUiScope/1' || v.publicSafe !== true
|
|
13
|
+
|| v.applicability !== 'non-ui' || typeof v.targetEpicId !== 'string' || !/^P[1-9][0-9]{0,11}$/.test(v.targetEpicId)
|
|
14
|
+
|| typeof v.accountingId !== 'string' || !/^arch-accounting-[a-f0-9]{32}$/.test(v.accountingId)
|
|
15
|
+
|| !['licenseHash', 'projectHash', 'graphRevision', 'rootInputSha256', 'macSha256'].every(k => typeof v[k] === 'string' && /^[a-f0-9]{64}$/.test(v[k])))
|
|
16
|
+
return undefined;
|
|
17
|
+
const excluded = NON_UI_EXCLUDED_STAGE_COMMANDS;
|
|
18
|
+
if (!Array.isArray(v.excludedStageCommands) || v.excludedStageCommands.length !== excluded.length
|
|
19
|
+
|| !v.excludedStageCommands.every((s, i) => s === excluded[i]))
|
|
20
|
+
return undefined;
|
|
21
|
+
return Object.freeze({ ...v, excludedStageCommands: Object.freeze([...excluded]) });
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Public command order only; no step IDs, resolutions, prompts or execution grants. */
|
|
2
|
+
export const ARCHITECTURE_PUBLIC_STAGE_COMMANDS = Object.freeze([
|
|
3
|
+
'arch-prd', 'arch-architecture', 'arch-fitness-functions', 'arch-api-contracts',
|
|
4
|
+
'generate-pacts', 'arch-api-integrations', 'arch-database', 'arch-security',
|
|
5
|
+
'arch-design-system', 'arch-ux-design', 'arch-performance', 'arch-testing',
|
|
6
|
+
'arch-infrastructure', 'arch-review', 'update-memory',
|
|
7
|
+
]);
|
|
8
|
+
export const ARCHITECTURE_NON_UI_EXCLUDED_COMMANDS = Object.freeze([
|
|
9
|
+
'arch-design-system', 'arch-ux-design',
|
|
10
|
+
]);
|
|
11
|
+
export const ARCHITECTURE_NON_UI_STAGE_COMMANDS = Object.freeze(ARCHITECTURE_PUBLIC_STAGE_COMMANDS.filter(command => !ARCHITECTURE_NON_UI_EXCLUDED_COMMANDS.some(excluded => excluded === command)));
|
|
@@ -177,10 +177,12 @@ export function lexInvocationEnvelope(input) {
|
|
|
177
177
|
if (escaped) {
|
|
178
178
|
const allowed = char === '\\' || char === ' ' || char === '\t' || char === '\r' || char === '\n'
|
|
179
179
|
|| (quote === 'single' && char === "'") || (quote === 'double' && char === '"');
|
|
180
|
-
|
|
180
|
+
// A quoted Windows path such as src\win\async.c is literal user text.
|
|
181
|
+
// Keep unquoted shell-shaped escapes fail-closed.
|
|
182
|
+
if (!allowed && !quote)
|
|
181
183
|
return { ok: false, reason: 'unsupported_escape', tokenCount: tokens.length };
|
|
182
184
|
startSegment(i - 1, quote);
|
|
183
|
-
value += char
|
|
185
|
+
value += allowed ? char : `\\${char}`;
|
|
184
186
|
escaped = false;
|
|
185
187
|
continue;
|
|
186
188
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function isPrivateQaStructuralAdmission(value) {
|
|
2
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
3
|
+
return false;
|
|
4
|
+
const r = value, checks = r.checks;
|
|
5
|
+
return Object.keys(r).sort().join('|') === ['schemaVersion', 'kind', 'stepId', 'generationId', 'graphRevision', 'topologyGenerationId', 'tier', 'checks', 'publicSafe'].sort().join('|')
|
|
6
|
+
&& r.schemaVersion === 1 && r.kind === 'server-private-qa-structural-admission' && r.stepId === 'step-8721319d'
|
|
7
|
+
&& typeof r.generationId === 'string' && /^sha256:[a-f0-9]{64}$/.test(r.generationId)
|
|
8
|
+
&& typeof r.graphRevision === 'string' && /^[a-f0-9]{64}$/.test(r.graphRevision)
|
|
9
|
+
&& typeof r.topologyGenerationId === 'string' && /^sha256:[a-f0-9]{64}$/.test(r.topologyGenerationId)
|
|
10
|
+
&& ['free', 'pro', 'enterprise'].includes(String(r.tier)) && r.publicSafe === true
|
|
11
|
+
&& !!checks && typeof checks === 'object' && !Array.isArray(checks)
|
|
12
|
+
&& Object.keys(checks).sort().join('|') === ['classifiedAssetDelivery', 'licensedCommandAdmission', 'registeredStatusMapping', 'prerequisiteStateAdmitted'].sort().join('|')
|
|
13
|
+
&& Object.values(checks).every(result => result === true);
|
|
14
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function isPrivateQaSkippedPredecessors(value) {
|
|
2
|
+
if (!Array.isArray(value) || value.length > 2)
|
|
3
|
+
return false;
|
|
4
|
+
const ids = [];
|
|
5
|
+
for (const item of value) {
|
|
6
|
+
if (isPrivateYoloSkippedPredecessors([item])) {
|
|
7
|
+
ids.push(item.stepId);
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
if (!item || typeof item !== 'object' || Array.isArray(item))
|
|
11
|
+
return false;
|
|
12
|
+
const r = item;
|
|
13
|
+
if (Object.keys(r).sort().join('|') !== ['stepId', 'featureGate', 'reason', 'tier', 'publicSafe'].sort().join('|')
|
|
14
|
+
|| r.stepId !== 'step-b2fe7cb5' || r.featureGate !== 'validate-tests'
|
|
15
|
+
|| r.reason !== 'subscription-tier' || r.tier !== 'free' || r.publicSafe !== true)
|
|
16
|
+
return false;
|
|
17
|
+
ids.push(r.stepId);
|
|
18
|
+
}
|
|
19
|
+
return new Set(ids).size === ids.length && (value.length < 2
|
|
20
|
+
|| ids[0] === 'step-a8ce5c64' && ids[1] === 'step-b2fe7cb5' && value[0].tier === 'free');
|
|
21
|
+
}
|
|
22
|
+
export function isPrivateYoloSkippedPredecessors(value) {
|
|
23
|
+
return Array.isArray(value) && value.length <= 1 && value.every(item => {
|
|
24
|
+
if (!item || typeof item !== 'object' || Array.isArray(item))
|
|
25
|
+
return false;
|
|
26
|
+
const r = item;
|
|
27
|
+
return Object.keys(r).sort().join('|') === ['stepId', 'featureFlagId', 'enabled', 'tier', 'publicSafe'].sort().join('|')
|
|
28
|
+
&& r.stepId === 'step-a8ce5c64' && r.featureFlagId === 'property-testing'
|
|
29
|
+
&& typeof r.enabled === 'boolean' && ['free', 'pro', 'enterprise'].includes(String(r.tier))
|
|
30
|
+
&& (r.enabled === false || r.tier === 'free') && r.publicSafe === true;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Bounded project command declarations from the submitted story/spec artifacts.
|
|
2
|
+
* These are planning data, never permission to execute or independent QA.
|
|
3
|
+
*/
|
|
4
|
+
export const PROJECT_VALIDATION_KINDS = ['unit', 'integration', 'contract', 'bdd-example', 'e2e'];
|
|
5
|
+
export function readProjectValidationCommands(storyId, sources) {
|
|
6
|
+
const byKind = new Map();
|
|
7
|
+
let declared = false, invalid = false;
|
|
8
|
+
const allowedPaths = new Set(['story', 'spec', 'tasks'].map(suffix => `docs/stories/${storyId}.${suffix}.md`));
|
|
9
|
+
if (sources.length > 3 || new Set(sources.map(source => source.path)).size !== sources.length) {
|
|
10
|
+
return { declared: true, invalid: true, commands: [] };
|
|
11
|
+
}
|
|
12
|
+
for (const source of sources) {
|
|
13
|
+
if (!allowedPaths.has(source.path) || Buffer.byteLength(source.content) > 131072) {
|
|
14
|
+
invalid = true;
|
|
15
|
+
declared = true;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
let active = false, fenced = false, headings = 0, entries = 0;
|
|
19
|
+
for (const raw of source.content.split(/\r?\n/)) {
|
|
20
|
+
const line = raw.trim();
|
|
21
|
+
if (/^(?:```|~~~)/.test(line)) {
|
|
22
|
+
fenced = !fenced;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (fenced)
|
|
26
|
+
continue;
|
|
27
|
+
if (/^##\s+/.test(line)) {
|
|
28
|
+
if (active && entries === 0)
|
|
29
|
+
invalid = true;
|
|
30
|
+
active = line === '## Validation Commands';
|
|
31
|
+
if (active) {
|
|
32
|
+
declared = true;
|
|
33
|
+
headings++;
|
|
34
|
+
entries = 0;
|
|
35
|
+
if (headings > 1)
|
|
36
|
+
invalid = true;
|
|
37
|
+
}
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (!active || !line)
|
|
41
|
+
continue;
|
|
42
|
+
const match = /^- (unit|integration|contract|bdd-example|e2e): `([^`]{1,220})`$/.exec(line);
|
|
43
|
+
if (!match) {
|
|
44
|
+
invalid = true;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const kind = match[1], command = match[2];
|
|
48
|
+
// No shell language, quoted substitutions, inline secrets or private URLs.
|
|
49
|
+
// A command stays a literal argv-shaped string throughout this planner.
|
|
50
|
+
if (!/^[A-Za-z0-9_./-]+(?: [A-Za-z0-9_./:@%+=,-]+)*$/.test(command)
|
|
51
|
+
|| /(?:token|password|license_key|secret|credential)=|(?:https?|ssh):\/\/|@[^ /]+\.[A-Za-z]/i.test(command)
|
|
52
|
+
|| command.split(' ').some(arg => arg.split('/').includes('..'))) {
|
|
53
|
+
invalid = true;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
entries++;
|
|
57
|
+
const prior = byKind.get(kind);
|
|
58
|
+
if (prior && prior.command !== command) {
|
|
59
|
+
invalid = true;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (prior?.sourcePaths.includes(source.path)) {
|
|
63
|
+
invalid = true;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
byKind.set(kind, { kind, command, sourcePaths: [...(prior?.sourcePaths ?? []), source.path] });
|
|
67
|
+
}
|
|
68
|
+
if (active && entries === 0)
|
|
69
|
+
invalid = true;
|
|
70
|
+
}
|
|
71
|
+
if (declared && !byKind.has('unit'))
|
|
72
|
+
invalid = true;
|
|
73
|
+
return { declared, invalid, commands: [...byKind.values()] };
|
|
74
|
+
}
|
|
@@ -6,6 +6,8 @@ export const YOLO_SPEC_TOTAL_LIMIT_BYTES = 128 * 1024;
|
|
|
6
6
|
export const YOLO_SPEC_MAX_ARTIFACTS = 12;
|
|
7
7
|
export const YOLO_SPEC_MAX_AGE_MS = 120_000;
|
|
8
8
|
export const YOLO_SPEC_FUTURE_SKEW_MS = 30_000;
|
|
9
|
+
/** Public server capability for both mandatory top-level YOLO invoke fields. */
|
|
10
|
+
export const YOLO_INVOKE_ENVELOPE_CAPABILITY = 'yolo-invoke-envelope-v1';
|
|
9
11
|
const HASH = /^[a-f0-9]{64}$/;
|
|
10
12
|
const HEAD = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
|
|
11
13
|
const STORY_ID = /^[A-Za-z0-9]+(?:\.[A-Za-z0-9]+)+$/;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: neocortex-root
|
|
3
|
-
description: "🧠 Neocortex Root Agent v4.60.
|
|
3
|
+
description: "🧠 Neocortex Root Agent v4.60.66 | OrNexus Team"
|
|
4
4
|
model: opus
|
|
5
5
|
color: blue
|
|
6
6
|
tools:
|
|
@@ -108,7 +108,7 @@ SEMPRE que este agente for invocado, imprima o banner abaixo como PRIMEIRO outpu
|
|
|
108
108
|
┌────────────────────────────────────────────────────────────┐
|
|
109
109
|
│ │
|
|
110
110
|
│ ####### N E O C O R T E X │
|
|
111
|
-
│ ### ######## v4.60.
|
|
111
|
+
│ ### ######## v4.60.66 │
|
|
112
112
|
│ ######### ##### │
|
|
113
113
|
│ ## ############## Development Orchestrator │
|
|
114
114
|
│ ## ### ###### ## OrNexus Team │
|