@ornexus/neocortex 4.60.72 → 4.60.73
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 +24 -24
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +2 -2
- package/packages/client/dist/adapters/adapter-registry.js +108 -1
- package/packages/client/dist/adapters/antigravity-adapter.js +77 -2
- package/packages/client/dist/adapters/claude-code-adapter.js +79 -3
- package/packages/client/dist/adapters/codex-adapter.js +80 -2
- package/packages/client/dist/adapters/cursor-adapter.js +115 -4
- package/packages/client/dist/adapters/gemini-adapter.js +71 -2
- package/packages/client/dist/adapters/grok-adapter.js +42 -2
- package/packages/client/dist/adapters/index.js +22 -1
- package/packages/client/dist/adapters/platform-detector.js +212 -1
- package/packages/client/dist/adapters/target-adapter.js +12 -0
- package/packages/client/dist/adapters/vscode-adapter.js +72 -2
- package/packages/client/dist/agent/refresh-stubs.js +417 -2
- package/packages/client/dist/agent/update-agent-yaml.js +102 -1
- package/packages/client/dist/agent/update-description.js +251 -1
- package/packages/client/dist/cache/crypto-utils.js +78 -1
- package/packages/client/dist/cache/encrypted-cache.js +108 -1
- package/packages/client/dist/cache/in-memory-asset-cache.js +73 -1
- package/packages/client/dist/cache/index.js +13 -1
- package/packages/client/dist/cache/protected-pi-boundary.js +44 -1
- package/packages/client/dist/checkpoint/checkpoint-client-reader.js +127 -2
- package/packages/client/dist/checkpoint/index.js +11 -1
- package/packages/client/dist/checkpoint/shared-checkpoint-types.js +32 -1
- package/packages/client/dist/cli.js +358 -5
- package/packages/client/dist/commands/activate.js +394 -8
- package/packages/client/dist/commands/architecture-answers.js +274 -7
- package/packages/client/dist/commands/architecture-memory-terminal.js +253 -4
- package/packages/client/dist/commands/architecture-non-ui-continuation.js +100 -1
- package/packages/client/dist/commands/architecture-root-binding.js +51 -1
- package/packages/client/dist/commands/cache-status.js +112 -2
- package/packages/client/dist/commands/config.js +88 -1
- package/packages/client/dist/commands/doctor.js +635 -2
- package/packages/client/dist/commands/invoke.js +7200 -143
- package/packages/client/dist/commands/legacy-epic-terminal.js +71 -1
- package/packages/client/dist/commands/legacy-story-branch.js +96 -1
- package/packages/client/dist/commands/legacy-story-pr.js +276 -1
- package/packages/client/dist/commands/mutation-qa-checkpoint.js +285 -5
- package/packages/client/dist/commands/mutation-qa-gate.js +54 -1
- package/packages/client/dist/commands/mutation-qa-git.js +41 -1
- package/packages/client/dist/commands/mutation-qa-policy.js +102 -1
- package/packages/client/dist/commands/mutation-qa-run.js +219 -3
- package/packages/client/dist/commands/mutation-qa-verdict.js +149 -1
- package/packages/client/dist/commands/mutation-qa.js +220 -1
- package/packages/client/dist/commands/native-agent.js +136 -2
- package/packages/client/dist/commands/planning-diagnosis.js +43 -1
- package/packages/client/dist/commands/planning-generation.js +53 -1
- package/packages/client/dist/commands/planning-memory.js +40 -1
- package/packages/client/dist/commands/planning-research.js +42 -1
- package/packages/client/dist/commands/private-session.js +75 -1
- package/packages/client/dist/commands/property-qa.js +139 -1
- package/packages/client/dist/commands/qa-control.js +16 -1
- package/packages/client/dist/commands/qa-scan-browser-launch.js +55 -1
- package/packages/client/dist/commands/qa-scan-browser-route.js +28 -1
- package/packages/client/dist/commands/qa-scan-capture.js +663 -5
- package/packages/client/dist/commands/qa-scan-discovery.js +376 -3
- package/packages/client/dist/commands/qa-scan-review.js +826 -5
- package/packages/client/dist/commands/qa-synthetic-backend-capture.js +266 -1
- package/packages/client/dist/commands/qa-synthetic-backend-review.js +297 -1
- package/packages/client/dist/commands/qa-synthetic-backend.js +340 -2
- package/packages/client/dist/commands/qa-synthetic-broker-port.js +85 -1
- package/packages/client/dist/commands/qa-synthetic-browser.js +39 -1
- package/packages/client/dist/commands/refactor-characterization.js +671 -21
- package/packages/client/dist/commands/refactor-commit.js +399 -13
- package/packages/client/dist/commands/refactor-control.js +142 -3
- package/packages/client/dist/commands/refactor-cpp-assertions.js +93 -3
- package/packages/client/dist/commands/refactor-review.js +283 -5
- package/packages/client/dist/commands/refactor-root.js +588 -7
- package/packages/client/dist/commands/refresh-memory.js +156 -3
- package/packages/client/dist/commands/shared-architecture-non-ui.js +24 -1
- package/packages/client/dist/commands/story-checkpoint.js +171 -1
- package/packages/client/dist/config/profile-directory.js +13 -1
- package/packages/client/dist/config/resolver-selection.js +278 -1
- package/packages/client/dist/config/secure-config.js +281 -12
- package/packages/client/dist/config.js +223 -2
- package/packages/client/dist/constants.js +25 -1
- package/packages/client/dist/context/context-collector.js +222 -2
- package/packages/client/dist/context/context-sanitizer.js +145 -1
- package/packages/client/dist/continuity/autonomous-governance.js +285 -1
- package/packages/client/dist/continuity/continuity-client-state-store.js +1587 -1
- package/packages/client/dist/continuity/invoke-hooks.js +129 -1
- package/packages/client/dist/continuity/migrations/001-initial-schema.js +12 -2
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +12 -2
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +12 -2
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +12 -2
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +12 -2
- package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +10 -2
- package/packages/client/dist/continuity/native-agent-store.js +69 -1
- package/packages/client/dist/continuity/native-agent-types.js +90 -1
- package/packages/client/dist/continuity/outbox.js +117 -1
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +172 -1
- package/packages/client/dist/continuity/sqlite-store.d.ts +22 -1
- package/packages/client/dist/continuity/sqlite-store.js +2612 -81
- package/packages/client/dist/effects/invoke-effect-gateways.js +62 -1
- package/packages/client/dist/errors/error-messages.js +228 -2
- package/packages/client/dist/errors/frontmatter-diagnostics.js +125 -1
- package/packages/client/dist/evidence/collector.js +347 -1
- package/packages/client/dist/evidence/index.js +1 -1
- package/packages/client/dist/evidence/types.js +2 -0
- package/packages/client/dist/fs/atomic-state-replace.js +152 -1
- package/packages/client/dist/generated/command-registry.generated.js +4076 -1
- package/packages/client/dist/generated/public-projections.generated.js +149 -1
- package/packages/client/dist/git/direct-yolo-c01-retry.js +138 -4
- package/packages/client/dist/git/direct-yolo-checkpoint.js +1234 -4
- package/packages/client/dist/git/epic-operational-state.d.ts +198 -0
- package/packages/client/dist/git/epic-operational-state.js +672 -0
- package/packages/client/dist/git/git-lifecycle-step-ids.js +14 -1
- package/packages/client/dist/git/git-lifecycle-store.d.ts +9 -1
- package/packages/client/dist/git/git-lifecycle-store.js +1981 -9
- package/packages/client/dist/git/legacy-story-branch-checkpoint.js +259 -9
- package/packages/client/dist/git/legacy-story-branch-setup.js +348 -4
- package/packages/client/dist/git/legacy-story-pr.js +3538 -70
- package/packages/client/dist/git/secure-filesystem-boundary.js +182 -5
- package/packages/client/dist/graph-retrieval/pre-command-hook.js +284 -1
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +237 -1
- package/packages/client/dist/i18n/first-run.js +60 -2
- package/packages/client/dist/index.js +47 -1
- package/packages/client/dist/invocation/invoke-input.js +24 -1
- package/packages/client/dist/license/index.js +5 -1
- package/packages/client/dist/license/license-client.js +304 -1
- package/packages/client/dist/machine/fingerprint.js +163 -2
- package/packages/client/dist/machine/index.js +5 -1
- package/packages/client/dist/memory/project-memory-path-scope.js +62 -1
- package/packages/client/dist/memory/project-memory-writer.js +1007 -40
- package/packages/client/dist/memory/shared-project-memory-types.js +253 -2
- package/packages/client/dist/migrations/epic-lifecycle-backfill.d.ts +97 -0
- package/packages/client/dist/migrations/epic-lifecycle-backfill.js +1060 -0
- package/packages/client/dist/migrations/project-identity-capability.js +50 -1
- package/packages/client/dist/migrations/project-identity.js +493 -7
- package/packages/client/dist/migrations/state-json.d.ts +22 -0
- package/packages/client/dist/migrations/state-json.js +393 -4
- package/packages/client/dist/policy/architecture-policy.js +184 -2
- package/packages/client/dist/policy/index.js +7 -1
- package/packages/client/dist/policy/shared-policy-types.js +38 -0
- package/packages/client/dist/policy/subagent-approval-policy.js +55 -1
- package/packages/client/dist/private-execution/clean-baseline.js +279 -2
- package/packages/client/dist/private-execution/codex-executor.js +574 -4
- package/packages/client/dist/private-execution/codex-host-runtime.js +137 -1
- package/packages/client/dist/private-execution/codex-lifecycle-guard.js +97 -1
- package/packages/client/dist/private-execution/codex-scoped-permissions.js +128 -1
- package/packages/client/dist/private-execution/delivery.js +410 -13
- package/packages/client/dist/private-execution/diagnosis-root-review.js +294 -2
- package/packages/client/dist/private-execution/frozen-handoff.js +19 -6
- package/packages/client/dist/private-execution/implementation-validation.js +106 -2
- package/packages/client/dist/private-execution/isolated-admission.js +1432 -23
- package/packages/client/dist/private-execution/isolated-session.js +725 -5
- package/packages/client/dist/private-execution/isolated-workspace.js +122 -1
- package/packages/client/dist/private-execution/pact-consumer-runtime.js +409 -3
- package/packages/client/dist/private-execution/pact-test-source.js +258 -1
- package/packages/client/dist/private-execution/pact-toolchain.js +290 -3
- package/packages/client/dist/private-execution/pact-write-set.js +172 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +406 -5
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +462 -5
- package/packages/client/dist/private-execution/planning-memory-checkpoint.js +139 -3
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +325 -4
- package/packages/client/dist/private-execution/private-report-store.js +42 -1
- package/packages/client/dist/private-execution/property-test-candidate.js +103 -1
- package/packages/client/dist/private-execution/property-test-choices.js +147 -3
- package/packages/client/dist/private-execution/property-test-plan.js +271 -7
- package/packages/client/dist/private-execution/property-test-review.js +258 -4
- package/packages/client/dist/private-execution/property-test-runtime.js +372 -9
- package/packages/client/dist/private-execution/property-test-source.js +139 -1
- package/packages/client/dist/private-execution/root-checkpoint.js +80 -1
- package/packages/client/dist/private-execution/root-memory-git-evidence.js +135 -3
- package/packages/client/dist/private-execution/root-memory-recovery.js +93 -1
- package/packages/client/dist/private-execution/root-memory-request.js +29 -1
- package/packages/client/dist/private-execution/root-memory-scope.js +178 -1
- package/packages/client/dist/private-execution/root-memory-writer.js +102 -1
- package/packages/client/dist/private-execution/session-lease.js +63 -1
- package/packages/client/dist/private-execution/shared-private-admission-types.js +50 -1
- package/packages/client/dist/private-execution/shared-project-validation.js +66 -1
- package/packages/client/dist/private-execution/shared-root-memory-types.js +61 -1
- package/packages/client/dist/private-execution/ux-source-validation.js +372 -1
- package/packages/client/dist/private-execution/ux-write-set.js +191 -2
- package/packages/client/dist/registry/registry-reconciliation.js +234 -1
- package/packages/client/dist/resilience/circuit-breaker.js +170 -1
- package/packages/client/dist/resilience/degradation-manager.js +164 -1
- package/packages/client/dist/resilience/freshness-indicator.js +100 -1
- package/packages/client/dist/resilience/index.js +8 -1
- package/packages/client/dist/resilience/recovery-detector.js +74 -1
- package/packages/client/dist/resolvers/asset-resolver.js +13 -0
- package/packages/client/dist/resolvers/local-resolver.js +255 -8
- package/packages/client/dist/resolvers/remote-resolver.js +233 -1
- package/packages/client/dist/runner/binary.js +404 -1
- package/packages/client/dist/runner/cli.js +1571 -17
- package/packages/client/dist/runner/headless/adapters.js +49 -1
- package/packages/client/dist/runner/headless/claude-code-adapter.js +79 -1
- package/packages/client/dist/runner/headless/continuous-story-workspace.js +1628 -11
- package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +69 -1
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +110 -2
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +1236 -8
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +318 -2
- package/packages/client/dist/runner/headless/fake-adapter.js +62 -1
- package/packages/client/dist/runner/headless/managed-profile.js +132 -1
- package/packages/client/dist/runner/headless/opencode-adapter.js +145 -2
- package/packages/client/dist/runner/headless/prepared-story-bundle.js +43 -1
- package/packages/client/dist/runner/headless/resolver.js +231 -1
- package/packages/client/dist/runner/headless/run-yolo.js +885 -1
- package/packages/client/dist/runner/headless/run-yoloop.js +2574 -2
- package/packages/client/dist/runner/headless/types.js +574 -2
- package/packages/client/dist/runner/local-console.js +396 -13
- package/packages/client/dist/runner/portal-sync-worker.js +1487 -1
- package/packages/client/dist/runner/project-identity.js +106 -1
- package/packages/client/dist/runner/scheduler.js +995 -7
- package/packages/client/dist/runner-cli.js +18 -2
- package/packages/client/dist/state/invocation-shape.js +13 -1
- package/packages/client/dist/state/project-state-snapshot.d.ts +8 -0
- package/packages/client/dist/state/project-state-snapshot.js +1731 -1
- package/packages/client/dist/state/state-json-repair.js +785 -3
- package/packages/client/dist/state/structural-dag-projection.js +118 -1
- package/packages/client/dist/telemetry/index.js +5 -1
- package/packages/client/dist/telemetry/offline-queue.js +131 -1
- package/packages/client/dist/tier/index.js +5 -1
- package/packages/client/dist/tier/tier-aware-client.js +405 -1
- package/packages/client/dist/types/index.js +38 -1
- package/packages/client/dist/version.js +27 -1
- package/packages/client/dist/yolo/change-evidence-collector.js +126 -1
- package/packages/client/dist/yolo/invoke-envelope-capability.js +62 -1
- package/packages/client/dist/yolo/spec-envelope-collector.js +184 -5
- package/packages/client/dist/yoloop/discovery-hook.js +300 -2
- package/packages/client/dist/yoloop/index.js +8 -1
- package/packages/client/dist/yoloop/invoke-hooks.js +669 -12
- package/packages/client/dist/yoloop/shared-discover-epics.js +1007 -1
- package/packages/client/dist/yoloop/shared-yoloop-types.d.ts +65 -1
- package/packages/client/dist/yoloop/shared-yoloop-types.js +33 -1
- package/packages/client/dist/yoloop/target-normalization.js +180 -1
- package/packages/client/dist/yoloop/yoloop-client-state-store.d.ts +8 -0
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1920 -1
- package/packages/shared/dist/yolo/spec-envelope.js +3 -6
- 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 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
/** Closed client projection. Signature authenticity remains a server-only check. */
|
|
2
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
+
import { ARCHITECTURE_NON_UI_COMMANDS, ARCHITECTURE_PUBLIC_COMMANDS, parseArchitectureNonUiScopeReceipt } from './shared-architecture-non-ui.js';
|
|
4
|
+
const obj = (x) => !!x && typeof x === 'object' && !Array.isArray(x);
|
|
5
|
+
const commands = ARCHITECTURE_NON_UI_COMMANDS;
|
|
6
|
+
function boundScope(execution) {
|
|
7
|
+
const scope = parseArchitectureNonUiScopeReceipt(execution.nonUiScopeReceipt);
|
|
8
|
+
return scope && scope.targetEpicId === execution.targetEpicId && scope.graphRevision === execution.graphRevision
|
|
9
|
+
&& obj(execution.accounting) && scope.accountingId === execution.accounting.accountingId
|
|
10
|
+
&& obj(execution.evidenceExpectation) && scope.rootInputSha256 === execution.evidenceExpectation.inputHash ? scope : undefined;
|
|
11
|
+
}
|
|
12
|
+
export function architectureMemoryPredecessorCount(execution) {
|
|
13
|
+
if (execution.nonUiScopeReceipt === undefined)
|
|
14
|
+
return ARCHITECTURE_PUBLIC_COMMANDS.length - 1;
|
|
15
|
+
if (!boundScope(execution))
|
|
16
|
+
throw new Error('architecture-non-ui-scope-invalid');
|
|
17
|
+
return commands.length - 1;
|
|
18
|
+
}
|
|
19
|
+
function prefix(rows, n, target, graph) {
|
|
20
|
+
return Array.isArray(rows) && rows.length === n && rows.every((r, i) => obj(r) && r.targetEpicId === target && r.stageCommand === commands[i]
|
|
21
|
+
&& obj(r.completionEvidence) && obj(r.validationEvidence)
|
|
22
|
+
&& r.completionEvidence.stageCommand === r.stageCommand && r.completionEvidence.status === 'succeeded'
|
|
23
|
+
&& r.validationEvidence.stageCommand === r.stageCommand && r.validationEvidence.status === 'passed'
|
|
24
|
+
&& r.completionEvidence.targetEpicId === target && r.validationEvidence.targetEpicId === target
|
|
25
|
+
&& r.completionEvidence.artifactHash === r.validationEvidence.artifactHash
|
|
26
|
+
&& obj(r.validationEvidence.isolated) && obj(r.validationEvidence.regression)
|
|
27
|
+
&& r.validationEvidence.isolated.graphHash === graph && r.validationEvidence.regression.graphHash === graph);
|
|
28
|
+
}
|
|
29
|
+
function approvedReview(r) {
|
|
30
|
+
const d = r.reviewDecision, c = r.completionEvidence, v = r.validationEvidence;
|
|
31
|
+
return obj(d) && obj(c) && obj(v) && d.schemaVersion === 'ArchitectureReviewDecision/1' && d.decision === 'approved'
|
|
32
|
+
&& d.targetEpicId === r.targetEpicId && d.graphRevision === r.graphRevision && d.artifactHash === c.artifactHash
|
|
33
|
+
&& d.artifactHash === v.artifactHash && d.completionReceiptId === c.receiptId && d.validationReceiptId === v.receiptId;
|
|
34
|
+
}
|
|
35
|
+
export function classifyNonUiArchitectureTransition(request, execution, memoryReceiptValid = false) {
|
|
36
|
+
const checkpoint = execution.checkpoint;
|
|
37
|
+
if (!obj(checkpoint))
|
|
38
|
+
return;
|
|
39
|
+
const scope = boundScope(checkpoint);
|
|
40
|
+
if (!scope || scope.targetEpicId !== request.targetEpicId || scope.graphRevision !== request.graphRevision
|
|
41
|
+
|| !obj(request.evidenceExpectation) || scope.rootInputSha256 !== request.evidenceExpectation.inputHash
|
|
42
|
+
|| !obj(request.accounting) || scope.accountingId !== request.accounting.accountingId
|
|
43
|
+
|| request.nonUiScopeReceipt !== undefined && !isDeepStrictEqual(request.nonUiScopeReceipt, scope))
|
|
44
|
+
return;
|
|
45
|
+
const old = request.acceptedStages, next = checkpoint.acceptedStages, idx = commands.indexOf(String(request.currentStageCommand));
|
|
46
|
+
const target = request.targetEpicId, graph = request.graphRevision;
|
|
47
|
+
const same = (key) => isDeepStrictEqual(checkpoint[key], request[key]);
|
|
48
|
+
const idle = request.childStatus === undefined && request.completionEvidence === undefined && request.validationEvidence === undefined;
|
|
49
|
+
const cleared = checkpoint.childStatus === undefined && checkpoint.completionEvidence === undefined && checkpoint.validationEvidence === undefined;
|
|
50
|
+
if (request.currentStageCommand === 'arch-design-system' && request.continuationState === 'advance' && idle && cleared
|
|
51
|
+
&& checkpoint.currentStageCommand === 'arch-performance' && checkpoint.continuationState === 'advance'
|
|
52
|
+
&& execution.nextAction === 'resume' && prefix(old, commands.indexOf('arch-performance'), target, graph) && isDeepStrictEqual(next, old))
|
|
53
|
+
return 'advance';
|
|
54
|
+
if (idx < commands.indexOf('arch-security'))
|
|
55
|
+
return;
|
|
56
|
+
if (request.nonUiScopeReceipt === undefined && request.currentStageCommand !== 'arch-security')
|
|
57
|
+
return;
|
|
58
|
+
if (request.continuationState === 'complete' && request.currentStageCommand === 'update-memory'
|
|
59
|
+
&& checkpoint.continuationState === 'complete' && checkpoint.currentStageCommand === 'update-memory'
|
|
60
|
+
&& execution.nextAction === 'complete' && prefix(old, commands.length, target, graph) && isDeepStrictEqual(next, old)
|
|
61
|
+
&& ['childStatus', 'completionEvidence', 'validationEvidence', 'reviewDecision', 'terminalMemoryCheckpoint'].every(same)
|
|
62
|
+
&& memoryReceiptValid)
|
|
63
|
+
return 'complete-replay';
|
|
64
|
+
if (!prefix(old, idx, target, graph))
|
|
65
|
+
return;
|
|
66
|
+
if (idle && cleared && ['advance', 'delegate'].includes(String(request.continuationState))
|
|
67
|
+
&& checkpoint.currentStageCommand === request.currentStageCommand && checkpoint.continuationState === 'delegate'
|
|
68
|
+
&& execution.nextAction === 'delegate' && isDeepStrictEqual(next, old) && same('reviewDecision'))
|
|
69
|
+
return 'delegate';
|
|
70
|
+
const c = request.completionEvidence, v = request.validationEvidence;
|
|
71
|
+
if (request.childStatus !== 'succeeded' || !obj(c) || !obj(v) || c.status !== 'succeeded' || v.status !== 'passed'
|
|
72
|
+
|| c.stageCommand !== request.currentStageCommand || v.stageCommand !== request.currentStageCommand
|
|
73
|
+
|| c.targetEpicId !== target || v.targetEpicId !== target || c.artifactHash !== v.artifactHash)
|
|
74
|
+
return;
|
|
75
|
+
if (request.currentStageCommand === 'arch-review' && !approvedReview(request)) {
|
|
76
|
+
if (checkpoint.currentStageCommand === 'arch-review' && checkpoint.continuationState === 'ask-user'
|
|
77
|
+
&& execution.nextAction === 'ask-user' && isDeepStrictEqual(next, old)
|
|
78
|
+
&& ['childStatus', 'completionEvidence', 'validationEvidence'].every(same)
|
|
79
|
+
&& isDeepStrictEqual(checkpoint.questionIds, ['ARCH-REVIEW-A09-APPROVAL'])
|
|
80
|
+
&& request.reviewDecision === undefined)
|
|
81
|
+
return 'ask-user';
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (request.currentStageCommand === 'arch-review' && (request.continuationState !== 'ask-user'
|
|
85
|
+
|| !isDeepStrictEqual(request.questionIds, ['ARCH-REVIEW-A09-APPROVAL'])))
|
|
86
|
+
return;
|
|
87
|
+
const expected = [...old, { targetEpicId: target, stageCommand: request.currentStageCommand, completionEvidence: c, validationEvidence: v }];
|
|
88
|
+
if (!isDeepStrictEqual(next, expected) || !same('reviewDecision'))
|
|
89
|
+
return;
|
|
90
|
+
if (request.currentStageCommand === 'update-memory') {
|
|
91
|
+
if (checkpoint.currentStageCommand === 'update-memory' && checkpoint.continuationState === 'complete'
|
|
92
|
+
&& execution.nextAction === 'complete' && ['childStatus', 'completionEvidence', 'validationEvidence', 'terminalMemoryCheckpoint'].every(same)
|
|
93
|
+
&& memoryReceiptValid)
|
|
94
|
+
return 'complete';
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (cleared && checkpoint.currentStageCommand === commands[idx + 1] && checkpoint.continuationState === 'advance'
|
|
98
|
+
&& execution.nextAction === 'resume')
|
|
99
|
+
return 'advance';
|
|
100
|
+
}
|
|
@@ -1 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A first architecture root may bind only to an explicitly selected,
|
|
3
|
+
* committed epic. The digest is stable across stage commits but changes when
|
|
4
|
+
* the epic source changes; it never grants child, Git or billing authority.
|
|
5
|
+
*/
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import { execFileSync } from 'node:child_process';
|
|
8
|
+
import { lstatSync, realpathSync } from 'node:fs';
|
|
9
|
+
import { join, resolve } from 'node:path';
|
|
10
|
+
import { resolveClientPreFlightTrigger } from '../tier/tier-aware-client.js';
|
|
11
|
+
const EPIC_ID = /^P[1-9][0-9]{0,11}$/;
|
|
12
|
+
const OID = /^[a-f0-9]{40,64}$/;
|
|
13
|
+
export function explicitArchitectureEpicTarget(args) {
|
|
14
|
+
const match = args.match(/^\s*(\*?[^\s]+)[ \t]+"[^"\n]{1,4096}"[ \t]+@docs\/epics\/epic-(P[1-9][0-9]{0,11})\.md\s*$/);
|
|
15
|
+
return match && resolveClientPreFlightTrigger(match[1]) === 'arch-plan' ? match[2] : undefined;
|
|
16
|
+
}
|
|
17
|
+
export function deriveCommittedArchitectureEpicGraphRevision(projectRoot, epicId) {
|
|
18
|
+
if (!EPIC_ID.test(epicId))
|
|
19
|
+
throw new Error('architecture-root-epic-binding-invalid');
|
|
20
|
+
const root = resolve(projectRoot);
|
|
21
|
+
const relativePath = `docs/epics/epic-${epicId}.md`;
|
|
22
|
+
const path = join(root, relativePath);
|
|
23
|
+
try {
|
|
24
|
+
if (realpathSync(root) !== root)
|
|
25
|
+
throw new Error('architecture-root-epic-binding-invalid');
|
|
26
|
+
if (realpathSync(join(root, 'docs')) !== join(root, 'docs')
|
|
27
|
+
|| realpathSync(join(root, 'docs', 'epics')) !== join(root, 'docs', 'epics')
|
|
28
|
+
|| realpathSync(path) !== path)
|
|
29
|
+
throw new Error('architecture-root-epic-binding-invalid');
|
|
30
|
+
const entry = lstatSync(path);
|
|
31
|
+
if (!entry.isFile() || entry.isSymbolicLink() || entry.size > 256 * 1024) {
|
|
32
|
+
throw new Error('architecture-root-epic-binding-invalid');
|
|
33
|
+
}
|
|
34
|
+
const run = (arguments_) => execFileSync('git', [...arguments_], {
|
|
35
|
+
cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 1024 * 1024,
|
|
36
|
+
}).trim();
|
|
37
|
+
if (resolve(run(['rev-parse', '--show-toplevel'])) !== root) {
|
|
38
|
+
throw new Error('architecture-root-epic-binding-invalid');
|
|
39
|
+
}
|
|
40
|
+
const committed = run(['rev-parse', '--verify', `HEAD:${relativePath}`]);
|
|
41
|
+
const working = run(['hash-object', '--', relativePath]);
|
|
42
|
+
const staged = run(['ls-files', '--stage', '--', relativePath]).match(/^100644 ([a-f0-9]{40,64}) 0\t/);
|
|
43
|
+
if (!OID.test(committed) || working !== committed || staged?.[1] !== committed) {
|
|
44
|
+
throw new Error('architecture-root-epic-binding-invalid');
|
|
45
|
+
}
|
|
46
|
+
return createHash('sha256').update(`architecture-committed-epic-v1\0${epicId}\0${committed}`).digest('hex');
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw new Error('architecture-root-epic-binding-invalid');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,2 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Neocortex CLI, licensed under the
|
|
6
|
+
* Functional Source License, Version 1.1 (FSL-1.1).
|
|
7
|
+
*
|
|
8
|
+
* Change Date: February 20, 2029
|
|
9
|
+
* Change License: MIT
|
|
10
|
+
*
|
|
11
|
+
* See the LICENSE file in the project root for full license text.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @neocortex/client - Cache Status Command
|
|
15
|
+
*
|
|
16
|
+
* Displays comprehensive cache and circuit breaker status information.
|
|
17
|
+
* Shows entry count, total size, age range, stale entries, circuit state,
|
|
18
|
+
* and telemetry queue stats.
|
|
19
|
+
*
|
|
20
|
+
* Story 42.9 - AC7
|
|
21
|
+
*/
|
|
22
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
23
|
+
import { join } from 'node:path';
|
|
24
|
+
// ── Implementation ──────────────────────────────────────────────────────
|
|
25
|
+
/**
|
|
26
|
+
* Gather comprehensive cache status information.
|
|
27
|
+
*/
|
|
28
|
+
export async function getCacheStatus(options) {
|
|
29
|
+
const staleThreshold = options.staleThresholdMs ?? 86_400_000; // 24h default
|
|
30
|
+
let totalEntries = 0;
|
|
31
|
+
let totalSizeBytes = 0;
|
|
32
|
+
let staleEntries = 0;
|
|
33
|
+
let oldestEntry = null;
|
|
34
|
+
let newestEntry = null;
|
|
35
|
+
try {
|
|
36
|
+
const entries = await readdir(options.cacheDir);
|
|
37
|
+
const encFiles = entries.filter((e) => e.endsWith('.enc'));
|
|
38
|
+
totalEntries = encFiles.length;
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
for (const file of encFiles) {
|
|
41
|
+
try {
|
|
42
|
+
const filePath = join(options.cacheDir, file);
|
|
43
|
+
const fileStat = await stat(filePath);
|
|
44
|
+
totalSizeBytes += fileStat.size;
|
|
45
|
+
const mtime = fileStat.mtime;
|
|
46
|
+
if (!oldestEntry || mtime < oldestEntry)
|
|
47
|
+
oldestEntry = mtime;
|
|
48
|
+
if (!newestEntry || mtime > newestEntry)
|
|
49
|
+
newestEntry = mtime;
|
|
50
|
+
if (now - mtime.getTime() > staleThreshold) {
|
|
51
|
+
staleEntries++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Skip files that can't be stat'd
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Cache directory doesn't exist or can't be read
|
|
61
|
+
}
|
|
62
|
+
const circuitState = options.circuitBreaker.getState().state;
|
|
63
|
+
let telemetryQueueSize = 0;
|
|
64
|
+
try {
|
|
65
|
+
const queueStats = await options.telemetryQueue.getStats();
|
|
66
|
+
telemetryQueueSize = queueStats.count;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Queue unavailable
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
totalEntries,
|
|
73
|
+
totalSizeBytes,
|
|
74
|
+
totalSizeFormatted: formatBytes(totalSizeBytes),
|
|
75
|
+
oldestEntry,
|
|
76
|
+
newestEntry,
|
|
77
|
+
staleEntries,
|
|
78
|
+
circuitState,
|
|
79
|
+
lastSync: newestEntry, // Most recent cache write approximates last sync
|
|
80
|
+
telemetryQueueSize,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Format cache status as a human-readable string for terminal output.
|
|
85
|
+
*/
|
|
86
|
+
export function formatCacheStatus(info) {
|
|
87
|
+
const lines = [
|
|
88
|
+
'+-------------------------------------------------+',
|
|
89
|
+
'| NEOCORTEX CACHE STATUS |',
|
|
90
|
+
'+-------------------------------------------------+',
|
|
91
|
+
`| Total entries: ${String(info.totalEntries).padEnd(29)}|`,
|
|
92
|
+
`| Total size: ${info.totalSizeFormatted.padEnd(29)}|`,
|
|
93
|
+
`| Oldest entry: ${(info.oldestEntry?.toISOString() ?? 'N/A').padEnd(29)}|`,
|
|
94
|
+
`| Newest entry: ${(info.newestEntry?.toISOString() ?? 'N/A').padEnd(29)}|`,
|
|
95
|
+
`| Stale entries: ${String(info.staleEntries).padEnd(29)}|`,
|
|
96
|
+
'|-------------------------------------------------|',
|
|
97
|
+
`| Circuit breaker: ${info.circuitState.padEnd(29)}|`,
|
|
98
|
+
`| Last sync: ${(info.lastSync?.toISOString() ?? 'N/A').padEnd(29)}|`,
|
|
99
|
+
`| Telemetry queue: ${(info.telemetryQueueSize + ' events').padEnd(29)}|`,
|
|
100
|
+
'+-------------------------------------------------+',
|
|
101
|
+
];
|
|
102
|
+
return lines.join('\n');
|
|
103
|
+
}
|
|
104
|
+
// ── Helpers ─────────────────────────────────────────────────────────────
|
|
105
|
+
function formatBytes(bytes) {
|
|
106
|
+
if (bytes === 0)
|
|
107
|
+
return '0 B';
|
|
108
|
+
const units = ['B', 'KB', 'MB', 'GB'];
|
|
109
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
110
|
+
const value = bytes / Math.pow(1024, i);
|
|
111
|
+
return `${value.toFixed(i === 0 ? 0 : 1)} ${units[i]}`;
|
|
112
|
+
}
|
|
@@ -1 +1,88 @@
|
|
|
1
|
-
import{SUBAGENT_APPROVAL_EVIDENCE
|
|
1
|
+
import { SUBAGENT_APPROVAL_EVIDENCE, deriveSubagentHostApprovalPolicy, } from '../policy/subagent-approval-policy.js';
|
|
2
|
+
import { detectPlatform } from '../adapters/platform-detector.js';
|
|
3
|
+
import { ApprovalPolicyConfigError, getSubagentApprovalPolicy, resetSubagentApprovalMode, setSubagentApprovalMode, } from '../config.js';
|
|
4
|
+
function renderResult(result, json) {
|
|
5
|
+
const payload = {
|
|
6
|
+
evidence: SUBAGENT_APPROVAL_EVIDENCE,
|
|
7
|
+
...result.resolution,
|
|
8
|
+
auditEvent: result.auditEvent?.event,
|
|
9
|
+
};
|
|
10
|
+
if (json)
|
|
11
|
+
return JSON.stringify(payload, null, 2);
|
|
12
|
+
return [
|
|
13
|
+
SUBAGENT_APPROVAL_EVIDENCE,
|
|
14
|
+
`requested=${payload.requestedMode}`,
|
|
15
|
+
`effective=${payload.effectiveMode}`,
|
|
16
|
+
`source=${payload.source}`,
|
|
17
|
+
`scope=${payload.scope}`,
|
|
18
|
+
`platform=${payload.platformTarget}`,
|
|
19
|
+
`reason=${payload.effectiveReason}`,
|
|
20
|
+
`fallback=${payload.fallbackMode}`,
|
|
21
|
+
`fallbackReason=${payload.fallbackReasonCode ?? 'none'}`,
|
|
22
|
+
].join(' ');
|
|
23
|
+
}
|
|
24
|
+
export async function configCliHandler(args, dependencies = {}) {
|
|
25
|
+
const stdout = dependencies.stdout ?? console.log;
|
|
26
|
+
const stderr = dependencies.stderr ?? console.error;
|
|
27
|
+
let action = 'status';
|
|
28
|
+
let platformTarget;
|
|
29
|
+
let json = false;
|
|
30
|
+
let actionSeen = false;
|
|
31
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
32
|
+
const value = args[index];
|
|
33
|
+
if (value === '--json') {
|
|
34
|
+
json = true;
|
|
35
|
+
}
|
|
36
|
+
else if (value === '--platform-target') {
|
|
37
|
+
platformTarget = args[index + 1];
|
|
38
|
+
index += 1;
|
|
39
|
+
if (!platformTarget) {
|
|
40
|
+
stderr('Error: --platform-target requires a value.');
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (!actionSeen &&
|
|
45
|
+
(value === 'status' ||
|
|
46
|
+
value === 'max' ||
|
|
47
|
+
value === 'standard' ||
|
|
48
|
+
value === 'disabled' ||
|
|
49
|
+
value === 'reset')) {
|
|
50
|
+
action = value;
|
|
51
|
+
actionSeen = true;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
stderr('Error: expected status, max, standard, disabled, or reset.');
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const env = dependencies.env ?? process.env;
|
|
59
|
+
const detection = detectPlatform({
|
|
60
|
+
cwd: dependencies.cwd ?? process.cwd(),
|
|
61
|
+
env,
|
|
62
|
+
targetFlag: platformTarget,
|
|
63
|
+
});
|
|
64
|
+
const hostPolicy = deriveSubagentHostApprovalPolicy(detection.targetId);
|
|
65
|
+
const options = {
|
|
66
|
+
configFilePath: dependencies.configFilePath,
|
|
67
|
+
platformTarget: detection.targetId,
|
|
68
|
+
hostPolicy,
|
|
69
|
+
now: dependencies.now,
|
|
70
|
+
};
|
|
71
|
+
try {
|
|
72
|
+
const result = action === 'status'
|
|
73
|
+
? getSubagentApprovalPolicy(options)
|
|
74
|
+
: action === 'reset'
|
|
75
|
+
? resetSubagentApprovalMode(options)
|
|
76
|
+
: setSubagentApprovalMode(action, options);
|
|
77
|
+
stdout(renderResult(result, json));
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error instanceof ApprovalPolicyConfigError) {
|
|
82
|
+
stderr(`Error: ${error.reasonCode}`);
|
|
83
|
+
return 1;
|
|
84
|
+
}
|
|
85
|
+
stderr('Error: approval-policy-update-failed');
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
}
|