@decionis/agent-safe-pipeline 0.1.3 → 0.2.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.
Files changed (104) hide show
  1. package/README.md +477 -16
  2. package/dist/Index.d.ts +9 -0
  3. package/dist/Index.d.ts.map +1 -1
  4. package/dist/Index.js +8 -0
  5. package/dist/Index.js.map +1 -1
  6. package/dist/approval/PresenceApprovalCoordinator.d.ts +25 -0
  7. package/dist/approval/PresenceApprovalCoordinator.d.ts.map +1 -1
  8. package/dist/approval/PresenceApprovalCoordinator.js +54 -6
  9. package/dist/approval/PresenceApprovalCoordinator.js.map +1 -1
  10. package/dist/audit/AuditRecorder.d.ts +122 -0
  11. package/dist/audit/AuditRecorder.d.ts.map +1 -0
  12. package/dist/audit/AuditRecorder.js +312 -0
  13. package/dist/audit/AuditRecorder.js.map +1 -0
  14. package/dist/decision/CreateGate.d.ts +123 -0
  15. package/dist/decision/CreateGate.d.ts.map +1 -0
  16. package/dist/decision/CreateGate.js +211 -0
  17. package/dist/decision/CreateGate.js.map +1 -0
  18. package/dist/decision/DecionisGate.d.ts +109 -3
  19. package/dist/decision/DecionisGate.d.ts.map +1 -1
  20. package/dist/decision/DecionisGate.js +823 -46
  21. package/dist/decision/DecionisGate.js.map +1 -1
  22. package/dist/decision/DecisionAuthority.d.ts +76 -1
  23. package/dist/decision/DecisionAuthority.d.ts.map +1 -1
  24. package/dist/decision/DecisionAuthority.js.map +1 -1
  25. package/dist/decision/FixtureDecisionAuthority.d.ts +27 -1
  26. package/dist/decision/FixtureDecisionAuthority.d.ts.map +1 -1
  27. package/dist/decision/FixtureDecisionAuthority.js +47 -0
  28. package/dist/decision/FixtureDecisionAuthority.js.map +1 -1
  29. package/dist/decision/ImmutableGateDecision.d.ts.map +1 -1
  30. package/dist/decision/ImmutableGateDecision.js +26 -0
  31. package/dist/decision/ImmutableGateDecision.js.map +1 -1
  32. package/dist/decision/Provision.d.ts +33 -0
  33. package/dist/decision/Provision.d.ts.map +1 -0
  34. package/dist/decision/Provision.js +116 -0
  35. package/dist/decision/Provision.js.map +1 -0
  36. package/dist/decision/ShadowGate.d.ts +31 -0
  37. package/dist/decision/ShadowGate.d.ts.map +1 -0
  38. package/dist/decision/ShadowGate.js +79 -0
  39. package/dist/decision/ShadowGate.js.map +1 -0
  40. package/dist/execution/ActionRegistry.d.ts +66 -0
  41. package/dist/execution/ActionRegistry.d.ts.map +1 -1
  42. package/dist/execution/ActionRegistry.js +110 -1
  43. package/dist/execution/ActionRegistry.js.map +1 -1
  44. package/dist/execution/AuthorizationVerifier.d.ts +149 -1
  45. package/dist/execution/AuthorizationVerifier.d.ts.map +1 -1
  46. package/dist/execution/AuthorizationVerifier.js +302 -27
  47. package/dist/execution/AuthorizationVerifier.js.map +1 -1
  48. package/dist/execution/SafeExecutor.d.ts +102 -7
  49. package/dist/execution/SafeExecutor.d.ts.map +1 -1
  50. package/dist/execution/SafeExecutor.js +288 -17
  51. package/dist/execution/SafeExecutor.js.map +1 -1
  52. package/dist/http/ClientIdentification.d.ts +22 -0
  53. package/dist/http/ClientIdentification.d.ts.map +1 -0
  54. package/dist/http/ClientIdentification.js +44 -0
  55. package/dist/http/ClientIdentification.js.map +1 -0
  56. package/dist/http/Credential.d.ts +17 -0
  57. package/dist/http/Credential.d.ts.map +1 -0
  58. package/dist/http/Credential.js +5 -0
  59. package/dist/http/Credential.js.map +1 -0
  60. package/dist/http/StoredCredentials.d.ts +34 -0
  61. package/dist/http/StoredCredentials.d.ts.map +1 -0
  62. package/dist/http/StoredCredentials.js +85 -0
  63. package/dist/http/StoredCredentials.js.map +1 -0
  64. package/dist/intent/CanonicalIntentHasher.d.ts +1 -1
  65. package/dist/intent/CanonicalIntentHasher.d.ts.map +1 -1
  66. package/dist/intent/CanonicalIntentHasher.js +9 -2
  67. package/dist/intent/CanonicalIntentHasher.js.map +1 -1
  68. package/dist/intent/ExecutionIntent.d.ts +26 -2
  69. package/dist/intent/ExecutionIntent.d.ts.map +1 -1
  70. package/dist/intent/ExecutionIntent.js +11 -0
  71. package/dist/intent/ExecutionIntent.js.map +1 -1
  72. package/dist/intent/IntentCapture.d.ts +5 -0
  73. package/dist/intent/IntentCapture.d.ts.map +1 -1
  74. package/dist/intent/IntentCapture.js +15 -1
  75. package/dist/intent/IntentCapture.js.map +1 -1
  76. package/dist/report/DecisionReport.d.ts +22 -0
  77. package/dist/report/DecisionReport.d.ts.map +1 -0
  78. package/dist/report/DecisionReport.js +37 -0
  79. package/dist/report/DecisionReport.js.map +1 -0
  80. package/dist/report/DossierReport.d.ts +43 -0
  81. package/dist/report/DossierReport.d.ts.map +1 -0
  82. package/dist/report/DossierReport.js +130 -0
  83. package/dist/report/DossierReport.js.map +1 -0
  84. package/dist/report/HostedOutcome.d.ts +18 -0
  85. package/dist/report/HostedOutcome.d.ts.map +1 -0
  86. package/dist/report/HostedOutcome.js +24 -0
  87. package/dist/report/HostedOutcome.js.map +1 -0
  88. package/dist/shadow/ShadowPipeline.d.ts +75 -5
  89. package/dist/shadow/ShadowPipeline.d.ts.map +1 -1
  90. package/dist/shadow/ShadowPipeline.js +157 -7
  91. package/dist/shadow/ShadowPipeline.js.map +1 -1
  92. package/dist/testing/Index.d.ts +12 -0
  93. package/dist/testing/Index.d.ts.map +1 -0
  94. package/dist/testing/Index.js +12 -0
  95. package/dist/testing/Index.js.map +1 -0
  96. package/dist/testing/LocalAuthority.d.ts +292 -0
  97. package/dist/testing/LocalAuthority.d.ts.map +1 -0
  98. package/dist/testing/LocalAuthority.js +1124 -0
  99. package/dist/testing/LocalAuthority.js.map +1 -0
  100. package/dist/testing/LocalPresence.d.ts +210 -0
  101. package/dist/testing/LocalPresence.d.ts.map +1 -0
  102. package/dist/testing/LocalPresence.js +473 -0
  103. package/dist/testing/LocalPresence.js.map +1 -0
  104. package/package.json +40 -4
@@ -1,13 +1,83 @@
1
- import type { DecisionAuthority, GateDecision } from "../decision/DecisionAuthority.js";
1
+ import type { AuditRecorder } from "../audit/AuditRecorder.js";
2
+ import type { DecisionAuthority, DecisionVerdict } from "../decision/DecisionAuthority.js";
2
3
  import type { CapturedIntent } from "../intent/ExecutionIntent.js";
4
+ export type ShadowObservationStatus = "OBSERVED" | "UNAVAILABLE" | "TIMED_OUT" | "INVALID" | "ABORTED";
5
+ /**
6
+ * Non-authoritative record of what the authority would have decided.
7
+ *
8
+ * The shape deliberately has no `authorization` or `failClosed` field, so it
9
+ * is not structurally assignable to `GateDecision`, and it carries explicit
10
+ * `mode: "SHADOW"` and `authority: "OBSERVATIONAL"` markers that
11
+ * `SafeExecutor` rejects at runtime after any cast or JSON round trip.
12
+ */
13
+ export interface ShadowObservation {
14
+ readonly mode: "SHADOW";
15
+ readonly authority: "OBSERVATIONAL";
16
+ readonly status: ShadowObservationStatus;
17
+ readonly intentHash: string;
18
+ /** Policy verdict when the authority answered; `null` when it did not or failed closed. */
19
+ readonly verdict: DecisionVerdict | null;
20
+ readonly decisionId: string | null;
21
+ readonly dossierId: string | null;
22
+ readonly reasonCodes: readonly string[];
23
+ /** `true` when the authority returned a grant that this pipeline discarded. */
24
+ readonly grantDiscarded: boolean;
25
+ readonly durationMs: number;
26
+ }
27
+ export type ShadowProductionOutcome<TResult> = {
28
+ readonly status: "COMPLETED";
29
+ readonly result: TResult;
30
+ } | {
31
+ readonly status: "FAILED";
32
+ readonly error: unknown;
33
+ };
34
+ /** Production outcome available immediately; the observation settles on its own bound. */
35
+ export interface ShadowRun<TResult> {
36
+ readonly mode: "SHADOW";
37
+ readonly production: ShadowProductionOutcome<TResult>;
38
+ readonly observation: Promise<ShadowObservation>;
39
+ }
3
40
  export interface ShadowComparison<TResult> {
4
41
  readonly mode: "SHADOW";
5
- readonly productionResult: TResult;
6
- readonly hypotheticalDecision: GateDecision;
42
+ readonly production: ShadowProductionOutcome<TResult>;
43
+ readonly observation: ShadowObservation;
44
+ }
45
+ export interface ShadowPipelineOptions {
46
+ /** Optional recorder; every observation is emitted as an `OBSERVATIONAL` `SHADOW_EVALUATED` event. */
47
+ readonly audit?: AuditRecorder;
48
+ /** Independent bound on the hypothetical evaluation. Default 2000 ms, clamped to [1, 15000]. */
49
+ readonly timeoutMs?: number;
50
+ /** Injectable epoch-millisecond clock for deterministic duration tests. */
51
+ readonly clock?: () => number;
52
+ }
53
+ export interface ShadowObserveOptions {
54
+ /** Cancels the observation only; production execution is never cancelled by this pipeline. */
55
+ readonly signal?: AbortSignal;
7
56
  }
57
+ /**
58
+ * Runs an existing production execution unchanged while asking an authority
59
+ * what it would have decided. The observation is failure-isolated, bounded,
60
+ * and never carries execution authority.
61
+ */
8
62
  export declare class ShadowPipeline {
9
63
  private readonly authority;
10
- constructor(authority: DecisionAuthority);
11
- compare<TResult>(captured: CapturedIntent, existingExecution: () => Promise<TResult> | TResult): Promise<ShadowComparison<TResult>>;
64
+ private readonly audit;
65
+ private readonly timeoutMs;
66
+ private readonly clock;
67
+ constructor(authority: DecisionAuthority, options?: ShadowPipelineOptions);
68
+ /**
69
+ * Invokes `existingExecution` exactly once and returns as soon as it settles.
70
+ * Its result or thrown error is preserved verbatim. The observation promise
71
+ * never rejects and never delays production.
72
+ */
73
+ observe<TResult>(captured: CapturedIntent, existingExecution: () => Promise<TResult> | TResult, options?: ShadowObserveOptions): Promise<ShadowRun<TResult>>;
74
+ /** `observe`, then wait for the bounded observation so both sides can be compared inline. */
75
+ compare<TResult>(captured: CapturedIntent, existingExecution: () => Promise<TResult> | TResult, options?: ShadowObserveOptions): Promise<ShadowComparison<TResult>>;
76
+ private evaluate;
77
+ private record;
78
+ private static empty;
79
+ /** Validates a decision from any authority; the grant, if any, is discarded and reported. */
80
+ private static classify;
81
+ private static isBoundedIdentifier;
12
82
  }
13
83
  //# sourceMappingURL=ShadowPipeline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ShadowPipeline.d.ts","sourceRoot":"","sources":["../../src/shadow/ShadowPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,Y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/B;AAaD;;;;GAIG;AACH,qBAAa,cAAc;IAMvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAL5B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4B;IAClD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;gBAGlB,SAAS,EAAE,iBAAiB,EAC7C,OAAO,GAAE,qBAA0B;IAarC;;;;OAIG;IACU,OAAO,CAAC,OAAO,EAC1B,QAAQ,EAAE,cAAc,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EACnD,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAW9B,6FAA6F;IAChF,OAAO,CAAC,OAAO,EAC1B,QAAQ,EAAE,cAAc,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EACnD,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IASrC,OAAO,CAAC,QAAQ;YAwCF,MAAM;IAiBpB,OAAO,CAAC,MAAM,CAAC,KAAK;IAWpB,6FAA6F;IAC7F,OAAO,CAAC,MAAM,CAAC,QAAQ;IAyCvB,OAAO,CAAC,MAAM,CAAC,mBAAmB;CAUnC"}
@@ -1,14 +1,164 @@
1
+ const DEFAULT_TIMEOUT_MS = 2_000;
2
+ const MAX_TIMEOUT_MS = 15_000;
3
+ const MAX_REASON_CODES = 50;
4
+ const MAX_IDENTIFIER_LENGTH = 200;
5
+ const VERDICTS = new Set(["ALLOW", "ESCALATE", "BLOCK"]);
6
+ /**
7
+ * Runs an existing production execution unchanged while asking an authority
8
+ * what it would have decided. The observation is failure-isolated, bounded,
9
+ * and never carries execution authority.
10
+ */
1
11
  export class ShadowPipeline {
2
12
  authority;
3
- constructor(authority) {
13
+ audit;
14
+ timeoutMs;
15
+ clock;
16
+ constructor(authority, options = {}) {
4
17
  this.authority = authority;
18
+ if (authority.evaluationMode === "ENFORCEMENT") {
19
+ throw new Error("SHADOW_AUTHORITY_MUST_BE_OBSERVATIONAL");
20
+ }
21
+ if (options.timeoutMs !== undefined && !Number.isFinite(options.timeoutMs)) {
22
+ throw new Error("SHADOW_TIMEOUT_INVALID");
23
+ }
24
+ this.audit = options.audit;
25
+ this.timeoutMs = Math.min(Math.max(options.timeoutMs ?? DEFAULT_TIMEOUT_MS, 1), MAX_TIMEOUT_MS);
26
+ this.clock = options.clock ?? Date.now;
5
27
  }
6
- async compare(captured, existingExecution) {
7
- const [productionResult, hypotheticalDecision] = await Promise.all([
8
- existingExecution(),
9
- this.authority.evaluate(captured),
10
- ]);
11
- return { mode: "SHADOW", productionResult, hypotheticalDecision };
28
+ /**
29
+ * Invokes `existingExecution` exactly once and returns as soon as it settles.
30
+ * Its result or thrown error is preserved verbatim. The observation promise
31
+ * never rejects and never delays production.
32
+ */
33
+ async observe(captured, existingExecution, options = {}) {
34
+ const observation = this.evaluate(captured, options.signal);
35
+ let production;
36
+ try {
37
+ production = { status: "COMPLETED", result: await existingExecution() };
38
+ }
39
+ catch (error) {
40
+ production = { status: "FAILED", error };
41
+ }
42
+ return Object.freeze({ mode: "SHADOW", production: Object.freeze(production), observation });
43
+ }
44
+ /** `observe`, then wait for the bounded observation so both sides can be compared inline. */
45
+ async compare(captured, existingExecution, options = {}) {
46
+ const run = await this.observe(captured, existingExecution, options);
47
+ return Object.freeze({
48
+ mode: "SHADOW",
49
+ production: run.production,
50
+ observation: await run.observation,
51
+ });
52
+ }
53
+ evaluate(captured, signal) {
54
+ const startedAt = this.clock();
55
+ const settled = new Promise((resolve) => {
56
+ let done = false;
57
+ const finish = (classified) => {
58
+ if (done)
59
+ return;
60
+ done = true;
61
+ clearTimeout(timer);
62
+ signal?.removeEventListener("abort", onAbort);
63
+ resolve(classified);
64
+ };
65
+ const onAbort = () => finish(ShadowPipeline.empty("ABORTED"));
66
+ const timer = setTimeout(() => finish(ShadowPipeline.empty("TIMED_OUT")), this.timeoutMs);
67
+ if (signal?.aborted === true) {
68
+ onAbort();
69
+ return;
70
+ }
71
+ signal?.addEventListener("abort", onAbort, { once: true });
72
+ // Promise.resolve().then isolates a synchronously throwing authority.
73
+ void Promise.resolve()
74
+ .then(async () => await this.authority.evaluate(captured))
75
+ .then((decision) => finish(ShadowPipeline.classify(captured, decision)), () => finish(ShadowPipeline.empty("UNAVAILABLE")));
76
+ });
77
+ return settled.then(async (classified) => {
78
+ const observation = Object.freeze({
79
+ mode: "SHADOW",
80
+ authority: "OBSERVATIONAL",
81
+ intentHash: captured.intentHash,
82
+ ...classified,
83
+ reasonCodes: Object.freeze([...classified.reasonCodes]),
84
+ durationMs: Math.max(0, this.clock() - startedAt),
85
+ });
86
+ await this.record(captured, observation);
87
+ return observation;
88
+ });
89
+ }
90
+ async record(captured, observation) {
91
+ if (this.audit === undefined)
92
+ return;
93
+ await this.audit.record({
94
+ eventType: "SHADOW_EVALUATED",
95
+ authority: "OBSERVATIONAL",
96
+ captured,
97
+ ...(observation.verdict === null ? {} : { verdict: observation.verdict }),
98
+ ...(observation.decisionId === null ? {} : { decisionId: observation.decisionId }),
99
+ ...(observation.dossierId === null ? {} : { dossierId: observation.dossierId }),
100
+ reasonCodes: [`SHADOW_${observation.status}`, ...observation.reasonCodes].slice(0, MAX_REASON_CODES),
101
+ durationMs: observation.durationMs,
102
+ });
103
+ }
104
+ static empty(status, reasonCodes = []) {
105
+ return {
106
+ status,
107
+ verdict: null,
108
+ decisionId: null,
109
+ dossierId: null,
110
+ reasonCodes,
111
+ grantDiscarded: false,
112
+ };
113
+ }
114
+ /** Validates a decision from any authority; the grant, if any, is discarded and reported. */
115
+ static classify(captured, decision) {
116
+ const candidate = decision;
117
+ if (candidate === null ||
118
+ typeof candidate !== "object" ||
119
+ typeof candidate.verdict !== "string" ||
120
+ !VERDICTS.has(candidate.verdict) ||
121
+ !ShadowPipeline.isBoundedIdentifier(candidate.decisionId) ||
122
+ !(candidate.dossierId === null || ShadowPipeline.isBoundedIdentifier(candidate.dossierId)) ||
123
+ !Array.isArray(candidate.reasonCodes) ||
124
+ candidate.reasonCodes.length > MAX_REASON_CODES ||
125
+ !candidate.reasonCodes.every((code) => ShadowPipeline.isBoundedIdentifier(code))) {
126
+ return ShadowPipeline.empty("INVALID", ["SHADOW_DECISION_MALFORMED"]);
127
+ }
128
+ if (candidate.intentHash !== captured.intentHash) {
129
+ return ShadowPipeline.empty("INVALID", ["SHADOW_BINDING_MISMATCH"]);
130
+ }
131
+ const grantDiscarded = candidate.authorization !== null && typeof candidate.authorization === "object";
132
+ if (candidate.failClosed === true) {
133
+ // The authority did not answer the policy question; report unavailability, not a verdict.
134
+ return {
135
+ status: "UNAVAILABLE",
136
+ verdict: null,
137
+ decisionId: candidate.decisionId,
138
+ dossierId: candidate.dossierId,
139
+ reasonCodes: [...candidate.reasonCodes],
140
+ grantDiscarded,
141
+ };
142
+ }
143
+ return {
144
+ status: "OBSERVED",
145
+ verdict: candidate.verdict,
146
+ decisionId: candidate.decisionId,
147
+ dossierId: candidate.dossierId,
148
+ reasonCodes: [...candidate.reasonCodes],
149
+ grantDiscarded,
150
+ };
151
+ }
152
+ static isBoundedIdentifier(value) {
153
+ if (typeof value !== "string" || value.length < 1 || value.length > MAX_IDENTIFIER_LENGTH) {
154
+ return false;
155
+ }
156
+ for (let index = 0; index < value.length; index += 1) {
157
+ const codeUnit = value.charCodeAt(index);
158
+ if (codeUnit <= 0x1f || codeUnit === 0x7f)
159
+ return false;
160
+ }
161
+ return true;
12
162
  }
13
163
  }
14
164
  //# sourceMappingURL=ShadowPipeline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ShadowPipeline.js","sourceRoot":"","sources":["../../src/shadow/ShadowPipeline.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,cAAc;IACW;IAApC,YAAoC,SAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;IAAG,CAAC;IAE7D,KAA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ry: loopback doubles for Decionis and Presence plus the
3
+ * development fixture primitives. Import from
4
+ * `@decionis/agent-safe-pipeline/testing`. Nothing here is production
5
+ * authority; the fixture authority refuses to construct under
6
+ * `NODE_ENV=production`, and the local servers bind only to loopback.
7
+ */
8
+ export { FixtureAuthorizationVerifier, FixtureDecisionAuthority, createFixtureAuthorityPair, type FixtureAuthorityPair, type FixtureCommitRecord, type FixtureVerdictResolver, type UnsafeFixtureAuthorityOptions, } from "../decision/FixtureDecisionAuthority.js";
9
+ export { InMemoryReplayStore } from "../execution/ReplayStore.js";
10
+ export { LocalPresence, LOCAL_PRESENCE_API_KEY, readBody, type LocalAuthenticator, type LocalCeremonyResponse, type LocalPresenceOptions, type LocalPresenceRequestRecord, type LocalReceipt, type LocalReceiptBinding, type LocalReceiptVerification, type LocalVerificationRecord, type LocalVerificationStatus, } from "./LocalPresence.js";
11
+ export { AUTONOMOUS_LIMIT_MINOR, CLAIM_ATTESTATION_TYPE, HUMAN_LIMIT_MINOR, LocalAuthority, LOCAL_AUTHORITY_API_KEY, LOCAL_AUTHORITY_ISSUER, LOCAL_AUTHORITY_JWKS_PATH, hashBinding, stableStringify, type LocalAuthorityOptions, type LocalClaimAttestationClaims, type LocalAuthorityPolicy, type LocalAuthorityRequestRecord, type LocalGrantRecord, type LocalManagedEscalationRecord, type LocalRouteOverride, } from "./LocalAuthority.js";
12
+ //# sourceMappingURL=Index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../../src/testing/Index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,GACnC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,QAAQ,EACR,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,GAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,WAAW,EACX,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Local testing entry: loopback doubles for Decionis and Presence plus the
3
+ * development fixture primitives. Import from
4
+ * `@decionis/agent-safe-pipeline/testing`. Nothing here is production
5
+ * authority; the fixture authority refuses to construct under
6
+ * `NODE_ENV=production`, and the local servers bind only to loopback.
7
+ */
8
+ export { FixtureAuthorizationVerifier, FixtureDecisionAuthority, createFixtureAuthorityPair, } from "../decision/FixtureDecisionAuthority.js";
9
+ export { InMemoryReplayStore } from "../execution/ReplayStore.js";
10
+ export { LocalPresence, LOCAL_PRESENCE_API_KEY, readBody, } from "./LocalPresence.js";
11
+ export { AUTONOMOUS_LIMIT_MINOR, CLAIM_ATTESTATION_TYPE, HUMAN_LIMIT_MINOR, LocalAuthority, LOCAL_AUTHORITY_API_KEY, LOCAL_AUTHORITY_ISSUER, LOCAL_AUTHORITY_JWKS_PATH, hashBinding, stableStringify, } from "./LocalAuthority.js";
12
+ //# sourceMappingURL=Index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Index.js","sourceRoot":"","sources":["../../src/testing/Index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,GAK3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,QAAQ,GAUT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,WAAW,EACX,eAAe,GAQhB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,292 @@
1
+ import { z } from "zod";
2
+ import { type LocalPresence } from "./LocalPresence.js";
3
+ export declare const LOCAL_AUTHORITY_API_KEY = "test-key";
4
+ export declare const AUTONOMOUS_LIMIT_MINOR = 10000;
5
+ export declare const HUMAN_LIMIT_MINOR = 100000;
6
+ /** The issuer the fixture's grants and attestations name; a provider double checks it. */
7
+ export declare const LOCAL_AUTHORITY_ISSUER = "synthetic-authority";
8
+ /** Where the fixture publishes its attestation key, at the path Decionis documents. */
9
+ export declare const LOCAL_AUTHORITY_JWKS_PATH = "/.well-known/decionis-execution-grant-jwks.json";
10
+ export declare const CLAIM_ATTESTATION_TYPE = "decionis-claim-attestation+jwt";
11
+ /** `ExecutionAuthorityRequest`: the binding plus hash, mode, evidence, and managed constraints. */
12
+ declare const AuthorityRequestSchema: z.ZodObject<{
13
+ intent_hash: z.ZodString;
14
+ mode: z.ZodEnum<{
15
+ ENFORCEMENT: "ENFORCEMENT";
16
+ SHADOW: "SHADOW";
17
+ }>;
18
+ evidence: z.ZodOptional<z.ZodObject<{
19
+ humanApproval: z.ZodOptional<z.ZodObject<{
20
+ provider: z.ZodLiteral<"presence">;
21
+ requestId: z.ZodString;
22
+ receiptDossierId: z.ZodString;
23
+ }, z.core.$strict>>;
24
+ }, z.core.$strict>>;
25
+ escalation: z.ZodOptional<z.ZodObject<{
26
+ mode: z.ZodLiteral<"MANAGED">;
27
+ approver: z.ZodOptional<z.ZodObject<{
28
+ principal_id: z.ZodOptional<z.ZodString>;
29
+ role_id: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strict>>;
31
+ verification_requirements: z.ZodOptional<z.ZodObject<{
32
+ methods: z.ZodArray<z.ZodEnum<{
33
+ WEBAUTHN: "WEBAUTHN";
34
+ ACTIVE_LIVENESS: "ACTIVE_LIVENESS";
35
+ }>>;
36
+ level: z.ZodOptional<z.ZodEnum<{
37
+ STANDARD: "STANDARD";
38
+ HIGH_CONFIDENCE: "HIGH_CONFIDENCE";
39
+ }>>;
40
+ }, z.core.$strict>>;
41
+ }, z.core.$strict>>;
42
+ protocol_version: z.ZodLiteral<"agent-safe.intent/1">;
43
+ tenant_id: z.ZodUUID;
44
+ intent_id: z.ZodUUID;
45
+ captured_at: z.ZodISODateTime;
46
+ expires_at: z.ZodISODateTime;
47
+ actor: z.ZodObject<{
48
+ id: z.ZodString;
49
+ type: z.ZodString;
50
+ runtime: z.ZodOptional<z.ZodString>;
51
+ trust_level: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strict>;
53
+ action: z.ZodObject<{
54
+ type: z.ZodString;
55
+ resource: z.ZodString;
56
+ parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
57
+ }, z.core.$strict>;
58
+ context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
59
+ downstream_target: z.ZodObject<{
60
+ system: z.ZodString;
61
+ environment: z.ZodOptional<z.ZodString>;
62
+ operation: z.ZodString;
63
+ endpoint: z.ZodOptional<z.ZodString>;
64
+ }, z.core.$strict>;
65
+ expected_effect_digest: z.ZodOptional<z.ZodString>;
66
+ }, z.core.$strict>;
67
+ export type LocalAuthorityRequest = z.infer<typeof AuthorityRequestSchema>;
68
+ type Verdict = "ALLOW" | "ESCALATE" | "BLOCK";
69
+ type ManagedStatus = "PENDING_PRESENCE" | "PRESENCE_REQUESTED" | "AWAITING_APPROVER" | "PRESENCE_VERIFIED" | "REAUTHORIZING" | "GRANT_READY" | "EXPIRED" | "REJECTED" | "BLOCKED" | "CANCELLED" | "FAILED";
70
+ type LifecycleEntry = ManagedStatus | {
71
+ status: ManagedStatus;
72
+ reasonCodes?: string[];
73
+ };
74
+ type Decision = Record<string, unknown>;
75
+ /** Verdict for an intent evaluated without evidence; evidence handling stays generic. */
76
+ export type LocalAuthorityPolicy = (request: LocalAuthorityRequest) => Verdict;
77
+ export interface LocalRouteOverride {
78
+ readonly status?: number;
79
+ readonly body?: unknown;
80
+ readonly transform?: (body: unknown) => unknown;
81
+ readonly delayMs?: number;
82
+ readonly truncateTo?: number;
83
+ readonly destroy?: boolean;
84
+ }
85
+ export type LocalAuthorityRoute = "enforce" | "status" | "claim" | "finalize";
86
+ export interface LocalAuthorityRequestRecord {
87
+ readonly method: string;
88
+ readonly path: string;
89
+ readonly headers: Readonly<Record<string, string | null>>;
90
+ body: unknown;
91
+ recomputedHash: string | null;
92
+ response: {
93
+ readonly status: number | null;
94
+ readonly body: unknown;
95
+ } | null;
96
+ readonly at: string;
97
+ }
98
+ export interface LocalGrantRecord {
99
+ readonly jti: string;
100
+ readonly tenantId: string;
101
+ readonly actorId: string;
102
+ readonly action: string;
103
+ readonly audience: string;
104
+ readonly decisionId: string;
105
+ readonly dossierId: string;
106
+ readonly intentHash: string;
107
+ readonly issuedAt: number;
108
+ readonly expiresAt: number;
109
+ readonly nonce: string;
110
+ readonly bindingDigest: string;
111
+ /** The digest the authority bound over the canonical action parameters. */
112
+ readonly payloadDigest: string;
113
+ /** The expected-effect digest committed at enforce-and-bind; null when none was bound. */
114
+ readonly expectedEffectDigest: string | null;
115
+ /** Present for direct grants issued on client-supplied evidence; null for managed grants. */
116
+ readonly receiptDossierId: string | null;
117
+ claimed: boolean;
118
+ claimToken: string | null;
119
+ correlationId: string | null;
120
+ consumedBy: string | null;
121
+ finalized: "COMMITTED" | "FAILED" | "INDETERMINATE" | null;
122
+ }
123
+ export interface LocalManagedEscalationRecord {
124
+ readonly escalationId: string;
125
+ readonly request: LocalAuthorityRequest;
126
+ /** The `LocalPresence` request this escalation is orchestrated through, if any. */
127
+ readonly presenceRequestId: string | null;
128
+ /** Scripted statuses take precedence over orchestration; used to test client state handling. */
129
+ lifecycle: LifecycleEntry[] | null;
130
+ lookup: number;
131
+ status: ManagedStatus;
132
+ reasonCodes: string[];
133
+ finalDecision: Decision | null;
134
+ readonly initialDecision: Decision;
135
+ }
136
+ export interface LocalAuthorityOptions {
137
+ readonly apiKey?: string;
138
+ /** Verifies direct evidence and hosts managed escalations. */
139
+ readonly presence?: LocalPresence;
140
+ /** Legacy hook used when no `presence` is configured. */
141
+ readonly verifyReceipt?: (approval: {
142
+ readonly requestId: string;
143
+ readonly receiptDossierId: string;
144
+ }, intentHash: string) => boolean;
145
+ readonly policy?: LocalAuthorityPolicy;
146
+ /** Subject routed to for a managed escalation without an approver principal. */
147
+ readonly managedApproverId?: string;
148
+ /**
149
+ * API-key identities this deployment accepts as effect observers, mirroring
150
+ * `DECIONIS_TRUSTED_EFFECT_OBSERVER_API_KEY_IDS`. Empty by default, exactly as
151
+ * the hosted authority is by default, so `CONFIRMED` evidence is refused
152
+ * unless a test opts in. As in the hosted route, the allowlist is intersected
153
+ * with the caller's own authenticated identity — this double's `apiKey` — so
154
+ * naming any other id confirms nothing.
155
+ */
156
+ readonly trustedEffectObserverIds?: readonly string[];
157
+ readonly clock?: () => number;
158
+ /**
159
+ * Attach a verification envelope to every decision, as the hosted
160
+ * `evaluate-decision` does and `enforce-and-bind` may: a page URL under
161
+ * this double's own origin, so a test can see the link travel end to end.
162
+ */
163
+ readonly verificationLinks?: boolean;
164
+ }
165
+ /** The organization a provisioned synthetic workspace belongs to. */
166
+ export declare const LOCAL_AUTHORITY_PROVISIONAL_ORG_ID = "00000000-0000-4000-8000-000000000008";
167
+ /** What one claim attestation says, as the fixture signs it and a provider double reads it. */
168
+ export interface LocalClaimAttestationClaims {
169
+ readonly iss: string;
170
+ readonly sub: string;
171
+ readonly org_id: string;
172
+ readonly dossier_id: string;
173
+ readonly decision_id: string;
174
+ readonly binding: {
175
+ readonly intent_hash: string;
176
+ readonly execution_payload_digest: string;
177
+ readonly execution_payload_canonicalization_profile: string;
178
+ readonly expected_effect_digest?: string;
179
+ readonly execution_nonce: string;
180
+ readonly execution_correlation_id: string;
181
+ };
182
+ readonly claim_token_digest: string;
183
+ readonly claim_validated_at: string;
184
+ readonly jti: string;
185
+ readonly iat: number;
186
+ readonly nbf: number;
187
+ readonly exp: number;
188
+ }
189
+ /**
190
+ * Independent canonicalization: keys sorted by UTF-16 code unit, values encoded
191
+ * with JSON.stringify semantics. This deliberately does not import the
192
+ * package's hasher so the two implementations check each other.
193
+ */
194
+ export declare function stableStringify(value: unknown): string;
195
+ export declare function hashBinding(binding: unknown): string;
196
+ export declare class LocalAuthority {
197
+ /** Every request seen, oldest first, with bounded bodies and the response given. */
198
+ readonly requests: LocalAuthorityRequestRecord[];
199
+ /** Issued grants keyed by execution token. */
200
+ readonly grants: Map<string, LocalGrantRecord>;
201
+ /** Managed escalations keyed by their opaque identifier. */
202
+ readonly escalations: Map<string, LocalManagedEscalationRecord>;
203
+ private readonly apiKey;
204
+ private readonly presence;
205
+ private readonly legacyVerifyReceipt;
206
+ private readonly policy;
207
+ private readonly managedApproverId;
208
+ private readonly trustedEffectObserverIds;
209
+ private readonly clock;
210
+ private readonly attestationKey;
211
+ /** The `kid` the fixture's attestations name; a provider double looks it up in the JWKS. */
212
+ readonly attestationKeyId = "synthetic-exec-grant-1";
213
+ /**
214
+ * A drill knob: when set, the next claim binds a digest over parameters
215
+ * other than the ones captured, which is what a tampered or mismatched
216
+ * authority looks like from the executor's side, and what BEAP-L3-BND-01
217
+ * says the executor must refuse.
218
+ */
219
+ misbindNextPayloadDigest: boolean;
220
+ private readonly overrides;
221
+ private readonly managedByIntent;
222
+ private nextManagedLifecycle;
223
+ private decisions;
224
+ /** Every decision minted, by dossier id, for `GET /v1/protocol/dossiers/{id}`. */
225
+ private readonly dossiers;
226
+ private readonly verificationLinks;
227
+ private server;
228
+ private port;
229
+ constructor(options?: LocalAuthorityOptions);
230
+ /** The fixture's JWKS, as `GET /.well-known/decionis-execution-grant-jwks.json` serves it. */
231
+ get jwks(): {
232
+ readonly keys: readonly Record<string, unknown>[];
233
+ };
234
+ /**
235
+ * A compact JWS over the claim, signed the way Decionis signs one: EdDSA,
236
+ * the grant key, the attestation type in the protected header. Built with
237
+ * `node:crypto` alone so the fixture stays an independent implementation.
238
+ */
239
+ private attest;
240
+ get baseUrl(): string;
241
+ start(): Promise<void>;
242
+ stop(): Promise<void>;
243
+ /**
244
+ * Alters the next response on one route only. `transform` receives the
245
+ * computed body; `body` replaces it (an object or a raw string); `status`,
246
+ * `delayMs`, `truncateTo`, and `destroy` shape the transport behavior.
247
+ */
248
+ scriptOnce(route: LocalAuthorityRoute, override: LocalRouteOverride): void;
249
+ /** Statuses returned, in order, for the next managed escalation instead of orchestration. */
250
+ scriptNextManagedLifecycle(statuses: readonly LifecycleEntry[]): void;
251
+ private handle;
252
+ private enforceAndBind;
253
+ /** Keeps a minted decision for its dossier route, with the envelope when links are on. */
254
+ private remember;
255
+ /**
256
+ * The persisted record, shaped as `GET /v1/protocol/dossiers/{id}` returns
257
+ * it: a payload with the routing decision, the inputs and a proof bundle
258
+ * naming this double's key. The artifacts are not signed; the record says
259
+ * so in its issuer tier, and nothing here claims otherwise.
260
+ */
261
+ private dossierRecord;
262
+ /** Policy plus evidence handling: a valid receipt turns an escalation into an allow. */
263
+ private evaluate;
264
+ private verifyEvidence;
265
+ private baseDecision;
266
+ private grantDecision;
267
+ /** Opens a managed escalation: scripted, orchestrated through LocalPresence, or default-scripted. */
268
+ private openManaged;
269
+ /** Creates the Presence request the way Decionis does: bound structurally to the intent hash. */
270
+ private requestPresence;
271
+ private managedStatus;
272
+ private scripted;
273
+ /** Orchestrated state machine, mirroring Decionis's transitions against Presence. */
274
+ private advance;
275
+ private cancelManaged;
276
+ private claim;
277
+ private finalize;
278
+ /**
279
+ * The hosted route never trusts the allowlist alone: it returns at most the
280
+ * caller's own authenticated API-key identity, so a confirmed observation
281
+ * must name the identity that presented the credential. This double has one
282
+ * credential, so that credential is its identity.
283
+ */
284
+ private effectObserverIds;
285
+ /** Recomputes the hash independently and applies the contract's time rules. */
286
+ private assertBinding;
287
+ private respond;
288
+ private send;
289
+ private static isTerminal;
290
+ }
291
+ export {};
292
+ //# sourceMappingURL=LocalAuthority.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalAuthority.d.ts","sourceRoot":"","sources":["../../src/testing/LocalAuthority.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAElE,eAAO,MAAM,uBAAuB,aAAa,CAAC;AAClD,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAC7C,eAAO,MAAM,iBAAiB,SAAU,CAAC;AAQzC,0FAA0F;AAC1F,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;AAC5D,uFAAuF;AACvF,eAAO,MAAM,yBAAyB,oDAAoD,CAAC;AAC3F,eAAO,MAAM,sBAAsB,mCAAmC,CAAC;AA2HvE,mGAAmG;AACnG,QAAA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAM1B,CAAC;AA2BH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE3E,KAAK,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;AAC9C,KAAK,aAAa,GACd,kBAAkB,GAClB,oBAAoB,GACpB,mBAAmB,GACnB,mBAAmB,GACnB,eAAe,GACf,aAAa,GACb,SAAS,GACT,UAAU,GACV,SAAS,GACT,WAAW,GACX,QAAQ,CAAC;AACb,KAAK,cAAc,GAAG,aAAa,GA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