@neurcode-ai/governance-runtime 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/admission-provenance.d.ts +111 -0
  2. package/dist/admission-provenance.d.ts.map +1 -0
  3. package/dist/admission-provenance.js +735 -0
  4. package/dist/admission-provenance.js.map +1 -0
  5. package/dist/agent-guard-posture.d.ts +40 -0
  6. package/dist/agent-guard-posture.d.ts.map +1 -0
  7. package/dist/agent-guard-posture.js +117 -0
  8. package/dist/agent-guard-posture.js.map +1 -0
  9. package/dist/agent-invocation-observability.d.ts +47 -0
  10. package/dist/agent-invocation-observability.d.ts.map +1 -0
  11. package/dist/agent-invocation-observability.js +229 -0
  12. package/dist/agent-invocation-observability.js.map +1 -0
  13. package/dist/agent-plan.d.ts +119 -0
  14. package/dist/agent-plan.d.ts.map +1 -0
  15. package/dist/agent-plan.js +590 -0
  16. package/dist/agent-plan.js.map +1 -0
  17. package/dist/agent-runtime-adapter.d.ts +69 -0
  18. package/dist/agent-runtime-adapter.d.ts.map +1 -0
  19. package/dist/agent-runtime-adapter.js +274 -0
  20. package/dist/agent-runtime-adapter.js.map +1 -0
  21. package/dist/ai-change-record.d.ts +185 -0
  22. package/dist/ai-change-record.d.ts.map +1 -0
  23. package/dist/ai-change-record.js +580 -0
  24. package/dist/ai-change-record.js.map +1 -0
  25. package/dist/architecture-graph.d.ts +153 -0
  26. package/dist/architecture-graph.d.ts.map +1 -0
  27. package/dist/architecture-graph.js +646 -0
  28. package/dist/architecture-graph.js.map +1 -0
  29. package/dist/architecture-obligations.d.ts +161 -0
  30. package/dist/architecture-obligations.d.ts.map +1 -0
  31. package/dist/architecture-obligations.js +553 -0
  32. package/dist/architecture-obligations.js.map +1 -0
  33. package/dist/index.d.ts +10 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +104 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/profile.d.ts +159 -0
  38. package/dist/profile.d.ts.map +1 -0
  39. package/dist/profile.js +611 -0
  40. package/dist/profile.js.map +1 -0
  41. package/dist/session.d.ts +428 -0
  42. package/dist/session.d.ts.map +1 -0
  43. package/dist/session.js +2206 -0
  44. package/dist/session.js.map +1 -0
  45. package/package.json +13 -2
  46. package/src/constraints.ts +0 -828
  47. package/src/index.test.ts +0 -502
  48. package/src/index.ts +0 -463
  49. package/tsconfig.json +0 -19
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Agent Plan Capture V1
3
+ *
4
+ * Source-free model of the *agent's own stated plan* during an agentic coding
5
+ * session. This is intentionally distinct from the V0 diff-based plan
6
+ * verification primitives in `./index.ts` (PlanVerification*, PlanDiffFile,
7
+ * etc.). Here we capture what the agent *said it would do* so the runtime can
8
+ * answer: "is the agent still executing its own plan, or has it started making
9
+ * changes its plan never justified?"
10
+ *
11
+ * Hard rules honored by this module:
12
+ * - Never store source code, diffs, patches, or file contents. Only file path
13
+ * references, globs, and short natural-language summaries the agent emitted.
14
+ * - Extraction is conservative: when no plan is present we return null rather
15
+ * than inventing one, and a bare user prompt is never treated as an agent
16
+ * plan.
17
+ * - Everything is deterministic (no model calls, no randomness).
18
+ */
19
+ export type AgentPlanSource = 'claude_prompt' | 'manual' | 'mcp' | 'unknown';
20
+ export type AgentPlanConfidence = 'high' | 'medium' | 'low';
21
+ export declare const AGENT_PLAN_SCHEMA_VERSION: 1;
22
+ export interface AgentPlan {
23
+ schemaVersion: number;
24
+ /** Short natural-language description of the plan (source-free). */
25
+ summary: string;
26
+ /** Ordered plan steps as short text lines (source-free). */
27
+ steps: string[];
28
+ /** Concrete file paths the plan expects to touch. */
29
+ expectedFiles: string[];
30
+ /** Glob patterns the plan expects to touch. */
31
+ expectedGlobs: string[];
32
+ /** Stated constraints / guardrails the agent committed to. */
33
+ constraints: string[];
34
+ /** Stated risks / caveats the agent called out. */
35
+ risks: string[];
36
+ /** ISO-8601 timestamp of when the plan was captured. */
37
+ capturedAt: string;
38
+ source: AgentPlanSource;
39
+ confidence: AgentPlanConfidence;
40
+ }
41
+ export type PlanCoherenceVerdict = 'planned' | 'implied' | 'unplanned' | 'unknown';
42
+ export interface PlanCoherenceResult {
43
+ verdict: PlanCoherenceVerdict;
44
+ /** 0-100; higher means the edit is better justified by the agent's plan. */
45
+ score: number;
46
+ /** Plan items (file/glob/step text) that matched the edited path. */
47
+ matchedPlanItems: string[];
48
+ /** Human-readable, deterministic explanation lines. */
49
+ reasons: string[];
50
+ }
51
+ export interface PlanCoherenceInput {
52
+ /** The captured agent plan, if any. */
53
+ agentPlan?: AgentPlan | null;
54
+ /** Repo-relative path being edited. */
55
+ filePath: string;
56
+ /**
57
+ * Support paths derived from the *user intent* contract (e.g. globs the
58
+ * intent allows as supporting work). Kept as an input so this module stays
59
+ * decoupled from the intent-contract shape.
60
+ */
61
+ intentSupportGlobs?: string[];
62
+ /**
63
+ * Explicit override for whether the plan implies support work (tests,
64
+ * utilities, refactors). When omitted we infer it deterministically from the
65
+ * plan text.
66
+ */
67
+ planImpliesSupportWork?: boolean;
68
+ }
69
+ /**
70
+ * Extract expected file paths and globs from free-form plan text. We only look
71
+ * at backtick code spans and whitespace-delimited tokens that pass strict
72
+ * path/glob shape checks — never arbitrary words.
73
+ */
74
+ export declare function extractExpectedTargetsFromText(text: string): {
75
+ expectedFiles: string[];
76
+ expectedGlobs: string[];
77
+ };
78
+ /** Parse ordered/checklist step lines out of a markdown-ish block. */
79
+ export declare function parsePlanSteps(text: string): string[];
80
+ /** Does the plan text imply legitimate supporting work (tests/utils/refactor)? */
81
+ export declare function planImpliesSupportWork(plan: AgentPlan | null | undefined): boolean;
82
+ /** Is this path a conventional test or utility/support file? */
83
+ export declare function isTestOrUtilityPath(filePath: string): boolean;
84
+ /**
85
+ * Deterministically grade an edit against the agent's plan.
86
+ *
87
+ * Verdict precedence:
88
+ * 1. No agent plan captured -> unknown
89
+ * 2. Path matches expectedFiles/globs -> planned
90
+ * 3. Path is intent-support/test/util AND plan implies support work -> implied
91
+ * 4. Otherwise -> unplanned
92
+ *
93
+ * NOTE: this is advisory in V1. Boundary/approval blocks always override this
94
+ * verdict at the call sites; an `unplanned` verdict alone must not block.
95
+ */
96
+ export declare function evaluatePlanCoherence(input: PlanCoherenceInput): PlanCoherenceResult;
97
+ export interface ExtractAgentPlanOptions {
98
+ /** Override capture timestamp (mainly for deterministic tests). */
99
+ now?: Date;
100
+ /** Override the recorded source (e.g. 'mcp' when called from the MCP server). */
101
+ source?: AgentPlanSource;
102
+ }
103
+ /**
104
+ * Deterministically extract an {@link AgentPlan} from a Claude Code hook
105
+ * payload. Returns null when no plan is present — callers must treat a null
106
+ * result as "no plan", never as a failure.
107
+ *
108
+ * This function never throws: any malformed payload yields null.
109
+ */
110
+ export declare function extractAgentPlan(payload: unknown, options?: ExtractAgentPlanOptions): AgentPlan | null;
111
+ /**
112
+ * Source-free projection of an agent plan for live sync / evidence export.
113
+ * Drops nothing sensitive (the model is already source-free) but enforces the
114
+ * shape and trims away anything unexpected callers may have attached.
115
+ */
116
+ export declare function sanitizeAgentPlan(value: unknown): AgentPlan | undefined;
117
+ /** Sanitize a plan-coherence result coming back over the wire. */
118
+ export declare function sanitizePlanCoherence(value: unknown): PlanCoherenceResult | undefined;
119
+ //# sourceMappingURL=agent-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-plan.d.ts","sourceRoot":"","sources":["../src/agent-plan.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AAC7E,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5D,eAAO,MAAM,yBAAyB,EAAG,CAAU,CAAC;AAEpD,MAAM,WAAW,SAAS;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;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