@aegis-scan/core 0.16.6 → 0.17.7

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 (125) hide show
  1. package/README.md +37 -0
  2. package/dist/index.d.ts +5 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +5 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/manipulation-resistance/ai-io-boundary.d.ts +84 -0
  7. package/dist/manipulation-resistance/ai-io-boundary.d.ts.map +1 -0
  8. package/dist/manipulation-resistance/ai-io-boundary.js +216 -0
  9. package/dist/manipulation-resistance/ai-io-boundary.js.map +1 -0
  10. package/dist/manipulation-resistance/config-integrity.d.ts +28 -0
  11. package/dist/manipulation-resistance/config-integrity.d.ts.map +1 -0
  12. package/dist/manipulation-resistance/config-integrity.js +53 -0
  13. package/dist/manipulation-resistance/config-integrity.js.map +1 -0
  14. package/dist/manipulation-resistance/index.d.ts +16 -0
  15. package/dist/manipulation-resistance/index.d.ts.map +1 -0
  16. package/dist/manipulation-resistance/index.js +16 -0
  17. package/dist/manipulation-resistance/index.js.map +1 -0
  18. package/dist/manipulation-resistance/instruction-boundary.d.ts +50 -0
  19. package/dist/manipulation-resistance/instruction-boundary.d.ts.map +1 -0
  20. package/dist/manipulation-resistance/instruction-boundary.js +114 -0
  21. package/dist/manipulation-resistance/instruction-boundary.js.map +1 -0
  22. package/dist/manipulation-resistance/oob-blocker.d.ts +58 -0
  23. package/dist/manipulation-resistance/oob-blocker.d.ts.map +1 -0
  24. package/dist/manipulation-resistance/oob-blocker.js +55 -0
  25. package/dist/manipulation-resistance/oob-blocker.js.map +1 -0
  26. package/dist/manipulation-resistance/redirect-policy.d.ts +43 -0
  27. package/dist/manipulation-resistance/redirect-policy.d.ts.map +1 -0
  28. package/dist/manipulation-resistance/redirect-policy.js +197 -0
  29. package/dist/manipulation-resistance/redirect-policy.js.map +1 -0
  30. package/dist/manipulation-resistance/response-validator.d.ts +33 -0
  31. package/dist/manipulation-resistance/response-validator.d.ts.map +1 -0
  32. package/dist/manipulation-resistance/response-validator.js +186 -0
  33. package/dist/manipulation-resistance/response-validator.js.map +1 -0
  34. package/dist/manipulation-resistance/scope-expansion-detector.d.ts +33 -0
  35. package/dist/manipulation-resistance/scope-expansion-detector.d.ts.map +1 -0
  36. package/dist/manipulation-resistance/scope-expansion-detector.js +68 -0
  37. package/dist/manipulation-resistance/scope-expansion-detector.js.map +1 -0
  38. package/dist/oversight/approval-gates.d.ts +77 -0
  39. package/dist/oversight/approval-gates.d.ts.map +1 -0
  40. package/dist/oversight/approval-gates.js +133 -0
  41. package/dist/oversight/approval-gates.js.map +1 -0
  42. package/dist/oversight/authority-matrix.d.ts +39 -0
  43. package/dist/oversight/authority-matrix.d.ts.map +1 -0
  44. package/dist/oversight/authority-matrix.js +75 -0
  45. package/dist/oversight/authority-matrix.js.map +1 -0
  46. package/dist/oversight/cia-scoring.d.ts +56 -0
  47. package/dist/oversight/cia-scoring.d.ts.map +1 -0
  48. package/dist/oversight/cia-scoring.js +98 -0
  49. package/dist/oversight/cia-scoring.js.map +1 -0
  50. package/dist/oversight/escalation.d.ts +58 -0
  51. package/dist/oversight/escalation.d.ts.map +1 -0
  52. package/dist/oversight/escalation.js +97 -0
  53. package/dist/oversight/escalation.js.map +1 -0
  54. package/dist/oversight/index.d.ts +15 -0
  55. package/dist/oversight/index.d.ts.map +1 -0
  56. package/dist/oversight/index.js +15 -0
  57. package/dist/oversight/index.js.map +1 -0
  58. package/dist/roe/index.d.ts +3 -0
  59. package/dist/roe/index.d.ts.map +1 -0
  60. package/dist/roe/index.js +3 -0
  61. package/dist/roe/index.js.map +1 -0
  62. package/dist/roe/loader.d.ts +15 -0
  63. package/dist/roe/loader.d.ts.map +1 -0
  64. package/dist/roe/loader.js +56 -0
  65. package/dist/roe/loader.js.map +1 -0
  66. package/dist/roe/types.d.ts +738 -0
  67. package/dist/roe/types.d.ts.map +1 -0
  68. package/dist/roe/types.js +525 -0
  69. package/dist/roe/types.js.map +1 -0
  70. package/dist/runtime/chain.d.ts +60 -0
  71. package/dist/runtime/chain.d.ts.map +1 -0
  72. package/dist/runtime/chain.js +156 -0
  73. package/dist/runtime/chain.js.map +1 -0
  74. package/dist/runtime/events.d.ts +104 -0
  75. package/dist/runtime/events.d.ts.map +1 -0
  76. package/dist/runtime/events.js +68 -0
  77. package/dist/runtime/events.js.map +1 -0
  78. package/dist/runtime/hash.d.ts +16 -0
  79. package/dist/runtime/hash.d.ts.map +1 -0
  80. package/dist/runtime/hash.js +70 -0
  81. package/dist/runtime/hash.js.map +1 -0
  82. package/dist/runtime/index.d.ts +7 -0
  83. package/dist/runtime/index.d.ts.map +1 -0
  84. package/dist/runtime/index.js +7 -0
  85. package/dist/runtime/index.js.map +1 -0
  86. package/dist/runtime/notifications.d.ts +24 -0
  87. package/dist/runtime/notifications.d.ts.map +1 -0
  88. package/dist/runtime/notifications.js +41 -0
  89. package/dist/runtime/notifications.js.map +1 -0
  90. package/dist/runtime/signals.d.ts +56 -0
  91. package/dist/runtime/signals.d.ts.map +1 -0
  92. package/dist/runtime/signals.js +72 -0
  93. package/dist/runtime/signals.js.map +1 -0
  94. package/dist/runtime/state.d.ts +88 -0
  95. package/dist/runtime/state.d.ts.map +1 -0
  96. package/dist/runtime/state.js +172 -0
  97. package/dist/runtime/state.js.map +1 -0
  98. package/dist/safety-controls/boundary-monitor.d.ts +45 -0
  99. package/dist/safety-controls/boundary-monitor.d.ts.map +1 -0
  100. package/dist/safety-controls/boundary-monitor.js +77 -0
  101. package/dist/safety-controls/boundary-monitor.js.map +1 -0
  102. package/dist/safety-controls/decision-timeout.d.ts +56 -0
  103. package/dist/safety-controls/decision-timeout.d.ts.map +1 -0
  104. package/dist/safety-controls/decision-timeout.js +67 -0
  105. package/dist/safety-controls/decision-timeout.js.map +1 -0
  106. package/dist/safety-controls/health-monitor.d.ts +61 -0
  107. package/dist/safety-controls/health-monitor.d.ts.map +1 -0
  108. package/dist/safety-controls/health-monitor.js +79 -0
  109. package/dist/safety-controls/health-monitor.js.map +1 -0
  110. package/dist/safety-controls/index.d.ts +13 -0
  111. package/dist/safety-controls/index.d.ts.map +1 -0
  112. package/dist/safety-controls/index.js +13 -0
  113. package/dist/safety-controls/index.js.map +1 -0
  114. package/dist/safety-controls/kill-switch.d.ts +45 -0
  115. package/dist/safety-controls/kill-switch.d.ts.map +1 -0
  116. package/dist/safety-controls/kill-switch.js +117 -0
  117. package/dist/safety-controls/kill-switch.js.map +1 -0
  118. package/dist/safety-controls/post-test-integrity.d.ts +51 -0
  119. package/dist/safety-controls/post-test-integrity.d.ts.map +1 -0
  120. package/dist/safety-controls/post-test-integrity.js +79 -0
  121. package/dist/safety-controls/post-test-integrity.js.map +1 -0
  122. package/dist/types.d.ts +17 -0
  123. package/dist/types.d.ts.map +1 -1
  124. package/package.json +2 -1
  125. package/sbom.cdx.json +1 -1
@@ -0,0 +1,56 @@
1
+ /**
2
+ * CIA impact classification + threshold-breach escalation.
3
+ *
4
+ * Closes APTS-SC-001 (Impact Classification + CIA Scoring) +
5
+ * APTS-HO-012 (Impact Threshold Breach Escalation).
6
+ *
7
+ * Design notes:
8
+ * - Each finding gets a `cia_vector` with three ordinal axes
9
+ * (confidentiality, integrity, availability), each in
10
+ * `none | low | medium | high`. Per-CWE default mappings map
11
+ * OWASP/CWE classes to the impact axes most directly affected.
12
+ * - Operators override per-finding via the existing suppression
13
+ * pipeline (out-of-scope here — pipeline is in
14
+ * `packages/core/src/suppression-filter.ts`).
15
+ * - HO-012 reuses the same vector: when any axis ≥ threshold the
16
+ * orchestrator halts pending operator approval.
17
+ */
18
+ import type { CiaImpact, Finding } from '../types.js';
19
+ /**
20
+ * Per-CWE default CIA mapping. Conservative: unmapped CWEs return
21
+ * `default-low` so the orchestrator never silently misses an issue.
22
+ */
23
+ export declare const CWE_CIA_DEFAULTS: Readonly<Record<number, {
24
+ c: CiaImpact;
25
+ i: CiaImpact;
26
+ a: CiaImpact;
27
+ }>>;
28
+ /**
29
+ * Assign a CIA vector to a finding. Per-CWE default if mapped;
30
+ * otherwise fall back to severity-based default.
31
+ */
32
+ export declare function assignCiaVector(f: Pick<Finding, 'cwe' | 'severity'>): {
33
+ c: CiaImpact;
34
+ i: CiaImpact;
35
+ a: CiaImpact;
36
+ };
37
+ export interface CiaThresholdEvaluation {
38
+ breach: boolean;
39
+ axes_breached: Array<'c' | 'i' | 'a'>;
40
+ rationale: string;
41
+ apts_refs: string[];
42
+ }
43
+ /**
44
+ * Evaluate a CIA vector against a threshold. Returns breach=true if
45
+ * ANY axis equals-or-exceeds the configured threshold for that axis.
46
+ */
47
+ export declare function evaluateCiaThreshold(vector: {
48
+ c: CiaImpact;
49
+ i: CiaImpact;
50
+ a: CiaImpact;
51
+ }, threshold: {
52
+ c?: CiaImpact;
53
+ i?: CiaImpact;
54
+ a?: CiaImpact;
55
+ }): CiaThresholdEvaluation;
56
+ //# sourceMappingURL=cia-scoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cia-scoring.d.ts","sourceRoot":"","sources":["../../src/oversight/cia-scoring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC,CAyClG,CAAC;AAWH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,UAAU,CAAC,GAAG;IAAE,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,EAAE,SAAS,CAAA;CAAE,CAKlH;AASD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE;IAAE,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,EAAE,SAAS,CAAA;CAAE,EACpD,SAAS,EAAE;IAAE,CAAC,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,CAAC,EAAE,SAAS,CAAA;CAAE,GACzD,sBAAsB,CAsBxB"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Per-CWE default CIA mapping. Conservative: unmapped CWEs return
3
+ * `default-low` so the orchestrator never silently misses an issue.
4
+ */
5
+ export const CWE_CIA_DEFAULTS = Object.freeze({
6
+ // SQL Injection — direct DB access, full triad impact
7
+ 89: { c: 'high', i: 'high', a: 'medium' },
8
+ // Cross-Site Scripting — confidentiality (cookie/storage exfil) + integrity (DOM tamper)
9
+ 79: { c: 'high', i: 'medium', a: 'low' },
10
+ // CSRF — operator-driven state change
11
+ 352: { c: 'medium', i: 'high', a: 'medium' },
12
+ // Path Traversal — direct file-read + occasional write
13
+ 22: { c: 'high', i: 'medium', a: 'medium' },
14
+ // OS Command Injection — full RCE class
15
+ 78: { c: 'high', i: 'high', a: 'high' },
16
+ // SSRF — internal-network reach + downstream confidentiality
17
+ 918: { c: 'high', i: 'medium', a: 'medium' },
18
+ // Hardcoded Credentials — confidentiality + integrity
19
+ 798: { c: 'high', i: 'high', a: 'low' },
20
+ // Information Exposure / Sensitive Disclosure
21
+ 200: { c: 'high', i: 'low', a: 'low' },
22
+ // XML External Entity (XXE) — file-read + DoS
23
+ 611: { c: 'high', i: 'low', a: 'high' },
24
+ // Insecure Deserialization
25
+ 502: { c: 'high', i: 'high', a: 'high' },
26
+ // Improper Authentication
27
+ 287: { c: 'high', i: 'high', a: 'medium' },
28
+ // Improper Authorization
29
+ 285: { c: 'high', i: 'high', a: 'low' },
30
+ // Privilege Escalation
31
+ 269: { c: 'high', i: 'high', a: 'medium' },
32
+ // Open Redirect — phishing-class confidentiality
33
+ 601: { c: 'medium', i: 'low', a: 'low' },
34
+ // Cryptographic Issues — confidentiality + integrity
35
+ 327: { c: 'high', i: 'high', a: 'low' },
36
+ // Race Condition / TOCTOU
37
+ 362: { c: 'medium', i: 'high', a: 'medium' },
38
+ // Resource Exhaustion / DoS
39
+ 400: { c: 'low', i: 'low', a: 'high' },
40
+ // Improper Input Validation — generic
41
+ 20: { c: 'medium', i: 'medium', a: 'low' },
42
+ // Use of Hardcoded Cryptographic Key
43
+ 321: { c: 'high', i: 'high', a: 'low' },
44
+ // CRLF / HTTP Response Splitting
45
+ 113: { c: 'medium', i: 'medium', a: 'low' },
46
+ });
47
+ const SEVERITY_TO_DEFAULT_CIA = Object.freeze({
48
+ blocker: { c: 'high', i: 'high', a: 'high' },
49
+ critical: { c: 'high', i: 'high', a: 'medium' },
50
+ high: { c: 'high', i: 'medium', a: 'low' },
51
+ medium: { c: 'medium', i: 'medium', a: 'low' },
52
+ low: { c: 'low', i: 'low', a: 'low' },
53
+ info: { c: 'low', i: 'low', a: 'none' },
54
+ });
55
+ /**
56
+ * Assign a CIA vector to a finding. Per-CWE default if mapped;
57
+ * otherwise fall back to severity-based default.
58
+ */
59
+ export function assignCiaVector(f) {
60
+ if (f.cwe !== undefined && CWE_CIA_DEFAULTS[f.cwe]) {
61
+ return { ...CWE_CIA_DEFAULTS[f.cwe] };
62
+ }
63
+ return { ...SEVERITY_TO_DEFAULT_CIA[f.severity] };
64
+ }
65
+ const IMPACT_RANK = Object.freeze({
66
+ none: 0,
67
+ low: 1,
68
+ medium: 2,
69
+ high: 3,
70
+ });
71
+ /**
72
+ * Evaluate a CIA vector against a threshold. Returns breach=true if
73
+ * ANY axis equals-or-exceeds the configured threshold for that axis.
74
+ */
75
+ export function evaluateCiaThreshold(vector, threshold) {
76
+ const breached = [];
77
+ for (const axis of ['c', 'i', 'a']) {
78
+ const t = threshold[axis];
79
+ if (t !== undefined && IMPACT_RANK[vector[axis]] >= IMPACT_RANK[t]) {
80
+ breached.push(axis);
81
+ }
82
+ }
83
+ if (breached.length === 0) {
84
+ return {
85
+ breach: false,
86
+ axes_breached: [],
87
+ rationale: 'CIA vector below all configured thresholds',
88
+ apts_refs: ['APTS-SC-001'],
89
+ };
90
+ }
91
+ return {
92
+ breach: true,
93
+ axes_breached: breached,
94
+ rationale: `CIA threshold breached on ${breached.join(', ')} axis (${breached.map((a) => `${a}=${vector[a]}`).join(', ')})`,
95
+ apts_refs: ['APTS-SC-001', 'APTS-HO-012'],
96
+ };
97
+ }
98
+ //# sourceMappingURL=cia-scoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cia-scoring.js","sourceRoot":"","sources":["../../src/oversight/cia-scoring.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA2E,MAAM,CAAC,MAAM,CAAC;IACpH,sDAAsD;IACtD,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE;IACzC,yFAAyF;IACzF,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE;IACxC,sCAAsC;IACtC,GAAG,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE;IAC5C,uDAAuD;IACvD,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE;IAC3C,wCAAwC;IACxC,EAAE,EAAE,EAAE,CAAC,EAAE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AAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QAC3H,SAAS,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC;KAC1C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Unexpected-finding + confidence-based + compliance-trigger escalation.
3
+ *
4
+ * Closes APTS-HO-011 (Unexpected Findings Escalation Framework) +
5
+ * APTS-HO-013 (Confidence-Based Escalation) +
6
+ * APTS-HO-014 (Legal/Compliance Escalation Triggers).
7
+ *
8
+ * Design notes:
9
+ * - HO-011: when a finding's severity ≥ a configurable escalation
10
+ * threshold, return a halt-pending decision so the orchestrator
11
+ * emits a critical-finding event with stop_action `halt` and
12
+ * surfaces the finding for operator review.
13
+ * - HO-013: when finding.confidence === 'low', return a pause
14
+ * decision so operators can verify before continuing — extends
15
+ * the post-hoc `[LOW-CONFIDENCE]` PR badge to in-engagement.
16
+ * - HO-014: scan finding text for regulatory class markers
17
+ * (PII, PCI, PHI, GDPR, HIPAA) supplied by the operator's RoE.
18
+ * `on_match` is `halt` (default) or `notify`.
19
+ */
20
+ import type { Finding, Severity } from '../types.js';
21
+ export interface SeverityEscalationConfig {
22
+ /** Severity at which escalation fires. Default 'high'. */
23
+ threshold?: Severity;
24
+ }
25
+ export interface EscalationDecision {
26
+ escalate: boolean;
27
+ /** Action: 'halt' for halt-pending-approval, 'notify' for soft notify, 'continue' for no-op. */
28
+ action: 'halt' | 'notify' | 'continue';
29
+ reason: string;
30
+ apts_refs: string[];
31
+ }
32
+ /**
33
+ * HO-011 — escalate findings whose severity meets or exceeds threshold.
34
+ */
35
+ export declare function escalateOnSeverity(finding: Pick<Finding, 'severity' | 'id'>, config?: SeverityEscalationConfig): EscalationDecision;
36
+ export interface ConfidencePauseConfig {
37
+ /** When true, pause-on-low fires. Default false (operator opt-in). */
38
+ pause_on_low?: boolean;
39
+ }
40
+ /**
41
+ * HO-013 — pause when finding.confidence === 'low' and the operator
42
+ * has opted into pause_on_low. Otherwise emit a notify (soft) for the
43
+ * audit trail.
44
+ */
45
+ export declare function escalateOnConfidence(finding: Pick<Finding, 'confidence' | 'id'>, config?: ConfidencePauseConfig): EscalationDecision;
46
+ export interface ComplianceTriggerConfig {
47
+ /** Regulatory class markers operators want flagged. */
48
+ regulatory_class: string[];
49
+ /** Action on match. Default `halt`. */
50
+ on_match?: 'halt' | 'notify';
51
+ }
52
+ /**
53
+ * HO-014 — match a finding's text against the operator's regulatory
54
+ * class triggers. Returns escalate=true when any class matches; the
55
+ * action is `halt` or `notify` per the operator's policy.
56
+ */
57
+ export declare function escalateOnComplianceTrigger(finding: Pick<Finding, 'title' | 'description' | 'id'>, config: ComplianceTriggerConfig): EscalationDecision;
58
+ //# sourceMappingURL=escalation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escalation.d.ts","sourceRoot":"","sources":["../../src/oversight/escalation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAc,MAAM,aAAa,CAAC;AAWjE,MAAM,WAAW,wBAAwB;IACvC,0DAA0D;IAC1D,SAAS,CAAC,EAAE,QAAQ,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,gGAAgG;IAChG,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC,EACzC,MAAM,GAAE,wBAA6B,GACpC,kBAAkB,CAgBpB;AAED,MAAM,WAAW,qBAAqB;IACpC,sEAAsE;IACtE,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC,EAC3C,MAAM,GAAE,qBAA0B,GACjC,kBAAkB,CAwBpB;AAED,MAAM,WAAW,uBAAuB;IACtC,uDAAuD;IACvD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC9B;AAWD;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAAC,EACtD,MAAM,EAAE,uBAAuB,GAC9B,kBAAkB,CAsBpB"}
@@ -0,0 +1,97 @@
1
+ const SEVERITY_RANK = Object.freeze({
2
+ info: 0,
3
+ low: 1,
4
+ medium: 2,
5
+ high: 3,
6
+ critical: 4,
7
+ blocker: 5,
8
+ });
9
+ /**
10
+ * HO-011 — escalate findings whose severity meets or exceeds threshold.
11
+ */
12
+ export function escalateOnSeverity(finding, config = {}) {
13
+ const threshold = config.threshold ?? 'high';
14
+ if (SEVERITY_RANK[finding.severity] >= SEVERITY_RANK[threshold]) {
15
+ return {
16
+ escalate: true,
17
+ action: 'halt',
18
+ reason: `finding ${finding.id} severity ${finding.severity} ≥ escalation threshold ${threshold}`,
19
+ apts_refs: ['APTS-HO-011'],
20
+ };
21
+ }
22
+ return {
23
+ escalate: false,
24
+ action: 'continue',
25
+ reason: `finding ${finding.id} severity ${finding.severity} below threshold ${threshold}`,
26
+ apts_refs: ['APTS-HO-011'],
27
+ };
28
+ }
29
+ /**
30
+ * HO-013 — pause when finding.confidence === 'low' and the operator
31
+ * has opted into pause_on_low. Otherwise emit a notify (soft) for the
32
+ * audit trail.
33
+ */
34
+ export function escalateOnConfidence(finding, config = {}) {
35
+ const c = finding.confidence;
36
+ if (c !== 'low') {
37
+ return {
38
+ escalate: false,
39
+ action: 'continue',
40
+ reason: `finding ${finding.id} confidence "${c ?? 'unset'}" not low`,
41
+ apts_refs: ['APTS-HO-013'],
42
+ };
43
+ }
44
+ if (config.pause_on_low === true) {
45
+ return {
46
+ escalate: true,
47
+ action: 'halt',
48
+ reason: `finding ${finding.id} confidence is low — engagement paused for verification`,
49
+ apts_refs: ['APTS-HO-013'],
50
+ };
51
+ }
52
+ return {
53
+ escalate: true,
54
+ action: 'notify',
55
+ reason: `finding ${finding.id} confidence is low — soft escalation (set pause_on_low to halt)`,
56
+ apts_refs: ['APTS-HO-013'],
57
+ };
58
+ }
59
+ const DEFAULT_REGULATORY_PATTERNS = Object.freeze({
60
+ PII: /\b(?:PII|personal[\s-]?identifiable|personally[\s-]?identifiable|GDPR)\b/iu,
61
+ PCI: /\b(?:PCI(?:[\s-]?DSS)?|cardholder[\s-]?data|primary[\s-]?account[\s-]?number|CVV)\b/iu,
62
+ PHI: /\b(?:PHI|protected[\s-]?health|HIPAA|patient[\s-]?record)\b/iu,
63
+ GDPR: /\b(?:GDPR|right[\s-]?to[\s-]?erasure|data[\s-]?subject)\b/iu,
64
+ HIPAA: /\bHIPAA\b/iu,
65
+ SOX: /\b(?:Sarbanes[\s-]?Oxley|SOX[\s-]?compliance|SOX)\b/iu,
66
+ });
67
+ /**
68
+ * HO-014 — match a finding's text against the operator's regulatory
69
+ * class triggers. Returns escalate=true when any class matches; the
70
+ * action is `halt` or `notify` per the operator's policy.
71
+ */
72
+ export function escalateOnComplianceTrigger(finding, config) {
73
+ const text = `${finding.title}\n${finding.description ?? ''}`;
74
+ const matched = [];
75
+ for (const cls of config.regulatory_class) {
76
+ const re = DEFAULT_REGULATORY_PATTERNS[cls.toUpperCase()];
77
+ if (!re)
78
+ continue;
79
+ if (re.test(text))
80
+ matched.push(cls);
81
+ }
82
+ if (matched.length === 0) {
83
+ return {
84
+ escalate: false,
85
+ action: 'continue',
86
+ reason: `finding ${finding.id} did not match any configured regulatory class`,
87
+ apts_refs: ['APTS-HO-014'],
88
+ };
89
+ }
90
+ return {
91
+ escalate: true,
92
+ action: config.on_match ?? 'halt',
93
+ reason: `finding ${finding.id} matched regulatory class(es): ${matched.join(', ')}`,
94
+ apts_refs: ['APTS-HO-014'],
95
+ };
96
+ }
97
+ //# sourceMappingURL=escalation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escalation.js","sourceRoot":"","sources":["../../src/oversight/escalation.ts"],"names":[],"mappings":"AAqBA,MAAM,aAAa,GAAuC,MAAM,CAAC,MAAM,CAAC;IACtE,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;CACX,CAAC,CAAC;AAeH;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAyC,EACzC,SAAmC,EAAE;IAErC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC;IAC7C,IAAI,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAChE,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,WAAW,OAAO,CAAC,EAAE,aAAa,OAAO,CAAC,QAAQ,2BAA2B,SAAS,EAAE;YAChG,SAAS,EAAE,CAAC,aAAa,CAAC;SAC3B,CAAC;IACJ,CAAC;IACD,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,WAAW,OAAO,CAAC,EAAE,aAAa,OAAO,CAAC,QAAQ,oBAAoB,SAAS,EAAE;QACzF,SAAS,EAAE,CAAC,aAAa,CAAC;KAC3B,CAAC;AACJ,CAAC;AAOD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAA2C,EAC3C,SAAgC,EAAE;IAElC,MAAM,CAAC,G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AC1D,IAAI,CAAC,EAAE;YAAE,SAAS;QAClB,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,UAAU;YAClB,MAAM,EAAE,WAAW,OAAO,CAAC,EAAE,gDAAgD;YAC7E,SAAS,EAAE,CAAC,aAAa,CAAC;SAC3B,CAAC;IACJ,CAAC;IACD,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,MAAM,CAAC,QAAQ,IAAI,MAAM;QACjC,MAAM,EAAE,WAAW,OAAO,CAAC,EAAE,kCAAkC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACnF,SAAS,EAAE,CAAC,aAAa,CAAC;KAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Oversight public surface.
3
+ *
4
+ * Closes APTS Tier-1 entries: SC-001 (CIA scoring), HO-001 (pre-approval
5
+ * gates per AL-level), HO-004 (authority delegation matrix), HO-010
6
+ * (mandatory human decision points), HO-011 (unexpected-finding
7
+ * escalation), HO-012 (impact-threshold-breach escalation), HO-013
8
+ * (confidence-based escalation), HO-014 (legal/compliance escalation
9
+ * triggers).
10
+ */
11
+ export { assignCiaVector, evaluateCiaThreshold, CWE_CIA_DEFAULTS, type CiaThresholdEvaluation, } from './cia-scoring.js';
12
+ export { evaluateApprovalGate, detectIrreversibleActions, evaluateIrreversibleGate, PHASE_TO_AUTONOMY_LEVEL, type AutonomyLevel, type AutonomyLevelPolicy, type AutonomyLevelsConfig, type ApprovalGateDecision, type IrreversibleGateDecision, } from './approval-gates.js';
13
+ export { validateDelegationMatrix, rolesForAction, type DelegationEntry, type AuthorityMatrixValidation, } from './authority-matrix.js';
14
+ export { escalateOnSeverity, escalateOnConfidence, escalateOnComplianceTrigger, type SeverityEscalationConfig, type ConfidencePauseConfig, type ComplianceTriggerConfig, type EscalationDecision, } from './escalation.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oversight/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,KAAK,sBAAsB,GAC5B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,yBAAyB,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Oversight public surface.
3
+ *
4
+ * Closes APTS Tier-1 entries: SC-001 (CIA scoring), HO-001 (pre-approval
5
+ * gates per AL-level), HO-004 (authority delegation matrix), HO-010
6
+ * (mandatory human decision points), HO-011 (unexpected-finding
7
+ * escalation), HO-012 (impact-threshold-breach escalation), HO-013
8
+ * (confidence-based escalation), HO-014 (legal/compliance escalation
9
+ * triggers).
10
+ */
11
+ export { assignCiaVector, evaluateCiaThreshold, CWE_CIA_DEFAULTS, } from './cia-scoring.js';
12
+ export { evaluateApprovalGate, detectIrreversibleActions, evaluateIrreversibleGate, PHASE_TO_AUTONOMY_LEVEL, } from './approval-gates.js';
13
+ export { validateDelegationMatrix, rolesForAction, } from './authority-matrix.js';
14
+ export { escalateOnSeverity, escalateOnConfidence, escalateOnComplianceTrigger, } from './escalation.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/oversight/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,gBAAgB,GAEjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,GAMxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,cAAc,GAGf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,GAK5B,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { RoESchema, validateTargetInScope, validateTemporalEnvelope, getAssetCriticality, validateAction, synthesizeMinimalRoE, type RoE, type ValidationDecision, } from './types.js';
2
+ export { loadRoE, type RoEParseResult, type RoEParseSuccess, type RoEParseFailure, } from './loader.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/roe/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,KAAK,GAAG,EACR,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,OAAO,EACP,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { RoESchema, validateTargetInScope, validateTemporalEnvelope, getAssetCriticality, validateAction, synthesizeMinimalRoE, } from './types.js';
2
+ export { loadRoE, } from './loader.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/roe/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,GAGrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,OAAO,GAIR,MAAM,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type RoE } from './types.js';
2
+ export interface RoEParseSuccess {
3
+ ok: true;
4
+ roe: RoE;
5
+ }
6
+ export interface RoEParseFailure {
7
+ ok: false;
8
+ /** Operator-readable error message safe to print to stderr. */
9
+ error: string;
10
+ /** Phase the error occurred in. */
11
+ phase: 'file-missing' | 'json-parse' | 'schema-validation';
12
+ }
13
+ export type RoEParseResult = RoEParseSuccess | RoEParseFailure;
14
+ export declare function loadRoE(path: string): RoEParseResult;
15
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/roe/loader.ts"],"names":[],"mappings":"AAQA,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,IAAI,CAAC;IACT,GAAG,EAAE,GAAG,CAAC;CACV;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,KAAK,CAAC;IACV,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,mBAAmB,CAAC;CAC5D;AAED,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,eAAe,CAAC;AAE/D,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CA+CpD"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * RoE loader — read + validate from disk. Accepts JSON; YAML support deferred.
3
+ *
4
+ * Returns either a validated RoE or a structured ParseError (file-missing,
5
+ * invalid-JSON, schema-violation) so the caller can surface a precise
6
+ * operator-readable message.
7
+ */
8
+ import { readFileSync, existsSync } from 'node:fs';
9
+ import { RoESchema } from './types.js';
10
+ export function loadRoE(path) {
11
+ if (!existsSync(path)) {
12
+ return {
13
+ ok: false,
14
+ error: `RoE file not found at ${path}`,
15
+ phase: 'file-missing',
16
+ };
17
+ }
18
+ let raw;
19
+ try {
20
+ raw = readFileSync(path, 'utf-8');
21
+ }
22
+ catch (err) {
23
+ return {
24
+ ok: false,
25
+ error: `RoE file unreadable at ${path}: ${err instanceof Error ? err.message : String(err)}`,
26
+ phase: 'file-missing',
27
+ };
28
+ }
29
+ let parsed;
30
+ try {
31
+ parsed = JSON.parse(raw);
32
+ }
33
+ catch (err) {
34
+ return {
35
+ ok: false,
36
+ error: `RoE file at ${path} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`,
37
+ phase: 'json-parse',
38
+ };
39
+ }
40
+ const result = RoESchema.safeParse(parsed);
41
+ if (!result.success) {
42
+ const formatted = result.error.issues
43
+ .map((issue) => {
44
+ const path = issue.path.length > 0 ? issue.path.join('.') : '<root>';
45
+ return ` ${path}: ${issue.message}`;
46
+ })
47
+ .join('\n');
48
+ return {
49
+ ok: false,
50
+ error: `RoE schema validation failed:\n${formatted}`,
51
+ phase: 'schema-validation',
52
+ };
53
+ }
54
+ return { ok: true, roe: result.data };
55
+ }
56
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/roe/loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,SAAS,EAAY,MAAM,YAAY,CAAC;AAiBjD,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OA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