@neurcode-ai/cli 0.10.1 → 0.12.0
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/.telemetry-bundle/dist/contracts.d.ts +1 -1
- package/README.md +74 -25
- package/dist/commands/remediate-export.js +1 -1
- package/dist/commands/replay.d.ts.map +1 -1
- package/dist/commands/replay.js +36 -0
- package/dist/commands/replay.js.map +1 -1
- package/dist/commands/verify-output.d.ts.map +1 -1
- package/dist/commands/verify-output.js +66 -4
- package/dist/commands/verify-output.js.map +1 -1
- package/dist/commands/verify.d.ts +22 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +446 -34
- package/dist/commands/verify.js.map +1 -1
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js +4 -0
- package/dist/daemon/server.js.map +1 -1
- package/dist/governance/intent/drift-detector.d.ts +100 -0
- package/dist/governance/intent/drift-detector.d.ts.map +1 -0
- package/dist/governance/intent/drift-detector.js +275 -0
- package/dist/governance/intent/drift-detector.js.map +1 -0
- package/dist/governance/intent/glob-match.d.ts +43 -0
- package/dist/governance/intent/glob-match.d.ts.map +1 -0
- package/dist/governance/intent/glob-match.js +108 -0
- package/dist/governance/intent/glob-match.js.map +1 -0
- package/dist/governance/intent/import-graph.d.ts +56 -0
- package/dist/governance/intent/import-graph.d.ts.map +1 -0
- package/dist/governance/intent/import-graph.js +133 -0
- package/dist/governance/intent/import-graph.js.map +1 -0
- package/dist/governance/intent/index.d.ts +23 -0
- package/dist/governance/intent/index.d.ts.map +1 -0
- package/dist/governance/intent/index.js +48 -0
- package/dist/governance/intent/index.js.map +1 -0
- package/dist/governance/intent/intelligence-boundaries.d.ts +69 -0
- package/dist/governance/intent/intelligence-boundaries.d.ts.map +1 -0
- package/dist/governance/intent/intelligence-boundaries.js +163 -0
- package/dist/governance/intent/intelligence-boundaries.js.map +1 -0
- package/dist/governance/intent/intent-contract.d.ts +76 -0
- package/dist/governance/intent/intent-contract.d.ts.map +1 -0
- package/dist/governance/intent/intent-contract.js +397 -0
- package/dist/governance/intent/intent-contract.js.map +1 -0
- package/dist/governance/intent/intent-graph.d.ts +135 -0
- package/dist/governance/intent/intent-graph.d.ts.map +1 -0
- package/dist/governance/intent/intent-graph.js +67 -0
- package/dist/governance/intent/intent-graph.js.map +1 -0
- package/dist/governance/pipeline/computation-trace.d.ts +52 -0
- package/dist/governance/pipeline/computation-trace.d.ts.map +1 -0
- package/dist/governance/pipeline/computation-trace.js +79 -0
- package/dist/governance/pipeline/computation-trace.js.map +1 -0
- package/dist/governance/pipeline/envelope-assembly.d.ts +132 -0
- package/dist/governance/pipeline/envelope-assembly.d.ts.map +1 -0
- package/dist/governance/pipeline/envelope-assembly.js +140 -0
- package/dist/governance/pipeline/envelope-assembly.js.map +1 -0
- package/dist/governance/pipeline/fingerprint.d.ts +34 -0
- package/dist/governance/pipeline/fingerprint.d.ts.map +1 -0
- package/dist/governance/pipeline/fingerprint.js +78 -0
- package/dist/governance/pipeline/fingerprint.js.map +1 -0
- package/dist/governance/pipeline/helpers.d.ts +74 -0
- package/dist/governance/pipeline/helpers.d.ts.map +1 -0
- package/dist/governance/pipeline/helpers.js +112 -0
- package/dist/governance/pipeline/helpers.js.map +1 -0
- package/dist/governance/pipeline/index.d.ts +27 -0
- package/dist/governance/pipeline/index.d.ts.map +1 -0
- package/dist/governance/pipeline/index.js +63 -0
- package/dist/governance/pipeline/index.js.map +1 -0
- package/dist/governance/pipeline/lineage.d.ts +26 -0
- package/dist/governance/pipeline/lineage.d.ts.map +1 -0
- package/dist/governance/pipeline/lineage.js +51 -0
- package/dist/governance/pipeline/lineage.js.map +1 -0
- package/dist/governance/pipeline/orchestration/advisory-mode-contract.d.ts +15 -0
- package/dist/governance/pipeline/orchestration/advisory-mode-contract.d.ts.map +1 -0
- package/dist/governance/pipeline/orchestration/advisory-mode-contract.js +44 -0
- package/dist/governance/pipeline/orchestration/advisory-mode-contract.js.map +1 -0
- package/dist/governance/pipeline/orchestration/advisory-mode.d.ts +102 -0
- package/dist/governance/pipeline/orchestration/advisory-mode.d.ts.map +1 -0
- package/dist/governance/pipeline/orchestration/advisory-mode.js +170 -0
- package/dist/governance/pipeline/orchestration/advisory-mode.js.map +1 -0
- package/dist/governance/pipeline/orchestration/evidence-lifecycle.d.ts +133 -0
- package/dist/governance/pipeline/orchestration/evidence-lifecycle.d.ts.map +1 -0
- package/dist/governance/pipeline/orchestration/evidence-lifecycle.js +125 -0
- package/dist/governance/pipeline/orchestration/evidence-lifecycle.js.map +1 -0
- package/dist/governance/pipeline/orchestration/index.d.ts +16 -0
- package/dist/governance/pipeline/orchestration/index.d.ts.map +1 -0
- package/dist/governance/pipeline/orchestration/index.js +30 -0
- package/dist/governance/pipeline/orchestration/index.js.map +1 -0
- package/dist/governance/pipeline/orchestration/intent-drift-orchestration.d.ts +65 -0
- package/dist/governance/pipeline/orchestration/intent-drift-orchestration.d.ts.map +1 -0
- package/dist/governance/pipeline/orchestration/intent-drift-orchestration.js +102 -0
- package/dist/governance/pipeline/orchestration/intent-drift-orchestration.js.map +1 -0
- package/dist/governance/pipeline/orchestration/plan-structural-analysis.d.ts +41 -0
- package/dist/governance/pipeline/orchestration/plan-structural-analysis.d.ts.map +1 -0
- package/dist/governance/pipeline/orchestration/plan-structural-analysis.js +74 -0
- package/dist/governance/pipeline/orchestration/plan-structural-analysis.js.map +1 -0
- package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.d.ts +165 -0
- package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.d.ts.map +1 -0
- package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.js +160 -0
- package/dist/governance/pipeline/orchestration/policy-evaluation-summaries.js.map +1 -0
- package/dist/governance/pipeline/orchestration/scope-guard-orchestration.d.ts +152 -0
- package/dist/governance/pipeline/orchestration/scope-guard-orchestration.d.ts.map +1 -0
- package/dist/governance/pipeline/orchestration/scope-guard-orchestration.js +188 -0
- package/dist/governance/pipeline/orchestration/scope-guard-orchestration.js.map +1 -0
- package/dist/governance/pipeline/runtime.d.ts +70 -0
- package/dist/governance/pipeline/runtime.d.ts.map +1 -0
- package/dist/governance/pipeline/runtime.js +223 -0
- package/dist/governance/pipeline/runtime.js.map +1 -0
- package/dist/governance/pipeline/shared-types.d.ts +7 -0
- package/dist/governance/pipeline/shared-types.d.ts.map +1 -0
- package/dist/governance/pipeline/shared-types.js +7 -0
- package/dist/governance/pipeline/shared-types.js.map +1 -0
- package/dist/governance/pipeline/stages/compiled-policy-stage.d.ts +28 -0
- package/dist/governance/pipeline/stages/compiled-policy-stage.d.ts.map +1 -0
- package/dist/governance/pipeline/stages/compiled-policy-stage.js +53 -0
- package/dist/governance/pipeline/stages/compiled-policy-stage.js.map +1 -0
- package/dist/governance/pipeline/stages/diff-normalization-stage.d.ts +63 -0
- package/dist/governance/pipeline/stages/diff-normalization-stage.d.ts.map +1 -0
- package/dist/governance/pipeline/stages/diff-normalization-stage.js +140 -0
- package/dist/governance/pipeline/stages/diff-normalization-stage.js.map +1 -0
- package/dist/governance/pipeline/stages/governance-synthesis-stage.d.ts +53 -0
- package/dist/governance/pipeline/stages/governance-synthesis-stage.d.ts.map +1 -0
- package/dist/governance/pipeline/stages/governance-synthesis-stage.js +129 -0
- package/dist/governance/pipeline/stages/governance-synthesis-stage.js.map +1 -0
- package/dist/governance/pipeline/stages/index.d.ts +29 -0
- package/dist/governance/pipeline/stages/index.d.ts.map +1 -0
- package/dist/governance/pipeline/stages/index.js +40 -0
- package/dist/governance/pipeline/stages/index.js.map +1 -0
- package/dist/governance/pipeline/stages/policy-lock-stage.d.ts +31 -0
- package/dist/governance/pipeline/stages/policy-lock-stage.d.ts.map +1 -0
- package/dist/governance/pipeline/stages/policy-lock-stage.js +71 -0
- package/dist/governance/pipeline/stages/policy-lock-stage.js.map +1 -0
- package/dist/governance/pipeline/stages/runtime-guard-stage.d.ts +29 -0
- package/dist/governance/pipeline/stages/runtime-guard-stage.d.ts.map +1 -0
- package/dist/governance/pipeline/stages/runtime-guard-stage.js +65 -0
- package/dist/governance/pipeline/stages/runtime-guard-stage.js.map +1 -0
- package/dist/governance/pipeline/stages/structural-analysis-stage.d.ts +24 -0
- package/dist/governance/pipeline/stages/structural-analysis-stage.d.ts.map +1 -0
- package/dist/governance/pipeline/stages/structural-analysis-stage.js +58 -0
- package/dist/governance/pipeline/stages/structural-analysis-stage.js.map +1 -0
- package/dist/governance/pipeline/summary.d.ts +14 -0
- package/dist/governance/pipeline/summary.d.ts.map +1 -0
- package/dist/governance/pipeline/summary.js +50 -0
- package/dist/governance/pipeline/summary.js.map +1 -0
- package/dist/governance/pipeline/types.d.ts +69 -0
- package/dist/governance/pipeline/types.d.ts.map +1 -0
- package/dist/governance/pipeline/types.js +30 -0
- package/dist/governance/pipeline/types.js.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/active-engineering-context.d.ts +16 -0
- package/dist/utils/active-engineering-context.d.ts.map +1 -1
- package/dist/utils/active-engineering-context.js +302 -0
- package/dist/utils/active-engineering-context.js.map +1 -1
- package/dist/utils/import-edge-classifier.d.ts +76 -0
- package/dist/utils/import-edge-classifier.d.ts.map +1 -0
- package/dist/utils/import-edge-classifier.js +308 -0
- package/dist/utils/import-edge-classifier.js.map +1 -0
- package/dist/utils/import-edge-extractor.d.ts +52 -0
- package/dist/utils/import-edge-extractor.d.ts.map +1 -0
- package/dist/utils/import-edge-extractor.js +223 -0
- package/dist/utils/import-edge-extractor.js.map +1 -0
- package/dist/utils/import-edge-governance.d.ts +37 -0
- package/dist/utils/import-edge-governance.d.ts.map +1 -0
- package/dist/utils/import-edge-governance.js +56 -0
- package/dist/utils/import-edge-governance.js.map +1 -0
- package/dist/utils/path-boundary-classifier.d.ts +42 -0
- package/dist/utils/path-boundary-classifier.d.ts.map +1 -0
- package/dist/utils/path-boundary-classifier.js +143 -0
- package/dist/utils/path-boundary-classifier.js.map +1 -0
- package/dist/utils/replay-html-report.d.ts +29 -0
- package/dist/utils/replay-html-report.d.ts.map +1 -0
- package/dist/utils/replay-html-report.js +309 -0
- package/dist/utils/replay-html-report.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope-Guard + Governance Evaluation Orchestration
|
|
3
|
+
* --------------------------------------------------
|
|
4
|
+
* Extracts the plan-resolution / governance-evaluation / scope-guard compute
|
|
5
|
+
* region previously inlined at `commands/verify.ts:4238–4376`.
|
|
6
|
+
*
|
|
7
|
+
* RESPONSIBILITIES (data-pure):
|
|
8
|
+
* - resolve plan scope (local Plan Sync vs remote plan fetch)
|
|
9
|
+
* - run the intent-aware engine
|
|
10
|
+
* - run structural analysis (via the existing plan-structural-analysis module)
|
|
11
|
+
* - call evaluateGovernance
|
|
12
|
+
* - resolve session ID and fetch allowed files
|
|
13
|
+
* - compute the approved-set intersection and filtered violations
|
|
14
|
+
*
|
|
15
|
+
* EXPLICITLY NOT RESPONSIBLE FOR:
|
|
16
|
+
* - rendering scope violations (chalk output, emitVerifyJson, exitWithEvidence)
|
|
17
|
+
* - `scopeGuardPassed` flag lifecycle (caller owns that)
|
|
18
|
+
* - catch-block error logging (caller owns the surrounding try/catch)
|
|
19
|
+
*
|
|
20
|
+
* SEMANTIC PRESERVATION:
|
|
21
|
+
* The computation sequence, fault-swallowing behaviour (intent engine, session
|
|
22
|
+
* fetch), and intersection logic are byte-identical to the prior inline region.
|
|
23
|
+
*
|
|
24
|
+
* REPLAY INVARIANT:
|
|
25
|
+
* - evaluateGovernance call params are identical to lines 4317-4330
|
|
26
|
+
* - runPlanStructuralAnalysis call is identical to lines 4312-4315
|
|
27
|
+
* - runIntentEngine call is identical to lines 4293-4302
|
|
28
|
+
* - getSessionId() fallback chain is identical to lines 4335-4342
|
|
29
|
+
* - allowedFiles resolution is identical to lines 4352-4371
|
|
30
|
+
* - approvedSet intersection is identical to lines 4373-4376
|
|
31
|
+
*/
|
|
32
|
+
import { evaluateGovernance } from '../../../utils/governance';
|
|
33
|
+
import type { IntentIssue, IntentSummary, FlowIssue, RegressionIssue } from '../../../intent-engine';
|
|
34
|
+
import type { StructuralViolation } from '../../../structural-rules/types';
|
|
35
|
+
import type { DiffFile } from '@neurcode-ai/diff-parser';
|
|
36
|
+
import type { OrgGovernanceSettings } from '@neurcode-ai/core';
|
|
37
|
+
interface PlanData {
|
|
38
|
+
intent: string;
|
|
39
|
+
sessionId: string | null;
|
|
40
|
+
content: {
|
|
41
|
+
title?: unknown;
|
|
42
|
+
summary?: unknown;
|
|
43
|
+
files: Array<{
|
|
44
|
+
action: string;
|
|
45
|
+
path: string;
|
|
46
|
+
}>;
|
|
47
|
+
dependencies?: unknown;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
interface SessionData {
|
|
51
|
+
session: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
export interface ScopeGuardPlanClient {
|
|
54
|
+
getPlan(planId: string): Promise<PlanData>;
|
|
55
|
+
getSession(sessionId: string): Promise<SessionData>;
|
|
56
|
+
}
|
|
57
|
+
export interface ScopeGuardLocalPlan {
|
|
58
|
+
intent: string;
|
|
59
|
+
constraints: string[];
|
|
60
|
+
expectedFiles?: string[];
|
|
61
|
+
}
|
|
62
|
+
export interface ScopeGuardSigningParams {
|
|
63
|
+
signedLogsRequired: boolean;
|
|
64
|
+
/** May be null when no signing key is configured. */
|
|
65
|
+
signingKey: string | null | undefined;
|
|
66
|
+
signingKeyId: string | null | undefined;
|
|
67
|
+
signingKeys: Record<string, string>;
|
|
68
|
+
/** String identifier for the AI-log signer (matches evaluateGovernance's signer param). */
|
|
69
|
+
signer: string | undefined;
|
|
70
|
+
}
|
|
71
|
+
export interface ScopeGuardOrchestrationInput {
|
|
72
|
+
/** True when the resolved planId is 'local-plan-sync'. */
|
|
73
|
+
useLocalPlanSync: boolean;
|
|
74
|
+
/** Snapshot from ensureLocalPlan(). */
|
|
75
|
+
localPlanSync: ScopeGuardLocalPlan;
|
|
76
|
+
/** Deduplicated expected files from the local plan file. */
|
|
77
|
+
localPlanExpectedFiles: string[];
|
|
78
|
+
/** Resolved plan ID (truthy, non-advisory). */
|
|
79
|
+
finalPlanId: string;
|
|
80
|
+
/** API client duck-typed to the two methods we need. */
|
|
81
|
+
client: ScopeGuardPlanClient;
|
|
82
|
+
/** Normalised diff files from the diff-normalization stage. */
|
|
83
|
+
diffFiles: DiffFile[];
|
|
84
|
+
/** Absolute project root path. */
|
|
85
|
+
projectRoot: string;
|
|
86
|
+
/** Config file data (neurcode.config.json). Narrow type — only fields used. */
|
|
87
|
+
configData: {
|
|
88
|
+
sessionId?: unknown;
|
|
89
|
+
lastSessionId?: unknown;
|
|
90
|
+
};
|
|
91
|
+
/** Governance signing credentials. */
|
|
92
|
+
signing: ScopeGuardSigningParams;
|
|
93
|
+
/** Org governance settings fetched from remote, or null. */
|
|
94
|
+
orgGovernanceSettings: OrgGovernanceSettings | null;
|
|
95
|
+
/** Returns true for file paths that should be excluded from scope-guard checks. */
|
|
96
|
+
shouldIgnore: (path: string) => boolean;
|
|
97
|
+
}
|
|
98
|
+
/** Note surfaced when session resolution is attempted but fails or not available. */
|
|
99
|
+
export type SessionResolutionNote = 'session_not_available' | 'no_session_id' | null;
|
|
100
|
+
export interface ScopeGuardOrchestrationResult {
|
|
101
|
+
/** Union of remote plan files and local plan files. */
|
|
102
|
+
planFilesForVerification: string[];
|
|
103
|
+
/** Dependency paths from the remote plan (empty for local sync). */
|
|
104
|
+
planDependencies: string[];
|
|
105
|
+
/** Original intent / constraint text used for intent-engine input. */
|
|
106
|
+
intentConstraintsForVerification: string | undefined;
|
|
107
|
+
/** Task label passed to evaluateGovernance. */
|
|
108
|
+
governanceTask: string;
|
|
109
|
+
/** Session ID extracted from the remote plan response (null for local sync). */
|
|
110
|
+
remotePlanSessionId: string | null;
|
|
111
|
+
intentEngineIssues: IntentIssue[];
|
|
112
|
+
intentEngineDomains: string[];
|
|
113
|
+
intentEngineSummary: IntentSummary | null;
|
|
114
|
+
intentEngineFlowIssues: FlowIssue[];
|
|
115
|
+
intentEngineRegressions: RegressionIssue[];
|
|
116
|
+
structuralViolations: StructuralViolation[];
|
|
117
|
+
structuralRulesApplied: string[];
|
|
118
|
+
structuralSuppressedCount: number;
|
|
119
|
+
governanceResult: ReturnType<typeof evaluateGovernance> | null;
|
|
120
|
+
/** All file paths from the diff. */
|
|
121
|
+
modifiedFiles: string[];
|
|
122
|
+
/** Files from session allowedFiles (empty when session resolution fails). */
|
|
123
|
+
allowedFiles: string[];
|
|
124
|
+
/** Union set of plan files + allowedFiles (the approval boundary). */
|
|
125
|
+
approvedSet: Set<string>;
|
|
126
|
+
/** Modified files not in approvedSet (before shouldIgnore). */
|
|
127
|
+
violations: string[];
|
|
128
|
+
/** Violations after shouldIgnore filtering — the actionable violation set. */
|
|
129
|
+
filteredViolations: string[];
|
|
130
|
+
/** Resolved session ID string (for caller debug rendering). */
|
|
131
|
+
sessionIdString: string | null;
|
|
132
|
+
/**
|
|
133
|
+
* Set to true when useLocalPlanSync is true so the caller can render
|
|
134
|
+
* "Plan Sync scope loaded: N file(s)".
|
|
135
|
+
*/
|
|
136
|
+
planSyncUsed: boolean;
|
|
137
|
+
planSyncFileCount: number;
|
|
138
|
+
/**
|
|
139
|
+
* Indicates why session-based allowed files were unavailable.
|
|
140
|
+
* Caller decides whether and how to surface this to the user.
|
|
141
|
+
*/
|
|
142
|
+
sessionResolutionNote: SessionResolutionNote;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Compute the scope-guard orchestration result. Replaces the inline compute
|
|
146
|
+
* region at verify.ts:4239–4376.
|
|
147
|
+
*
|
|
148
|
+
* Does not emit JSON, does not log, does not exit.
|
|
149
|
+
*/
|
|
150
|
+
export declare function runScopeGuardOrchestration(input: ScopeGuardOrchestrationInput): Promise<ScopeGuardOrchestrationResult>;
|
|
151
|
+
export {};
|
|
152
|
+
//# sourceMappingURL=scope-guard-orchestration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-guard-orchestration.d.ts","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/scope-guard-orchestration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGrG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM/D,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,EAAE,KAAK,CAAC;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC/C,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,CAAC;CACH;AAKD,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3C,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACrD;AAID,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;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+
* Extracts the plan-resolution / governance-evaluation / scope-guard compute
|
|
6
|
+
* region previously inlined at `commands/verify.ts:4238–4376`.
|
|
7
|
+
*
|
|
8
|
+
* RESPONSIBILITIES (data-pure):
|
|
9
|
+
* - resolve plan scope (local Plan Sync vs remote plan fetch)
|
|
10
|
+
* - run the intent-aware engine
|
|
11
|
+
* - run structural analysis (via the existing plan-structural-analysis module)
|
|
12
|
+
* - call evaluateGovernance
|
|
13
|
+
* - resolve session ID and fetch allowed files
|
|
14
|
+
* - compute the approved-set intersection and filtered violations
|
|
15
|
+
*
|
|
16
|
+
* EXPLICITLY NOT RESPONSIBLE FOR:
|
|
17
|
+
* - rendering scope violations (chalk output, emitVerifyJson, exitWithEvidence)
|
|
18
|
+
* - `scopeGuardPassed` flag lifecycle (caller owns that)
|
|
19
|
+
* - catch-block error logging (caller owns the surrounding try/catch)
|
|
20
|
+
*
|
|
21
|
+
* SEMANTIC PRESERVATION:
|
|
22
|
+
* The computation sequence, fault-swallowing behaviour (intent engine, session
|
|
23
|
+
* fetch), and intersection logic are byte-identical to the prior inline region.
|
|
24
|
+
*
|
|
25
|
+
* REPLAY INVARIANT:
|
|
26
|
+
* - evaluateGovernance call params are identical to lines 4317-4330
|
|
27
|
+
* - runPlanStructuralAnalysis call is identical to lines 4312-4315
|
|
28
|
+
* - runIntentEngine call is identical to lines 4293-4302
|
|
29
|
+
* - getSessionId() fallback chain is identical to lines 4335-4342
|
|
30
|
+
* - allowedFiles resolution is identical to lines 4352-4371
|
|
31
|
+
* - approvedSet intersection is identical to lines 4373-4376
|
|
32
|
+
*/
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.runScopeGuardOrchestration = runScopeGuardOrchestration;
|
|
35
|
+
const governance_1 = require("../../../utils/governance");
|
|
36
|
+
const intent_engine_1 = require("../../../intent-engine");
|
|
37
|
+
const state_1 = require("../../../utils/state");
|
|
38
|
+
const plan_structural_analysis_1 = require("./plan-structural-analysis");
|
|
39
|
+
/**
|
|
40
|
+
* Compute the scope-guard orchestration result. Replaces the inline compute
|
|
41
|
+
* region at verify.ts:4239–4376.
|
|
42
|
+
*
|
|
43
|
+
* Does not emit JSON, does not log, does not exit.
|
|
44
|
+
*/
|
|
45
|
+
async function runScopeGuardOrchestration(input) {
|
|
46
|
+
const { useLocalPlanSync, localPlanSync, localPlanExpectedFiles, finalPlanId, client, diffFiles, projectRoot, configData, signing, orgGovernanceSettings, shouldIgnore, } = input;
|
|
47
|
+
// ── Step A: Modified files ────────────────────────────────────────────────
|
|
48
|
+
const modifiedFiles = diffFiles.map(f => f.path);
|
|
49
|
+
// ── Step B: Resolve plan scope ────────────────────────────────────────────
|
|
50
|
+
let originalIntent = '';
|
|
51
|
+
let governanceTask = 'Plan verification';
|
|
52
|
+
let planFiles = [];
|
|
53
|
+
let planDependencies = [];
|
|
54
|
+
let remotePlanSessionId = null;
|
|
55
|
+
let planSyncUsed = false;
|
|
56
|
+
if (useLocalPlanSync) {
|
|
57
|
+
const localIntent = (localPlanSync.intent || '').trim();
|
|
58
|
+
const localConstraintText = localPlanSync.constraints.length > 0 ? localPlanSync.constraints.join('; ') : '';
|
|
59
|
+
planFiles = [...localPlanExpectedFiles];
|
|
60
|
+
originalIntent = localIntent || localConstraintText;
|
|
61
|
+
governanceTask = localIntent
|
|
62
|
+
? `Local Plan Sync: ${localIntent}`
|
|
63
|
+
: 'Local Plan Sync verification';
|
|
64
|
+
planSyncUsed = true;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const planData = await client.getPlan(finalPlanId);
|
|
68
|
+
originalIntent = planData.intent || '';
|
|
69
|
+
const planTitle = typeof planData.content.title === 'string'
|
|
70
|
+
? planData.content.title?.trim()
|
|
71
|
+
: '';
|
|
72
|
+
const planSummary = typeof planData.content.summary === 'string' ? planData.content.summary.trim() : '';
|
|
73
|
+
governanceTask = planTitle || planSummary || originalIntent || 'Plan verification';
|
|
74
|
+
planFiles = planData.content.files
|
|
75
|
+
.filter((f) => f.action === 'CREATE' || f.action === 'MODIFY')
|
|
76
|
+
.map((f) => f.path);
|
|
77
|
+
planDependencies = Array.isArray(planData.content.dependencies)
|
|
78
|
+
? planData.content.dependencies.filter((item) => typeof item === 'string')
|
|
79
|
+
: [];
|
|
80
|
+
remotePlanSessionId = planData.sessionId || null;
|
|
81
|
+
}
|
|
82
|
+
const planFilesForVerification = [...new Set([...planFiles, ...localPlanExpectedFiles])];
|
|
83
|
+
const intentConstraintsForVerification = originalIntent || undefined;
|
|
84
|
+
// ── Intent-Aware Engine ───────────────────────────────────────────────────
|
|
85
|
+
let intentEngineIssues = [];
|
|
86
|
+
let intentEngineDomains = [];
|
|
87
|
+
let intentEngineSummary = null;
|
|
88
|
+
let intentEngineFlowIssues = [];
|
|
89
|
+
let intentEngineRegressions = [];
|
|
90
|
+
if (intentConstraintsForVerification && diffFiles.length > 0) {
|
|
91
|
+
try {
|
|
92
|
+
const engineResult = (0, intent_engine_1.runIntentEngine)(intentConstraintsForVerification, diffFiles, projectRoot);
|
|
93
|
+
intentEngineIssues = engineResult.intentIssues;
|
|
94
|
+
intentEngineDomains = engineResult.checkedDomains;
|
|
95
|
+
intentEngineSummary = engineResult.intentSummary;
|
|
96
|
+
intentEngineFlowIssues = engineResult.flowIssues;
|
|
97
|
+
intentEngineRegressions = engineResult.regressions;
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// Non-fatal: intent engine errors must never break verification
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// ── Structural Rule Engine (plan-mode) ────────────────────────────────────
|
|
104
|
+
const planStructural = (0, plan_structural_analysis_1.runPlanStructuralAnalysis)({ projectRoot, diffFiles });
|
|
105
|
+
// ── Governance Evaluation ─────────────────────────────────────────────────
|
|
106
|
+
const governanceResult = (0, governance_1.evaluateGovernance)({
|
|
107
|
+
projectRoot,
|
|
108
|
+
task: governanceTask,
|
|
109
|
+
expectedFiles: planFilesForVerification,
|
|
110
|
+
expectedDependencies: planDependencies,
|
|
111
|
+
diffFiles,
|
|
112
|
+
contextCandidates: planFilesForVerification,
|
|
113
|
+
orgGovernance: orgGovernanceSettings,
|
|
114
|
+
requireSignedAiLogs: signing.signedLogsRequired,
|
|
115
|
+
// Normalise null → undefined to match evaluateGovernance's optional params.
|
|
116
|
+
signingKey: signing.signingKey ?? undefined,
|
|
117
|
+
signingKeyId: signing.signingKeyId ?? undefined,
|
|
118
|
+
signingKeys: signing.signingKeys,
|
|
119
|
+
signer: signing.signer,
|
|
120
|
+
});
|
|
121
|
+
// ── Session ID Resolution ─────────────────────────────────────────────────
|
|
122
|
+
// Priority: state file → config.sessionId → config.lastSessionId → plan sessionId
|
|
123
|
+
// Use explicit if/else chain to keep TypeScript narrowing clear.
|
|
124
|
+
let sessionIdString = (0, state_1.getSessionId)();
|
|
125
|
+
if (!sessionIdString) {
|
|
126
|
+
if (typeof configData.sessionId === 'string') {
|
|
127
|
+
sessionIdString = configData.sessionId;
|
|
128
|
+
}
|
|
129
|
+
else if (typeof configData.lastSessionId === 'string') {
|
|
130
|
+
sessionIdString = configData.lastSessionId;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (!sessionIdString && remotePlanSessionId) {
|
|
134
|
+
sessionIdString = remotePlanSessionId;
|
|
135
|
+
}
|
|
136
|
+
// ── Allowed Files (from session) ──────────────────────────────────────────
|
|
137
|
+
let allowedFiles = [];
|
|
138
|
+
let sessionResolutionNote = null;
|
|
139
|
+
if (sessionIdString) {
|
|
140
|
+
try {
|
|
141
|
+
const sessionData = await client.getSession(sessionIdString);
|
|
142
|
+
allowedFiles = sessionData.session.allowedFiles || [];
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// Non-fatal: session fetch failure means scope-guard uses plan files only
|
|
146
|
+
sessionResolutionNote = 'session_not_available';
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
sessionResolutionNote = 'no_session_id';
|
|
151
|
+
}
|
|
152
|
+
// ── Step C: Intersection Logic ────────────────────────────────────────────
|
|
153
|
+
const approvedSet = new Set([...planFilesForVerification, ...allowedFiles]);
|
|
154
|
+
const violations = modifiedFiles.filter(f => !approvedSet.has(f));
|
|
155
|
+
const filteredViolations = violations.filter((p) => !shouldIgnore(p));
|
|
156
|
+
return {
|
|
157
|
+
// Plan scope
|
|
158
|
+
planFilesForVerification,
|
|
159
|
+
planDependencies,
|
|
160
|
+
intentConstraintsForVerification,
|
|
161
|
+
governanceTask,
|
|
162
|
+
remotePlanSessionId,
|
|
163
|
+
// Intent engine
|
|
164
|
+
intentEngineIssues,
|
|
165
|
+
intentEngineDomains,
|
|
166
|
+
intentEngineSummary,
|
|
167
|
+
intentEngineFlowIssues,
|
|
168
|
+
intentEngineRegressions,
|
|
169
|
+
// Structural
|
|
170
|
+
structuralViolations: planStructural.violations,
|
|
171
|
+
structuralRulesApplied: planStructural.rulesApplied,
|
|
172
|
+
structuralSuppressedCount: planStructural.suppressedCount,
|
|
173
|
+
// Governance
|
|
174
|
+
governanceResult,
|
|
175
|
+
// Scope guard
|
|
176
|
+
modifiedFiles,
|
|
177
|
+
allowedFiles,
|
|
178
|
+
approvedSet,
|
|
179
|
+
violations,
|
|
180
|
+
filteredViolations,
|
|
181
|
+
sessionIdString,
|
|
182
|
+
// UI hints
|
|
183
|
+
planSyncUsed,
|
|
184
|
+
planSyncFileCount: planFiles.length,
|
|
185
|
+
sessionResolutionNote,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=scope-guard-orchestration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-guard-orchestration.js","sourceRoot":"","sources":["../../../../src/governance/pipeline/orchestration/scope-guard-orchestration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;AAsJH,gEAmLC;AAvUD,0DAA+D;AAC/D,0DAAyD;AAEzD,gDAAoD;AACpD,yEAAuE;AA0IvE;;;;;GAK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AAwB;QACxB,gBAAgB;QAChB,gCAAgC;QAChC,cAAc;QACd,mBAAmB;QAEnB,gBAAgB;QAChB,kBAAkB;QAClB,mBAAmB;QACnB,mBAAmB;QACnB,sBAAsB;QACtB,uBAAuB;QAEvB,aAAa;QACb,oBAAoB,EAAE,cAAc,CAAC,UAAU;QAC/C,sBAAsB,EAAE,cAAc,CAAC,YAAY;QACnD,yBAAyB,EAAE,cAAc,CAAC,eAAe;QAEzD,aAAa;QACb,gBAAgB;QAEhB,cAAc;QACd,aAAa;QACb,YAAY;QACZ,WAAW;QACX,UAAU;QACV,kBAAkB;QAClB,eAAe;QAEf,WAAW;QACX,YAAY;QACZ,iBAAiB,EAAE,SAAS,CAAC,MAAM;QACnC,qBAAqB;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Governance pipeline runtime.
|
|
3
|
+
*
|
|
4
|
+
* Executes individual stages with:
|
|
5
|
+
* - deterministic input/output fingerprinting
|
|
6
|
+
* - bounded failure isolation per stage
|
|
7
|
+
* - timing + item-count metrics
|
|
8
|
+
* - dependency precondition checks
|
|
9
|
+
* - replay-metadata emission
|
|
10
|
+
*
|
|
11
|
+
* The runtime is INTENTIONALLY minimal. It does not implement a generic
|
|
12
|
+
* workflow engine; it is a thin, explicit ledger for the canonical
|
|
13
|
+
* verify pipeline.
|
|
14
|
+
*/
|
|
15
|
+
import type { GovernanceStageId, GovernanceStageResult } from '@neurcode-ai/contracts';
|
|
16
|
+
import type { GovernancePipelineContext, GovernancePipelineStage } from './types';
|
|
17
|
+
export interface RunStageOptions {
|
|
18
|
+
/** Override status when the stage chose to skip itself (returns null). */
|
|
19
|
+
skipReason?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Run a single pipeline stage. The result is appended to the context ledger
|
|
23
|
+
* automatically; callers can also read it from the return value.
|
|
24
|
+
*
|
|
25
|
+
* Dependency preconditions:
|
|
26
|
+
* For each id in stage.boundary.dependencies, the ledger must contain a
|
|
27
|
+
* prior entry with status === 'succeeded' or 'degraded'. Missing or failed
|
|
28
|
+
* dependencies cause an 'aborted-precondition' failure.
|
|
29
|
+
*
|
|
30
|
+
* Failure isolation:
|
|
31
|
+
* When stage.boundary.isolateFailure is true, exceptions are caught and the
|
|
32
|
+
* result is recorded with status === 'failed'. Otherwise exceptions propagate
|
|
33
|
+
* to the caller (after the result is appended to the ledger).
|
|
34
|
+
*/
|
|
35
|
+
export declare function runStage<TIn, TOut>(stage: GovernancePipelineStage<TIn, TOut>, input: TIn, ctx: GovernancePipelineContext, options?: RunStageOptions): Promise<GovernanceStageResult<TOut>>;
|
|
36
|
+
/**
|
|
37
|
+
* Pipeline-level execution: runs a sequential array of stages and returns the
|
|
38
|
+
* accumulated ledger. Stops on the first unrecoverable failure.
|
|
39
|
+
*
|
|
40
|
+
* Most callers should use `runStage` directly inside verify.ts — this helper
|
|
41
|
+
* exists for tests, fixture replay, and future fully-staged orchestration.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runPipeline(stages: Array<{
|
|
44
|
+
stage: GovernancePipelineStage<unknown, unknown>;
|
|
45
|
+
input: unknown;
|
|
46
|
+
}>, ctx: GovernancePipelineContext): Promise<GovernanceStageResult[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the most recent result for a given stage from the ledger.
|
|
49
|
+
* Returns undefined if the stage has not run yet.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getStageResult<T = unknown>(ctx: GovernancePipelineContext, stageId: GovernanceStageId): GovernanceStageResult<T> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Build an immutable pipeline context. Convenience factory.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createPipelineContext(init: {
|
|
56
|
+
projectRoot: string;
|
|
57
|
+
ciMode: boolean;
|
|
58
|
+
jsonMode: boolean;
|
|
59
|
+
startedAtMs?: number;
|
|
60
|
+
runId?: string;
|
|
61
|
+
}): GovernancePipelineContext;
|
|
62
|
+
/**
|
|
63
|
+
* Thrown when a required stage fails. The pipeline runtime appends the failing
|
|
64
|
+
* result to the ledger BEFORE throwing, so callers can inspect via ctx.ledger.
|
|
65
|
+
*/
|
|
66
|
+
export declare class GovernanceStageAbortedError extends Error {
|
|
67
|
+
readonly result: GovernanceStageResult;
|
|
68
|
+
constructor(result: GovernanceStageResult);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/governance/pipeline/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAGV,iBAAiB,EAGjB,qBAAqB,EAEtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,eAAe;IAC9B,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,IAAI,EACtC,KAAK,EAAE,uBAAuB,CAAC,GAAG,EAAE,IAAI,CAAC,EACzC,KAAK,EAAE,GAAG,EACV,GAAG,EAAE,yBAAyB,EAC9B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAuFtC;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,EACnF,GAAG,EAAE,yBAAyB,GAC7B,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAYlC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EACxC,GAAG,EAAE,yBAAyB,EAC9B,OAAO,EAAE,iBAAiB,GACzB,qBAAqB,CAAC,CAAC,CAAC,GAAG,SAAS,CAOtC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,yBAAyB,CAS5B;AAED;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;gBAC3B,MAAM,EAAE,qBAAqB;CAO1C"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Governance pipeline runtime.
|
|
4
|
+
*
|
|
5
|
+
* Executes individual stages with:
|
|
6
|
+
* - deterministic input/output fingerprinting
|
|
7
|
+
* - bounded failure isolation per stage
|
|
8
|
+
* - timing + item-count metrics
|
|
9
|
+
* - dependency precondition checks
|
|
10
|
+
* - replay-metadata emission
|
|
11
|
+
*
|
|
12
|
+
* The runtime is INTENTIONALLY minimal. It does not implement a generic
|
|
13
|
+
* workflow engine; it is a thin, explicit ledger for the canonical
|
|
14
|
+
* verify pipeline.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.GovernanceStageAbortedError = void 0;
|
|
18
|
+
exports.runStage = runStage;
|
|
19
|
+
exports.runPipeline = runPipeline;
|
|
20
|
+
exports.getStageResult = getStageResult;
|
|
21
|
+
exports.createPipelineContext = createPipelineContext;
|
|
22
|
+
/**
|
|
23
|
+
* Run a single pipeline stage. The result is appended to the context ledger
|
|
24
|
+
* automatically; callers can also read it from the return value.
|
|
25
|
+
*
|
|
26
|
+
* Dependency preconditions:
|
|
27
|
+
* For each id in stage.boundary.dependencies, the ledger must contain a
|
|
28
|
+
* prior entry with status === 'succeeded' or 'degraded'. Missing or failed
|
|
29
|
+
* dependencies cause an 'aborted-precondition' failure.
|
|
30
|
+
*
|
|
31
|
+
* Failure isolation:
|
|
32
|
+
* When stage.boundary.isolateFailure is true, exceptions are caught and the
|
|
33
|
+
* result is recorded with status === 'failed'. Otherwise exceptions propagate
|
|
34
|
+
* to the caller (after the result is appended to the ledger).
|
|
35
|
+
*/
|
|
36
|
+
async function runStage(stage, input, ctx, options = {}) {
|
|
37
|
+
const startedAtMs = Date.now();
|
|
38
|
+
const startedAt = new Date(startedAtMs).toISOString();
|
|
39
|
+
const inputFingerprint = stage.fingerprintInput?.(input);
|
|
40
|
+
const memoryBaseline = readHeapUsed();
|
|
41
|
+
// Dependency precondition check
|
|
42
|
+
const unmetDependency = findUnmetDependency(stage.boundary.dependencies, ctx);
|
|
43
|
+
if (unmetDependency) {
|
|
44
|
+
const finishedAtMs = Date.now();
|
|
45
|
+
const result = {
|
|
46
|
+
stageId: stage.id,
|
|
47
|
+
status: 'failed',
|
|
48
|
+
output: null,
|
|
49
|
+
metrics: emitMetrics(startedAtMs, finishedAtMs, memoryBaseline, input, null, stage),
|
|
50
|
+
replay: {
|
|
51
|
+
stageId: stage.id,
|
|
52
|
+
determinism: stage.determinism,
|
|
53
|
+
inputFingerprint,
|
|
54
|
+
dependsOn: [...stage.boundary.dependencies],
|
|
55
|
+
startedAt,
|
|
56
|
+
finishedAt: new Date(finishedAtMs).toISOString(),
|
|
57
|
+
},
|
|
58
|
+
failure: {
|
|
59
|
+
category: 'aborted-precondition',
|
|
60
|
+
message: `stage '${stage.id}' aborted: dependency '${unmetDependency}' did not succeed`,
|
|
61
|
+
recoverable: stage.boundary.isolateFailure,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
ctx.ledger.push(result);
|
|
65
|
+
if (!stage.boundary.isolateFailure && stage.boundary.required) {
|
|
66
|
+
throw new GovernanceStageAbortedError(result);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
// Execute
|
|
71
|
+
let output = null;
|
|
72
|
+
let status = 'succeeded';
|
|
73
|
+
let failure;
|
|
74
|
+
try {
|
|
75
|
+
const raw = await stage.execute(input, ctx);
|
|
76
|
+
if (raw === null || raw === undefined) {
|
|
77
|
+
output = null;
|
|
78
|
+
status = options.skipReason ? 'skipped' : 'degraded';
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
output = raw;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
output = null;
|
|
86
|
+
status = 'failed';
|
|
87
|
+
failure = {
|
|
88
|
+
category: classifyError(err),
|
|
89
|
+
message: shortError(err),
|
|
90
|
+
recoverable: stage.boundary.isolateFailure,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const finishedAtMs = Date.now();
|
|
94
|
+
const outputFingerprint = output !== null ? stage.fingerprintOutput?.(output) : undefined;
|
|
95
|
+
const result = {
|
|
96
|
+
stageId: stage.id,
|
|
97
|
+
status,
|
|
98
|
+
output,
|
|
99
|
+
metrics: emitMetrics(startedAtMs, finishedAtMs, memoryBaseline, input, output, stage),
|
|
100
|
+
replay: {
|
|
101
|
+
stageId: stage.id,
|
|
102
|
+
determinism: stage.determinism,
|
|
103
|
+
inputFingerprint,
|
|
104
|
+
outputFingerprint,
|
|
105
|
+
dependsOn: [...stage.boundary.dependencies],
|
|
106
|
+
startedAt,
|
|
107
|
+
finishedAt: new Date(finishedAtMs).toISOString(),
|
|
108
|
+
},
|
|
109
|
+
failure,
|
|
110
|
+
notes: options.skipReason ? [options.skipReason] : undefined,
|
|
111
|
+
};
|
|
112
|
+
ctx.ledger.push(result);
|
|
113
|
+
if (status === 'failed' && !stage.boundary.isolateFailure) {
|
|
114
|
+
throw new GovernanceStageAbortedError(result);
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Pipeline-level execution: runs a sequential array of stages and returns the
|
|
120
|
+
* accumulated ledger. Stops on the first unrecoverable failure.
|
|
121
|
+
*
|
|
122
|
+
* Most callers should use `runStage` directly inside verify.ts — this helper
|
|
123
|
+
* exists for tests, fixture replay, and future fully-staged orchestration.
|
|
124
|
+
*/
|
|
125
|
+
async function runPipeline(stages, ctx) {
|
|
126
|
+
for (const { stage, input } of stages) {
|
|
127
|
+
try {
|
|
128
|
+
await runStage(stage, input, ctx);
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
if (err instanceof GovernanceStageAbortedError) {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return ctx.ledger;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get the most recent result for a given stage from the ledger.
|
|
141
|
+
* Returns undefined if the stage has not run yet.
|
|
142
|
+
*/
|
|
143
|
+
function getStageResult(ctx, stageId) {
|
|
144
|
+
for (let i = ctx.ledger.length - 1; i >= 0; i--) {
|
|
145
|
+
if (ctx.ledger[i].stageId === stageId) {
|
|
146
|
+
return ctx.ledger[i];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Build an immutable pipeline context. Convenience factory.
|
|
153
|
+
*/
|
|
154
|
+
function createPipelineContext(init) {
|
|
155
|
+
return {
|
|
156
|
+
projectRoot: init.projectRoot,
|
|
157
|
+
ciMode: init.ciMode,
|
|
158
|
+
jsonMode: init.jsonMode,
|
|
159
|
+
startedAtMs: init.startedAtMs ?? Date.now(),
|
|
160
|
+
runId: init.runId,
|
|
161
|
+
ledger: [],
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Thrown when a required stage fails. The pipeline runtime appends the failing
|
|
166
|
+
* result to the ledger BEFORE throwing, so callers can inspect via ctx.ledger.
|
|
167
|
+
*/
|
|
168
|
+
class GovernanceStageAbortedError extends Error {
|
|
169
|
+
result;
|
|
170
|
+
constructor(result) {
|
|
171
|
+
super(`governance stage '${result.stageId}' aborted: ${result.failure?.message ?? 'unknown failure'}`);
|
|
172
|
+
this.name = 'GovernanceStageAbortedError';
|
|
173
|
+
this.result = result;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.GovernanceStageAbortedError = GovernanceStageAbortedError;
|
|
177
|
+
// ── Internals ────────────────────────────────────────────────────────────────
|
|
178
|
+
function findUnmetDependency(deps, ctx) {
|
|
179
|
+
for (const dep of deps) {
|
|
180
|
+
const prior = getStageResult(ctx, dep);
|
|
181
|
+
if (!prior || (prior.status !== 'succeeded' && prior.status !== 'degraded')) {
|
|
182
|
+
return dep;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
function emitMetrics(startedAtMs, finishedAtMs, memoryBaseline, input, output, stage) {
|
|
188
|
+
const memoryNow = readHeapUsed();
|
|
189
|
+
const memoryDeltaBytes = typeof memoryBaseline === 'number' && typeof memoryNow === 'number'
|
|
190
|
+
? memoryNow - memoryBaseline
|
|
191
|
+
: undefined;
|
|
192
|
+
return {
|
|
193
|
+
durationMs: finishedAtMs - startedAtMs,
|
|
194
|
+
inputItemCount: stage.inputItemCount?.(input),
|
|
195
|
+
outputItemCount: output !== null ? stage.outputItemCount?.(output) : undefined,
|
|
196
|
+
memoryDeltaBytes,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function readHeapUsed() {
|
|
200
|
+
try {
|
|
201
|
+
return process.memoryUsage().heapUsed;
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function classifyError(err) {
|
|
208
|
+
const message = (err instanceof Error ? err.message : String(err)).toLowerCase();
|
|
209
|
+
if (message.includes('timeout') || message.includes('timed out'))
|
|
210
|
+
return 'timeout';
|
|
211
|
+
if (message.includes('invariant'))
|
|
212
|
+
return 'invariant-violation';
|
|
213
|
+
if (message.includes('depend'))
|
|
214
|
+
return 'degraded-dependency';
|
|
215
|
+
return 'exception';
|
|
216
|
+
}
|
|
217
|
+
function shortError(err) {
|
|
218
|
+
const raw = err instanceof Error ? (err.message || err.name) : String(err);
|
|
219
|
+
// Strip absolute paths and bound length so failure messages stay stable + PII-free.
|
|
220
|
+
const stripped = raw.replace(/\/Users\/[^/\s]+\//g, '/<user>/').replace(/\/home\/[^/\s]+\//g, '/<user>/');
|
|
221
|
+
return stripped.length > 240 ? stripped.slice(0, 237) + '…' : stripped;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/governance/pipeline/runtime.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAmCH,4BA4FC;AASD,kCAeC;AAMD,wCAUC;AAKD,sDAeC;AAtKD;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,QAAQ,CAC5B,KAAyC,EACzC,KAAU,EACV,GAA8B,EAC9B,UAA2B,EAAE;IAE7B,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC/B,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC;IACtD,MAAM,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC;IACzD,MAAM,cAAc,GAAG,YAAY,EAAE,CAAC;IAEtC,gCAAgC;IAChC,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC9E,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,MAAM,GAAgC;YAC1C,OAAO,EAAE,KAAK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