martin-loop 0.1.4 → 1.3.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/CODE_OF_CONDUCT.md +32 -0
- package/README.md +172 -227
- package/demo/seeded-workspace/README.md +35 -0
- package/demo/seeded-workspace/TASKS.md +29 -0
- package/demo/seeded-workspace/martin.config.yaml +11 -0
- package/demo/seeded-workspace/package.json +8 -0
- package/demo/seeded-workspace/src/invoice-summary.js +11 -0
- package/demo/seeded-workspace/test/invoice-summary.test.js +20 -0
- package/dist/bin/martin-loop.js +0 -0
- package/dist/vendor/adapters/claude-cli.d.ts +19 -4
- package/dist/vendor/adapters/claude-cli.js +55 -24
- package/dist/vendor/adapters/cli-bridge.d.ts +1 -0
- package/dist/vendor/adapters/cli-bridge.js +154 -28
- package/dist/vendor/adapters/counter.d.ts +1 -0
- package/dist/vendor/adapters/counter.js +4 -0
- package/dist/vendor/adapters/git-baseline.d.ts +50 -0
- package/dist/vendor/adapters/git-baseline.js +233 -0
- package/dist/vendor/adapters/index.d.ts +1 -0
- package/dist/vendor/adapters/index.js +1 -0
- package/dist/vendor/adapters/openrouter-adapter.d.ts +15 -0
- package/dist/vendor/adapters/openrouter-adapter.js +302 -0
- package/dist/vendor/adapters/usage.d.ts +48 -0
- package/dist/vendor/adapters/usage.js +66 -0
- package/dist/vendor/adapters/verifier-only.d.ts +7 -0
- package/dist/vendor/adapters/verifier-only.js +57 -0
- package/dist/vendor/cli/bin/exit.d.ts +12 -0
- package/dist/vendor/cli/bin/exit.js +28 -0
- package/dist/vendor/cli/commands/analyze.d.ts +5 -0
- package/dist/vendor/cli/commands/analyze.js +58 -0
- package/dist/vendor/cli/commands/audit-log-verify.d.ts +34 -0
- package/dist/vendor/cli/commands/audit-log-verify.js +99 -0
- package/dist/vendor/cli/commands/audit.d.ts +8 -0
- package/dist/vendor/cli/commands/audit.js +199 -0
- package/dist/vendor/cli/commands/corpus.d.ts +5 -0
- package/dist/vendor/cli/commands/corpus.js +60 -0
- package/dist/vendor/cli/commands/doctor.d.ts +8 -0
- package/dist/vendor/cli/commands/doctor.js +219 -0
- package/dist/vendor/cli/commands/explain.d.ts +17 -0
- package/dist/vendor/cli/commands/explain.js +176 -0
- package/dist/vendor/cli/commands/export.d.ts +5 -0
- package/dist/vendor/cli/commands/export.js +60 -0
- package/dist/vendor/cli/commands/governance.d.ts +8 -0
- package/dist/vendor/cli/commands/governance.js +95 -0
- package/dist/vendor/cli/commands/improve.d.ts +18 -0
- package/dist/vendor/cli/commands/improve.js +396 -0
- package/dist/vendor/cli/commands/init.d.ts +8 -0
- package/dist/vendor/cli/commands/init.js +281 -0
- package/dist/vendor/cli/commands/migration.d.ts +8 -0
- package/dist/vendor/cli/commands/migration.js +67 -0
- package/dist/vendor/cli/commands/prior.d.ts +23 -0
- package/dist/vendor/cli/commands/prior.js +145 -0
- package/dist/vendor/cli/commands/resume.d.ts +21 -0
- package/dist/vendor/cli/commands/resume.js +73 -0
- package/dist/vendor/cli/commands/verify.d.ts +6 -0
- package/dist/vendor/cli/commands/verify.js +43 -0
- package/dist/vendor/cli/index.d.ts +6 -1
- package/dist/vendor/cli/index.js +124 -7
- package/dist/vendor/cli/research/public-corpus.d.ts +43 -0
- package/dist/vendor/cli/research/public-corpus.js +151 -0
- package/dist/vendor/cli/ui/error-card.d.ts +38 -0
- package/dist/vendor/cli/ui/error-card.js +103 -0
- package/dist/vendor/cli/ui/mission-brief.d.ts +41 -0
- package/dist/vendor/cli/ui/mission-brief.js +173 -0
- package/dist/vendor/cli/ui/summary-card.d.ts +34 -0
- package/dist/vendor/cli/ui/summary-card.js +102 -0
- package/dist/vendor/contracts/audit.d.ts +46 -0
- package/dist/vendor/contracts/audit.js +360 -0
- package/dist/vendor/contracts/index.d.ts +3 -1
- package/dist/vendor/contracts/post-phase15.d.ts +240 -0
- package/dist/vendor/contracts/post-phase15.js +166 -0
- package/dist/vendor/core/agent/mandates.d.ts +46 -0
- package/dist/vendor/core/agent/mandates.js +178 -0
- package/dist/vendor/core/agent/receipts.d.ts +38 -0
- package/dist/vendor/core/agent/receipts.js +131 -0
- package/dist/vendor/core/agent/signing.d.ts +17 -0
- package/dist/vendor/core/agent/signing.js +91 -0
- package/dist/vendor/core/attestation/sign.d.ts +25 -0
- package/dist/vendor/core/attestation/sign.js +216 -0
- package/dist/vendor/core/autonomy/autonomous-promotion.d.ts +120 -0
- package/dist/vendor/core/autonomy/autonomous-promotion.js +346 -0
- package/dist/vendor/core/autonomy/envelope-v2.d.ts +29 -0
- package/dist/vendor/core/autonomy/envelope-v2.js +60 -0
- package/dist/vendor/core/autonomy/envelope.d.ts +17 -0
- package/dist/vendor/core/autonomy/envelope.js +27 -0
- package/dist/vendor/core/autonomy/escalation-ledger.d.ts +20 -0
- package/dist/vendor/core/autonomy/escalation-ledger.js +18 -0
- package/dist/vendor/core/autonomy/resume.d.ts +15 -0
- package/dist/vendor/core/autonomy/resume.js +23 -0
- package/dist/vendor/core/circuit/circuit-breaker.d.ts +60 -0
- package/dist/vendor/core/circuit/circuit-breaker.js +143 -0
- package/dist/vendor/core/compiler.d.ts +2 -0
- package/dist/vendor/core/compiler.js +10 -4
- package/dist/vendor/core/context-distillation.d.ts +3 -0
- package/dist/vendor/core/context-distillation.js +44 -0
- package/dist/vendor/core/context-flow/compile-context.d.ts +8 -0
- package/dist/vendor/core/context-flow/compile-context.js +111 -0
- package/dist/vendor/core/context-flow/entities.d.ts +2 -0
- package/dist/vendor/core/context-flow/entities.js +44 -0
- package/dist/vendor/core/context-flow/evaluate-policy.d.ts +2 -0
- package/dist/vendor/core/context-flow/evaluate-policy.js +42 -0
- package/dist/vendor/core/context-flow/index.d.ts +11 -0
- package/dist/vendor/core/context-flow/index.js +24 -0
- package/dist/vendor/core/context-flow/labels.d.ts +3 -0
- package/dist/vendor/core/context-flow/labels.js +17 -0
- package/dist/vendor/core/context-flow/normalizer.d.ts +9 -0
- package/dist/vendor/core/context-flow/normalizer.js +69 -0
- package/dist/vendor/core/context-flow/profiles.d.ts +33 -0
- package/dist/vendor/core/context-flow/profiles.js +36 -0
- package/dist/vendor/core/context-flow/redaction.d.ts +1 -0
- package/dist/vendor/core/context-flow/redaction.js +6 -0
- package/dist/vendor/core/context-flow/sensitivity.d.ts +2 -0
- package/dist/vendor/core/context-flow/sensitivity.js +27 -0
- package/dist/vendor/core/context-flow/sync-preview.d.ts +2 -0
- package/dist/vendor/core/context-flow/sync-preview.js +22 -0
- package/dist/vendor/core/context-flow/token-estimator.d.ts +3 -0
- package/dist/vendor/core/context-flow/token-estimator.js +13 -0
- package/dist/vendor/core/context-flow/types.d.ts +91 -0
- package/dist/vendor/core/context-flow/types.js +2 -0
- package/dist/vendor/core/context-integrity.d.ts +26 -0
- package/dist/vendor/core/context-integrity.js +56 -0
- package/dist/vendor/core/context-utility.d.ts +47 -0
- package/dist/vendor/core/context-utility.js +405 -0
- package/dist/vendor/core/cost/pipeline.d.ts +92 -0
- package/dist/vendor/core/cost/pipeline.js +141 -0
- package/dist/vendor/core/cost/tagged-cost.d.ts +27 -0
- package/dist/vendor/core/cost/tagged-cost.js +55 -0
- package/dist/vendor/core/cost-governor.d.ts +2 -0
- package/dist/vendor/core/cost-governor.js +50 -0
- package/dist/vendor/core/cve/cve-check.d.ts +80 -0
- package/dist/vendor/core/cve/cve-check.js +172 -0
- package/dist/vendor/core/digital-twin/index.d.ts +27 -0
- package/dist/vendor/core/digital-twin/index.js +90 -0
- package/dist/vendor/core/drift/drift-graph.d.ts +47 -0
- package/dist/vendor/core/drift/drift-graph.js +100 -0
- package/dist/vendor/core/drift/objective-lock.d.ts +69 -0
- package/dist/vendor/core/drift/objective-lock.js +88 -0
- package/dist/vendor/core/drift/scope.d.ts +46 -0
- package/dist/vendor/core/drift/scope.js +102 -0
- package/dist/vendor/core/drift/signature-lock.d.ts +48 -0
- package/dist/vendor/core/drift/signature-lock.js +202 -0
- package/dist/vendor/core/drift/stale-proof-gate.d.ts +21 -0
- package/dist/vendor/core/drift/stale-proof-gate.js +19 -0
- package/dist/vendor/core/eval/known-bad-world-runner.d.ts +24 -0
- package/dist/vendor/core/eval/known-bad-world-runner.js +256 -0
- package/dist/vendor/core/evidence/claim-audit.d.ts +18 -0
- package/dist/vendor/core/evidence/claim-audit.js +89 -0
- package/dist/vendor/core/exit-intelligence.d.ts +2 -0
- package/dist/vendor/core/exit-intelligence.js +58 -0
- package/dist/vendor/core/explain/formatter.d.ts +42 -0
- package/dist/vendor/core/explain/formatter.js +171 -0
- package/dist/vendor/core/explain/timeline.d.ts +29 -0
- package/dist/vendor/core/explain/timeline.js +213 -0
- package/dist/vendor/core/failure-taxonomy.d.ts +2 -0
- package/dist/vendor/core/failure-taxonomy.js +76 -0
- package/dist/vendor/core/gateway/index.d.ts +10 -0
- package/dist/vendor/core/gateway/index.js +12 -0
- package/dist/vendor/core/gateway/registry.d.ts +40 -0
- package/dist/vendor/core/gateway/registry.js +97 -0
- package/dist/vendor/core/gateway/transport.d.ts +31 -0
- package/dist/vendor/core/gateway/transport.js +82 -0
- package/dist/vendor/core/gateway/vault.d.ts +19 -0
- package/dist/vendor/core/gateway/vault.js +29 -0
- package/dist/vendor/core/graph/adapters.d.ts +43 -0
- package/dist/vendor/core/graph/adapters.js +91 -0
- package/dist/vendor/core/graph/hotspots.d.ts +22 -0
- package/dist/vendor/core/graph/hotspots.js +30 -0
- package/dist/vendor/core/graph/index.d.ts +1 -0
- package/dist/vendor/core/graph/index.js +2 -0
- package/dist/vendor/core/honey/honey-tokens.d.ts +32 -0
- package/dist/vendor/core/honey/honey-tokens.js +44 -0
- package/dist/vendor/core/index.d.ts +7 -4
- package/dist/vendor/core/index.js +222 -64
- package/dist/vendor/core/learning/bayesian-update.d.ts +31 -0
- package/dist/vendor/core/learning/bayesian-update.js +60 -0
- package/dist/vendor/core/learning/prior-sets.d.ts +42 -0
- package/dist/vendor/core/learning/prior-sets.js +111 -0
- package/dist/vendor/core/learning/promotion-gate.d.ts +17 -0
- package/dist/vendor/core/learning/promotion-gate.js +23 -0
- package/dist/vendor/core/leash/blast-radius.d.ts +42 -0
- package/dist/vendor/core/leash/blast-radius.js +156 -0
- package/dist/vendor/core/leash/policy-leash.d.ts +31 -0
- package/dist/vendor/core/leash/policy-leash.js +117 -0
- package/dist/vendor/core/memo/memo.d.ts +63 -0
- package/dist/vendor/core/memo/memo.js +97 -0
- package/dist/vendor/core/memory/learning-pipeline.d.ts +154 -0
- package/dist/vendor/core/memory/learning-pipeline.js +391 -0
- package/dist/vendor/core/memory/palace.d.ts +84 -0
- package/dist/vendor/core/memory/palace.js +379 -0
- package/dist/vendor/core/merge/ast-merge.d.ts +22 -0
- package/dist/vendor/core/merge/ast-merge.js +350 -0
- package/dist/vendor/core/merge/text-merge.d.ts +12 -0
- package/dist/vendor/core/merge/text-merge.js +182 -0
- package/dist/vendor/core/otel/tracer.d.ts +45 -0
- package/dist/vendor/core/otel/tracer.js +116 -0
- package/dist/vendor/core/parallel/parallel-attempts.d.ts +28 -0
- package/dist/vendor/core/parallel/parallel-attempts.js +41 -0
- package/dist/vendor/core/parallel/scorer.d.ts +24 -0
- package/dist/vendor/core/parallel/scorer.js +65 -0
- package/dist/vendor/core/pattern-detection.d.ts +64 -0
- package/dist/vendor/core/pattern-detection.js +108 -0
- package/dist/vendor/core/persistence/checkpoint.d.ts +44 -0
- package/dist/vendor/core/persistence/checkpoint.js +156 -0
- package/dist/vendor/core/persistence/cleanup.d.ts +22 -0
- package/dist/vendor/core/persistence/cleanup.js +131 -0
- package/dist/vendor/core/persistence/index.d.ts +2 -0
- package/dist/vendor/core/persistence/index.js +1 -0
- package/dist/vendor/core/persistence/runs-reader.d.ts +52 -0
- package/dist/vendor/core/persistence/runs-reader.js +84 -0
- package/dist/vendor/core/persistence/store.d.ts +6 -1
- package/dist/vendor/core/persistence/store.js +5 -0
- package/dist/vendor/core/policy/file-touch-quota.d.ts +60 -0
- package/dist/vendor/core/policy/file-touch-quota.js +105 -0
- package/dist/vendor/core/policy/policy-loader.d.ts +30 -0
- package/dist/vendor/core/policy/policy-loader.js +170 -0
- package/dist/vendor/core/policy/policy-schema.d.ts +55 -0
- package/dist/vendor/core/policy/policy-schema.js +78 -0
- package/dist/vendor/core/policy.d.ts +6 -0
- package/dist/vendor/core/probe/probe.d.ts +49 -0
- package/dist/vendor/core/probe/probe.js +115 -0
- package/dist/vendor/core/proof/patch-proof.d.ts +58 -0
- package/dist/vendor/core/proof/patch-proof.js +84 -0
- package/dist/vendor/core/proof/semantic-probe.d.ts +25 -0
- package/dist/vendor/core/proof/semantic-probe.js +82 -0
- package/dist/vendor/core/recovery/failure-mode-runner.d.ts +29 -0
- package/dist/vendor/core/recovery/failure-mode-runner.js +39 -0
- package/dist/vendor/core/red-blue/red-phase.d.ts +64 -0
- package/dist/vendor/core/red-blue/red-phase.js +141 -0
- package/dist/vendor/core/red-blue/risk-tiers.d.ts +22 -0
- package/dist/vendor/core/red-blue/risk-tiers.js +33 -0
- package/dist/vendor/core/replay/replay.d.ts +85 -0
- package/dist/vendor/core/replay/replay.js +109 -0
- package/dist/vendor/core/router/engine.d.ts +54 -0
- package/dist/vendor/core/router/engine.js +131 -0
- package/dist/vendor/core/router/index.d.ts +1 -0
- package/dist/vendor/core/router/index.js +2 -0
- package/dist/vendor/core/router/trust-calibration.d.ts +57 -0
- package/dist/vendor/core/router/trust-calibration.js +127 -0
- package/dist/vendor/core/run-martin.d.ts +2 -0
- package/dist/vendor/core/run-martin.js +287 -0
- package/dist/vendor/core/security/cve-scanner.d.ts +62 -0
- package/dist/vendor/core/security/cve-scanner.js +178 -0
- package/dist/vendor/core/sentinel/efficiency-sentinel.d.ts +29 -0
- package/dist/vendor/core/sentinel/efficiency-sentinel.js +30 -0
- package/dist/vendor/core/sentinel/progress-guard.d.ts +35 -0
- package/dist/vendor/core/sentinel/progress-guard.js +46 -0
- package/dist/vendor/core/siem/siem-emitter.d.ts +49 -0
- package/dist/vendor/core/siem/siem-emitter.js +157 -0
- package/dist/vendor/core/strategy/attempt-brief.d.ts +22 -0
- package/dist/vendor/core/strategy/attempt-brief.js +89 -0
- package/dist/vendor/core/summarize/diff-summary.d.ts +35 -0
- package/dist/vendor/core/summarize/diff-summary.js +204 -0
- package/dist/vendor/core/surface-signals.d.ts +21 -0
- package/dist/vendor/core/surface-signals.js +139 -0
- package/dist/vendor/core/truth/truth-wall.d.ts +51 -0
- package/dist/vendor/core/truth/truth-wall.js +69 -0
- package/dist/vendor/core/truth-spine.d.ts +26 -0
- package/dist/vendor/core/truth-spine.js +62 -0
- package/dist/vendor/core/types.d.ts +115 -0
- package/dist/vendor/core/types.js +2 -0
- package/dist/vendor/core/verification/tiered-verify.d.ts +17 -0
- package/dist/vendor/core/verification/tiered-verify.js +29 -0
- package/dist/vendor/core/verifier-pyramid.d.ts +32 -0
- package/dist/vendor/core/verifier-pyramid.js +111 -0
- package/dist/vendor/core/workflow-artifacts.d.ts +99 -0
- package/dist/vendor/core/workflow-artifacts.js +668 -0
- package/dist/vendor/core/wrap/supervised-run.d.ts +96 -0
- package/dist/vendor/core/wrap/supervised-run.js +178 -0
- package/docs/assets/cli-animated.svg +139 -0
- package/docs/assets/cli-static.svg +34 -0
- package/docs/assets/github-hero-v2.svg +23 -0
- package/docs/assets/martin-raplph.png.jpg +0 -0
- package/docs/assets/martinloop-logo.png +0 -0
- package/docs/assets/nvidia-inception-program-light.png +0 -0
- package/docs/assets/nvidia-inception-program.png +0 -0
- package/docs/assets/phase3c-sidesidebyside-demo.html +228 -0
- package/docs/assets/side-by-side.svg +134 -0
- package/docs/oss/CLAUDE-CODE-WALKTHROUGH.md +142 -0
- package/docs/oss/EXAMPLES.md +9 -1
- package/docs/oss/OSS-BOUNDARY-REPORT.json +109 -113
- package/docs/oss/OSS-BOUNDARY-REPORT.md +48 -48
- package/docs/oss/QUICKSTART.md +39 -4
- package/docs/oss/RALPH-LOOP-SAFETY.md +113 -0
- package/docs/oss/README.md +7 -4
- package/docs/oss/RELEASE-SURFACE-REPORT.json +46 -45
- package/docs/oss/RELEASE-SURFACE-REPORT.md +36 -35
- package/package.json +129 -49
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
export type FuturePlanTier = "starter" | "pro" | "enterprise";
|
|
2
|
+
export type FutureCapabilityId = "hosted_dashboard_basic" | "shared_team_visibility" | "cost_history" | "loop_heatmap" | "basic_routing_analytics" | "basic_exports" | "finance_board" | "engineering_board" | "failure_taxonomy_reports" | "forecasting_and_variance" | "artifact_drilldown" | "product_intelligence_consent_controls" | "advanced_routing_intelligence" | "approvals_and_policy_workflows" | "audit_exports" | "benchmark_controls" | "org_level_data_sharing_controls" | "enterprise_governance_controls";
|
|
3
|
+
export type PostPhase15ToggleKey = "service_operation" | "aggregate_product_intelligence" | "benchmark_participation" | "advanced_artifact_contribution" | "model_improvement_contribution" | "support_diagnostics";
|
|
4
|
+
export type PostPhase15BoardId = "finance" | "engineering" | "routing" | "failures" | "benchmarks";
|
|
5
|
+
export type PostPhase15SettingsSection = "data-privacy" | "consent-history" | "eligibility";
|
|
6
|
+
export type PostPhase15ViewerRole = "admin" | "workspace";
|
|
7
|
+
export type PostPhase15EligibilityKey = "benchmark_eligible" | "model_improvement_eligible";
|
|
8
|
+
export type PostPhase15EligibilityStatus = "eligible" | "blocked";
|
|
9
|
+
export type PostPhase15DashboardExportFormat = "json" | "csv";
|
|
10
|
+
export type PostPhase15CoverageStatus = "complete" | "partial" | "none";
|
|
11
|
+
export type PostPhase15ConfidenceLevel = "high" | "medium" | "low" | "n/a";
|
|
12
|
+
export type PostPhase15DashboardOutcomeView = "all" | "successful" | "failed";
|
|
13
|
+
export type PostPhase15DashboardAccountingView = "all" | "exact" | "estimated";
|
|
14
|
+
export type PostPhase15DashboardExactness = "exact_only" | "mixed" | "estimated_only" | "unavailable";
|
|
15
|
+
export type PostPhase15DashboardDataState = "no_live_query_wiring" | "artifact_backed_summary" | "hardened_query_wiring" | "eligibility_blocked";
|
|
16
|
+
export type PostPhase15ArtifactFreshnessStatus = "fresh" | "aging" | "stale";
|
|
17
|
+
export type PostPhase15LegalDocumentId = "privacy" | "terms" | "benchmarking-disclosure" | "data-processing-addendum";
|
|
18
|
+
export interface PostPhase15ToggleDefinition {
|
|
19
|
+
key: PostPhase15ToggleKey;
|
|
20
|
+
label: string;
|
|
21
|
+
defaultValue: boolean;
|
|
22
|
+
scope: "workspace" | "organization";
|
|
23
|
+
policySection: string;
|
|
24
|
+
requiresExplicitConfirmation: boolean;
|
|
25
|
+
description: string;
|
|
26
|
+
}
|
|
27
|
+
export interface PostPhase15ToggleState {
|
|
28
|
+
key: PostPhase15ToggleKey;
|
|
29
|
+
label: string;
|
|
30
|
+
defaultValue: boolean;
|
|
31
|
+
currentValue: boolean;
|
|
32
|
+
editable: boolean;
|
|
33
|
+
scope: "workspace" | "organization";
|
|
34
|
+
policySection: string;
|
|
35
|
+
requiresExplicitConfirmation: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface PostPhase15SettingsControlGroup {
|
|
38
|
+
key: "benchmarking" | "product-intelligence" | "support-diagnostics";
|
|
39
|
+
title: string;
|
|
40
|
+
description: string;
|
|
41
|
+
toggleKeys: PostPhase15ToggleKey[];
|
|
42
|
+
documentId: PostPhase15LegalDocumentId;
|
|
43
|
+
}
|
|
44
|
+
export interface PostPhase15PolicyLink {
|
|
45
|
+
key: "privacy_policy" | "terms" | "benchmarking_disclosure" | "data_processing_addendum";
|
|
46
|
+
label: string;
|
|
47
|
+
href: string;
|
|
48
|
+
documentId: PostPhase15LegalDocumentId;
|
|
49
|
+
sectionId: string | null;
|
|
50
|
+
}
|
|
51
|
+
export interface PostPhase15RetentionSummary {
|
|
52
|
+
retentionPolicyId: string;
|
|
53
|
+
defaultWindowDays: number;
|
|
54
|
+
supportDiagnosticsWindowDays: number;
|
|
55
|
+
benchmarkWindowDays: number;
|
|
56
|
+
modelImprovementWindowDays: number;
|
|
57
|
+
summary: string;
|
|
58
|
+
}
|
|
59
|
+
export interface PostPhase15DisabledResponse {
|
|
60
|
+
error: "Not Found";
|
|
61
|
+
feature: "post-phase15";
|
|
62
|
+
enabled: false;
|
|
63
|
+
}
|
|
64
|
+
export interface PostPhase15ScopedResponseFields {
|
|
65
|
+
workspaceId: string;
|
|
66
|
+
viewerRole: PostPhase15ViewerRole;
|
|
67
|
+
}
|
|
68
|
+
export interface PostPhase15DataPrivacyHardenedResponse extends PostPhase15ScopedResponseFields {
|
|
69
|
+
status: "hardened";
|
|
70
|
+
section: "data-privacy";
|
|
71
|
+
toggles: PostPhase15ToggleState[];
|
|
72
|
+
controlGroups: PostPhase15SettingsControlGroup[];
|
|
73
|
+
policyLinks: PostPhase15PolicyLink[];
|
|
74
|
+
retentionSummary: PostPhase15RetentionSummary;
|
|
75
|
+
provenanceRule: string;
|
|
76
|
+
exactnessRule: string;
|
|
77
|
+
persistence: "default_contract" | "persisted";
|
|
78
|
+
}
|
|
79
|
+
export interface PostPhase15ConsentHistoryHardenedResponse extends PostPhase15ScopedResponseFields {
|
|
80
|
+
status: "hardened";
|
|
81
|
+
section: "consent-history";
|
|
82
|
+
events: Array<{
|
|
83
|
+
eventId: string;
|
|
84
|
+
toggleKey: PostPhase15ToggleKey;
|
|
85
|
+
oldValue: boolean;
|
|
86
|
+
newValue: boolean;
|
|
87
|
+
actorId: string;
|
|
88
|
+
actorRole: PostPhase15ViewerRole;
|
|
89
|
+
effectiveAt: string;
|
|
90
|
+
consentVersion: number;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
}>;
|
|
93
|
+
requiredFields: string[];
|
|
94
|
+
persistence: "default_contract" | "persisted";
|
|
95
|
+
}
|
|
96
|
+
export interface PostPhase15EligibilityHardenedResponse extends PostPhase15ScopedResponseFields {
|
|
97
|
+
status: "hardened";
|
|
98
|
+
section: "eligibility";
|
|
99
|
+
derivedEligibility: PostPhase15EligibilityDecision[];
|
|
100
|
+
safeDefault: "drop_unknown_rows";
|
|
101
|
+
evidenceMode: "consent_and_system_readiness";
|
|
102
|
+
}
|
|
103
|
+
export type PostPhase15SettingsGetResponse = PostPhase15DataPrivacyHardenedResponse | PostPhase15ConsentHistoryHardenedResponse | PostPhase15EligibilityHardenedResponse;
|
|
104
|
+
export interface PostPhase15SettingsPatchResponse {
|
|
105
|
+
workspaceId: string;
|
|
106
|
+
viewerRole: PostPhase15ViewerRole;
|
|
107
|
+
status: "hardened";
|
|
108
|
+
section: PostPhase15SettingsSection;
|
|
109
|
+
persistence: "persisted" | "not_persisted";
|
|
110
|
+
applied: false;
|
|
111
|
+
updates: PostPhase15ToggleUpdate[];
|
|
112
|
+
}
|
|
113
|
+
export interface PostPhase15ToggleUpdate {
|
|
114
|
+
key: PostPhase15ToggleKey;
|
|
115
|
+
value: boolean;
|
|
116
|
+
}
|
|
117
|
+
export interface PostPhase15BoardMetric {
|
|
118
|
+
key: string;
|
|
119
|
+
label: string;
|
|
120
|
+
value: number | null;
|
|
121
|
+
unit: "usd" | "count" | "pct" | "ratio" | "seconds";
|
|
122
|
+
provenance: "actual" | "estimated" | "modeled" | "unavailable";
|
|
123
|
+
coverageStatus: PostPhase15CoverageStatus;
|
|
124
|
+
confidenceLevel: PostPhase15ConfidenceLevel;
|
|
125
|
+
source: string;
|
|
126
|
+
}
|
|
127
|
+
export interface PostPhase15BoardBreakdown {
|
|
128
|
+
key: string;
|
|
129
|
+
label: string;
|
|
130
|
+
value: number | null;
|
|
131
|
+
provenance: "actual" | "estimated" | "modeled" | "unavailable";
|
|
132
|
+
coverageStatus: PostPhase15CoverageStatus;
|
|
133
|
+
confidenceLevel: PostPhase15ConfidenceLevel;
|
|
134
|
+
source: string;
|
|
135
|
+
}
|
|
136
|
+
export interface PostPhase15EligibilityRequirement {
|
|
137
|
+
key: string;
|
|
138
|
+
label: string;
|
|
139
|
+
satisfied: boolean;
|
|
140
|
+
blocking: boolean;
|
|
141
|
+
source: "consent_setting" | "system_readiness";
|
|
142
|
+
detail: string;
|
|
143
|
+
}
|
|
144
|
+
export interface PostPhase15EligibilityDecision {
|
|
145
|
+
key: PostPhase15EligibilityKey;
|
|
146
|
+
status: PostPhase15EligibilityStatus;
|
|
147
|
+
summary: string;
|
|
148
|
+
requirements: PostPhase15EligibilityRequirement[];
|
|
149
|
+
}
|
|
150
|
+
export interface PostPhase15DashboardFilterState {
|
|
151
|
+
from: string | null;
|
|
152
|
+
to: string | null;
|
|
153
|
+
outcomeView: PostPhase15DashboardOutcomeView;
|
|
154
|
+
provider: string | null;
|
|
155
|
+
model: string | null;
|
|
156
|
+
accountingView: PostPhase15DashboardAccountingView;
|
|
157
|
+
}
|
|
158
|
+
export interface PostPhase15ArtifactFreshness {
|
|
159
|
+
source: "benchmark_report";
|
|
160
|
+
sourceLabel: string;
|
|
161
|
+
generatedAt: string;
|
|
162
|
+
sourceUpdatedAt: string | null;
|
|
163
|
+
ageMinutes: number;
|
|
164
|
+
staleAfterMinutes: number;
|
|
165
|
+
status: PostPhase15ArtifactFreshnessStatus;
|
|
166
|
+
}
|
|
167
|
+
export interface PostPhase15ArtifactEvidence {
|
|
168
|
+
kind: "event" | "violation" | "budget_metric";
|
|
169
|
+
label: string;
|
|
170
|
+
detail: string;
|
|
171
|
+
timestamp: string;
|
|
172
|
+
}
|
|
173
|
+
export interface PostPhase15ArtifactDrilldownItem {
|
|
174
|
+
drawerKey: string;
|
|
175
|
+
runId: string;
|
|
176
|
+
attemptIndex: number | null;
|
|
177
|
+
title: string;
|
|
178
|
+
providerId: string | null;
|
|
179
|
+
model: string | null;
|
|
180
|
+
status: string | null;
|
|
181
|
+
patchDecision: string | null;
|
|
182
|
+
failureClass: string | null;
|
|
183
|
+
actualUsd: number | null;
|
|
184
|
+
modeledAvoidedUsd: number | null;
|
|
185
|
+
startedAt: string | null;
|
|
186
|
+
completedAt: string | null;
|
|
187
|
+
evidence: PostPhase15ArtifactEvidence[];
|
|
188
|
+
}
|
|
189
|
+
export interface PostPhase15RoutingRecommendation {
|
|
190
|
+
routeKey: string;
|
|
191
|
+
providerId: string | null;
|
|
192
|
+
model: string | null;
|
|
193
|
+
taskClass: string;
|
|
194
|
+
confidence: PostPhase15ConfidenceLevel;
|
|
195
|
+
summary: string;
|
|
196
|
+
reason: string;
|
|
197
|
+
routeWinRate: number | null;
|
|
198
|
+
costPerSuccessUsd: number | null;
|
|
199
|
+
medianLatencySeconds: number | null;
|
|
200
|
+
}
|
|
201
|
+
export interface PostPhase15DashboardSummaryHardenedResponse extends PostPhase15ScopedResponseFields {
|
|
202
|
+
status: "hardened";
|
|
203
|
+
board: PostPhase15BoardId;
|
|
204
|
+
kpiFamilies: string[];
|
|
205
|
+
provenanceRule: string;
|
|
206
|
+
dataState: PostPhase15DashboardDataState;
|
|
207
|
+
viewExactness: PostPhase15DashboardExactness;
|
|
208
|
+
exportFormats: PostPhase15DashboardExportFormat[];
|
|
209
|
+
filters: PostPhase15DashboardFilterState;
|
|
210
|
+
artifactFreshness?: PostPhase15ArtifactFreshness;
|
|
211
|
+
recommendation?: PostPhase15RoutingRecommendation;
|
|
212
|
+
statusDetail?: string;
|
|
213
|
+
metrics?: PostPhase15BoardMetric[];
|
|
214
|
+
breakdowns?: PostPhase15BoardBreakdown[];
|
|
215
|
+
}
|
|
216
|
+
export interface PostPhase15DashboardDrilldownResponse extends PostPhase15ScopedResponseFields {
|
|
217
|
+
status: "hardened";
|
|
218
|
+
board: PostPhase15BoardId;
|
|
219
|
+
metric: string | null;
|
|
220
|
+
filters: PostPhase15DashboardFilterState;
|
|
221
|
+
dataState: "no_live_query_wiring" | "hardened_query_wiring";
|
|
222
|
+
items: PostPhase15ArtifactDrilldownItem[];
|
|
223
|
+
}
|
|
224
|
+
export type PostPhase15DataPrivacyScaffoldResponse = PostPhase15DataPrivacyHardenedResponse;
|
|
225
|
+
export type PostPhase15ConsentHistoryScaffoldResponse = PostPhase15ConsentHistoryHardenedResponse;
|
|
226
|
+
export type PostPhase15EligibilityScaffoldResponse = PostPhase15EligibilityHardenedResponse;
|
|
227
|
+
export type PostPhase15DashboardSummaryScaffoldResponse = PostPhase15DashboardSummaryHardenedResponse;
|
|
228
|
+
export type PostPhase15DashboardDrilldownScaffoldResponse = PostPhase15DashboardDrilldownResponse;
|
|
229
|
+
export declare const FUTURE_CAPABILITY_MAP: Readonly<Record<FuturePlanTier, readonly FutureCapabilityId[]>>;
|
|
230
|
+
export declare const FUTURE_CAPABILITY_IDS: FutureCapabilityId[];
|
|
231
|
+
export declare const POST_PHASE15_TOGGLE_DEFAULTS: Readonly<Record<PostPhase15ToggleKey, PostPhase15ToggleDefinition>>;
|
|
232
|
+
export declare const POST_PHASE15_KPI_FAMILIES: Readonly<Record<PostPhase15BoardId, readonly string[]>>;
|
|
233
|
+
export declare const POST_PHASE15_PROVENANCE_RULE = "Every post-phase-15 metric must declare whether it is artifact-backed exact, artifact-backed estimated, or unavailable.";
|
|
234
|
+
export declare const POST_PHASE15_EXACTNESS_RULE = "If a value is modeled, the response must label it as estimated and cite the modeling source instead of silently blending it with exact artifact data.";
|
|
235
|
+
export declare const POST_PHASE15_SETTINGS_SECTIONS: readonly PostPhase15SettingsSection[];
|
|
236
|
+
export declare const POST_PHASE15_DASHBOARD_EXPORT_FORMATS: readonly PostPhase15DashboardExportFormat[];
|
|
237
|
+
export declare const POST_PHASE15_DASHBOARD_OUTCOME_VIEWS: readonly PostPhase15DashboardOutcomeView[];
|
|
238
|
+
export declare const POST_PHASE15_DASHBOARD_ACCOUNTING_VIEWS: readonly PostPhase15DashboardAccountingView[];
|
|
239
|
+
export declare function getFuturePlanCapabilities(tier: FuturePlanTier): FutureCapabilityId[];
|
|
240
|
+
export declare function futureTierIncludes(tier: FuturePlanTier, capability: FutureCapabilityId): boolean;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export const FUTURE_CAPABILITY_MAP = {
|
|
2
|
+
starter: [
|
|
3
|
+
"hosted_dashboard_basic",
|
|
4
|
+
"shared_team_visibility",
|
|
5
|
+
"cost_history",
|
|
6
|
+
"loop_heatmap",
|
|
7
|
+
"basic_routing_analytics",
|
|
8
|
+
"basic_exports"
|
|
9
|
+
],
|
|
10
|
+
pro: [
|
|
11
|
+
"hosted_dashboard_basic",
|
|
12
|
+
"shared_team_visibility",
|
|
13
|
+
"cost_history",
|
|
14
|
+
"loop_heatmap",
|
|
15
|
+
"basic_routing_analytics",
|
|
16
|
+
"basic_exports",
|
|
17
|
+
"finance_board",
|
|
18
|
+
"engineering_board",
|
|
19
|
+
"failure_taxonomy_reports",
|
|
20
|
+
"forecasting_and_variance",
|
|
21
|
+
"artifact_drilldown",
|
|
22
|
+
"product_intelligence_consent_controls"
|
|
23
|
+
],
|
|
24
|
+
enterprise: [
|
|
25
|
+
"hosted_dashboard_basic",
|
|
26
|
+
"shared_team_visibility",
|
|
27
|
+
"cost_history",
|
|
28
|
+
"loop_heatmap",
|
|
29
|
+
"basic_routing_analytics",
|
|
30
|
+
"basic_exports",
|
|
31
|
+
"finance_board",
|
|
32
|
+
"engineering_board",
|
|
33
|
+
"failure_taxonomy_reports",
|
|
34
|
+
"forecasting_and_variance",
|
|
35
|
+
"artifact_drilldown",
|
|
36
|
+
"product_intelligence_consent_controls",
|
|
37
|
+
"advanced_routing_intelligence",
|
|
38
|
+
"approvals_and_policy_workflows",
|
|
39
|
+
"audit_exports",
|
|
40
|
+
"benchmark_controls",
|
|
41
|
+
"org_level_data_sharing_controls",
|
|
42
|
+
"enterprise_governance_controls"
|
|
43
|
+
]
|
|
44
|
+
};
|
|
45
|
+
export const FUTURE_CAPABILITY_IDS = Array.from(new Set(Object.values(FUTURE_CAPABILITY_MAP).flat()));
|
|
46
|
+
export const POST_PHASE15_TOGGLE_DEFAULTS = {
|
|
47
|
+
service_operation: {
|
|
48
|
+
key: "service_operation",
|
|
49
|
+
label: "Service operation",
|
|
50
|
+
defaultValue: true,
|
|
51
|
+
scope: "workspace",
|
|
52
|
+
policySection: "Service Operation",
|
|
53
|
+
requiresExplicitConfirmation: false,
|
|
54
|
+
description: "Required for Martin Loop to operate the workspace safely."
|
|
55
|
+
},
|
|
56
|
+
aggregate_product_intelligence: {
|
|
57
|
+
key: "aggregate_product_intelligence",
|
|
58
|
+
label: "Aggregate product intelligence",
|
|
59
|
+
defaultValue: false,
|
|
60
|
+
scope: "organization",
|
|
61
|
+
policySection: "Aggregate Product Intelligence",
|
|
62
|
+
requiresExplicitConfirmation: true,
|
|
63
|
+
description: "Allows scrubbed aggregate learning outside the single customer boundary."
|
|
64
|
+
},
|
|
65
|
+
benchmark_participation: {
|
|
66
|
+
key: "benchmark_participation",
|
|
67
|
+
label: "Benchmark participation",
|
|
68
|
+
defaultValue: false,
|
|
69
|
+
scope: "organization",
|
|
70
|
+
policySection: "Benchmark Participation",
|
|
71
|
+
requiresExplicitConfirmation: true,
|
|
72
|
+
description: "Allows the workspace to contribute to cohort benchmark calculations."
|
|
73
|
+
},
|
|
74
|
+
advanced_artifact_contribution: {
|
|
75
|
+
key: "advanced_artifact_contribution",
|
|
76
|
+
label: "Advanced artifact contribution",
|
|
77
|
+
defaultValue: false,
|
|
78
|
+
scope: "workspace",
|
|
79
|
+
policySection: "Advanced Artifact Contribution",
|
|
80
|
+
requiresExplicitConfirmation: true,
|
|
81
|
+
description: "Allows richer derived artifacts to be used in future aggregate reporting flows."
|
|
82
|
+
},
|
|
83
|
+
model_improvement_contribution: {
|
|
84
|
+
key: "model_improvement_contribution",
|
|
85
|
+
label: "Model improvement contribution",
|
|
86
|
+
defaultValue: false,
|
|
87
|
+
scope: "organization",
|
|
88
|
+
policySection: "Model Improvement Contribution",
|
|
89
|
+
requiresExplicitConfirmation: true,
|
|
90
|
+
description: "Allows eligible data to contribute to future model-improvement programs."
|
|
91
|
+
},
|
|
92
|
+
support_diagnostics: {
|
|
93
|
+
key: "support_diagnostics",
|
|
94
|
+
label: "Support diagnostics",
|
|
95
|
+
defaultValue: false,
|
|
96
|
+
scope: "workspace",
|
|
97
|
+
policySection: "Support Diagnostics",
|
|
98
|
+
requiresExplicitConfirmation: true,
|
|
99
|
+
description: "Allows time-bounded diagnostic artifacts to be retained for support investigation."
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
export const POST_PHASE15_KPI_FAMILIES = {
|
|
103
|
+
finance: [
|
|
104
|
+
"spend_this_period",
|
|
105
|
+
"budget_variance",
|
|
106
|
+
"forecast_variance",
|
|
107
|
+
"protected_spend_usd",
|
|
108
|
+
"modeled_avoidance_usd"
|
|
109
|
+
],
|
|
110
|
+
engineering: [
|
|
111
|
+
"run_count",
|
|
112
|
+
"success_rate",
|
|
113
|
+
"grounding_violation_rate",
|
|
114
|
+
"rollback_success_rate",
|
|
115
|
+
"time_to_verified_outcome"
|
|
116
|
+
],
|
|
117
|
+
routing: [
|
|
118
|
+
"route_mix",
|
|
119
|
+
"policy_override_rate",
|
|
120
|
+
"latency_p95",
|
|
121
|
+
"routing_efficiency_score",
|
|
122
|
+
"fallback_rate"
|
|
123
|
+
],
|
|
124
|
+
failures: [
|
|
125
|
+
"failure_cost_usd",
|
|
126
|
+
"retry_waste_score",
|
|
127
|
+
"attempts_before_exit",
|
|
128
|
+
"protected_spend_usd",
|
|
129
|
+
"failure_family_rate"
|
|
130
|
+
],
|
|
131
|
+
benchmarks: [
|
|
132
|
+
"spend_efficiency_score",
|
|
133
|
+
"retry_waste_score",
|
|
134
|
+
"rollback_success_score",
|
|
135
|
+
"routing_efficiency_score",
|
|
136
|
+
"cohort_comparability_score"
|
|
137
|
+
]
|
|
138
|
+
};
|
|
139
|
+
export const POST_PHASE15_PROVENANCE_RULE = "Every post-phase-15 metric must declare whether it is artifact-backed exact, artifact-backed estimated, or unavailable.";
|
|
140
|
+
export const POST_PHASE15_EXACTNESS_RULE = "If a value is modeled, the response must label it as estimated and cite the modeling source instead of silently blending it with exact artifact data.";
|
|
141
|
+
export const POST_PHASE15_SETTINGS_SECTIONS = [
|
|
142
|
+
"data-privacy",
|
|
143
|
+
"consent-history",
|
|
144
|
+
"eligibility"
|
|
145
|
+
];
|
|
146
|
+
export const POST_PHASE15_DASHBOARD_EXPORT_FORMATS = [
|
|
147
|
+
"json",
|
|
148
|
+
"csv"
|
|
149
|
+
];
|
|
150
|
+
export const POST_PHASE15_DASHBOARD_OUTCOME_VIEWS = [
|
|
151
|
+
"all",
|
|
152
|
+
"successful",
|
|
153
|
+
"failed"
|
|
154
|
+
];
|
|
155
|
+
export const POST_PHASE15_DASHBOARD_ACCOUNTING_VIEWS = [
|
|
156
|
+
"all",
|
|
157
|
+
"exact",
|
|
158
|
+
"estimated"
|
|
159
|
+
];
|
|
160
|
+
export function getFuturePlanCapabilities(tier) {
|
|
161
|
+
return [...FUTURE_CAPABILITY_MAP[tier]];
|
|
162
|
+
}
|
|
163
|
+
export function futureTierIncludes(tier, capability) {
|
|
164
|
+
return FUTURE_CAPABILITY_MAP[tier].includes(capability);
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=post-phase15.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type AgentEd25519Signature, type AgentSigningOptions } from "./signing.js";
|
|
2
|
+
export interface AgentMandatePayload {
|
|
3
|
+
mandateId: string;
|
|
4
|
+
quoteId: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
agentPrincipalId: string;
|
|
7
|
+
repoAuthorityHash: string;
|
|
8
|
+
maxUsd: number;
|
|
9
|
+
maxIterations: number;
|
|
10
|
+
approvedBy: string;
|
|
11
|
+
issuedAt: string;
|
|
12
|
+
expiresAt: string;
|
|
13
|
+
}
|
|
14
|
+
export type AgentMandateSignature = AgentEd25519Signature;
|
|
15
|
+
export type SignedAgentMandate = AgentMandatePayload & {
|
|
16
|
+
signature: AgentMandateSignature;
|
|
17
|
+
};
|
|
18
|
+
export type AgentMandateSignOptions = AgentSigningOptions;
|
|
19
|
+
export interface AgentMandateVerifyOptions {
|
|
20
|
+
expectedQuoteId?: string;
|
|
21
|
+
expectedWorkspaceId?: string;
|
|
22
|
+
expectedAgentPrincipalId?: string;
|
|
23
|
+
expectedRepoAuthorityHash?: string;
|
|
24
|
+
expectedSignerKeyId?: string;
|
|
25
|
+
expectedSignerPublicKeyPem?: string;
|
|
26
|
+
trustedSignerKeyIds?: string[];
|
|
27
|
+
trustedSignerPublicKeys?: string[];
|
|
28
|
+
requestedUsd?: number;
|
|
29
|
+
requestedIterations?: number;
|
|
30
|
+
now?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AgentMandateVerificationResult {
|
|
33
|
+
verified: boolean;
|
|
34
|
+
mandateId: string | null;
|
|
35
|
+
quoteId: string | null;
|
|
36
|
+
workspaceId: string | null;
|
|
37
|
+
agentPrincipalId: string | null;
|
|
38
|
+
repoAuthorityHash: string | null;
|
|
39
|
+
maxUsd: number | null;
|
|
40
|
+
maxIterations: number | null;
|
|
41
|
+
expiresAt: string | null;
|
|
42
|
+
keyId?: string;
|
|
43
|
+
reasons: string[];
|
|
44
|
+
}
|
|
45
|
+
export declare function signAgentMandate(payload: AgentMandatePayload, options?: AgentMandateSignOptions): Promise<SignedAgentMandate>;
|
|
46
|
+
export declare function verifyAgentMandate(mandate: unknown, options?: AgentMandateVerifyOptions): AgentMandateVerificationResult;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { agentKeyId, readAgentEd25519Signature, signCanonicalAgentPayload, verifyCanonicalAgentPayload } from "./signing.js";
|
|
2
|
+
const MANDATE_KEY_NAMESPACE = "agent-mandates";
|
|
3
|
+
export async function signAgentMandate(payload, options = {}) {
|
|
4
|
+
return {
|
|
5
|
+
...payload,
|
|
6
|
+
signature: await signCanonicalAgentPayload(payload, MANDATE_KEY_NAMESPACE, options)
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function verifyAgentMandate(mandate, options = {}) {
|
|
10
|
+
const reasons = [];
|
|
11
|
+
if (!mandate || typeof mandate !== "object" || Array.isArray(mandate)) {
|
|
12
|
+
return {
|
|
13
|
+
verified: false,
|
|
14
|
+
mandateId: null,
|
|
15
|
+
quoteId: null,
|
|
16
|
+
workspaceId: null,
|
|
17
|
+
agentPrincipalId: null,
|
|
18
|
+
repoAuthorityHash: null,
|
|
19
|
+
maxUsd: null,
|
|
20
|
+
maxIterations: null,
|
|
21
|
+
expiresAt: null,
|
|
22
|
+
reasons: ["Agent mandate must be an object."]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const record = mandate;
|
|
26
|
+
const mandateId = readString(record.mandateId);
|
|
27
|
+
const quoteId = readString(record.quoteId);
|
|
28
|
+
const workspaceId = readString(record.workspaceId);
|
|
29
|
+
const agentPrincipalId = readString(record.agentPrincipalId);
|
|
30
|
+
const repoAuthorityHash = readString(record.repoAuthorityHash);
|
|
31
|
+
const maxUsd = readPositiveNumber(record.maxUsd);
|
|
32
|
+
const maxIterations = readPositiveInteger(record.maxIterations);
|
|
33
|
+
const approvedBy = readString(record.approvedBy);
|
|
34
|
+
const issuedAt = readString(record.issuedAt);
|
|
35
|
+
const expiresAt = readString(record.expiresAt);
|
|
36
|
+
const signature = readAgentEd25519Signature(record.signature);
|
|
37
|
+
if (!mandateId)
|
|
38
|
+
reasons.push("Agent mandate id is missing.");
|
|
39
|
+
if (!quoteId)
|
|
40
|
+
reasons.push("Agent mandate quote id is missing.");
|
|
41
|
+
if (!workspaceId)
|
|
42
|
+
reasons.push("Agent mandate workspace id is missing.");
|
|
43
|
+
if (!agentPrincipalId)
|
|
44
|
+
reasons.push("Agent mandate principal id is missing.");
|
|
45
|
+
if (!repoAuthorityHash)
|
|
46
|
+
reasons.push("Agent mandate repo authority hash is missing.");
|
|
47
|
+
if (maxUsd === null)
|
|
48
|
+
reasons.push("Agent mandate spend cap is missing.");
|
|
49
|
+
if (maxIterations === null)
|
|
50
|
+
reasons.push("Agent mandate iteration cap is missing.");
|
|
51
|
+
if (!approvedBy)
|
|
52
|
+
reasons.push("Agent mandate approver is missing.");
|
|
53
|
+
if (!issuedAt)
|
|
54
|
+
reasons.push("Agent mandate issued timestamp is missing.");
|
|
55
|
+
if (!expiresAt)
|
|
56
|
+
reasons.push("Agent mandate expiry is missing.");
|
|
57
|
+
if (!signature)
|
|
58
|
+
reasons.push("Agent mandate signature is missing.");
|
|
59
|
+
const timeWindow = validateMandateTimeWindow(issuedAt, expiresAt, options.now);
|
|
60
|
+
reasons.push(...timeWindow.reasons);
|
|
61
|
+
if (options.expectedQuoteId && quoteId && quoteId !== options.expectedQuoteId) {
|
|
62
|
+
reasons.push("Agent mandate quote binding does not match.");
|
|
63
|
+
}
|
|
64
|
+
if (options.expectedWorkspaceId && workspaceId && workspaceId !== options.expectedWorkspaceId) {
|
|
65
|
+
reasons.push("Agent mandate workspace binding does not match.");
|
|
66
|
+
}
|
|
67
|
+
if (options.expectedAgentPrincipalId &&
|
|
68
|
+
agentPrincipalId &&
|
|
69
|
+
agentPrincipalId !== options.expectedAgentPrincipalId) {
|
|
70
|
+
reasons.push("Agent mandate principal binding does not match.");
|
|
71
|
+
}
|
|
72
|
+
if (options.expectedRepoAuthorityHash &&
|
|
73
|
+
repoAuthorityHash &&
|
|
74
|
+
repoAuthorityHash !== options.expectedRepoAuthorityHash) {
|
|
75
|
+
reasons.push("Agent mandate repo authority binding does not match.");
|
|
76
|
+
}
|
|
77
|
+
if (options.requestedUsd !== undefined && maxUsd !== null && options.requestedUsd > maxUsd) {
|
|
78
|
+
reasons.push("Requested spend exceeds mandate cap.");
|
|
79
|
+
}
|
|
80
|
+
if (options.requestedIterations !== undefined &&
|
|
81
|
+
maxIterations !== null &&
|
|
82
|
+
options.requestedIterations > maxIterations) {
|
|
83
|
+
reasons.push("Requested iterations exceed mandate cap.");
|
|
84
|
+
}
|
|
85
|
+
if (signature) {
|
|
86
|
+
const expectedKeyId = agentKeyId(signature.publicKeyPem);
|
|
87
|
+
if (signature.keyId !== expectedKeyId) {
|
|
88
|
+
reasons.push("Agent mandate key id does not match public key.");
|
|
89
|
+
}
|
|
90
|
+
if (!isTrustedSigner(signature, options)) {
|
|
91
|
+
reasons.push("Agent mandate signer is untrusted.");
|
|
92
|
+
}
|
|
93
|
+
const payload = { ...record };
|
|
94
|
+
delete payload.signature;
|
|
95
|
+
try {
|
|
96
|
+
if (!verifyCanonicalAgentPayload(payload, signature)) {
|
|
97
|
+
reasons.push("Agent mandate signature verification failed.");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
reasons.push("Agent mandate signature verification failed.");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
verified: reasons.length === 0,
|
|
106
|
+
mandateId,
|
|
107
|
+
quoteId,
|
|
108
|
+
workspaceId,
|
|
109
|
+
agentPrincipalId,
|
|
110
|
+
repoAuthorityHash,
|
|
111
|
+
maxUsd,
|
|
112
|
+
maxIterations,
|
|
113
|
+
expiresAt,
|
|
114
|
+
...(signature ? { keyId: signature.keyId } : {}),
|
|
115
|
+
reasons
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function validateMandateTimeWindow(issuedAt, expiresAt, now) {
|
|
119
|
+
const reasons = [];
|
|
120
|
+
const issuedMs = parseTimestamp(issuedAt);
|
|
121
|
+
const expiresMs = parseTimestamp(expiresAt);
|
|
122
|
+
const nowMs = parseTimestamp(now ?? new Date().toISOString());
|
|
123
|
+
if (issuedAt && issuedMs === null) {
|
|
124
|
+
reasons.push("Agent mandate issued timestamp is invalid.");
|
|
125
|
+
}
|
|
126
|
+
if (expiresAt && expiresMs === null) {
|
|
127
|
+
reasons.push("Agent mandate expiry is invalid.");
|
|
128
|
+
}
|
|
129
|
+
if (now !== undefined && nowMs === null) {
|
|
130
|
+
reasons.push("Verification clock is invalid.");
|
|
131
|
+
}
|
|
132
|
+
if (issuedMs !== null && expiresMs !== null && issuedMs > expiresMs) {
|
|
133
|
+
reasons.push("Agent mandate issued timestamp is after expiry.");
|
|
134
|
+
}
|
|
135
|
+
if (issuedMs !== null && nowMs !== null && nowMs < issuedMs) {
|
|
136
|
+
reasons.push("Agent mandate is not yet valid.");
|
|
137
|
+
}
|
|
138
|
+
if (expiresMs !== null && nowMs !== null && nowMs > expiresMs) {
|
|
139
|
+
reasons.push("Agent mandate is expired.");
|
|
140
|
+
}
|
|
141
|
+
return { reasons };
|
|
142
|
+
}
|
|
143
|
+
function isTrustedSigner(signature, options) {
|
|
144
|
+
if (options.expectedSignerPublicKeyPem &&
|
|
145
|
+
normalizePem(signature.publicKeyPem) === normalizePem(options.expectedSignerPublicKeyPem)) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
if (options.expectedSignerKeyId) {
|
|
149
|
+
return signature.keyId === options.expectedSignerKeyId;
|
|
150
|
+
}
|
|
151
|
+
if (options.trustedSignerPublicKeys?.some((key) => normalizePem(key) === normalizePem(signature.publicKeyPem))) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
if (options.trustedSignerKeyIds?.includes(signature.keyId)) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
function normalizePem(value) {
|
|
160
|
+
return value.replace(/\r\n/g, "\n").trim();
|
|
161
|
+
}
|
|
162
|
+
function parseTimestamp(value) {
|
|
163
|
+
if (!value) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const parsed = Date.parse(value);
|
|
167
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
168
|
+
}
|
|
169
|
+
function readString(value) {
|
|
170
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
171
|
+
}
|
|
172
|
+
function readPositiveNumber(value) {
|
|
173
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : null;
|
|
174
|
+
}
|
|
175
|
+
function readPositiveInteger(value) {
|
|
176
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : null;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=mandates.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type AgentEd25519Signature, type AgentSigningOptions } from "./signing.js";
|
|
2
|
+
export interface AgentReceiptPayload {
|
|
3
|
+
receiptId: string;
|
|
4
|
+
runId: string;
|
|
5
|
+
quoteId: string;
|
|
6
|
+
mandateId: string;
|
|
7
|
+
status: "completed" | "failed" | "denied" | "expired";
|
|
8
|
+
ledgerHash: string;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
actualUsd?: number;
|
|
11
|
+
attempts?: number;
|
|
12
|
+
}
|
|
13
|
+
export type AgentReceiptSignature = AgentEd25519Signature;
|
|
14
|
+
export type SignedAgentReceipt = AgentReceiptPayload & {
|
|
15
|
+
signature: AgentReceiptSignature;
|
|
16
|
+
};
|
|
17
|
+
export interface AgentReceiptVerificationResult {
|
|
18
|
+
verified: boolean;
|
|
19
|
+
receiptId: string | null;
|
|
20
|
+
runId: string | null;
|
|
21
|
+
ledgerHash: string | null;
|
|
22
|
+
keyId?: string;
|
|
23
|
+
reasons: string[];
|
|
24
|
+
}
|
|
25
|
+
export type AgentReceiptSignOptions = AgentSigningOptions;
|
|
26
|
+
export interface AgentReceiptVerifyOptions {
|
|
27
|
+
expectedLedgerHash?: string;
|
|
28
|
+
expectedRunId?: string;
|
|
29
|
+
expectedQuoteId?: string;
|
|
30
|
+
expectedMandateId?: string;
|
|
31
|
+
expectedStatus?: AgentReceiptPayload["status"];
|
|
32
|
+
expectedSignerKeyId?: string;
|
|
33
|
+
expectedSignerPublicKeyPem?: string;
|
|
34
|
+
trustedSignerKeyIds?: string[];
|
|
35
|
+
trustedSignerPublicKeys?: string[];
|
|
36
|
+
}
|
|
37
|
+
export declare function signAgentReceipt(payload: AgentReceiptPayload, options?: AgentReceiptSignOptions): Promise<SignedAgentReceipt>;
|
|
38
|
+
export declare function verifyAgentReceipt(receipt: unknown, options?: AgentReceiptVerifyOptions): AgentReceiptVerificationResult;
|