@ornexus/neocortex 4.61.3 → 4.61.5

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/install.ps1 CHANGED
@@ -17,7 +17,7 @@ param(
17
17
  [string]$ServerUrl = ('https://{0}.{1}.{2}' -f 'api','neocortex','sh')
18
18
  )
19
19
 
20
- $VERSION = "4.61.3"
20
+ $VERSION = "4.61.5"
21
21
 
22
22
  # =============================================================================
23
23
  # CONFIGURACOES
package/install.sh CHANGED
@@ -4,7 +4,7 @@
4
4
  # Development Orchestrator
5
5
 
6
6
  # Versao do instalador
7
- VERSION="4.61.3"
7
+ VERSION="4.61.5"
8
8
 
9
9
  # Flags
10
10
  MIGRATION_DETECTED=false
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ornexus/neocortex",
3
- "version": "4.61.3",
4
- "description": "Neocortex v4.61.3",
3
+ "version": "4.61.5",
4
+ "description": "Neocortex v4.61.5",
5
5
  "keywords": [
6
6
  "claude",
7
7
  "claude-code",
@@ -792,6 +792,14 @@ export interface StoryWorktreeBarrierPollingOptions {
792
792
  * phase-1 prompt, which resumes at C05.
793
793
  */
794
794
  export declare function pollStoryWorktreeSpecBarrier(args: string, attempt: (args: string) => Promise<InvokeResult>, options?: StoryWorktreeBarrierPollingOptions): Promise<InvokeResult>;
795
+ /**
796
+ * 4.61.4: persist the server-returned C04 spec acceptance and phase-one receipt
797
+ * into the shared runtime evidence (git common dir), so the server can see
798
+ * every story's acceptance through any child's snapshot and open the barrier.
799
+ * The server re-validates both on every read; a persistence failure is
800
+ * reported, never fatal to the step result.
801
+ */
802
+ export declare function persistStoryWorktreePhaseEvidence(projectRoot: string, result: InvokeResult): Promise<void>;
795
803
  export declare function invoke(options: InvokeOptions): Promise<InvokeResult>;
796
804
  /**
797
805
  * Extract the canonical trigger for client-side pre-flight checks.
@@ -72,7 +72,7 @@ import { probeProjectIdentityMigrationCapability } from '../migrations/project-i
72
72
  import { normalizeYoloopStoryPlanningEvidence } from '../../../shared/dist/yoloop/planning-graph.js';
73
73
  import { normalizeContinuousWriteRef } from '../../../shared/dist/yoloop/wave-decision-receipt.js';
74
74
  import { epicHeadReconciliationInputDigest, epicHeadReconciliationPathsDigest, epicHeadReconciliationRangeDigest, } from '../../../shared/dist/yoloop/epic-terminal-git.js';
75
- import { applyGitLifecycleRuntimeOverlay, classifyGitLifecycleStoryCheckpointProjectionSync, ensureRuntimeEpic, ensureGitLifecycleRuntimeInitialized, executeP205TransientAuthorities, persistGitLifecycleGraphAuthority, P205_COMPLETE_COMMAND, gitLifecycleStoryWriteSet, isStoryWorktreeEvidenceContainer, mutateGitLifecycleRuntime, projectP205TransientExecutionEvidence, readGitLifecycleRuntimeSync, verifyLegacyCheckpointMigrationCandidateSync, } from '../git/git-lifecycle-store.js';
75
+ import { applyGitLifecycleRuntimeOverlay, classifyGitLifecycleStoryCheckpointProjectionSync, ensureRuntimeEpic, ensureGitLifecycleRuntimeInitialized, executeP205TransientAuthorities, persistGitLifecycleGraphAuthority, P205_COMPLETE_COMMAND, gitLifecycleStoryWriteSet, appendStoryWorktreeEvidence, isStoryWorktreeEvidenceContainer, mutateGitLifecycleRuntime, projectP205TransientExecutionEvidence, readGitLifecycleRuntimeSync, verifyLegacyCheckpointMigrationCandidateSync, } from '../git/git-lifecycle-store.js';
76
76
  import { verifyRootMemoryPhysicalWriteSet } from '../private-execution/root-memory-git-evidence.js';
77
77
  import { isRootProjectMemoryEffect } from '../private-execution/shared-root-memory-types.js';
78
78
  import { probeYoloInvokeEnvelopeCapability } from '../yolo/invoke-envelope-capability.js';
@@ -4836,10 +4836,46 @@ export async function pollStoryWorktreeSpecBarrier(args, attempt, options = {})
4836
4836
  await sleep(retryAfter);
4837
4837
  }
4838
4838
  }
4839
+ /**
4840
+ * 4.61.4: persist the server-returned C04 spec acceptance and phase-one receipt
4841
+ * into the shared runtime evidence (git common dir), so the server can see
4842
+ * every story's acceptance through any child's snapshot and open the barrier.
4843
+ * The server re-validates both on every read; a persistence failure is
4844
+ * reported, never fatal to the step result.
4845
+ */
4846
+ export async function persistStoryWorktreePhaseEvidence(projectRoot, result) {
4847
+ const phase = result.metadata?.storyWorktreePhase;
4848
+ if (!result.success || !phase || typeof phase !== 'object' || Array.isArray(phase))
4849
+ return;
4850
+ const record = phase;
4851
+ const acceptance = record.specAcceptance;
4852
+ const receipt = record.phaseOneReceipt;
4853
+ const storyId = typeof record.storyId === 'string' ? record.storyId : undefined;
4854
+ const epicId = storyId && /^P[0-9]{1,12}\./.test(storyId) ? storyId.split('.')[0] : undefined;
4855
+ if (!epicId || (acceptance === undefined && receipt === undefined))
4856
+ return;
4857
+ try {
4858
+ await mutateGitLifecycleRuntime(projectRoot, (document) => {
4859
+ appendStoryWorktreeEvidence(document, epicId, {
4860
+ ...(acceptance !== undefined ? { specAcceptances: [acceptance] } : {}),
4861
+ ...(receipt !== undefined ? { receipts: [receipt] } : {}),
4862
+ });
4863
+ });
4864
+ }
4865
+ catch (error) {
4866
+ const reason = error instanceof Error && /^[a-z0-9-]{1,80}$/.test(error.message) ? error.message : 'story-worktree-evidence-persist-failed';
4867
+ process.stderr.write(`[Neocortex] story-worktree evidence not persisted (${reason}); the root must re-dispatch this phase-1 prompt.\n`);
4868
+ }
4869
+ }
4839
4870
  export async function invoke(options) {
4840
4871
  if (!isStoryWorktreePhaseOneInvocation(options.args))
4841
4872
  return invokeOnce(options);
4842
- return pollStoryWorktreeSpecBarrier(options.args, () => invokeOnce(options));
4873
+ const projectRoot = options.projectRoot ?? process.cwd();
4874
+ return pollStoryWorktreeSpecBarrier(options.args, async () => {
4875
+ const result = await invokeOnce(options);
4876
+ await persistStoryWorktreePhaseEvidence(projectRoot, result);
4877
+ return result;
4878
+ });
4843
4879
  }
4844
4880
  async function invokeOnce(options) {
4845
4881
  // P205.07: admission is physically first. A rejected envelope cannot reach
@@ -357,7 +357,7 @@ export async function mutateGitLifecycleRuntime(projectRoot, mutate, options = {
357
357
  const commonDir = await gitCommonDir(projectRoot);
358
358
  const runtimeDirectory = await ensureRuntimeDirectory(commonDir);
359
359
  const lockPath = join(runtimeDirectory, LOCK_DIRECTORY);
360
- const lockOwner = await acquireLock(lockPath);
360
+ const lockOwner = await acquireLockWithBackoff(lockPath);
361
361
  try {
362
362
  const storePath = join(runtimeDirectory, GIT_LIFECYCLE_RUNTIME_FILE);
363
363
  const legacyStorePath = join(commonDir, LEGACY_STORE_FILE);
@@ -429,6 +429,17 @@ export function applyGitLifecycleRuntimeOverlay(tracked, runtime) {
429
429
  if (c01OnlyOverlay && Array.isArray(trackedSteps)
430
430
  && trackedSteps.includes(GIT_LIFECYCLE_SETUP_BRANCH_STEP_ID))
431
431
  continue;
432
+ // 4.61.5: C01 instructs the child not to touch tracked state, so later
433
+ // tracked progress (C02..) arrives without C01. Union C01 into it instead
434
+ // of letting the C01-only bridge mask that progress.
435
+ if (c01OnlyOverlay && Array.isArray(trackedSteps) && trackedSteps.length > 0) {
436
+ stories[storyId] = {
437
+ ...trackedStory,
438
+ steps_completed: [GIT_LIFECYCLE_SETUP_BRANCH_STEP_ID,
439
+ ...trackedSteps.filter((step) => step !== GIT_LIFECYCLE_SETUP_BRANCH_STEP_ID)],
440
+ };
441
+ continue;
442
+ }
432
443
  stories[storyId] = { ...trackedStory, ...structuredClone(overlay) };
433
444
  }
434
445
  return merged;
@@ -2384,6 +2395,24 @@ function safeShaArray(value) {
2384
2395
  function emptyDocument() {
2385
2396
  return { schemaVersion: 1, revision: 0, epics: {}, stories: {} };
2386
2397
  }
2398
+ /**
2399
+ * 4.61.5: parallel story-worktree children share this runtime; a live
2400
+ * holder is normally a sub-second write, so retry only `lock-active` with a
2401
+ * bounded backoff (about 4 s in total). Every other lock error fails at once.
2402
+ */
2403
+ async function acquireLockWithBackoff(lockPath) {
2404
+ const delays = [50, 100, 200, 400, 600, 800, 1000, 1000];
2405
+ for (let attempt = 0;; attempt += 1) {
2406
+ try {
2407
+ return await acquireLock(lockPath);
2408
+ }
2409
+ catch (error) {
2410
+ if (!(error instanceof Error) || error.message !== 'git-lifecycle-runtime-lock-active' || attempt >= delays.length)
2411
+ throw error;
2412
+ await new Promise((resolve) => setTimeout(resolve, delays[attempt]));
2413
+ }
2414
+ }
2415
+ }
2387
2416
  async function acquireLock(lockPath) {
2388
2417
  const parent = dirname(lockPath);
2389
2418
  const requested = { pid: process.pid, nonce: randomBytes(16).toString('hex') };
@@ -180,7 +180,10 @@ export function collectYoloChangeEvidence(options) {
180
180
  unavailable('runtime-state-unavailable', 'none', reconciliation);
181
181
  }
182
182
  const epic = runtime.epics[options.epicId];
183
- const lease = epic?.branch_lease;
183
+ // 4.61.5: inside a P225 story worktree the epic writer lease belongs to the
184
+ // root integration, not to this story; isolation comes from the story
185
+ // worktree lease, so the epic lease is not consulted here.
186
+ const lease = isActiveStoryWorktree(options.projectRoot, runtime, options.storyId) ? undefined : epic?.branch_lease;
184
187
  const currentBranch = git(options.projectRoot, ['symbolic-ref', '--quiet', '--short', 'HEAD'], 'execution-branch-mismatch', 'none', reconciliation).trim();
185
188
  if (epic?.branch_mode === 'epic' && epic.execution_branch === currentBranch)
186
189
  executionBranch = currentBranch;
@@ -243,3 +246,17 @@ export function collectYoloChangeEvidence(options) {
243
246
  }
244
247
  return evidence;
245
248
  }
249
+ /** True when `projectRoot` is the registered, active story worktree of `storyId`. */
250
+ function isActiveStoryWorktree(projectRoot, runtime, storyId) {
251
+ const toplevel = spawnSync('git', ['-C', projectRoot, 'rev-parse', '--show-toplevel'], { encoding: 'utf8', timeout: 3_000 });
252
+ if (toplevel.status !== 0)
253
+ return false;
254
+ let root;
255
+ try {
256
+ root = realpathSync(toplevel.stdout.trim());
257
+ }
258
+ catch {
259
+ return false;
260
+ }
261
+ return Object.values(runtime.storyWorktrees?.entries ?? {}).some((entry) => entry.storyId === storyId && entry.state === 'active' && entry.worktreePath === root);
262
+ }
@@ -21,7 +21,10 @@ export async function probeYoloInvokeEnvelopeCapability(serverUrl, fetcher = glo
21
21
  const timeout = setTimeout(() => controller.abort(), 5_000);
22
22
  timeout.unref?.();
23
23
  try {
24
- const response = await fetcher(`${serverUrl.replace(/\/+$/, '')}/api/v1/health`, {
24
+ // `/health` serves the same handler as `/api/v1/health` but is exempt from
25
+ // the API rate limit, so parallel story-worktree children cannot turn a
26
+ // 429 into a false `capability-missing`.
27
+ const response = await fetcher(`${serverUrl.replace(/\/+$/, '')}/health`, {
25
28
  method: 'GET',
26
29
  headers: { accept: 'application/json' },
27
30
  signal: controller.signal,
@@ -1,4 +1,4 @@
1
- # 🧠 Neocortex v4.61.3 | OrNexus Team
1
+ # 🧠 Neocortex v4.61.5 | OrNexus Team
2
2
 
3
3
  This project uses Neocortex, a Development Orchestrator.
4
4
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: neocortex
3
- description: "🧠 Neocortex v4.61.3 | OrNexus Team"
3
+ description: "🧠 Neocortex v4.61.5 | OrNexus Team"
4
4
  ---
5
5
 
6
6
  <!--
@@ -4,7 +4,7 @@ agent:
4
4
  name: 'Neocortex Root Agent'
5
5
  title: 'Development Orchestrator (Root)'
6
6
  icon: '>'
7
- version: '4.61.3'
7
+ version: '4.61.5'
8
8
  architecture: 'thin-client'
9
9
  module: stand-alone
10
10
  hasSidecar: false
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: neocortex-root
3
- description: "🧠 Neocortex Root Agent v4.61.3 | OrNexus Team"
3
+ description: "🧠 Neocortex Root Agent v4.61.5 | 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.61.3 │
111
+ │ ### ######## v4.61.5 │
112
112
  │ ######### ##### │
113
113
  │ ## ############## Development Orchestrator │
114
114
  │ ## ### ###### ## OrNexus Team │
@@ -4,7 +4,7 @@ agent:
4
4
  name: 'Neocortex'
5
5
  title: 'Development Orchestrator'
6
6
  icon: '>'
7
- version: '4.61.3'
7
+ version: '4.61.5'
8
8
  architecture: 'thin-client'
9
9
  module: stand-alone
10
10
  hasSidecar: false
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: neocortex
3
- description: "🧠 Neocortex v4.61.3 | OrNexus Team"
3
+ description: "🧠 Neocortex v4.61.5 | OrNexus Team"
4
4
  model: opus
5
5
  color: blue
6
6
  permissionMode: bypassPermissions
@@ -106,7 +106,7 @@ SEMPRE que este agente for invocado, imprima o banner abaixo como PRIMEIRO outpu
106
106
  ┌────────────────────────────────────────────────────────────┐
107
107
  │ │
108
108
  │ ####### N E O C O R T E X │
109
- │ ### ######## v4.61.3 │
109
+ │ ### ######## v4.61.5 │
110
110
  │ ######### ##### │
111
111
  │ ## ############## Development Orchestrator │
112
112
  │ ## ### ###### ## OrNexus Team │
@@ -32,7 +32,7 @@ Codex built-in commands or actions.
32
32
 
33
33
  <!-- END: Plugin Conflict Prevention -->
34
34
 
35
- # Neocortex v4.61.3 | OrNexus Team
35
+ # Neocortex v4.61.5 | OrNexus Team
36
36
 
37
37
  You are a Development Orchestrator. All orchestration logic is delivered by the remote Neocortex server.
38
38
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: neocortex
3
- description: "🧠 Neocortex v4.61.3 | OrNexus Team"
3
+ description: "🧠 Neocortex v4.61.5 | OrNexus Team"
4
4
  model: inherit
5
5
  readonly: false
6
6
  is_background: false
@@ -104,7 +104,7 @@ SEMPRE que este agente for invocado, imprima o banner abaixo como PRIMEIRO outpu
104
104
  ┌────────────────────────────────────────────────────────────┐
105
105
  │ │
106
106
  │ ####### N E O C O R T E X │
107
- │ ### ######## v4.61.3 │
107
+ │ ### ######## v4.61.5 │
108
108
  │ ######### ##### │
109
109
  │ ## ############## Development Orchestrator │
110
110
  │ ## ### ###### ## OrNexus Team │
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: neocortex-root
3
- description: "🧠 Neocortex v4.61.3 | OrNexus Team"
3
+ description: "🧠 Neocortex v4.61.5 | OrNexus Team"
4
4
  kind: local
5
5
  tools:
6
6
  # File operations (Gemini CLI built-ins)
@@ -62,7 +62,7 @@ SEMPRE que este agente for invocado, imprima o banner abaixo como PRIMEIRO outpu
62
62
  ┌────────────────────────────────────────────────────────────┐
63
63
  │ │
64
64
  │ ####### N E O C O R T E X │
65
- │ ### ######## v4.61.3 │
65
+ │ ### ######## v4.61.5 │
66
66
  │ ######### ##### │
67
67
  │ ## ############## Development Orchestrator │
68
68
  │ ## ### ###### ## OrNexus Team │
@@ -64,7 +64,7 @@ task directive, I keep root-owned inline/shell-loop execution.
64
64
  ┌────────────────────────────────────────────────────────────┐
65
65
  │ │
66
66
  │ ####### N E O C O R T E X │
67
- │ ### ######## v4.61.3 │
67
+ │ ### ######## v4.61.5 │
68
68
  │ ######### ##### │
69
69
  │ ## ############## Development Orchestrator │
70
70
  │ ## ### ###### ## OrNexus Team │
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: "neocortex"
3
- description: "Neocortex v4.61.3 | OrNexus Team"
3
+ description: "Neocortex v4.61.5 | OrNexus Team"
4
4
  tools:
5
5
  # Read / Edit (built-in tool sets)
6
6
  - read
@@ -72,7 +72,7 @@ SEMPRE que este agente for invocado, imprima o banner abaixo como PRIMEIRO outpu
72
72
  ┌────────────────────────────────────────────────────────────┐
73
73
  │ │
74
74
  │ ####### N E O C O R T E X │
75
- │ ### ######## v4.61.3 │
75
+ │ ### ######## v4.61.5 │
76
76
  │ ######### ##### │
77
77
  │ ## ############## Development Orchestrator │
78
78
  │ ## ### ###### ## OrNexus Team │