@ornexus/neocortex 4.60.73 → 4.60.74
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 +1216 -1210
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +2 -2
- package/packages/client/dist/adapters/adapter-registry.js +1 -108
- package/packages/client/dist/adapters/antigravity-adapter.js +2 -77
- package/packages/client/dist/adapters/claude-code-adapter.js +3 -79
- package/packages/client/dist/adapters/codex-adapter.js +2 -80
- package/packages/client/dist/adapters/cursor-adapter.js +4 -115
- package/packages/client/dist/adapters/gemini-adapter.js +2 -71
- package/packages/client/dist/adapters/grok-adapter.js +2 -42
- package/packages/client/dist/adapters/index.js +1 -22
- package/packages/client/dist/adapters/platform-detector.js +1 -212
- package/packages/client/dist/adapters/target-adapter.js +0 -12
- package/packages/client/dist/adapters/vscode-adapter.js +2 -72
- package/packages/client/dist/agent/refresh-stubs.js +2 -417
- package/packages/client/dist/agent/update-agent-yaml.js +1 -102
- package/packages/client/dist/agent/update-description.js +1 -251
- package/packages/client/dist/cache/crypto-utils.js +1 -78
- package/packages/client/dist/cache/encrypted-cache.js +1 -108
- package/packages/client/dist/cache/in-memory-asset-cache.js +1 -73
- package/packages/client/dist/cache/index.js +1 -13
- package/packages/client/dist/cache/protected-pi-boundary.js +1 -44
- package/packages/client/dist/checkpoint/checkpoint-client-reader.js +2 -127
- package/packages/client/dist/checkpoint/index.js +1 -11
- package/packages/client/dist/checkpoint/shared-checkpoint-types.js +1 -32
- package/packages/client/dist/cli.js +5 -358
- package/packages/client/dist/commands/activate.js +8 -394
- package/packages/client/dist/commands/architecture-answers.js +7 -274
- package/packages/client/dist/commands/architecture-memory-terminal.js +4 -253
- package/packages/client/dist/commands/architecture-non-ui-continuation.js +1 -100
- package/packages/client/dist/commands/architecture-root-binding.js +1 -51
- package/packages/client/dist/commands/cache-status.js +2 -112
- package/packages/client/dist/commands/config.js +1 -88
- package/packages/client/dist/commands/doctor.js +2 -635
- package/packages/client/dist/commands/invoke.js +143 -7200
- package/packages/client/dist/commands/legacy-epic-terminal.js +1 -71
- package/packages/client/dist/commands/legacy-story-branch.js +1 -96
- package/packages/client/dist/commands/legacy-story-pr.js +1 -276
- package/packages/client/dist/commands/mutation-qa-checkpoint.js +5 -285
- package/packages/client/dist/commands/mutation-qa-gate.js +1 -54
- package/packages/client/dist/commands/mutation-qa-git.js +1 -41
- package/packages/client/dist/commands/mutation-qa-policy.js +1 -102
- package/packages/client/dist/commands/mutation-qa-run.js +3 -219
- package/packages/client/dist/commands/mutation-qa-verdict.js +1 -149
- package/packages/client/dist/commands/mutation-qa.js +1 -220
- package/packages/client/dist/commands/native-agent.js +2 -136
- package/packages/client/dist/commands/planning-diagnosis.js +1 -43
- package/packages/client/dist/commands/planning-generation.js +1 -53
- package/packages/client/dist/commands/planning-memory.js +1 -40
- package/packages/client/dist/commands/planning-research.js +1 -42
- package/packages/client/dist/commands/private-session.js +1 -75
- package/packages/client/dist/commands/property-qa.js +1 -139
- package/packages/client/dist/commands/qa-control.js +1 -16
- package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -55
- package/packages/client/dist/commands/qa-scan-browser-route.js +1 -28
- package/packages/client/dist/commands/qa-scan-capture.js +5 -663
- package/packages/client/dist/commands/qa-scan-discovery.js +3 -376
- package/packages/client/dist/commands/qa-scan-review.js +5 -826
- package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -266
- package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -297
- package/packages/client/dist/commands/qa-synthetic-backend.js +2 -340
- package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -85
- package/packages/client/dist/commands/qa-synthetic-browser.js +1 -39
- package/packages/client/dist/commands/refactor-characterization.js +21 -671
- package/packages/client/dist/commands/refactor-commit.js +13 -399
- package/packages/client/dist/commands/refactor-control.js +3 -142
- package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -93
- package/packages/client/dist/commands/refactor-review.js +5 -283
- package/packages/client/dist/commands/refactor-root.js +7 -588
- package/packages/client/dist/commands/refresh-memory.js +3 -156
- package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -24
- package/packages/client/dist/commands/story-checkpoint.js +1 -171
- package/packages/client/dist/config/profile-directory.js +1 -13
- package/packages/client/dist/config/resolver-selection.js +1 -278
- package/packages/client/dist/config/secure-config.js +12 -281
- package/packages/client/dist/config.js +2 -223
- package/packages/client/dist/constants.js +1 -25
- package/packages/client/dist/context/context-collector.js +2 -222
- package/packages/client/dist/context/context-sanitizer.js +1 -145
- package/packages/client/dist/continuity/autonomous-governance.js +1 -285
- package/packages/client/dist/continuity/continuity-client-state-store.js +1 -1587
- package/packages/client/dist/continuity/invoke-hooks.js +1 -129
- package/packages/client/dist/continuity/migrations/001-initial-schema.js +2 -12
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +2 -12
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +2 -12
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +2 -12
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +2 -12
- package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +2 -10
- package/packages/client/dist/continuity/native-agent-store.js +1 -69
- package/packages/client/dist/continuity/native-agent-types.js +1 -90
- package/packages/client/dist/continuity/outbox.js +1 -117
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -172
- package/packages/client/dist/continuity/sqlite-store.js +81 -2612
- package/packages/client/dist/effects/invoke-effect-gateways.js +1 -62
- package/packages/client/dist/errors/error-messages.js +2 -228
- package/packages/client/dist/errors/frontmatter-diagnostics.js +1 -125
- package/packages/client/dist/evidence/collector.js +1 -347
- package/packages/client/dist/evidence/index.js +1 -1
- package/packages/client/dist/evidence/types.js +0 -2
- package/packages/client/dist/fs/atomic-state-replace.js +1 -152
- package/packages/client/dist/generated/command-registry.generated.js +1 -4076
- package/packages/client/dist/generated/public-projections.generated.js +1 -149
- package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -138
- package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -1234
- package/packages/client/dist/git/epic-operational-state.js +2 -672
- package/packages/client/dist/git/git-lifecycle-step-ids.js +1 -14
- package/packages/client/dist/git/git-lifecycle-store.d.ts +23 -0
- package/packages/client/dist/git/git-lifecycle-store.js +10 -1981
- package/packages/client/dist/git/legacy-story-branch-checkpoint.js +9 -259
- package/packages/client/dist/git/legacy-story-branch-setup.js +4 -348
- package/packages/client/dist/git/legacy-story-pr.js +70 -3538
- package/packages/client/dist/git/secure-filesystem-boundary.js +5 -182
- package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -284
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -237
- package/packages/client/dist/i18n/first-run.js +2 -60
- package/packages/client/dist/index.js +1 -47
- package/packages/client/dist/invocation/invoke-input.js +1 -24
- package/packages/client/dist/license/index.js +1 -5
- package/packages/client/dist/license/license-client.js +1 -304
- package/packages/client/dist/machine/fingerprint.js +2 -163
- package/packages/client/dist/machine/index.js +1 -5
- package/packages/client/dist/memory/project-memory-path-scope.js +1 -62
- package/packages/client/dist/memory/project-memory-writer.js +40 -1007
- package/packages/client/dist/memory/shared-project-memory-types.js +2 -253
- package/packages/client/dist/migrations/epic-lifecycle-backfill.js +3 -1060
- package/packages/client/dist/migrations/project-identity-capability.js +1 -50
- package/packages/client/dist/migrations/project-identity.js +7 -493
- package/packages/client/dist/migrations/state-json.js +4 -393
- package/packages/client/dist/policy/architecture-policy.js +2 -184
- package/packages/client/dist/policy/index.js +1 -7
- package/packages/client/dist/policy/shared-policy-types.js +0 -38
- package/packages/client/dist/policy/subagent-approval-policy.js +1 -55
- package/packages/client/dist/private-execution/clean-baseline.js +2 -279
- package/packages/client/dist/private-execution/codex-executor.js +4 -574
- package/packages/client/dist/private-execution/codex-host-runtime.js +1 -137
- package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -97
- package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -128
- package/packages/client/dist/private-execution/delivery.js +13 -410
- package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -294
- package/packages/client/dist/private-execution/frozen-handoff.js +6 -19
- package/packages/client/dist/private-execution/implementation-validation.js +2 -106
- package/packages/client/dist/private-execution/isolated-admission.js +23 -1432
- package/packages/client/dist/private-execution/isolated-session.js +5 -725
- package/packages/client/dist/private-execution/isolated-workspace.js +1 -122
- package/packages/client/dist/private-execution/pact-consumer-runtime.js +3 -409
- package/packages/client/dist/private-execution/pact-test-source.js +1 -258
- package/packages/client/dist/private-execution/pact-toolchain.js +3 -290
- package/packages/client/dist/private-execution/pact-write-set.js +1 -172
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -406
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +5 -462
- package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -139
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -325
- package/packages/client/dist/private-execution/private-report-store.js +1 -42
- package/packages/client/dist/private-execution/property-test-candidate.js +1 -103
- package/packages/client/dist/private-execution/property-test-choices.js +3 -147
- package/packages/client/dist/private-execution/property-test-plan.js +7 -271
- package/packages/client/dist/private-execution/property-test-review.js +4 -258
- package/packages/client/dist/private-execution/property-test-runtime.js +9 -372
- package/packages/client/dist/private-execution/property-test-source.js +1 -139
- package/packages/client/dist/private-execution/root-checkpoint.js +1 -80
- package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -135
- package/packages/client/dist/private-execution/root-memory-recovery.js +1 -93
- package/packages/client/dist/private-execution/root-memory-request.js +1 -29
- package/packages/client/dist/private-execution/root-memory-scope.js +1 -178
- package/packages/client/dist/private-execution/root-memory-writer.js +1 -102
- package/packages/client/dist/private-execution/session-lease.js +1 -63
- package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -50
- package/packages/client/dist/private-execution/shared-project-validation.js +1 -66
- package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -61
- package/packages/client/dist/private-execution/ux-source-validation.js +1 -372
- package/packages/client/dist/private-execution/ux-write-set.js +2 -191
- package/packages/client/dist/registry/registry-reconciliation.js +1 -234
- package/packages/client/dist/resilience/circuit-breaker.js +1 -170
- package/packages/client/dist/resilience/degradation-manager.js +1 -164
- package/packages/client/dist/resilience/freshness-indicator.js +1 -100
- package/packages/client/dist/resilience/index.js +1 -8
- package/packages/client/dist/resilience/recovery-detector.js +1 -74
- package/packages/client/dist/resolvers/asset-resolver.js +0 -13
- package/packages/client/dist/resolvers/local-resolver.js +8 -255
- package/packages/client/dist/resolvers/remote-resolver.js +1 -233
- package/packages/client/dist/runner/binary.js +1 -404
- package/packages/client/dist/runner/cli.js +17 -1571
- package/packages/client/dist/runner/headless/adapters.js +1 -49
- package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -79
- package/packages/client/dist/runner/headless/continuous-story-workspace.js +11 -1628
- package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +1 -69
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.d.ts +1 -1
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +2 -110
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.d.ts +2 -0
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +10 -1236
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.d.ts +18 -2
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +2 -318
- package/packages/client/dist/runner/headless/fake-adapter.js +1 -62
- package/packages/client/dist/runner/headless/managed-profile.js +1 -132
- package/packages/client/dist/runner/headless/opencode-adapter.js +2 -145
- package/packages/client/dist/runner/headless/prepared-story-bundle.js +1 -43
- package/packages/client/dist/runner/headless/resolver.js +1 -231
- package/packages/client/dist/runner/headless/run-yolo.js +1 -885
- package/packages/client/dist/runner/headless/run-yoloop.d.ts +1 -0
- package/packages/client/dist/runner/headless/run-yoloop.js +2 -2574
- package/packages/client/dist/runner/headless/types.js +2 -574
- package/packages/client/dist/runner/local-console.js +13 -396
- package/packages/client/dist/runner/portal-sync-worker.js +1 -1487
- package/packages/client/dist/runner/project-identity.js +1 -106
- package/packages/client/dist/runner/scheduler.js +7 -995
- package/packages/client/dist/runner-cli.js +2 -18
- package/packages/client/dist/state/invocation-shape.js +1 -13
- package/packages/client/dist/state/project-state-snapshot.js +1 -1731
- package/packages/client/dist/state/state-json-repair.js +3 -785
- package/packages/client/dist/state/structural-dag-projection.js +1 -118
- package/packages/client/dist/telemetry/index.js +1 -5
- package/packages/client/dist/telemetry/offline-queue.js +1 -131
- package/packages/client/dist/tier/index.js +1 -5
- package/packages/client/dist/tier/tier-aware-client.js +1 -405
- package/packages/client/dist/types/index.js +1 -38
- package/packages/client/dist/version.js +1 -27
- package/packages/client/dist/yolo/change-evidence-collector.js +1 -126
- package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -62
- package/packages/client/dist/yolo/spec-envelope-collector.js +5 -184
- package/packages/client/dist/yoloop/discovery-hook.js +2 -300
- package/packages/client/dist/yoloop/index.js +1 -8
- package/packages/client/dist/yoloop/invoke-hooks.js +12 -669
- package/packages/client/dist/yoloop/shared-discover-epics.js +1 -1007
- package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -33
- package/packages/client/dist/yoloop/target-normalization.js +1 -180
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1920
- package/packages/shared/dist/yolo/change-evidence.js +1 -1
- package/packages/shared/dist/yoloop/epic-terminal-git.js +144 -2
- 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,69 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/** Maximum PRs related to managed branches, independent of repository history size. */
|
|
3
|
-
export const GIT_INVENTORY_PR_LIMIT = 1000;
|
|
4
|
-
export function collectGitResourceOwnership(state) {
|
|
5
|
-
const claims = new Map();
|
|
6
|
-
const origins = new Set();
|
|
7
|
-
const epics = Object.entries(state.epics ?? {});
|
|
8
|
-
const stories = Object.entries(state.stories ?? {});
|
|
9
|
-
if (epics.length + stories.length > 10000)
|
|
10
|
-
throw new Error('git-reconciliation-state-inventory-limit');
|
|
11
|
-
const add = (claim) => {
|
|
12
|
-
if (!claim.branch || !claim.origin)
|
|
13
|
-
return;
|
|
14
|
-
claims.set(claim.branch, [...(claims.get(claim.branch) ?? []), claim]);
|
|
15
|
-
};
|
|
16
|
-
for (const [epicId, epic] of epics) {
|
|
17
|
-
const branch = str(epic.execution_branch), origin = str(epic.origin_branch);
|
|
18
|
-
if (origin)
|
|
19
|
-
origins.add(origin);
|
|
20
|
-
const receipt = record(epic.terminal_git_receipt);
|
|
21
|
-
const receiptMatches = receipt?.physicalStatus === 'pushed' && receipt.epicId === epicId
|
|
22
|
-
&& receipt.executionBranch === branch && receipt.originBranch === origin
|
|
23
|
-
&& sha(receipt.executionHeadSha) && sha(receipt.mergeSha) && sha(receipt.pushedSha);
|
|
24
|
-
// A receipt-only orphan can be reconciled; an explicitly resumed lifecycle
|
|
25
|
-
// or live writer always wins over an older terminal receipt.
|
|
26
|
-
const active = liveLease(epic.branch_lease)
|
|
27
|
-
|| (epic.status === undefined ? !receiptMatches : !terminal(epic.status));
|
|
28
|
-
add({ epicId, branch, origin, active,
|
|
29
|
-
proofs: receiptMatches ? [{ head: str(receipt.executionHeadSha),
|
|
30
|
-
evidence: ['terminal_receipt', 'canonical_convention', 'managed_metadata'],
|
|
31
|
-
mergeSha: str(receipt.mergeSha), pushedSha: str(receipt.pushedSha) }] : [],
|
|
32
|
-
prNumbers: prNumber(epic.pr_number), });
|
|
33
|
-
}
|
|
34
|
-
for (const [storyId, story] of stories) {
|
|
35
|
-
const epicId = str(story.epic_id) || storyId.split('.')[0];
|
|
36
|
-
const epic = state.epics?.[epicId];
|
|
37
|
-
const checkpoint = record(story.checkpoint);
|
|
38
|
-
const branch = str(story.branch_name) || str(checkpoint?.branch);
|
|
39
|
-
if (!epic || branch === str(epic.execution_branch))
|
|
40
|
-
continue;
|
|
41
|
-
const proofMatches = checkpoint?.branch === branch && sha(checkpoint.headSha);
|
|
42
|
-
add({ epicId, branch, origin: str(epic.origin_branch),
|
|
43
|
-
active: !terminal(story.status) || liveLease(story.branch_lease),
|
|
44
|
-
proofs: proofMatches ? [{ head: str(checkpoint.headSha),
|
|
45
|
-
evidence: ['state_reference', 'canonical_convention', 'managed_metadata'] }] : [],
|
|
46
|
-
prNumbers: prNumber(story.pr_number), });
|
|
47
|
-
}
|
|
48
|
-
// Convention is corroboration, never authority; validate it against the
|
|
49
|
-
// recorded owner rather than accepting a similar branch prefix.
|
|
50
|
-
for (const [branch, entries] of claims) {
|
|
51
|
-
claims.set(branch, entries.map((entry) => ({ ...entry, proofs: entry.proofs.map((proof) => ({
|
|
52
|
-
...proof, evidence: proof.evidence.filter((item) => item !== 'canonical_convention'
|
|
53
|
-
|| branch === `epic/${entry.epicId}` || branch.startsWith(`epic/${entry.epicId}/`)
|
|
54
|
-
|| branch.startsWith(`story/${entry.epicId}.`) || branch.startsWith(`story/${entry.epicId}/`)),
|
|
55
|
-
})) })));
|
|
56
|
-
}
|
|
57
|
-
return { claims, origins };
|
|
58
|
-
}
|
|
59
|
-
function str(value) { return typeof value === 'string' ? value : ''; }
|
|
60
|
-
function record(value) {
|
|
61
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
62
|
-
}
|
|
63
|
-
function sha(value) { return typeof value === 'string' && /^[a-f0-9]{40,64}$/.test(value); }
|
|
64
|
-
function terminal(value) { return ['done', 'completed', 'merged', 'superseded', 'cancelled', 'archived', 'rolled-back'].includes(str(value)); }
|
|
65
|
-
function liveLease(value) {
|
|
66
|
-
const lease = record(value);
|
|
67
|
-
return Boolean(lease && Date.parse(str(lease.expiresAt)) > Date.now());
|
|
68
|
-
}
|
|
69
|
-
function prNumber(value) { return Number.isSafeInteger(value) && Number(value) > 0 ? [Number(value)] : []; }
|
|
1
|
+
const I=2048,S=1e3;function N(e){const s=new Map,u=new Set,f=Object.entries(e.epics??{}),b=Object.entries(e.stories??{});if(f.length+b.length>1e4)throw new Error("git-reconciliation-state-inventory-limit");const _=t=>{!t.branch||!t.origin||s.set(t.branch,[...s.get(t.branch)??[],t])};for(const[t,r]of f){const i=c(r.execution_branch),o=c(r.origin_branch);o&&u.add(o);const n=d(r.terminal_git_receipt),a=n?.physicalStatus==="pushed"&&n.epicId===t&&n.executionBranch===i&&n.originBranch===o&&p(n.executionHeadSha)&&p(n.mergeSha)&&p(n.pushedSha),h=m(r.branch_lease)||(r.status===void 0?!a:!g(r.status));_({epicId:t,branch:i,origin:o,active:h,proofs:a?[{head:c(n.executionHeadSha),evidence:["terminal_receipt","canonical_convention","managed_metadata"],mergeSha:c(n.mergeSha),pushedSha:c(n.pushedSha)}]:[],prNumbers:l(r.pr_number)})}for(const[t,r]of b){const i=c(r.epic_id)||t.split(".")[0],o=e.epics?.[i],n=d(r.checkpoint),a=c(r.branch_name)||c(n?.branch);if(!o||a===c(o.execution_branch))continue;const h=n?.branch===a&&p(n.headSha);_({epicId:i,branch:a,origin:c(o.origin_branch),active:!g(r.status)||m(r.branch_lease),proofs:h?[{head:c(n.headSha),evidence:["state_reference","canonical_convention","managed_metadata"]}]:[],prNumbers:l(r.pr_number)})}for(const[t,r]of s)s.set(t,r.map(i=>({...i,proofs:i.proofs.map(o=>({...o,evidence:o.evidence.filter(n=>n!=="canonical_convention"||t===`epic/${i.epicId}`||t.startsWith(`epic/${i.epicId}/`)||t.startsWith(`story/${i.epicId}.`)||t.startsWith(`story/${i.epicId}/`))}))})));return{claims:s,origins:u}}function c(e){return typeof e=="string"?e:""}function d(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function p(e){return typeof e=="string"&&/^[a-f0-9]{40,64}$/.test(e)}function g(e){return["done","completed","merged","superseded","cancelled","archived","rolled-back"].includes(c(e))}function m(e){const s=d(e);return!!(s&&Date.parse(c(s.expiresAt))>Date.now())}function l(e){return Number.isSafeInteger(e)&&Number(e)>0?[Number(e)]:[]}export{S as GIT_INVENTORY_PR_LIMIT,I as GIT_INVENTORY_REF_LIMIT,N as collectGitResourceOwnership};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EpicMergeCandidateQaReceipt } from '../../../../shared/dist/yoloop/epic-terminal-git.js';
|
|
2
2
|
export interface EpicMergeCandidateBinding {
|
|
3
3
|
readonly originHeadSha: string;
|
|
4
4
|
readonly executionHeadSha: string;
|
|
@@ -1,61 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { execFile } from 'node:child_process';
|
|
3
|
-
import { createHash, randomBytes } from 'node:crypto';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { promisify } from 'node:util';
|
|
6
|
-
import { assertGitLifecyclePrivateDirectory, ensureGitLifecyclePrivateChildDirectory, executeP205TransientAuthority, gitLifecycleRuntimeDirectory, P205_COMPLETE_COMMAND, p205TransientAuthorityMatchesAggregate, projectP205TransientExecutionEvidence, removeGitLifecyclePrivateDirectory, } from '../../git/git-lifecycle-store.js';
|
|
7
|
-
import { anchoredCreateDirectory, anchoredDirectoryIdentity, anchoredExecuteGit, anchoredExecuteNode, anchoredExecuteNpm, secureFilesystemBoundaryAvailable, } from '../../git/secure-filesystem-boundary.js';
|
|
8
|
-
const exec = promisify(execFile);
|
|
9
|
-
const AUTHORITIES = new WeakMap();
|
|
10
|
-
export function verifiedEpicMergeCandidateReceipt(authority, binding) {
|
|
11
|
-
const record = authority && AUTHORITIES.get(authority);
|
|
12
|
-
if (!record || !p205TransientAuthorityMatchesAggregate(record.p205, binding.mergeSha, binding.graphRevision))
|
|
13
|
-
return undefined;
|
|
14
|
-
const age = Date.now() - record.acceptedAt;
|
|
15
|
-
if (age < 0 || age > 30 * 60 * 1000)
|
|
16
|
-
return undefined;
|
|
17
|
-
const receipt = record.receipt;
|
|
18
|
-
return receipt.originHeadSha === binding.originHeadSha && receipt.executionHeadSha === binding.executionHeadSha
|
|
19
|
-
&& receipt.mergeSha === binding.mergeSha && receipt.graphRevision === binding.graphRevision ? receipt : undefined;
|
|
20
|
-
}
|
|
21
|
-
export async function executeEpicMergeCandidateQa(projectRoot, binding, nowIso = new Date().toISOString()) {
|
|
22
|
-
if (!secureFilesystemBoundaryAvailable())
|
|
23
|
-
throw new Error('epic-merge-candidate-platform-unsupported');
|
|
24
|
-
if (![binding.originHeadSha, binding.executionHeadSha, binding.mergeSha].every((sha) => /^[a-f0-9]{40,64}$/.test(sha))
|
|
25
|
-
|| !/^[a-f0-9]{64}$/.test(binding.graphRevision))
|
|
26
|
-
throw new Error('epic-merge-candidate-binding-invalid');
|
|
27
|
-
const rootGit = async (...args) => String((await exec('git', args, { cwd: projectRoot, encoding: 'utf8' })).stdout).trim();
|
|
28
|
-
const parents = (await rootGit('rev-list', '--parents', '-n', '1', binding.mergeSha)).split(/\s+/);
|
|
29
|
-
if (parents.length !== 3 || parents[1] !== binding.originHeadSha || parents[2] !== binding.executionHeadSha) {
|
|
30
|
-
throw new Error('epic-merge-candidate-parents-invalid');
|
|
31
|
-
}
|
|
32
|
-
const treeSha = await rootGit('rev-parse', `${binding.mergeSha}^{tree}`);
|
|
33
|
-
const runtime = await gitLifecycleRuntimeDirectory(projectRoot);
|
|
34
|
-
const parent = await ensureGitLifecyclePrivateChildDirectory(runtime, 'merge-candidates');
|
|
35
|
-
const name = `${binding.mergeSha.slice(0, 16)}-${randomBytes(8).toString('hex')}`;
|
|
36
|
-
const identity = await anchoredCreateDirectory(parent, name);
|
|
37
|
-
const workspace = join(parent, name);
|
|
38
|
-
const git = async (...args) => (await anchoredExecuteGit(parent, name, identity, args)).toString('utf8').trim();
|
|
39
|
-
let p205;
|
|
40
|
-
try {
|
|
41
|
-
await git('init', '--quiet', '--template=');
|
|
42
|
-
await git('fetch', '--quiet', '--no-tags', projectRoot, binding.mergeSha);
|
|
43
|
-
await git('checkout', '--quiet', '--detach', 'FETCH_HEAD');
|
|
44
|
-
if (await git('rev-parse', 'HEAD') !== binding.mergeSha || await git('rev-parse', 'HEAD^{tree}') !== treeSha) {
|
|
45
|
-
throw new Error('epic-merge-candidate-checkout-invalid');
|
|
46
|
-
}
|
|
47
|
-
// Inspect committed entry modes before any filesystem read or npm effect:
|
|
48
|
-
// a symlinked manifest/lock/config can redirect install outside this tree.
|
|
49
|
-
const dependencyEntries = (await git('ls-files', '--stage', '-z', '--', 'package.json', '*/package.json', 'package-lock.json', '*/package-lock.json', 'npm-shrinkwrap.json', '*/npm-shrinkwrap.json', '.npmrc', '*/.npmrc')).split('\0').filter(Boolean);
|
|
50
|
-
if (dependencyEntries.length > 1024 || dependencyEntries.some((entry) => !/^100(?:644|755) [a-f0-9]{40,64} 0\t/.test(entry))) {
|
|
51
|
-
throw new Error('epic-merge-candidate-dependency-entry-unsafe');
|
|
52
|
-
}
|
|
53
|
-
// Each lockfile is installed into the candidate itself. No source
|
|
54
|
-
// node_modules symlink/copy can make QA test the wrong dependency graph.
|
|
55
|
-
const lockfiles = (await git('ls-files', '-z', '--', 'package-lock.json', '*/package-lock.json', 'npm-shrinkwrap.json', '*/npm-shrinkwrap.json')).split('\0').filter(Boolean);
|
|
56
|
-
if (lockfiles.length > 32)
|
|
57
|
-
throw new Error('epic-merge-candidate-dependency-limit');
|
|
58
|
-
const dependencies = JSON.parse((await anchoredExecuteNode(parent, name, identity, ['-e', `
|
|
1
|
+
import{execFile as D}from"node:child_process";import{createHash as x,randomBytes as A}from"node:crypto";import{join as H}from"node:path";import{promisify as j}from"node:util";import{P205_RELEASE_GATE_BUDGETS as O}from"../../../../shared/dist/yoloop/epic-terminal-git.js";import{assertGitLifecyclePrivateDirectory as L,ensureGitLifecyclePrivateChildDirectory as P,executeP205TransientAuthority as C,gitLifecycleRuntimeDirectory as R,P205_COMPLETE_COMMAND as _,p205TransientAuthorityMatchesAggregate as M,projectP205TransientExecutionEvidence as T,removeGitLifecyclePrivateDirectory as q}from"../../git/git-lifecycle-store.js";import{anchoredCreateDirectory as I,anchoredDirectoryIdentity as y,anchoredExecuteGit as N,anchoredExecuteNode as G,anchoredExecuteNpm as $,secureFilesystemBoundaryAvailable as z}from"../../git/secure-filesystem-boundary.js";const B=j(D),S=new WeakMap;function K(c,e){const s=c&&S.get(c);if(!s||!M(s.p205,e.mergeSha,e.graphRevision))return;const h=Date.now()-s.acceptedAt;if(h<0||h>O.aggregateValidityMs)return;const r=s.receipt;return r.originHeadSha===e.originHeadSha&&r.executionHeadSha===e.executionHeadSha&&r.mergeSha===e.mergeSha&&r.graphRevision===e.graphRevision?r:void 0}async function X(c,e,s=new Date().toISOString()){if(!z())throw new Error("epic-merge-candidate-platform-unsupported");if(![e.originHeadSha,e.executionHeadSha,e.mergeSha].every(a=>/^[a-f0-9]{40,64}$/.test(a))||!/^[a-f0-9]{64}$/.test(e.graphRevision))throw new Error("epic-merge-candidate-binding-invalid");const h=async(...a)=>String((await B("git",a,{cwd:c,encoding:"utf8"})).stdout).trim(),r=(await h("rev-list","--parents","-n","1",e.mergeSha)).split(/\s+/);if(r.length!==3||r[1]!==e.originHeadSha||r[2]!==e.executionHeadSha)throw new Error("epic-merge-candidate-parents-invalid");const f=await h("rev-parse",`${e.mergeSha}^{tree}`),v=await R(c),n=await P(v,"merge-candidates"),p=`${e.mergeSha.slice(0,16)}-${A(8).toString("hex")}`,o=await I(n,p),u=H(n,p),t=async(...a)=>(await N(n,p,o,a)).toString("utf8").trim();let w;try{if(await t("init","--quiet","--template="),await t("fetch","--quiet","--no-tags",c,e.mergeSha),await t("checkout","--quiet","--detach","FETCH_HEAD"),await t("rev-parse","HEAD")!==e.mergeSha||await t("rev-parse","HEAD^{tree}")!==f)throw new Error("epic-merge-candidate-checkout-invalid");const a=(await t("ls-files","--stage","-z","--","package.json","*/package.json","package-lock.json","*/package-lock.json","npm-shrinkwrap.json","*/npm-shrinkwrap.json",".npmrc","*/.npmrc")).split("\0").filter(Boolean);if(a.length>1024||a.some(l=>!/^100(?:644|755) [a-f0-9]{40,64} 0\t/.test(l)))throw new Error("epic-merge-candidate-dependency-entry-unsafe");const m=(await t("ls-files","-z","--","package-lock.json","*/package-lock.json","npm-shrinkwrap.json","*/npm-shrinkwrap.json")).split("\0").filter(Boolean);if(m.length>32)throw new Error("epic-merge-candidate-dependency-limit");const d=JSON.parse((await G(n,p,o,["-e",`
|
|
59
2
|
const fs=require('node:fs'); const path=require('node:path'); const locks=JSON.parse(process.argv[1]);
|
|
60
3
|
// npm-shrinkwrap wins over package-lock in the same installation root.
|
|
61
4
|
// Validate every selected root, not only the repository's top-level lock.
|
|
@@ -82,55 +25,4 @@ export async function executeEpicMergeCandidateQa(projectRoot, binding, nowIso =
|
|
|
82
25
|
}
|
|
83
26
|
process.stdout.write(JSON.stringify({unsafeLinks,roots:[...selected.keys()]
|
|
84
27
|
.filter(p=>!workspacePaths.has(p)).sort((a,b)=>a.length-b.length)}));
|
|
85
|
-
`,
|
|
86
|
-
if (dependencies.unsafeLinks)
|
|
87
|
-
throw new Error('epic-merge-candidate-dependency-link-unsafe');
|
|
88
|
-
if (dependencies.roots.length > 16)
|
|
89
|
-
throw new Error('epic-merge-candidate-dependency-limit');
|
|
90
|
-
for (const dependencyRoot of dependencies.roots) {
|
|
91
|
-
if (dependencyRoot !== '.' && !/^[A-Za-z0-9_.\/-]+$/.test(dependencyRoot)
|
|
92
|
-
|| dependencyRoot.split('/').includes('..'))
|
|
93
|
-
throw new Error('epic-merge-candidate-dependency-path-invalid');
|
|
94
|
-
await anchoredExecuteNpm(parent, name, identity, ['--prefix', dependencyRoot, 'ci', '--include=dev', '--no-audit', '--no-fund']);
|
|
95
|
-
}
|
|
96
|
-
if (await git('status', '--porcelain', '--untracked-files=normal'))
|
|
97
|
-
throw new Error('epic-merge-candidate-dirty');
|
|
98
|
-
p205 = await executeP205TransientAuthority(workspace, {
|
|
99
|
-
headSha: binding.mergeSha, graphRevision: binding.graphRevision, nowIso,
|
|
100
|
-
anchoredWorkspace: { parent, name, identity },
|
|
101
|
-
});
|
|
102
|
-
if (await git('status', '--porcelain', '--untracked-files=normal')
|
|
103
|
-
|| await git('rev-parse', 'HEAD') !== binding.mergeSha || await git('rev-parse', 'HEAD^{tree}') !== treeSha) {
|
|
104
|
-
throw new Error('epic-merge-candidate-raced');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
// Cleanup is identity-checked; a substituted directory is never removed.
|
|
109
|
-
await assertGitLifecyclePrivateDirectory(workspace, parent);
|
|
110
|
-
const current = await anchoredDirectoryIdentity(workspace);
|
|
111
|
-
if (current.dev !== identity.dev || current.ino !== identity.ino)
|
|
112
|
-
throw new Error('epic-merge-candidate-cleanup-owner-raced');
|
|
113
|
-
if (!(await removeGitLifecyclePrivateDirectory(workspace, parent, async (renamed) => {
|
|
114
|
-
const moved = await anchoredDirectoryIdentity(renamed);
|
|
115
|
-
return moved.dev === identity.dev && moved.ino === identity.ino;
|
|
116
|
-
})))
|
|
117
|
-
throw new Error('epic-merge-candidate-cleanup-unverified');
|
|
118
|
-
}
|
|
119
|
-
const evidence = projectP205TransientExecutionEvidence(p205);
|
|
120
|
-
if (!evidence || evidence.executionHeadSha !== binding.mergeSha)
|
|
121
|
-
throw new Error('epic-merge-candidate-authority-missing');
|
|
122
|
-
const receiptRef = `merge-qa:${createHash('sha256').update([
|
|
123
|
-
'epic-merge-candidate-qa-v1', binding.originHeadSha, binding.executionHeadSha, binding.mergeSha,
|
|
124
|
-
treeSha, binding.graphRevision, evidence.manifestDigest, evidence.resultDigest, evidence.gateIds.join(','),
|
|
125
|
-
].join('\0')).digest('hex')}`;
|
|
126
|
-
const candidateQa = Object.freeze({ schemaVersion: 1,
|
|
127
|
-
kind: 'epic_merge_candidate_qa', contract: 'P205-CI-02', command: P205_COMPLETE_COMMAND,
|
|
128
|
-
...binding, treeSha, manifestDigest: evidence.manifestDigest, resultDigest: evidence.resultDigest,
|
|
129
|
-
gateIds: Object.freeze([...evidence.gateIds]), checkedAt: evidence.executedAt, receiptRef,
|
|
130
|
-
});
|
|
131
|
-
const candidateAuthority = Object.freeze(Object.create(null));
|
|
132
|
-
// Freshness is process-local evidence captured after QA, not a caller's
|
|
133
|
-
// serialized timestamp. Clock rollback or expiry requires new execution.
|
|
134
|
-
AUTHORITIES.set(candidateAuthority, { receipt: candidateQa, p205: p205, acceptedAt: Date.now() });
|
|
135
|
-
return { candidateQa, candidateAuthority };
|
|
136
|
-
}
|
|
28
|
+
`,JSON.stringify(m)])).toString("utf8"));if(d.unsafeLinks)throw new Error("epic-merge-candidate-dependency-link-unsafe");if(d.roots.length>16)throw new Error("epic-merge-candidate-dependency-limit");for(const l of d.roots){if(l!=="."&&!/^[A-Za-z0-9_.\/-]+$/.test(l)||l.split("/").includes(".."))throw new Error("epic-merge-candidate-dependency-path-invalid");await $(n,p,o,["--prefix",l,"ci","--include=dev","--no-audit","--no-fund"])}if(await t("status","--porcelain","--untracked-files=normal"))throw new Error("epic-merge-candidate-dirty");if(w=await C(u,{headSha:e.mergeSha,graphRevision:e.graphRevision,nowIso:s,anchoredWorkspace:{parent:n,name:p,identity:o}}),await t("status","--porcelain","--untracked-files=normal")||await t("rev-parse","HEAD")!==e.mergeSha||await t("rev-parse","HEAD^{tree}")!==f)throw new Error("epic-merge-candidate-raced")}finally{await L(u,n);const a=await y(u);if(a.dev!==o.dev||a.ino!==o.ino)throw new Error("epic-merge-candidate-cleanup-owner-raced");if(!await q(u,n,async m=>{const d=await y(m);return d.dev===o.dev&&d.ino===o.ino}))throw new Error("epic-merge-candidate-cleanup-unverified")}const i=T(w);if(!i||i.executionHeadSha!==e.mergeSha)throw new Error("epic-merge-candidate-authority-missing");const E=`merge-qa:${x("sha256").update(["epic-merge-candidate-qa-v1",e.originHeadSha,e.executionHeadSha,e.mergeSha,f,e.graphRevision,i.manifestDigest,i.resultDigest,i.gateIds.join(",")].join("\0")).digest("hex")}`,g=Object.freeze({schemaVersion:1,kind:"epic_merge_candidate_qa",contract:"P205-CI-02",command:_,...e,treeSha:f,manifestDigest:i.manifestDigest,resultDigest:i.resultDigest,gateIds:Object.freeze([...i.gateIds]),checkedAt:i.executedAt,receiptRef:E}),k=Object.freeze(Object.create(null));return S.set(k,{receipt:g,p205:w,acceptedAt:Date.now()}),{candidateQa:g,candidateAuthority:k}}export{X as executeEpicMergeCandidateQa,K as verifiedEpicMergeCandidateReceipt};
|
|
@@ -8,5 +8,7 @@ export interface CliEpicTerminalGitAdapterOptions {
|
|
|
8
8
|
/** Command seams keep provider-destructive tests inside temporary fixtures. */
|
|
9
9
|
readonly gitRunner?: (...args: readonly string[]) => Promise<string>;
|
|
10
10
|
readonly providerRunner?: (...args: readonly string[]) => Promise<string>;
|
|
11
|
+
/** Deterministic physical freshness clock for tests; production uses the local clock. */
|
|
12
|
+
readonly now?: () => string;
|
|
11
13
|
}
|
|
12
14
|
export declare function createCliEpicTerminalGitAdapter(projectRoot: string, options?: CliEpicTerminalGitAdapterOptions): EpicTerminalGitAdapter;
|