@ornexus/neocortex 4.60.68 → 4.60.69
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 +1194 -1194
- 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 +3 -290
- 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.d.ts +6 -0
- package/packages/client/dist/commands/invoke.js +142 -7140
- 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 -2536
- 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/git-lifecycle-step-ids.js +1 -14
- package/packages/client/dist/git/git-lifecycle-store.js +9 -1938
- 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/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 -344
- 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/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.js +2 -110
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +8 -1236
- 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.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 -1677
- 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 -185
- 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 -1723
- 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,285 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @license FSL-1.1
|
|
3
|
-
* Copyright (c) 2026 OrNexus AI
|
|
4
|
-
*
|
|
5
|
-
* P199.03 -- public-safe autonomous execution governance envelope.
|
|
6
|
-
*/
|
|
7
|
-
import { createHash } from 'node:crypto';
|
|
8
|
-
export const AUTONOMOUS_GOVERNANCE_VERSION = 1;
|
|
9
|
-
export const AUTONOMOUS_GOVERNANCE_EVENT_TYPE = 'autonomous_governance_audit';
|
|
10
|
-
export const AUTONOMOUS_GOVERNANCE_EVIDENCE_TAG = '[P199-EV-GOVERNANCE]';
|
|
11
|
-
export const AUTONOMOUS_GOVERNANCE_REASON_CODES = Object.freeze({
|
|
12
|
-
OK: 'continuity-ok',
|
|
13
|
-
BYPASS_BLOCKED: 'headless-directive-rejected',
|
|
14
|
-
});
|
|
15
|
-
const DIRECT_YOLO_PATTERN = /^\*yolo @(?<target>docs\/stories\/(?<storyId>[A-Za-z0-9._-]+)\.story\.md)$/;
|
|
16
|
-
const DIRECT_YOLOOP_PATTERN = /^\*yoloop @(?<target>docs\/epics\/epic-(?<epicId>[A-Za-z0-9._-]+)\.md)$/;
|
|
17
|
-
const DIRECT_YOLOOP_DIRECTORY_PATTERN = /^\*yoloop @(?<target>docs\/epics\/?|docs\/epics)$/;
|
|
18
|
-
const STORY_TARGET_PATTERN = /^docs\/stories\/[A-Za-z0-9._-]+\.story\.md$/;
|
|
19
|
-
const EPIC_TARGET_PATTERN = /^docs\/epics\/epic-[A-Za-z0-9._-]+\.md$/;
|
|
20
|
-
const EPIC_DIRECTORY_TARGET_PATTERN = /^docs\/epics\/?$/;
|
|
21
|
-
const SAFE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/;
|
|
22
|
-
const HASH_PATTERN = /^sha256:[a-f0-9]{64}$/;
|
|
23
|
-
const UNSAFE_VALUE_PATTERN = /(https?:\/\/\S+|(?:^|\s)(?:\/(?:home|Users|media|mnt|tmp|var|etc|private)\/\S+|[A-Za-z]:\\\S+)|ghp_[A-Za-z0-9_]+|sk-[A-Za-z0-9_-]+|-----BEGIN [A-Z ]*PRIVATE KEY-----|authorization\s*:|password\s*=|token\s*=|api[_-]?key\s*=|license[_-]?key\s*=|raw[_-]?(?:logs?)\s*[:=]|transcript|stack\s*trace|stderr:|stdout:|system prompt|workflow body|step body|PROTECTED_|PRIVATE_INTERNALS|CUSTOMER_PII|\bPII\b|VENDOR_CORPUS)/i;
|
|
24
|
-
export function parseAutonomousInvokeIntent(args) {
|
|
25
|
-
const trimmed = args.trim();
|
|
26
|
-
const yolo = trimmed.match(DIRECT_YOLO_PATTERN);
|
|
27
|
-
if (yolo?.groups?.target && yolo.groups.storyId) {
|
|
28
|
-
return {
|
|
29
|
-
autonomousKind: 'yolo',
|
|
30
|
-
source: 'direct-yolo',
|
|
31
|
-
targetKind: 'story',
|
|
32
|
-
targetRef: yolo.groups.target,
|
|
33
|
-
storyId: yolo.groups.storyId,
|
|
34
|
-
commandHash: hashPublicValue(trimmed),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const yoloop = trimmed.match(DIRECT_YOLOOP_PATTERN);
|
|
38
|
-
if (yoloop?.groups?.target && yoloop.groups.epicId) {
|
|
39
|
-
return {
|
|
40
|
-
autonomousKind: 'yoloop',
|
|
41
|
-
source: 'direct-yoloop',
|
|
42
|
-
targetKind: 'epic',
|
|
43
|
-
targetRef: yoloop.groups.target,
|
|
44
|
-
epicId: yoloop.groups.epicId,
|
|
45
|
-
commandHash: hashPublicValue(trimmed),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
const yoloopDirectory = trimmed.match(DIRECT_YOLOOP_DIRECTORY_PATTERN);
|
|
49
|
-
if (yoloopDirectory?.groups?.target) {
|
|
50
|
-
return {
|
|
51
|
-
autonomousKind: 'yoloop',
|
|
52
|
-
source: 'direct-yoloop',
|
|
53
|
-
targetKind: 'epic_directory',
|
|
54
|
-
targetRef: 'docs/epics/',
|
|
55
|
-
commandHash: hashPublicValue(trimmed),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
export function isAutonomousInvoke(args) {
|
|
61
|
-
return parseAutonomousInvokeIntent(args) !== null;
|
|
62
|
-
}
|
|
63
|
-
export function buildAutonomousGovernanceEnvelope(input) {
|
|
64
|
-
const idBase = input.storyId ?? input.epicId ?? input.targetRef;
|
|
65
|
-
const safeBase = sanitizeIdPart(idBase);
|
|
66
|
-
const seed = input.operationSeed ?? `${input.autonomousKind}:${input.source}:${input.targetRef}:${input.jobId ?? ''}`;
|
|
67
|
-
const suffix = stableSuffix(seed);
|
|
68
|
-
const jobId = input.jobId ?? `job-${sanitizeIdPart(input.autonomousKind)}-${safeBase}`.slice(0, 96);
|
|
69
|
-
const executionId = `exec-gov-${safeBase}-${suffix}`.slice(0, 120);
|
|
70
|
-
const auditId = `audit-gov-${safeBase}-${suffix}`.slice(0, 120);
|
|
71
|
-
const receiptId = `receipt-gov-${safeBase}-${suffix}`.slice(0, 120);
|
|
72
|
-
const commandHash = input.commandHash ?? hashPublicValue(`${input.autonomousKind}:${input.targetRef}`);
|
|
73
|
-
return {
|
|
74
|
-
schemaVersion: 1,
|
|
75
|
-
contractVersion: 'continuity-v1',
|
|
76
|
-
governanceVersion: AUTONOMOUS_GOVERNANCE_VERSION,
|
|
77
|
-
envelopeId: `gov-${safeBase}-${suffix}`.slice(0, 120),
|
|
78
|
-
jobId,
|
|
79
|
-
executionId,
|
|
80
|
-
auditId,
|
|
81
|
-
receiptId,
|
|
82
|
-
autonomousKind: input.autonomousKind,
|
|
83
|
-
source: input.source,
|
|
84
|
-
targetKind: input.targetKind,
|
|
85
|
-
targetRef: input.targetRef,
|
|
86
|
-
...(input.storyId ? { storyId: input.storyId } : {}),
|
|
87
|
-
...(input.epicId ? { epicId: input.epicId } : {}),
|
|
88
|
-
status: input.status ?? 'accepted',
|
|
89
|
-
reasonCode: input.reasonCode ?? AUTONOMOUS_GOVERNANCE_REASON_CODES.OK,
|
|
90
|
-
publicSummary: `${AUTONOMOUS_GOVERNANCE_EVIDENCE_TAG} Autonomous execution accepted under public continuity governance.`,
|
|
91
|
-
counts: { targets: 1 },
|
|
92
|
-
hashes: { command: commandHash },
|
|
93
|
-
relativePaths: [input.targetRef],
|
|
94
|
-
publicSafe: true,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export function validateAutonomousGovernanceEnvelope(input, expected) {
|
|
98
|
-
const redactions = [];
|
|
99
|
-
if (!isRecord(input)) {
|
|
100
|
-
return rejectedGovernance('autonomousGovernance', redactions);
|
|
101
|
-
}
|
|
102
|
-
const envelope = input;
|
|
103
|
-
if (envelope.schemaVersion !== 1)
|
|
104
|
-
redactions.push(redaction('schemaVersion', 'unsafe_key', 'value-denied'));
|
|
105
|
-
if (envelope.contractVersion !== 'continuity-v1')
|
|
106
|
-
redactions.push(redaction('contractVersion', 'unsafe_key', 'value-denied'));
|
|
107
|
-
if (envelope.governanceVersion !== AUTONOMOUS_GOVERNANCE_VERSION)
|
|
108
|
-
redactions.push(redaction('governanceVersion', 'unsafe_key', 'value-denied'));
|
|
109
|
-
if (envelope.publicSafe !== true)
|
|
110
|
-
redactions.push(redaction('publicSafe', 'unsafe_key', 'value-denied'));
|
|
111
|
-
if (envelope.status !== 'accepted')
|
|
112
|
-
redactions.push(redaction('status', 'unsafe_key', 'value-denied'));
|
|
113
|
-
for (const field of ['envelopeId', 'jobId', 'executionId', 'auditId', 'receiptId', 'reasonCode']) {
|
|
114
|
-
if (!safeId(envelope[field]))
|
|
115
|
-
redactions.push(redaction(field, 'unsafe_key', 'value-denied'));
|
|
116
|
-
}
|
|
117
|
-
if (!safeKind(envelope.autonomousKind))
|
|
118
|
-
redactions.push(redaction('autonomousKind', 'unsafe_key', 'value-denied'));
|
|
119
|
-
if (!safeSource(envelope.source))
|
|
120
|
-
redactions.push(redaction('source', 'unsafe_key', 'value-denied'));
|
|
121
|
-
if (envelope.targetKind !== 'story' && envelope.targetKind !== 'epic' && envelope.targetKind !== 'epic_directory')
|
|
122
|
-
redactions.push(redaction('targetKind', 'unsafe_key', 'value-denied'));
|
|
123
|
-
if (typeof envelope.targetRef !== 'string' || !targetMatches(envelope.targetKind, envelope.targetRef))
|
|
124
|
-
redactions.push(redaction('targetRef', 'prompt_body', 'value-denied'));
|
|
125
|
-
if (envelope.storyId !== undefined && (!safeId(envelope.storyId) || envelope.targetKind !== 'story'))
|
|
126
|
-
redactions.push(redaction('storyId', 'prompt_body', 'value-denied'));
|
|
127
|
-
if (envelope.epicId !== undefined && (!safeId(envelope.epicId) || envelope.targetKind !== 'epic'))
|
|
128
|
-
redactions.push(redaction('epicId', 'prompt_body', 'value-denied'));
|
|
129
|
-
if (typeof envelope.publicSummary !== 'string' || envelope.publicSummary.length > 240 || unsafe(envelope.publicSummary))
|
|
130
|
-
redactions.push(redaction('publicSummary', 'unbounded_text', 'value-denied'));
|
|
131
|
-
if (!isRecord(envelope.counts) || typeof envelope.counts.targets !== 'number')
|
|
132
|
-
redactions.push(redaction('counts', 'unsafe_key', 'value-denied'));
|
|
133
|
-
if (!isRecord(envelope.hashes) || typeof envelope.hashes.command !== 'string' || !HASH_PATTERN.test(envelope.hashes.command))
|
|
134
|
-
redactions.push(redaction('hashes.command', 'prompt_body', 'value-denied'));
|
|
135
|
-
if (!Array.isArray(envelope.relativePaths) || envelope.relativePaths.length !== 1 || envelope.relativePaths[0] !== envelope.targetRef)
|
|
136
|
-
redactions.push(redaction('relativePaths', 'local_absolute_path', 'value-denied'));
|
|
137
|
-
if (expected?.autonomousKind && envelope.autonomousKind !== expected.autonomousKind)
|
|
138
|
-
redactions.push(redaction('autonomousKind', 'unsafe_key', 'operation-denied'));
|
|
139
|
-
if (expected?.jobId && envelope.jobId !== expected.jobId)
|
|
140
|
-
redactions.push(redaction('jobId', 'unsafe_key', 'operation-denied'));
|
|
141
|
-
if (expected?.targetKind && envelope.targetKind !== expected.targetKind)
|
|
142
|
-
redactions.push(redaction('targetKind', 'prompt_body', 'operation-denied'));
|
|
143
|
-
if (expected?.targetRef && envelope.targetRef !== expected.targetRef)
|
|
144
|
-
redactions.push(redaction('targetRef', 'prompt_body', 'operation-denied'));
|
|
145
|
-
if (redactions.length > 0)
|
|
146
|
-
return rejectedGovernance('autonomousGovernance', redactions);
|
|
147
|
-
return { ok: true, envelope: envelope };
|
|
148
|
-
}
|
|
149
|
-
export function readAutonomousGovernanceEnvelopeFromMetadata(metadataJson, expected) {
|
|
150
|
-
if (!metadataJson)
|
|
151
|
-
return rejectedGovernance('autonomousGovernance', []);
|
|
152
|
-
try {
|
|
153
|
-
const metadata = JSON.parse(metadataJson);
|
|
154
|
-
if (!isRecord(metadata))
|
|
155
|
-
return rejectedGovernance('autonomousGovernance', []);
|
|
156
|
-
return validateAutonomousGovernanceEnvelope(metadata.autonomousGovernance, expected);
|
|
157
|
-
}
|
|
158
|
-
catch {
|
|
159
|
-
return rejectedGovernance('autonomousGovernance', []);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
export function recordAutonomousGovernance(store, envelope, nowIso, options = {}) {
|
|
163
|
-
const validation = validateAutonomousGovernanceEnvelope(envelope);
|
|
164
|
-
if (!validation.ok)
|
|
165
|
-
return failedRecord(envelope, validation.publicSummary);
|
|
166
|
-
if (options.requireExistingJob && !store.jobExists(envelope.jobId)) {
|
|
167
|
-
return failedRecord(envelope, `${AUTONOMOUS_GOVERNANCE_EVIDENCE_TAG} Governance bypass blocked before autonomous execution.`);
|
|
168
|
-
}
|
|
169
|
-
store.runInTransaction(() => {
|
|
170
|
-
if (!options.requireExistingJob) {
|
|
171
|
-
store.recordJob({
|
|
172
|
-
jobId: envelope.jobId,
|
|
173
|
-
kind: 'runner',
|
|
174
|
-
status: 'active',
|
|
175
|
-
createdAt: nowIso,
|
|
176
|
-
updatedAt: nowIso,
|
|
177
|
-
summary: `${AUTONOMOUS_GOVERNANCE_EVIDENCE_TAG} Governed autonomous execution job.`,
|
|
178
|
-
reasonCode: envelope.reasonCode,
|
|
179
|
-
operationId: `${envelope.executionId}:job`,
|
|
180
|
-
idempotencyKey: `${envelope.envelopeId}:job`,
|
|
181
|
-
metadata: { autonomousGovernance: envelope, publicSafe: true },
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
store.appendEvent({
|
|
185
|
-
eventId: envelope.auditId,
|
|
186
|
-
jobId: envelope.jobId,
|
|
187
|
-
operationId: `${envelope.executionId}:audit`,
|
|
188
|
-
idempotencyKey: `${envelope.envelopeId}:audit`,
|
|
189
|
-
type: AUTONOMOUS_GOVERNANCE_EVENT_TYPE,
|
|
190
|
-
summary: envelope.publicSummary,
|
|
191
|
-
reasonCode: envelope.reasonCode,
|
|
192
|
-
createdAt: nowIso,
|
|
193
|
-
metadata: { autonomousGovernance: envelope, publicSafe: true },
|
|
194
|
-
});
|
|
195
|
-
store.appendReceipt({
|
|
196
|
-
receiptId: envelope.receiptId,
|
|
197
|
-
jobId: envelope.jobId,
|
|
198
|
-
operationId: `${envelope.executionId}:receipt`,
|
|
199
|
-
idempotencyKey: `${envelope.envelopeId}:receipt`,
|
|
200
|
-
status: 'accepted',
|
|
201
|
-
reasonCode: envelope.reasonCode,
|
|
202
|
-
appliedOperationIds: [envelope.executionId],
|
|
203
|
-
createdAt: nowIso,
|
|
204
|
-
metadata: { autonomousGovernance: envelope, publicSafe: true },
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
return {
|
|
208
|
-
ok: true,
|
|
209
|
-
envelope,
|
|
210
|
-
reasonCode: envelope.reasonCode,
|
|
211
|
-
publicSummary: envelope.publicSummary,
|
|
212
|
-
publicSafe: true,
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
export function autonomousGovernanceMetadata(envelope, base) {
|
|
216
|
-
return {
|
|
217
|
-
...(base ?? {}),
|
|
218
|
-
autonomousGovernance: envelope,
|
|
219
|
-
governanceVersion: AUTONOMOUS_GOVERNANCE_VERSION,
|
|
220
|
-
governanceEvidence: AUTONOMOUS_GOVERNANCE_EVIDENCE_TAG,
|
|
221
|
-
publicSafe: true,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
function rejectedGovernance(field, redactions) {
|
|
225
|
-
return {
|
|
226
|
-
ok: false,
|
|
227
|
-
reasonCode: AUTONOMOUS_GOVERNANCE_REASON_CODES.BYPASS_BLOCKED,
|
|
228
|
-
publicSummary: `${AUTONOMOUS_GOVERNANCE_EVIDENCE_TAG} Governance envelope missing or invalid before autonomous execution.`,
|
|
229
|
-
redactionSummary: redactions.length > 0 ? redactions : [redaction(field, 'unsafe_key', 'operation-denied')],
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
function failedRecord(envelope, publicSummary) {
|
|
233
|
-
return {
|
|
234
|
-
ok: false,
|
|
235
|
-
envelope,
|
|
236
|
-
reasonCode: AUTONOMOUS_GOVERNANCE_REASON_CODES.BYPASS_BLOCKED,
|
|
237
|
-
publicSummary,
|
|
238
|
-
publicSafe: true,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
function hashPublicValue(value) {
|
|
242
|
-
return `sha256:${createHash('sha256').update(value).digest('hex')}`;
|
|
243
|
-
}
|
|
244
|
-
function stableSuffix(value) {
|
|
245
|
-
return createHash('sha256').update(value).digest('hex').slice(0, 12);
|
|
246
|
-
}
|
|
247
|
-
function sanitizeIdPart(value) {
|
|
248
|
-
const normalized = value
|
|
249
|
-
.replace(/^docs\/stories\//, '')
|
|
250
|
-
.replace(/^docs\/epics\/epic-/, '')
|
|
251
|
-
.replace(/\.story\.md$/, '')
|
|
252
|
-
.replace(/\.md$/, '')
|
|
253
|
-
.replace(/[^A-Za-z0-9._-]+/g, '-')
|
|
254
|
-
.replace(/^-+|-+$/g, '');
|
|
255
|
-
return (normalized || 'autonomous').slice(0, 60);
|
|
256
|
-
}
|
|
257
|
-
function safeId(value) {
|
|
258
|
-
return typeof value === 'string' && SAFE_ID_PATTERN.test(value) && !unsafe(value);
|
|
259
|
-
}
|
|
260
|
-
function safeKind(value) {
|
|
261
|
-
return value === 'yolo' || value === 'yoloop' || value === 'run_yolo' || value === 'run_yoloop';
|
|
262
|
-
}
|
|
263
|
-
function safeSource(value) {
|
|
264
|
-
return value === 'direct-yolo' || value === 'direct-yoloop' || value === 'headless-run-yolo' || value === 'headless-run-yoloop' || value === 'delegated-subagent';
|
|
265
|
-
}
|
|
266
|
-
function targetMatches(kind, targetRef) {
|
|
267
|
-
if (unsafe(targetRef))
|
|
268
|
-
return false;
|
|
269
|
-
if (kind === 'story')
|
|
270
|
-
return STORY_TARGET_PATTERN.test(targetRef);
|
|
271
|
-
if (kind === 'epic')
|
|
272
|
-
return EPIC_TARGET_PATTERN.test(targetRef);
|
|
273
|
-
if (kind === 'epic_directory')
|
|
274
|
-
return EPIC_DIRECTORY_TARGET_PATTERN.test(targetRef);
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
function unsafe(value) {
|
|
278
|
-
return UNSAFE_VALUE_PATTERN.test(value) || /[;&|`$<>\n\r\0]/.test(value);
|
|
279
|
-
}
|
|
280
|
-
function isRecord(value) {
|
|
281
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
282
|
-
}
|
|
283
|
-
function redaction(field, reason, evidence) {
|
|
284
|
-
return { field, reason, evidence, publicSafe: true };
|
|
285
|
-
}
|
|
1
|
+
import{createHash as y}from"node:crypto";const c=1,R="autonomous_governance_audit",s="[P199-EV-GOVERNANCE]",p=Object.freeze({OK:"continuity-ok",BYPASS_BLOCKED:"headless-directive-rejected"}),S=/^\*yolo @(?<target>docs\/stories\/(?<storyId>[A-Za-z0-9._-]+)\.story\.md)$/,T=/^\*yoloop @(?<target>docs\/epics\/epic-(?<epicId>[A-Za-z0-9._-]+)\.md)$/,O=/^\*yoloop @(?<target>docs\/epics\/?|docs\/epics)$/,K=/^docs\/stories\/[A-Za-z0-9._-]+\.story\.md$/,v=/^docs\/epics\/epic-[A-Za-z0-9._-]+\.md$/,$=/^docs\/epics\/?$/,C=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/,N=/^sha256:[a-f0-9]{64}$/,P=/(https?:\/\/\S+|(?:^|\s)(?:\/(?:home|Users|media|mnt|tmp|var|etc|private)\/\S+|[A-Za-z]:\\\S+)|ghp_[A-Za-z0-9_]+|sk-[A-Za-z0-9_-]+|-----BEGIN [A-Z ]*PRIVATE KEY-----|authorization\s*:|password\s*=|token\s*=|api[_-]?key\s*=|license[_-]?key\s*=|raw[_-]?(?:logs?)\s*[:=]|transcript|stack\s*trace|stderr:|stdout:|system prompt|workflow body|step body|PROTECTED_|PRIVATE_INTERNALS|CUSTOMER_PII|\bPII\b|VENDOR_CORPUS)/i;function G(e){const o=e.trim(),r=o.match(S);if(r?.groups?.target&&r.groups.storyId)return{autonomousKind:"yolo",source:"direct-yolo",targetKind:"story",targetRef:r.groups.target,storyId:r.groups.storyId,commandHash:u(o)};const t=o.match(T);return t?.groups?.target&&t.groups.epicId?{autonomousKind:"yoloop",source:"direct-yoloop",targetKind:"epic",targetRef:t.groups.target,epicId:t.groups.epicId,commandHash:u(o)}:o.match(O)?.groups?.target?{autonomousKind:"yoloop",source:"direct-yoloop",targetKind:"epic_directory",targetRef:"docs/epics/",commandHash:u(o)}:null}function D(e){return G(e)!==null}function U(e){const o=e.storyId??e.epicId??e.targetRef,r=g(o),t=e.operationSeed??`${e.autonomousKind}:${e.source}:${e.targetRef}:${e.jobId??""}`,a=k(t),_=e.jobId??`job-${g(e.autonomousKind)}-${r}`.slice(0,96),h=`exec-gov-${r}-${a}`.slice(0,120),b=`audit-gov-${r}-${a}`.slice(0,120),E=`receipt-gov-${r}-${a}`.slice(0,120),A=e.commandHash??u(`${e.autonomousKind}:${e.targetRef}`);return{schemaVersion:1,contractVersion:"continuity-v1",governanceVersion:c,envelopeId:`gov-${r}-${a}`.slice(0,120),jobId:_,executionId:h,auditId:b,receiptId:E,autonomousKind:e.autonomousKind,source:e.source,targetKind:e.targetKind,targetRef:e.targetRef,...e.storyId?{storyId:e.storyId}:{},...e.epicId?{epicId:e.epicId}:{},status:e.status??"accepted",reasonCode:e.reasonCode??p.OK,publicSummary:`${s} Autonomous execution accepted under public continuity governance.`,counts:{targets:1},hashes:{command:A},relativePaths:[e.targetRef],publicSafe:!0}}function l(e,o){const r=[];if(!d(e))return i("autonomousGovernance",r);const t=e;t.schemaVersion!==1&&r.push(n("schemaVersion","unsafe_key","value-denied")),t.contractVersion!=="continuity-v1"&&r.push(n("contractVersion","unsafe_key","value-denied")),t.governanceVersion!==c&&r.push(n("governanceVersion","unsafe_key","value-denied")),t.publicSafe!==!0&&r.push(n("publicSafe","unsafe_key","value-denied")),t.status!=="accepted"&&r.push(n("status","unsafe_key","value-denied"));for(const a of["envelopeId","jobId","executionId","auditId","receiptId","reasonCode"])f(t[a])||r.push(n(a,"unsafe_key","value-denied"));return j(t.autonomousKind)||r.push(n("autonomousKind","unsafe_key","value-denied")),V(t.source)||r.push(n("source","unsafe_key","value-denied")),t.targetKind!=="story"&&t.targetKind!=="epic"&&t.targetKind!=="epic_directory"&&r.push(n("targetKind","unsafe_key","value-denied")),(typeof t.targetRef!="string"||!x(t.targetKind,t.targetRef))&&r.push(n("targetRef","prompt_body","value-denied")),t.storyId!==void 0&&(!f(t.storyId)||t.targetKind!=="story")&&r.push(n("storyId","prompt_body","value-denied")),t.epicId!==void 0&&(!f(t.epicId)||t.targetKind!=="epic")&&r.push(n("epicId","prompt_body","value-denied")),(typeof t.publicSummary!="string"||t.publicSummary.length>240||m(t.publicSummary))&&r.push(n("publicSummary","unbounded_text","value-denied")),(!d(t.counts)||typeof t.counts.targets!="number")&&r.push(n("counts","unsafe_key","value-denied")),(!d(t.hashes)||typeof t.hashes.command!="string"||!N.test(t.hashes.command))&&r.push(n("hashes.command","prompt_body","value-denied")),(!Array.isArray(t.relativePaths)||t.relativePaths.length!==1||t.relativePaths[0]!==t.targetRef)&&r.push(n("relativePaths","local_absolute_path","value-denied")),o?.autonomousKind&&t.autonomousKind!==o.autonomousKind&&r.push(n("autonomousKind","unsafe_key","operation-denied")),o?.jobId&&t.jobId!==o.jobId&&r.push(n("jobId","unsafe_key","operation-denied")),o?.targetKind&&t.targetKind!==o.targetKind&&r.push(n("targetKind","prompt_body","operation-denied")),o?.targetRef&&t.targetRef!==o.targetRef&&r.push(n("targetRef","prompt_body","operation-denied")),r.length>0?i("autonomousGovernance",r):{ok:!0,envelope:t}}function Y(e,o){if(!e)return i("autonomousGovernance",[]);try{const r=JSON.parse(e);return d(r)?l(r.autonomousGovernance,o):i("autonomousGovernance",[])}catch{return i("autonomousGovernance",[])}}function Z(e,o,r,t={}){const a=l(o);return a.ok?t.requireExistingJob&&!e.jobExists(o.jobId)?I(o,`${s} Governance bypass blocked before autonomous execution.`):(e.runInTransaction(()=>{t.requireExistingJob||e.recordJob({jobId:o.jobId,kind:"runner",status:"active",createdAt:r,updatedAt:r,summary:`${s} Governed autonomous execution job.`,reasonCode:o.reasonCode,operationId:`${o.executionId}:job`,idempotencyKey:`${o.envelopeId}:job`,metadata:{autonomousGovernance:o,publicSafe:!0}}),e.appendEvent({eventId:o.auditId,jobId:o.jobId,operationId:`${o.executionId}:audit`,idempotencyKey:`${o.envelopeId}:audit`,type:R,summary:o.publicSummary,reasonCode:o.reasonCode,createdAt:r,metadata:{autonomousGovernance:o,publicSafe:!0}}),e.appendReceipt({receiptId:o.receiptId,jobId:o.jobId,operationId:`${o.executionId}:receipt`,idempotencyKey:`${o.envelopeId}:receipt`,status:"accepted",reasonCode:o.reasonCode,appliedOperationIds:[o.executionId],createdAt:r,metadata:{autonomousGovernance:o,publicSafe:!0}})}),{ok:!0,envelope:o,reasonCode:o.reasonCode,publicSummary:o.publicSummary,publicSafe:!0}):I(o,a.publicSummary)}function B(e,o){return{...o??{},autonomousGovernance:e,governanceVersion:c,governanceEvidence:s,publicSafe:!0}}function i(e,o){return{ok:!1,reasonCode:p.BYPASS_BLOCKED,publicSummary:`${s} Governance envelope missing or invalid before autonomous execution.`,redactionSummary:o.length>0?o:[n(e,"unsafe_key","operation-denied")]}}function I(e,o){return{ok:!1,envelope:e,reasonCode:p.BYPASS_BLOCKED,publicSummary:o,publicSafe:!0}}function u(e){return`sha256:${y("sha256").update(e).digest("hex")}`}function k(e){return y("sha256").update(e).digest("hex").slice(0,12)}function g(e){return(e.replace(/^docs\/stories\//,"").replace(/^docs\/epics\/epic-/,"").replace(/\.story\.md$/,"").replace(/\.md$/,"").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"autonomous").slice(0,60)}function f(e){return typeof e=="string"&&C.test(e)&&!m(e)}function j(e){return e==="yolo"||e==="yoloop"||e==="run_yolo"||e==="run_yoloop"}function V(e){return e==="direct-yolo"||e==="direct-yoloop"||e==="headless-run-yolo"||e==="headless-run-yoloop"||e==="delegated-subagent"}function x(e,o){return m(o)?!1:e==="story"?K.test(o):e==="epic"?v.test(o):e==="epic_directory"?$.test(o):!1}function m(e){return P.test(e)||/[;&|`$<>\n\r\0]/.test(e)}function d(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function n(e,o,r){return{field:e,reason:o,evidence:r,publicSafe:!0}}export{R as AUTONOMOUS_GOVERNANCE_EVENT_TYPE,s as AUTONOMOUS_GOVERNANCE_EVIDENCE_TAG,p as AUTONOMOUS_GOVERNANCE_REASON_CODES,c as AUTONOMOUS_GOVERNANCE_VERSION,B as autonomousGovernanceMetadata,U as buildAutonomousGovernanceEnvelope,D as isAutonomousInvoke,G as parseAutonomousInvokeIntent,Y as readAutonomousGovernanceEnvelopeFromMetadata,Z as recordAutonomousGovernance,l as validateAutonomousGovernanceEnvelope};
|