coderifts 4.11.0 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3028,7 +3028,7 @@ var require_package = __commonJS({
3028
3028
  "package.json"(exports2, module2) {
3029
3029
  module2.exports = {
3030
3030
  name: "coderifts",
3031
- version: "4.11.0",
3031
+ version: "4.12.0",
3032
3032
  description: "Detect breaking API changes from the command line. Works locally or with the CodeRifts cloud API.",
3033
3033
  author: "CodeRifts <hello@coderifts.com>",
3034
3034
  license: "MIT",
@@ -3073,7 +3073,7 @@ var require_package = __commonJS({
3073
3073
  test: "node --test test/*.test.js"
3074
3074
  },
3075
3075
  dependencies: {
3076
- "@coderifts/agent-guard": "^9.0.0",
3076
+ "@coderifts/agent-guard": "^10.0.0",
3077
3077
  chalk: "^4.1.2",
3078
3078
  "cli-table3": "^0.6.4",
3079
3079
  commander: "^12.0.0",
@@ -66545,6 +66545,133 @@ var require_execution_time_fingerprint = __commonJS({
66545
66545
  }
66546
66546
  });
66547
66547
 
66548
+ // node_modules/@coderifts/agent-guard/dist/cjs/coverage-observed.js
66549
+ var require_coverage_observed = __commonJS({
66550
+ "node_modules/@coderifts/agent-guard/dist/cjs/coverage-observed.js"(exports2) {
66551
+ "use strict";
66552
+ Object.defineProperty(exports2, "__esModule", { value: true });
66553
+ exports2.createCoverageObserver = createCoverageObserver;
66554
+ exports2.freezeCoverageObserved = freezeCoverageObserved;
66555
+ exports2.formatCoverageObservedLine = formatCoverageObservedLine;
66556
+ function uniqueInOrder(names) {
66557
+ const seen = /* @__PURE__ */ new Set();
66558
+ const out = [];
66559
+ for (const n of names) {
66560
+ if (seen.has(n))
66561
+ continue;
66562
+ seen.add(n);
66563
+ out.push(n);
66564
+ }
66565
+ return out;
66566
+ }
66567
+ function createCoverageObserver() {
66568
+ const table = /* @__PURE__ */ new Set();
66569
+ const governed = [];
66570
+ const host = [];
66571
+ let hostReported = false;
66572
+ function snapshot() {
66573
+ const tools = uniqueInOrder(governed);
66574
+ if (!hostReported) {
66575
+ return freezeCoverageObserved({
66576
+ class: "UNKNOWN_OUTSIDE_SCOPE",
66577
+ governed_calls: governed.length,
66578
+ tools
66579
+ });
66580
+ }
66581
+ const ungovernedList = host.filter((n) => !table.has(n));
66582
+ if (ungovernedList.length > 0) {
66583
+ return freezeCoverageObserved({
66584
+ class: "INCOMPLETE_OBSERVED",
66585
+ governed_calls: governed.length,
66586
+ tools,
66587
+ total_calls: host.length,
66588
+ ungoverned_calls: ungovernedList.length,
66589
+ ungoverned_tools: uniqueInOrder(ungovernedList)
66590
+ });
66591
+ }
66592
+ return freezeCoverageObserved({
66593
+ class: "COMPLETE_OBSERVED",
66594
+ governed_calls: governed.length,
66595
+ tools,
66596
+ total_calls: host.length,
66597
+ ungoverned_calls: 0,
66598
+ ungoverned_tools: []
66599
+ });
66600
+ }
66601
+ function reportOne(ev) {
66602
+ if (!ev || typeof ev.name !== "string")
66603
+ return false;
66604
+ const name = ev.name.trim();
66605
+ if (!name)
66606
+ return false;
66607
+ host.push(name);
66608
+ return true;
66609
+ }
66610
+ const handle = {
66611
+ snapshot,
66612
+ reportToolDispatch(ev) {
66613
+ if (reportOne(ev))
66614
+ hostReported = true;
66615
+ },
66616
+ reportToolDispatchBatch(evs) {
66617
+ if (!Array.isArray(evs))
66618
+ return;
66619
+ hostReported = true;
66620
+ for (const ev of evs)
66621
+ reportOne(ev);
66622
+ }
66623
+ };
66624
+ return {
66625
+ setTableNames(names) {
66626
+ table.clear();
66627
+ if (!Array.isArray(names) && !names)
66628
+ return;
66629
+ for (const n of names) {
66630
+ if (typeof n === "string" && n)
66631
+ table.add(n);
66632
+ }
66633
+ },
66634
+ recordGoverned(name) {
66635
+ if (typeof name === "string" && name)
66636
+ governed.push(name);
66637
+ },
66638
+ snapshot,
66639
+ handle
66640
+ };
66641
+ }
66642
+ function freezeCoverageObserved(obs) {
66643
+ const tools = Object.freeze(obs.tools.slice());
66644
+ if (obs.class === "UNKNOWN_OUTSIDE_SCOPE") {
66645
+ return Object.freeze({
66646
+ class: "UNKNOWN_OUTSIDE_SCOPE",
66647
+ governed_calls: obs.governed_calls,
66648
+ tools
66649
+ });
66650
+ }
66651
+ return Object.freeze({
66652
+ class: obs.class,
66653
+ governed_calls: obs.governed_calls,
66654
+ tools,
66655
+ total_calls: obs.total_calls,
66656
+ ungoverned_calls: obs.ungoverned_calls,
66657
+ ungoverned_tools: Object.freeze((obs.ungoverned_tools || []).slice())
66658
+ });
66659
+ }
66660
+ function formatCoverageObservedLine(obs) {
66661
+ const n = obs.governed_calls;
66662
+ const callWord = n === 1 ? "call" : "calls";
66663
+ if (obs.class === "UNKNOWN_OUTSIDE_SCOPE") {
66664
+ return `governed ${n} ${callWord}; traffic outside the guarded table not observable from here`;
66665
+ }
66666
+ if (obs.class === "INCOMPLETE_OBSERVED") {
66667
+ const names = obs.ungoverned_tools.join(", ");
66668
+ return `governed ${n}/${obs.total_calls} dispatched calls; ${obs.ungoverned_calls} outside the guarded table: ${names}`;
66669
+ }
66670
+ return `governed ${n}/${obs.total_calls} dispatched calls; 0 outside the guarded table`;
66671
+ }
66672
+ }
66673
+ });
66674
+
66548
66675
  // node_modules/@coderifts/agent-guard/dist/cjs/execution-proof.js
66549
66676
  var require_execution_proof = __commonJS({
66550
66677
  "node_modules/@coderifts/agent-guard/dist/cjs/execution-proof.js"(exports2) {
@@ -66555,6 +66682,7 @@ var require_execution_proof = __commonJS({
66555
66682
  exports2.hashExecutionResult = hashExecutionResult;
66556
66683
  exports2.buildExecutionProof = buildExecutionProof;
66557
66684
  var node_crypto_1 = require("node:crypto");
66685
+ var coverage_observed_js_1 = require_coverage_observed();
66558
66686
  exports2.EXECUTION_PROOF_SPEC = "guard-execution-proof.v1";
66559
66687
  var LIMITS = Object.freeze({
66560
66688
  does_not_claim_change_safe: true,
@@ -66681,9 +66809,21 @@ var require_execution_proof = __commonJS({
66681
66809
  if (input.casEvidence && typeof input.casEvidence === "object") {
66682
66810
  proof.cas_evidence = Object.freeze({ ...input.casEvidence });
66683
66811
  }
66812
+ if (input.commitLabel === "authorized_and_committed" || input.commitLabel === "authorized_not_committed") {
66813
+ proof.commit_label = input.commitLabel;
66814
+ if (input.commitLabel === "authorized_not_committed" && input.commitEvidenceReason === "commit_evidence_missing") {
66815
+ proof.commit_evidence_reason = "commit_evidence_missing";
66816
+ }
66817
+ }
66818
+ if (typeof input.monitoringAttestation === "string" && input.monitoringAttestation.length > 0) {
66819
+ proof.monitoring_attestation = input.monitoringAttestation;
66820
+ }
66684
66821
  if (Array.isArray(input.recheckTrail) && input.recheckTrail.length > 0) {
66685
66822
  proof.recheck_trail = Object.freeze(input.recheckTrail.map((e) => Object.freeze({ ...e })));
66686
66823
  }
66824
+ if (input.coverageObserved && typeof input.coverageObserved === "object") {
66825
+ proof.coverage_observed = (0, coverage_observed_js_1.freezeCoverageObserved)(input.coverageObserved);
66826
+ }
66687
66827
  return freezeProof(proof);
66688
66828
  }
66689
66829
  function freezeMonitoringDelivery(d) {
@@ -67780,6 +67920,64 @@ var require_errors5 = __commonJS({
67780
67920
  }
67781
67921
  });
67782
67922
 
67923
+ // node_modules/@coderifts/sdk/dist/cjs/decision.js
67924
+ var require_decision = __commonJS({
67925
+ "node_modules/@coderifts/sdk/dist/cjs/decision.js"(exports2) {
67926
+ "use strict";
67927
+ Object.defineProperty(exports2, "__esModule", { value: true });
67928
+ exports2.hasExplicitExecutionAction = hasExplicitExecutionAction;
67929
+ exports2.readDecision = readDecision;
67930
+ var EXECUTION_ACTION = {
67931
+ ALLOW: "CONTINUE",
67932
+ WARN: "CONTINUE_WITH_MONITORING",
67933
+ REQUIRE_APPROVAL: "REQUEST_APPROVAL",
67934
+ BLOCK: "STOP"
67935
+ };
67936
+ function isExecutionAction(v) {
67937
+ return v === "CONTINUE" || v === "CONTINUE_WITH_MONITORING" || v === "REQUEST_APPROVAL" || v === "STOP";
67938
+ }
67939
+ function hasExplicitExecutionAction(response) {
67940
+ if (!response || typeof response !== "object")
67941
+ return false;
67942
+ const r = response;
67943
+ const env = r.decision_result;
67944
+ if (env && typeof env === "object" && isExecutionAction(env.execution_action))
67945
+ return true;
67946
+ return isExecutionAction(r.execution_action);
67947
+ }
67948
+ function readDecision(response) {
67949
+ if (!response || typeof response !== "object") {
67950
+ return { executionAction: "STOP", decision: null, reason: "UNREADABLE_DECISION" };
67951
+ }
67952
+ const r = response;
67953
+ const env = r.decision_result;
67954
+ if (env && typeof env === "object" && isExecutionAction(env.execution_action)) {
67955
+ const receipt = env.receipt;
67956
+ return {
67957
+ executionAction: env.execution_action,
67958
+ decision: typeof env.decision === "string" ? env.decision : null,
67959
+ envelope: env,
67960
+ receipt: receipt && typeof receipt === "object" ? receipt : void 0
67961
+ };
67962
+ }
67963
+ if (isExecutionAction(r.execution_action)) {
67964
+ return {
67965
+ executionAction: r.execution_action,
67966
+ decision: typeof r.decision === "string" ? r.decision : null
67967
+ };
67968
+ }
67969
+ if (typeof r.decision === "string" && Object.prototype.hasOwnProperty.call(EXECUTION_ACTION, r.decision)) {
67970
+ return { executionAction: EXECUTION_ACTION[r.decision], decision: r.decision };
67971
+ }
67972
+ return {
67973
+ executionAction: "STOP",
67974
+ decision: typeof r.decision === "string" ? r.decision : null,
67975
+ reason: "UNREADABLE_DECISION"
67976
+ };
67977
+ }
67978
+ }
67979
+ });
67980
+
67783
67981
  // node_modules/@coderifts/sdk/dist/cjs/client.js
67784
67982
  var require_client = __commonJS({
67785
67983
  "node_modules/@coderifts/sdk/dist/cjs/client.js"(exports2) {
@@ -67787,6 +67985,7 @@ var require_client = __commonJS({
67787
67985
  Object.defineProperty(exports2, "__esModule", { value: true });
67788
67986
  exports2.CodeRifts = void 0;
67789
67987
  var errors_js_1 = require_errors5();
67988
+ var decision_js_1 = require_decision();
67790
67989
  var DEFAULT_BASE_URL = "https://app.coderifts.com";
67791
67990
  var DEFAULT_TIMEOUT = 3e4;
67792
67991
  var CodeRifts = class {
@@ -67853,11 +68052,15 @@ var require_client = __commonJS({
67853
68052
  old_spec: req.old_spec,
67854
68053
  new_spec: req.new_spec
67855
68054
  });
67856
- const decision = raw.decision || "ALLOW";
68055
+ const read = (0, decision_js_1.readDecision)(raw);
68056
+ const safe = read.executionAction === "CONTINUE" && (0, decision_js_1.hasExplicitExecutionAction)(raw);
67857
68057
  return {
67858
- decision,
68058
+ decision: raw.decision,
68059
+ // Pass through — do not invent. Live POST /api/v1/agent/preflight emits this
68060
+ // top-level; hiding it taught the wrong shape.
68061
+ execution_action: raw.execution_action,
67859
68062
  omega_api: raw.omega_api ?? 0,
67860
- safe: decision === "ALLOW" || decision === "WARN",
68063
+ safe,
67861
68064
  reflex_triggers: raw.reflex_triggers || [],
67862
68065
  affected_tools: raw.affected_tools || [],
67863
68066
  confidence_score: raw.confidence_score,
@@ -67877,9 +68080,13 @@ var require_client = __commonJS({
67877
68080
  }
67878
68081
  // ─── 3. explainDecision ────────────────────────────────────────────────
67879
68082
  /**
67880
- * Returns a human-readable explanation of why a decision was made.
68083
+ * Human-readable explanation of a decision. **Advisory prose, not a gate.**
67881
68084
  *
67882
- * Computed client-side from the omega components and reflex triggers.
68085
+ * Computed client-side no HTTP. For control flow call `readDecision` on the
68086
+ * response yourself. This method renders a summary from `execution_action`
68087
+ * (via `readDecision`); `decision` is the governance label in the prose and
68088
+ * never selects a branch. Unknown / absent action → "treat as STOP". Never
68089
+ * reports a change as "safe to proceed".
67883
68090
  */
67884
68091
  async explainDecision(req) {
67885
68092
  const components = [];
@@ -67895,36 +68102,47 @@ var require_client = __commonJS({
67895
68102
  }
67896
68103
  }
67897
68104
  const triggers = req.reflex_triggers || [];
68105
+ const read = (0, decision_js_1.readDecision)(advisoryReadInput(req));
67898
68106
  let summary = `Decision: ${req.decision} (\u03A9_API = ${req.omega_api}).`;
67899
68107
  if (triggers.length > 0) {
67900
68108
  summary += ` ${triggers.length} reflex rule(s) triggered.`;
67901
68109
  }
67902
- if (req.decision === "BLOCK") {
67903
- summary += " This change is blocked due to high risk.";
67904
- } else if (req.decision === "REQUIRE_APPROVAL") {
67905
- summary += " This change requires manual approval before merging.";
67906
- } else if (req.decision === "WARN") {
67907
- summary += " This change has warnings but can proceed.";
68110
+ if (read.reason) {
68111
+ summary += ` ${UNREADABLE_SUMMARY}`;
67908
68112
  } else {
67909
- summary += " This change is safe to proceed.";
68113
+ summary += ` ${ACTION_SUMMARY[read.executionAction]}`;
67910
68114
  }
67911
- return { summary, components };
68115
+ return {
68116
+ summary,
68117
+ components,
68118
+ execution_action: read.executionAction,
68119
+ reason: read.reason
68120
+ };
67912
68121
  }
67913
68122
  // ─── 4. howToUnblock ───────────────────────────────────────────────────
67914
68123
  /**
67915
- * Returns actionable steps to resolve a BLOCK decision.
68124
+ * Actionable steps to resolve a halted change. **Advisory prose, not a gate.**
67916
68125
  *
67917
- * Computed client-side from breaking changes and detected patterns.
68126
+ * Computed client-side no HTTP. For control flow call `readDecision`.
68127
+ * "No unblock needed" is emitted **only** for a readable CONTINUE /
68128
+ * CONTINUE_WITH_MONITORING. An unrecognised or absent action is treated as
68129
+ * STOP and still yields steps — never "no unblock needed".
67918
68130
  */
67919
68131
  async howToUnblock(req) {
68132
+ const read = (0, decision_js_1.readDecision)(advisoryReadInput(req));
67920
68133
  const actions = [];
67921
68134
  let step = 1;
67922
- if (req.decision !== "BLOCK") {
68135
+ if (!read.reason && NO_UNBLOCK_ACTIONS.has(read.executionAction)) {
67923
68136
  actions.push({
67924
68137
  step: step++,
67925
- description: `Current decision is "${req.decision}" \u2014 no unblock needed.`
68138
+ description: `Execution action is "${read.executionAction}" (decision: "${req.decision}") \u2014 no unblock needed.`
67926
68139
  });
67927
- return { actions };
68140
+ return { actions, execution_action: read.executionAction, reason: read.reason };
68141
+ }
68142
+ if (read.reason) {
68143
+ actions.push({ step: step++, description: UNREADABLE_UNBLOCK });
68144
+ } else if (read.executionAction === "REQUEST_APPROVAL") {
68145
+ actions.push({ step: step++, description: ACTION_SUMMARY.REQUEST_APPROVAL });
67928
68146
  }
67929
68147
  const bcs = req.breaking_changes || [];
67930
68148
  if (bcs.length > 0) {
@@ -67945,7 +68163,7 @@ var require_client = __commonJS({
67945
68163
  step: step++,
67946
68164
  description: "Request a manual override via POST /api/v1/ledger/:id/override if this is an emergency."
67947
68165
  });
67948
- return { actions };
68166
+ return { actions, execution_action: read.executionAction, reason: read.reason };
67949
68167
  }
67950
68168
  // ─── 5. scoreMcp ──────────────────────────────────────────────────────
67951
68169
  /**
@@ -68067,6 +68285,25 @@ var require_client = __commonJS({
68067
68285
  }
68068
68286
  };
68069
68287
  exports2.CodeRifts = CodeRifts;
68288
+ var ACTION_SUMMARY = {
68289
+ CONTINUE: "Execution action: CONTINUE \u2014 this change may proceed.",
68290
+ CONTINUE_WITH_MONITORING: "Execution action: CONTINUE_WITH_MONITORING \u2014 this change may proceed only with monitoring wired.",
68291
+ REQUEST_APPROVAL: "Execution action: REQUEST_APPROVAL \u2014 manual approval is required before this change may proceed.",
68292
+ STOP: "Execution action: STOP \u2014 this change must not proceed."
68293
+ };
68294
+ var UNREADABLE_SUMMARY = "Execution action is unrecognised or absent (UNREADABLE_DECISION) \u2014 treat as STOP; this change must not proceed.";
68295
+ var UNREADABLE_UNBLOCK = "Execution action is unrecognised or absent (UNREADABLE_DECISION) \u2014 treat as STOP. Re-read a response that carries execution_action, and resolve the findings below before proceeding.";
68296
+ var NO_UNBLOCK_ACTIONS = /* @__PURE__ */ new Set(["CONTINUE", "CONTINUE_WITH_MONITORING"]);
68297
+ function advisoryReadInput(req) {
68298
+ if (req.response !== void 0) {
68299
+ if (!req.response || typeof req.response !== "object" || Array.isArray(req.response)) {
68300
+ return req.response;
68301
+ }
68302
+ const { decision: _omit, ...rest } = req.response;
68303
+ return rest;
68304
+ }
68305
+ return { execution_action: req.execution_action };
68306
+ }
68070
68307
  function describeComponent(name, value) {
68071
68308
  const descriptions = {
68072
68309
  S_contract: "Contract severity score \u2014 measures how severe the breaking changes are",
@@ -68084,50 +68321,94 @@ var require_client = __commonJS({
68084
68321
  }
68085
68322
  });
68086
68323
 
68087
- // node_modules/@coderifts/sdk/dist/cjs/decision.js
68088
- var require_decision = __commonJS({
68089
- "node_modules/@coderifts/sdk/dist/cjs/decision.js"(exports2) {
68324
+ // node_modules/@coderifts/sdk/dist/cjs/policy.js
68325
+ var require_policy = __commonJS({
68326
+ "node_modules/@coderifts/sdk/dist/cjs/policy.js"(exports2) {
68090
68327
  "use strict";
68091
68328
  Object.defineProperty(exports2, "__esModule", { value: true });
68092
- exports2.readDecision = readDecision;
68093
- var EXECUTION_ACTION = {
68094
- ALLOW: "CONTINUE",
68095
- WARN: "CONTINUE_WITH_MONITORING",
68096
- REQUIRE_APPROVAL: "REQUEST_APPROVAL",
68097
- BLOCK: "STOP"
68098
- };
68099
- function isExecutionAction(v) {
68100
- return v === "CONTINUE" || v === "CONTINUE_WITH_MONITORING" || v === "REQUEST_APPROVAL" || v === "STOP";
68329
+ exports2.POLICY_ABSENT_WARN = exports2.CODERIFTS_POLICY = exports2.POLICY_MARKER = void 0;
68330
+ exports2.policyPresenceOf = policyPresenceOf;
68331
+ exports2.detectPolicyPresence = detectPolicyPresence;
68332
+ exports2.withPolicy = withPolicy;
68333
+ exports2.warnPolicyAbsentOnce = warnPolicyAbsentOnce;
68334
+ exports2.observePolicyPresence = observePolicyPresence;
68335
+ exports2.resetPolicyWarnForTests = resetPolicyWarnForTests;
68336
+ exports2.POLICY_MARKER = "A receipt authorizes ONE operation: a merge receipt does not authorize a deploy.";
68337
+ exports2.CODERIFTS_POLICY = 'Call `preflight_change_set` before merge, deploy, publish, or tool registration when a contract artifact changed (OpenAPI/Swagger, GraphQL, gRPC/protobuf, AsyncAPI, MCP manifest, or agent tool schemas).\n\nSend the complete base-to-head change set: every changed contract artifact with full before and after content. Do not send a single-file subset when other contract files also change.\n\nBranch on `execution_action` only. Do not branch on `decision` and do not branch on `safe_for_agent` (not_for_control_flow_use_execution_action). Canonical `execution_action` values: CONTINUE, CONTINUE_WITH_MONITORING, REQUEST_APPROVAL, STOP.\n\nAn unrecognised `execution_action` is not permission: fail closed (halt or re-preflight). Well-known code: `not_permission_fail_closed`.\n\nWhen `execution_action` is REQUEST_APPROVAL or STOP, surface the detected patterns and the blast radius, and propose the safer path \u2014 deprecate-then-remove, an additive change, or a new version \u2014 rather than shipping the break.\n\n`CONTINUE_WITH_MONITORING` requires a wired monitoring sink (`monitoringSinkWired`). It is not "proceed with caution" without monitoring.\n\nDo not call CodeRifts tools for a documentation-only change (README, guides, comments) with no contract artifact content change.\n\nIf you already hold a chain receipt and only need authenticity/lifecycle: `verify_receipt`. If you need a past decision by id: `get_decision_details`. Neither replaces preflight for a new change set.\n\nThe CodeRifts MCP server exposes exactly three tools \u2014 `preflight_change_set`, `verify_receipt`, `get_decision_details`. Do not invent or assume others.\n\nA receipt authorizes ONE operation: a merge receipt does not authorize a deploy. Before a different operation (deploy, publish), call `preflight_change_set` with `context.operation` set to that operation \u2014 reusing a differently-scoped receipt is not permitted and will fail at the gate.\n\nA stale or superseded receipt on a changed head requires a NEW preflight \u2014 `verify_receipt` cannot re-diff.\n\nFor mutating tools, put only the guarded version in the agent\'s tool table; keep the raw handler host-only and unreachable from that table. How you name tools is yours \u2014 this is a reachability property, not a product rename of host tools. CodeRifts cannot see or stop a raw call the host makes outside the table it returns; adopt this as a host convention, not as a guarantee from the package.\n\nCodeRifts reports a governance decision and `execution_action`; it does not by itself block merges. Blocking requires separate repository configuration (required status checks, enforcement) that this rule file does not set.\n\nTo act (mutate a contract, merge, deploy, or publish): call `preflight_change_set` with `preflight_mode` authorize. Analyze is informational (`may_execute` is always false) and is not permission. Read `execution_action` on the `decision_result` envelope.\n\nBefore acting under a held receipt: call `verify_receipt` with the intended `context` (operation, environment, repository, branch, pull_request) for THIS attempt. Do not act on a receipt whose scope does not match.\n\nAct only when `currently_authorized` is true (`control_envelope.receipt_view.currently_authorized`). A valid-looking token is not permission if `currently_authorized` is false or omitted.\n\nCommit / CAS evidence is a separate measurement (`commit_observation` on GuardOutcome). It is not a substitute for authorize + `currently_authorized`. Production hosts that want the fail-closed conjunction lock it with `profile: ENFORCING_STRICT` on withCodeRifts.\n\nIf the host requests an execution grant (opt-in `include_execution_grant`), the grant is bound to operation + target + after-payload (`scope_hash`) and is short-lived \u2014 never reuse it after the after-payload changes.\n\nAn ATOMIC-profile grant carries `state_nonce` and is single-use at the executor \u2014 if the executor has consumed the nonce, re-preflight; do not retry the same grant.\n\nWith a proven tenant\u2194repo binding you may request `derivation:"server"` instead of assembling `artifacts[]` yourself (`context.repository` + `context.base` + `context.head` required; caller-supplied artifacts are rejected on that path).\n\nA commit is only proven when an executor attestation verifies (customer-held executor key, `cas_evidence: executor_attested`); otherwise say "authorized, commit not proven".';
68338
+ exports2.POLICY_ABSENT_WARN = "CodeRifts policy text not detected in the system prompt. The agent will still see the tools, but measured evidence shows operation-scope misuse is markedly more likely without it. See https://github.com/coderifts/agent-guard#policy-delivery.";
68339
+ function textHasMarker(text) {
68340
+ return text.includes(exports2.POLICY_MARKER);
68101
68341
  }
68102
- function readDecision(response) {
68103
- if (!response || typeof response !== "object") {
68104
- return { executionAction: "STOP", decision: null, reason: "UNREADABLE_DECISION" };
68105
- }
68106
- const r = response;
68107
- const env = r.decision_result;
68108
- if (env && typeof env === "object" && isExecutionAction(env.execution_action)) {
68109
- const receipt = env.receipt;
68110
- return {
68111
- executionAction: env.execution_action,
68112
- decision: typeof env.decision === "string" ? env.decision : null,
68113
- envelope: env,
68114
- receipt: receipt && typeof receipt === "object" ? receipt : void 0
68115
- };
68342
+ function contentHasMarker(content) {
68343
+ if (typeof content === "string")
68344
+ return textHasMarker(content);
68345
+ if (Array.isArray(content))
68346
+ return content.some(contentHasMarker);
68347
+ if (content && typeof content === "object") {
68348
+ const o = content;
68349
+ if (typeof o.text === "string" && textHasMarker(o.text))
68350
+ return true;
68351
+ if (typeof o.content === "string" && textHasMarker(o.content))
68352
+ return true;
68116
68353
  }
68117
- if (isExecutionAction(r.execution_action)) {
68118
- return {
68119
- executionAction: r.execution_action,
68120
- decision: typeof r.decision === "string" ? r.decision : null
68121
- };
68354
+ return false;
68355
+ }
68356
+ function policyPresenceOf(text) {
68357
+ if (text == null)
68358
+ return "unknown";
68359
+ return textHasMarker(String(text)) ? "detected" : "absent";
68360
+ }
68361
+ function detectPolicyPresence(text) {
68362
+ return policyPresenceOf(text);
68363
+ }
68364
+ function appendPolicyToString(existing) {
68365
+ if (textHasMarker(existing))
68366
+ return existing;
68367
+ if (existing.trim() === "")
68368
+ return exports2.CODERIFTS_POLICY;
68369
+ return existing + "\n\n" + exports2.CODERIFTS_POLICY;
68370
+ }
68371
+ function withPolicy(input, opts) {
68372
+ const inject = opts?.injectPolicy !== false;
68373
+ if (typeof input === "string") {
68374
+ if (!inject)
68375
+ return input;
68376
+ return appendPolicyToString(input);
68122
68377
  }
68123
- if (typeof r.decision === "string" && Object.prototype.hasOwnProperty.call(EXECUTION_ACTION, r.decision)) {
68124
- return { executionAction: EXECUTION_ACTION[r.decision], decision: r.decision };
68378
+ const copy = input.map((m) => ({ ...m }));
68379
+ if (!inject)
68380
+ return copy;
68381
+ if (copy.some((m) => contentHasMarker(m.content)))
68382
+ return copy;
68383
+ const sysIdx = copy.findIndex((m) => String(m.role).toLowerCase() === "system");
68384
+ if (sysIdx >= 0) {
68385
+ const sys = copy[sysIdx];
68386
+ if (typeof sys.content === "string") {
68387
+ copy[sysIdx] = { ...sys, content: appendPolicyToString(sys.content) };
68388
+ return copy;
68389
+ }
68390
+ return [{ role: "system", content: exports2.CODERIFTS_POLICY }, ...copy];
68125
68391
  }
68126
- return {
68127
- executionAction: "STOP",
68128
- decision: typeof r.decision === "string" ? r.decision : null,
68129
- reason: "UNREADABLE_DECISION"
68130
- };
68392
+ return [{ role: "system", content: exports2.CODERIFTS_POLICY }, ...copy];
68393
+ }
68394
+ var warnedThisProcess = false;
68395
+ function defaultWarn(msg) {
68396
+ console.warn(msg);
68397
+ }
68398
+ function warnPolicyAbsentOnce() {
68399
+ if (warnedThisProcess)
68400
+ return;
68401
+ warnedThisProcess = true;
68402
+ defaultWarn(exports2.POLICY_ABSENT_WARN);
68403
+ }
68404
+ function observePolicyPresence(text) {
68405
+ const presence = policyPresenceOf(text);
68406
+ if (presence === "absent")
68407
+ warnPolicyAbsentOnce();
68408
+ return presence;
68409
+ }
68410
+ function resetPolicyWarnForTests() {
68411
+ warnedThisProcess = false;
68131
68412
  }
68132
68413
  }
68133
68414
  });
@@ -68589,16 +68870,268 @@ var require_execution_attestation = __commonJS({
68589
68870
  }
68590
68871
  });
68591
68872
 
68873
+ // node_modules/@coderifts/sdk/dist/cjs/monitoring-attestation.js
68874
+ var require_monitoring_attestation = __commonJS({
68875
+ "node_modules/@coderifts/sdk/dist/cjs/monitoring-attestation.js"(exports2) {
68876
+ "use strict";
68877
+ Object.defineProperty(exports2, "__esModule", { value: true });
68878
+ exports2.CLOCK_SKEW_LEEWAY_MS = exports2.MONITOR_ATTEST_ENVELOPE_TAG = exports2.MONITOR_ATTEST_SIGNING_PREFIX = exports2.MONITOR_ATTEST_VERSION = void 0;
68879
+ exports2.monitorAttestSigningInput = monitorAttestSigningInput;
68880
+ exports2.verifyMonitoringAttestation = verifyMonitoringAttestation;
68881
+ var crypto_1 = require("crypto");
68882
+ var leeway_js_1 = require_leeway();
68883
+ Object.defineProperty(exports2, "CLOCK_SKEW_LEEWAY_MS", { enumerable: true, get: function() {
68884
+ return leeway_js_1.CLOCK_SKEW_LEEWAY_MS;
68885
+ } });
68886
+ exports2.MONITOR_ATTEST_VERSION = "cr.monitor.attest.v1";
68887
+ exports2.MONITOR_ATTEST_SIGNING_PREFIX = "crmonattest.v1";
68888
+ exports2.MONITOR_ATTEST_ENVELOPE_TAG = "cr.monitor.attest.v1";
68889
+ var REQUIRED_FIELDS = [
68890
+ "kid",
68891
+ "decision_id",
68892
+ "receipt_digest",
68893
+ "delivery_status",
68894
+ "sink_kind",
68895
+ "observed_at"
68896
+ ];
68897
+ var DELIVERY_STATUSES = ["delivered_acked", "sent_unacked", "not_delivered"];
68898
+ var SINK_KINDS = ["callback", "http"];
68899
+ var OPTIONAL_STRINGS = ["ack_digest"];
68900
+ var ALLOWED_KEYS = /* @__PURE__ */ new Set(["v", ...REQUIRED_FIELDS, ...OPTIONAL_STRINGS, "attempt_count", "meta"]);
68901
+ function scalar(v) {
68902
+ return v == null ? "" : String(v);
68903
+ }
68904
+ function canonicalMeta(meta) {
68905
+ const keys = Object.keys(meta).sort();
68906
+ const o = {};
68907
+ for (const k of keys)
68908
+ o[k] = meta[k];
68909
+ return JSON.stringify(o);
68910
+ }
68911
+ function metaOk(meta) {
68912
+ if (meta == null)
68913
+ return true;
68914
+ if (typeof meta !== "object" || Array.isArray(meta))
68915
+ return false;
68916
+ const obj = meta;
68917
+ const keys = Object.keys(obj);
68918
+ if (keys.length > 8)
68919
+ return false;
68920
+ for (const k of keys) {
68921
+ if (k.length === 0 || k.length > 64 || k.includes("|"))
68922
+ return false;
68923
+ const v = obj[k];
68924
+ const t = typeof v;
68925
+ if (t !== "string" && t !== "number" && t !== "boolean")
68926
+ return false;
68927
+ if (t === "string" && (v.length > 256 || v.includes("|")))
68928
+ return false;
68929
+ }
68930
+ return true;
68931
+ }
68932
+ function monitorAttestSigningInput(body) {
68933
+ const parts = [
68934
+ exports2.MONITOR_ATTEST_SIGNING_PREFIX,
68935
+ scalar(body.kid),
68936
+ scalar(body.decision_id),
68937
+ scalar(body.receipt_digest),
68938
+ scalar(body.delivery_status),
68939
+ body.ack_digest != null && String(body.ack_digest).length > 0 ? String(body.ack_digest) : "",
68940
+ scalar(body.sink_kind),
68941
+ scalar(body.observed_at),
68942
+ body.attempt_count != null ? String(body.attempt_count) : ""
68943
+ ];
68944
+ if (body.meta && typeof body.meta === "object") {
68945
+ parts.push(canonicalMeta(body.meta));
68946
+ }
68947
+ return parts.join("|");
68948
+ }
68949
+ function isIssueTimeWithinKeyWindow(ts, keyMeta) {
68950
+ if (!keyMeta || keyMeta.status === "active")
68951
+ return true;
68952
+ if (keyMeta.status !== "retired")
68953
+ return false;
68954
+ if (typeof keyMeta.retired_at !== "string" || keyMeta.retired_at.length === 0)
68955
+ return false;
68956
+ if (typeof ts !== "string" || ts.length === 0)
68957
+ return false;
68958
+ const issueMs = Date.parse(ts);
68959
+ if (!Number.isFinite(issueMs))
68960
+ return false;
68961
+ if (keyMeta.valid_from) {
68962
+ const fromMs = Date.parse(keyMeta.valid_from);
68963
+ if (Number.isFinite(fromMs) && issueMs < fromMs)
68964
+ return false;
68965
+ }
68966
+ const retiredMs = Date.parse(keyMeta.retired_at);
68967
+ if (!Number.isFinite(retiredMs))
68968
+ return false;
68969
+ if (issueMs >= retiredMs)
68970
+ return false;
68971
+ return true;
68972
+ }
68973
+ function resolveMonitoringKey(registry, kid) {
68974
+ if (!registry || !Array.isArray(registry.keys) || !kid)
68975
+ return null;
68976
+ const matches = registry.keys.filter((k) => k && k.kid === kid && typeof k.public_key_pem === "string");
68977
+ if (matches.length === 0)
68978
+ return null;
68979
+ const entry = matches.find((k) => k.status === "active") || matches[0];
68980
+ try {
68981
+ return {
68982
+ publicKey: (0, crypto_1.createPublicKey)(entry.public_key_pem),
68983
+ status: entry.status === "retired" ? "retired" : "active",
68984
+ valid_from: entry.valid_from || null,
68985
+ retired_at: entry.retired_at || null
68986
+ };
68987
+ } catch {
68988
+ return null;
68989
+ }
68990
+ }
68991
+ function verifyMonitoringAttestation(token, opts) {
68992
+ const fail = (status, reason, payload2) => ({ valid: false, status, reason, payload: payload2 });
68993
+ if (typeof token !== "string" || token.length === 0) {
68994
+ return fail("MON_ATTEST_MALFORMED", "malformed_structure");
68995
+ }
68996
+ const segments = token.split("|");
68997
+ if (segments.length !== 4 || segments.some((s) => !s)) {
68998
+ return fail("MON_ATTEST_MALFORMED", "malformed_structure");
68999
+ }
69000
+ if (segments[0] !== exports2.MONITOR_ATTEST_ENVELOPE_TAG) {
69001
+ return fail("MON_ATTEST_MALFORMED", "unsupported_version");
69002
+ }
69003
+ let payload;
69004
+ try {
69005
+ payload = JSON.parse(Buffer.from(segments[2], "base64url").toString("utf8"));
69006
+ } catch {
69007
+ return fail("MON_ATTEST_MALFORMED", "bad_json");
69008
+ }
69009
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
69010
+ return fail("MON_ATTEST_MALFORMED", "bad_json");
69011
+ }
69012
+ if (payload.v !== exports2.MONITOR_ATTEST_VERSION) {
69013
+ return fail("MON_ATTEST_MALFORMED", "unsupported_version", payload);
69014
+ }
69015
+ for (const k of REQUIRED_FIELDS) {
69016
+ if (typeof payload[k] !== "string" || !payload[k].length) {
69017
+ return fail("MON_ATTEST_MALFORMED", "missing_field", payload);
69018
+ }
69019
+ }
69020
+ if (!DELIVERY_STATUSES.includes(payload.delivery_status)) {
69021
+ return fail("MON_ATTEST_MALFORMED", "bad_delivery_status", payload);
69022
+ }
69023
+ if (!SINK_KINDS.includes(payload.sink_kind)) {
69024
+ return fail("MON_ATTEST_MALFORMED", "bad_sink_kind", payload);
69025
+ }
69026
+ for (const k of OPTIONAL_STRINGS) {
69027
+ if (payload[k] != null && typeof payload[k] !== "string") {
69028
+ return fail("MON_ATTEST_MALFORMED", "bad_optional", payload);
69029
+ }
69030
+ }
69031
+ if (payload.attempt_count != null && typeof payload.attempt_count !== "number") {
69032
+ return fail("MON_ATTEST_MALFORMED", "bad_attempt_count", payload);
69033
+ }
69034
+ if (payload.kid !== segments[1]) {
69035
+ return fail("MON_ATTEST_MALFORMED", "kid_mismatch", payload);
69036
+ }
69037
+ for (const k of Object.keys(payload)) {
69038
+ if (!ALLOWED_KEYS.has(k))
69039
+ return fail("MON_ATTEST_MALFORMED", "unknown_field", payload);
69040
+ }
69041
+ if (!metaOk(payload.meta))
69042
+ return fail("MON_ATTEST_MALFORMED", "meta_bounds", payload);
69043
+ if (typeof payload.ack_digest === "string" && payload.ack_digest.length > 0 && !payload.ack_digest.startsWith("sha256:")) {
69044
+ return fail("MON_ATTEST_MALFORMED", "bad_ack_digest", payload);
69045
+ }
69046
+ if (typeof payload.receipt_digest === "string" && !payload.receipt_digest.startsWith("sha256:")) {
69047
+ return fail("MON_ATTEST_MALFORMED", "bad_receipt_digest", payload);
69048
+ }
69049
+ for (const k of [...REQUIRED_FIELDS, ...OPTIONAL_STRINGS]) {
69050
+ if (typeof payload[k] === "string" && payload[k].includes("|")) {
69051
+ return fail("MON_ATTEST_INVALID_SIGNATURE", "delimiter_in_field", payload);
69052
+ }
69053
+ }
69054
+ const resolved = resolveMonitoringKey(opts.registry, String(payload.kid));
69055
+ if (!resolved)
69056
+ return fail("MON_ATTEST_UNKNOWN_KEY", "unknown_kid", payload);
69057
+ let sigOk = false;
69058
+ try {
69059
+ sigOk = (0, crypto_1.verify)(null, Buffer.from(monitorAttestSigningInput(payload), "utf8"), resolved.publicKey, Buffer.from(segments[3], "base64url"));
69060
+ } catch {
69061
+ return fail("MON_ATTEST_INVALID_SIGNATURE", "signature_error", payload);
69062
+ }
69063
+ if (!sigOk)
69064
+ return fail("MON_ATTEST_INVALID_SIGNATURE", "signature_mismatch", payload);
69065
+ const now = Number.isFinite(opts.now) ? opts.now : Date.now();
69066
+ const observedMs = Date.parse(String(payload.observed_at));
69067
+ if (!Number.isFinite(observedMs))
69068
+ return fail("MON_ATTEST_MALFORMED", "bad_timestamp", payload);
69069
+ if ((0, leeway_js_1.isIssuedInFuture)(observedMs, now, opts.intended)) {
69070
+ return fail("MON_ATTEST_MALFORMED", "observed_at_in_future", payload);
69071
+ }
69072
+ let retiredHistorical = false;
69073
+ if (resolved.status === "retired") {
69074
+ if (!isIssueTimeWithinKeyWindow(String(payload.observed_at), resolved)) {
69075
+ return fail("MON_ATTEST_UNKNOWN_KEY", "retired_key_outside_window", payload);
69076
+ }
69077
+ retiredHistorical = true;
69078
+ }
69079
+ const intended = opts.intended;
69080
+ const wantsCross = !!(intended && (intended.decision_id || intended.receipt_digest));
69081
+ if (wantsCross && intended) {
69082
+ if (intended.decision_id && intended.decision_id !== payload.decision_id) {
69083
+ return fail("MON_ATTEST_UNBOUND", "decision_id_mismatch", payload);
69084
+ }
69085
+ if (intended.receipt_digest && intended.receipt_digest !== payload.receipt_digest) {
69086
+ return fail("MON_ATTEST_UNBOUND", "receipt_digest_mismatch", payload);
69087
+ }
69088
+ }
69089
+ if (retiredHistorical) {
69090
+ return { valid: true, status: "MON_ATTEST_RETIRED_KEY_VALID_AT_ISSUE", reason: null, payload };
69091
+ }
69092
+ return { valid: true, status: "MON_ATTEST_VALID", reason: null, payload };
69093
+ }
69094
+ }
69095
+ });
69096
+
68592
69097
  // node_modules/@coderifts/sdk/dist/cjs/index.js
68593
69098
  var require_cjs3 = __commonJS({
68594
69099
  "node_modules/@coderifts/sdk/dist/cjs/index.js"(exports2) {
68595
69100
  "use strict";
68596
69101
  Object.defineProperty(exports2, "__esModule", { value: true });
68597
- exports2.ATTEST_ENVELOPE_TAG = exports2.ATTEST_SIGNING_PREFIX = exports2.ATTEST_VERSION = exports2.attestSigningInput = exports2.verifyExecutionAttestation = exports2.GRANT_SIGNING_PREFIX = exports2.GRANT_VERSION = exports2.receiptDigest = exports2.afterPayloadCanonical = exports2.computeScopeHash = exports2.verifyExecutionGrant = exports2.isIssuedInFuture = exports2.isReceiptExpired = exports2.declaresDestructiveProduction = exports2.expiryLeewayMs = exports2.CLOCK_SKEW_LEEWAY_MS = exports2.readDecision = exports2.AuthError = exports2.RateLimitError = exports2.TimeoutError = exports2.ApiError = exports2.CodeRiftsError = exports2.CodeRifts = void 0;
69102
+ exports2.MONITOR_ATTEST_ENVELOPE_TAG = exports2.MONITOR_ATTEST_SIGNING_PREFIX = exports2.MONITOR_ATTEST_VERSION = exports2.monitorAttestSigningInput = exports2.verifyMonitoringAttestation = exports2.ATTEST_ENVELOPE_TAG = exports2.ATTEST_SIGNING_PREFIX = exports2.ATTEST_VERSION = exports2.attestSigningInput = exports2.verifyExecutionAttestation = exports2.GRANT_SIGNING_PREFIX = exports2.GRANT_VERSION = exports2.receiptDigest = exports2.afterPayloadCanonical = exports2.computeScopeHash = exports2.verifyExecutionGrant = exports2.isIssuedInFuture = exports2.isReceiptExpired = exports2.declaresDestructiveProduction = exports2.expiryLeewayMs = exports2.CLOCK_SKEW_LEEWAY_MS = exports2.readDecision = exports2.AuthError = exports2.RateLimitError = exports2.TimeoutError = exports2.ApiError = exports2.CodeRiftsError = exports2.resetPolicyWarnForTests = exports2.warnPolicyAbsentOnce = exports2.observePolicyPresence = exports2.detectPolicyPresence = exports2.policyPresenceOf = exports2.withPolicy = exports2.POLICY_ABSENT_WARN = exports2.POLICY_MARKER = exports2.CODERIFTS_POLICY = exports2.CodeRifts = void 0;
68598
69103
  var client_js_1 = require_client();
68599
69104
  Object.defineProperty(exports2, "CodeRifts", { enumerable: true, get: function() {
68600
69105
  return client_js_1.CodeRifts;
68601
69106
  } });
69107
+ var policy_js_1 = require_policy();
69108
+ Object.defineProperty(exports2, "CODERIFTS_POLICY", { enumerable: true, get: function() {
69109
+ return policy_js_1.CODERIFTS_POLICY;
69110
+ } });
69111
+ Object.defineProperty(exports2, "POLICY_MARKER", { enumerable: true, get: function() {
69112
+ return policy_js_1.POLICY_MARKER;
69113
+ } });
69114
+ Object.defineProperty(exports2, "POLICY_ABSENT_WARN", { enumerable: true, get: function() {
69115
+ return policy_js_1.POLICY_ABSENT_WARN;
69116
+ } });
69117
+ Object.defineProperty(exports2, "withPolicy", { enumerable: true, get: function() {
69118
+ return policy_js_1.withPolicy;
69119
+ } });
69120
+ Object.defineProperty(exports2, "policyPresenceOf", { enumerable: true, get: function() {
69121
+ return policy_js_1.policyPresenceOf;
69122
+ } });
69123
+ Object.defineProperty(exports2, "detectPolicyPresence", { enumerable: true, get: function() {
69124
+ return policy_js_1.detectPolicyPresence;
69125
+ } });
69126
+ Object.defineProperty(exports2, "observePolicyPresence", { enumerable: true, get: function() {
69127
+ return policy_js_1.observePolicyPresence;
69128
+ } });
69129
+ Object.defineProperty(exports2, "warnPolicyAbsentOnce", { enumerable: true, get: function() {
69130
+ return policy_js_1.warnPolicyAbsentOnce;
69131
+ } });
69132
+ Object.defineProperty(exports2, "resetPolicyWarnForTests", { enumerable: true, get: function() {
69133
+ return policy_js_1.resetPolicyWarnForTests;
69134
+ } });
68602
69135
  var errors_js_1 = require_errors5();
68603
69136
  Object.defineProperty(exports2, "CodeRiftsError", { enumerable: true, get: function() {
68604
69137
  return errors_js_1.CodeRiftsError;
@@ -68670,6 +69203,22 @@ var require_cjs3 = __commonJS({
68670
69203
  Object.defineProperty(exports2, "ATTEST_ENVELOPE_TAG", { enumerable: true, get: function() {
68671
69204
  return execution_attestation_js_1.ATTEST_ENVELOPE_TAG;
68672
69205
  } });
69206
+ var monitoring_attestation_js_1 = require_monitoring_attestation();
69207
+ Object.defineProperty(exports2, "verifyMonitoringAttestation", { enumerable: true, get: function() {
69208
+ return monitoring_attestation_js_1.verifyMonitoringAttestation;
69209
+ } });
69210
+ Object.defineProperty(exports2, "monitorAttestSigningInput", { enumerable: true, get: function() {
69211
+ return monitoring_attestation_js_1.monitorAttestSigningInput;
69212
+ } });
69213
+ Object.defineProperty(exports2, "MONITOR_ATTEST_VERSION", { enumerable: true, get: function() {
69214
+ return monitoring_attestation_js_1.MONITOR_ATTEST_VERSION;
69215
+ } });
69216
+ Object.defineProperty(exports2, "MONITOR_ATTEST_SIGNING_PREFIX", { enumerable: true, get: function() {
69217
+ return monitoring_attestation_js_1.MONITOR_ATTEST_SIGNING_PREFIX;
69218
+ } });
69219
+ Object.defineProperty(exports2, "MONITOR_ATTEST_ENVELOPE_TAG", { enumerable: true, get: function() {
69220
+ return monitoring_attestation_js_1.MONITOR_ATTEST_ENVELOPE_TAG;
69221
+ } });
68673
69222
  }
68674
69223
  });
68675
69224
 
@@ -68678,7 +69227,8 @@ var require_cas_attestation = __commonJS({
68678
69227
  "node_modules/@coderifts/agent-guard/dist/cjs/cas-attestation.js"(exports2) {
68679
69228
  "use strict";
68680
69229
  Object.defineProperty(exports2, "__esModule", { value: true });
68681
- exports2.CAS_ATTESTATION_SPEC = void 0;
69230
+ exports2.COMMIT_EVIDENCE_MISSING = exports2.CAS_ATTESTATION_SPEC = void 0;
69231
+ exports2.strictCommitObservation = strictCommitObservation;
68682
69232
  exports2.extractExecutorAttestationToken = extractExecutorAttestationToken;
68683
69233
  exports2.evaluateCasEvidence = evaluateCasEvidence;
68684
69234
  exports2.isGuardExecutionProof = isGuardExecutionProof;
@@ -68695,6 +69245,32 @@ var require_cas_attestation = __commonJS({
68695
69245
  does_not_claim_host_cannot_bypass: true,
68696
69246
  does_not_claim_governance_redecision: true
68697
69247
  });
69248
+ exports2.COMMIT_EVIDENCE_MISSING = "commit_evidence_missing";
69249
+ function bindingIntendedSupplied(outcome, opts) {
69250
+ const from = intendedFromOutcome(outcome);
69251
+ if (opts.grant && String(opts.grant).length > 0)
69252
+ return true;
69253
+ if (from.grant && String(from.grant).length > 0)
69254
+ return true;
69255
+ if (opts.receipt_digest && String(opts.receipt_digest).length > 0)
69256
+ return true;
69257
+ if (from.receipt_digest && String(from.receipt_digest).length > 0)
69258
+ return true;
69259
+ const gf = opts.grant_fields;
69260
+ if (gf && (gf.jti || gf.scope_hash || gf.receipt_digest))
69261
+ return true;
69262
+ return false;
69263
+ }
69264
+ function strictCommitObservation(outcome, evidence, opts = {}) {
69265
+ const crossChecked = evidence != null && evidence.class === "executor_attested" && bindingIntendedSupplied(outcome, opts);
69266
+ if (crossChecked) {
69267
+ return { commit_label: "authorized_and_committed" };
69268
+ }
69269
+ return {
69270
+ commit_label: "authorized_not_committed",
69271
+ commit_evidence_reason: exports2.COMMIT_EVIDENCE_MISSING
69272
+ };
69273
+ }
68698
69274
  var ABSENT_EVIDENCE = Object.freeze({
68699
69275
  class: "absent",
68700
69276
  attest_status: null,
@@ -68750,6 +69326,7 @@ var require_cas_attestation = __commonJS({
68750
69326
  const fromOutcome = intendedFromOutcome(outcome);
68751
69327
  const grant = opts.grant || fromOutcome.grant || null;
68752
69328
  const receipt_digest = opts.receipt_digest || fromOutcome.receipt_digest || null;
69329
+ const grant_fields = opts.grant_fields || null;
68753
69330
  if (!registry || !Array.isArray(registry.keys)) {
68754
69331
  return hostClaimed(null, null, null);
68755
69332
  }
@@ -68761,6 +69338,8 @@ var require_cas_attestation = __commonJS({
68761
69338
  intended.grant = grant;
68762
69339
  if (receipt_digest)
68763
69340
  intended.receipt_digest = receipt_digest;
69341
+ if (grant_fields)
69342
+ intended.grant_fields = grant_fields;
68764
69343
  const wantsIntended = Object.keys(intended).length > 0;
68765
69344
  let verified;
68766
69345
  try {
@@ -68848,7 +69427,12 @@ var require_cas_attestation = __commonJS({
68848
69427
  const write_ran = cas.write_ran === true;
68849
69428
  const stale_during_commit = cas.status === "committed_stale_detected";
68850
69429
  const refused = cas.status === "refused";
68851
- const authorized_and_committed = receipt_verified && cas.status === "committed";
69430
+ const cas_evidence = evaluateCasEvidence(outcome, opts);
69431
+ let authorized_and_committed = receipt_verified && cas.status === "committed";
69432
+ if (opts.profile === "ENFORCING_STRICT") {
69433
+ const obs = strictCommitObservation(outcome, cas_evidence, opts);
69434
+ authorized_and_committed = authorized_and_committed && obs.commit_label === "authorized_and_committed";
69435
+ }
68852
69436
  const attestation = {
68853
69437
  attestation_spec: exports2.CAS_ATTESTATION_SPEC,
68854
69438
  references: Object.freeze({
@@ -68865,7 +69449,7 @@ var require_cas_attestation = __commonJS({
68865
69449
  stale_during_commit,
68866
69450
  refused
68867
69451
  }),
68868
- cas_evidence: evaluateCasEvidence(outcome, opts),
69452
+ cas_evidence,
68869
69453
  limits: LIMITS
68870
69454
  };
68871
69455
  return freezeAttestation(attestation);
@@ -69113,7 +69697,15 @@ var require_monitoring_delivery = __commonJS({
69113
69697
  reason: "sink_unrecognised"
69114
69698
  };
69115
69699
  }
69116
- function formatMonitoringDeliveryLine(d) {
69700
+ function formatMonitoringDeliveryLine(d, attestedKid) {
69701
+ if (attestedKid) {
69702
+ if (d.status === "sent_unacked")
69703
+ return `monitoring: sent, not acked (attested kid ${attestedKid})`;
69704
+ if (d.status === "not_delivered") {
69705
+ return d.reason ? `monitoring: NOT delivered (${d.reason}; attested kid ${attestedKid})` : `monitoring: NOT delivered (attested kid ${attestedKid})`;
69706
+ }
69707
+ return `monitoring: delivered (attested kid ${attestedKid})`;
69708
+ }
69117
69709
  if (d.status === "sent_unacked")
69118
69710
  return "monitoring: sent, not acked";
69119
69711
  if (d.status === "not_delivered") {
@@ -69139,6 +69731,267 @@ var require_monitoring_delivery = __commonJS({
69139
69731
  }
69140
69732
  });
69141
69733
 
69734
+ // node_modules/@coderifts/agent-guard/dist/cjs/monitoring-attestation.js
69735
+ var require_monitoring_attestation2 = __commonJS({
69736
+ "node_modules/@coderifts/agent-guard/dist/cjs/monitoring-attestation.js"(exports2) {
69737
+ "use strict";
69738
+ Object.defineProperty(exports2, "__esModule", { value: true });
69739
+ exports2.MONITOR_ATTEST_ENVELOPE_TAG = exports2.MONITOR_ATTEST_SIGNING_PREFIX = exports2.MONITOR_ATTEST_VERSION = void 0;
69740
+ exports2.monitorAttestSigningInput = monitorAttestSigningInput;
69741
+ exports2.receiptDigestOfToken = receiptDigestOfToken;
69742
+ exports2.tryIssueMonitoringAttestation = tryIssueMonitoringAttestation;
69743
+ exports2.kidFromMonitoringAttestation = kidFromMonitoringAttestation;
69744
+ var node_crypto_1 = require("node:crypto");
69745
+ exports2.MONITOR_ATTEST_VERSION = "cr.monitor.attest.v1";
69746
+ exports2.MONITOR_ATTEST_SIGNING_PREFIX = "crmonattest.v1";
69747
+ exports2.MONITOR_ATTEST_ENVELOPE_TAG = "cr.monitor.attest.v1";
69748
+ var DELIVERY_STATUSES = ["delivered_acked", "sent_unacked", "not_delivered"];
69749
+ var SINK_KINDS = ["callback", "http"];
69750
+ function scalar(v) {
69751
+ return v == null ? "" : String(v);
69752
+ }
69753
+ function monitorAttestSigningInput(body) {
69754
+ const parts = [
69755
+ exports2.MONITOR_ATTEST_SIGNING_PREFIX,
69756
+ scalar(body.kid),
69757
+ scalar(body.decision_id),
69758
+ scalar(body.receipt_digest),
69759
+ scalar(body.delivery_status),
69760
+ body.ack_digest != null && String(body.ack_digest).length > 0 ? String(body.ack_digest) : "",
69761
+ scalar(body.sink_kind),
69762
+ scalar(body.observed_at),
69763
+ body.attempt_count != null ? String(body.attempt_count) : ""
69764
+ ];
69765
+ return parts.join("|");
69766
+ }
69767
+ function receiptDigestOfToken(token) {
69768
+ return "sha256:" + (0, node_crypto_1.createHash)("sha256").update(String(token), "utf8").digest("hex");
69769
+ }
69770
+ function b64url(buf) {
69771
+ return buf.toString("base64url");
69772
+ }
69773
+ function envelopeReceiptToken(envelope) {
69774
+ if (!envelope || typeof envelope !== "object")
69775
+ return null;
69776
+ const rec = envelope.receipt;
69777
+ if (rec && typeof rec.token === "string" && rec.token.length > 0)
69778
+ return rec.token;
69779
+ return null;
69780
+ }
69781
+ async function tryIssueMonitoringAttestation(args) {
69782
+ const cfg = args.config;
69783
+ if (!cfg || typeof cfg.kid !== "string" || !cfg.kid || typeof cfg.signer !== "function") {
69784
+ return void 0;
69785
+ }
69786
+ const delivery = args.delivery;
69787
+ if (!delivery || typeof delivery.status !== "string")
69788
+ return void 0;
69789
+ if (!DELIVERY_STATUSES.includes(delivery.status))
69790
+ return void 0;
69791
+ const decision_id = args.envelope && typeof args.envelope.decision_id === "string" ? args.envelope.decision_id : "";
69792
+ const token = envelopeReceiptToken(args.envelope);
69793
+ if (!decision_id || !token)
69794
+ return void 0;
69795
+ const rawKind = delivery.evidence && delivery.evidence.sink_kind;
69796
+ const sink_kind = SINK_KINDS.includes(String(rawKind)) ? rawKind : "callback";
69797
+ const observed_at = delivery.evidence && delivery.evidence.at || args.now || (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "Z");
69798
+ const ack_digest = delivery.status === "delivered_acked" && delivery.evidence && typeof delivery.evidence.ack_hash === "string" && delivery.evidence.ack_hash.startsWith("sha256:") ? delivery.evidence.ack_hash : void 0;
69799
+ const body = {
69800
+ v: exports2.MONITOR_ATTEST_VERSION,
69801
+ kid: cfg.kid,
69802
+ decision_id,
69803
+ receipt_digest: receiptDigestOfToken(token),
69804
+ delivery_status: delivery.status,
69805
+ sink_kind,
69806
+ observed_at
69807
+ };
69808
+ if (ack_digest)
69809
+ body.ack_digest = ack_digest;
69810
+ const input = Buffer.from(monitorAttestSigningInput(body), "utf8");
69811
+ let sig;
69812
+ try {
69813
+ sig = await cfg.signer(input);
69814
+ } catch {
69815
+ return void 0;
69816
+ }
69817
+ if (sig == null)
69818
+ return void 0;
69819
+ const sigBuf = Buffer.isBuffer(sig) ? sig : Buffer.from(sig);
69820
+ if (sigBuf.length === 0)
69821
+ return void 0;
69822
+ return [
69823
+ exports2.MONITOR_ATTEST_ENVELOPE_TAG,
69824
+ cfg.kid,
69825
+ b64url(Buffer.from(JSON.stringify(body), "utf8")),
69826
+ b64url(sigBuf)
69827
+ ].join("|");
69828
+ }
69829
+ function kidFromMonitoringAttestation(token) {
69830
+ if (typeof token !== "string" || token.length === 0)
69831
+ return null;
69832
+ const parts = token.split("|");
69833
+ if (parts.length !== 4 || parts[0] !== exports2.MONITOR_ATTEST_ENVELOPE_TAG)
69834
+ return null;
69835
+ return parts[1] || null;
69836
+ }
69837
+ }
69838
+ });
69839
+
69840
+ // node_modules/@coderifts/agent-guard/dist/cjs/policy.js
69841
+ var require_policy2 = __commonJS({
69842
+ "node_modules/@coderifts/agent-guard/dist/cjs/policy.js"(exports2) {
69843
+ "use strict";
69844
+ Object.defineProperty(exports2, "__esModule", { value: true });
69845
+ exports2.POLICY_ABSENT_WARN = exports2.CODERIFTS_POLICY = exports2.POLICY_MARKER = void 0;
69846
+ exports2.policyPresenceOf = policyPresenceOf;
69847
+ exports2.detectPolicyPresence = detectPolicyPresence;
69848
+ exports2.withPolicy = withPolicy;
69849
+ exports2.warnPolicyAbsentOnce = warnPolicyAbsentOnce;
69850
+ exports2.observePolicyPresence = observePolicyPresence;
69851
+ exports2.resetPolicyWarnForTests = resetPolicyWarnForTests;
69852
+ exports2.POLICY_MARKER = "A receipt authorizes ONE operation: a merge receipt does not authorize a deploy.";
69853
+ exports2.CODERIFTS_POLICY = 'Call `preflight_change_set` before merge, deploy, publish, or tool registration when a contract artifact changed (OpenAPI/Swagger, GraphQL, gRPC/protobuf, AsyncAPI, MCP manifest, or agent tool schemas).\n\nSend the complete base-to-head change set: every changed contract artifact with full before and after content. Do not send a single-file subset when other contract files also change.\n\nBranch on `execution_action` only. Do not branch on `decision` and do not branch on `safe_for_agent` (not_for_control_flow_use_execution_action). Canonical `execution_action` values: CONTINUE, CONTINUE_WITH_MONITORING, REQUEST_APPROVAL, STOP.\n\nAn unrecognised `execution_action` is not permission: fail closed (halt or re-preflight). Well-known code: `not_permission_fail_closed`.\n\nWhen `execution_action` is REQUEST_APPROVAL or STOP, surface the detected patterns and the blast radius, and propose the safer path \u2014 deprecate-then-remove, an additive change, or a new version \u2014 rather than shipping the break.\n\n`CONTINUE_WITH_MONITORING` requires a wired monitoring sink (`monitoringSinkWired`). It is not "proceed with caution" without monitoring.\n\nDo not call CodeRifts tools for a documentation-only change (README, guides, comments) with no contract artifact content change.\n\nIf you already hold a chain receipt and only need authenticity/lifecycle: `verify_receipt`. If you need a past decision by id: `get_decision_details`. Neither replaces preflight for a new change set.\n\nThe CodeRifts MCP server exposes exactly three tools \u2014 `preflight_change_set`, `verify_receipt`, `get_decision_details`. Do not invent or assume others.\n\nA receipt authorizes ONE operation: a merge receipt does not authorize a deploy. Before a different operation (deploy, publish), call `preflight_change_set` with `context.operation` set to that operation \u2014 reusing a differently-scoped receipt is not permitted and will fail at the gate.\n\nA stale or superseded receipt on a changed head requires a NEW preflight \u2014 `verify_receipt` cannot re-diff.\n\nFor mutating tools, put only the guarded version in the agent\'s tool table; keep the raw handler host-only and unreachable from that table. How you name tools is yours \u2014 this is a reachability property, not a product rename of host tools. CodeRifts cannot see or stop a raw call the host makes outside the table it returns; adopt this as a host convention, not as a guarantee from the package.\n\nCodeRifts reports a governance decision and `execution_action`; it does not by itself block merges. Blocking requires separate repository configuration (required status checks, enforcement) that this rule file does not set.\n\nTo act (mutate a contract, merge, deploy, or publish): call `preflight_change_set` with `preflight_mode` authorize. Analyze is informational (`may_execute` is always false) and is not permission. Read `execution_action` on the `decision_result` envelope.\n\nBefore acting under a held receipt: call `verify_receipt` with the intended `context` (operation, environment, repository, branch, pull_request) for THIS attempt. Do not act on a receipt whose scope does not match.\n\nAct only when `currently_authorized` is true (`control_envelope.receipt_view.currently_authorized`). A valid-looking token is not permission if `currently_authorized` is false or omitted.\n\nCommit / CAS evidence is a separate measurement (`commit_observation` on GuardOutcome). It is not a substitute for authorize + `currently_authorized`. Production hosts that want the fail-closed conjunction lock it with `profile: ENFORCING_STRICT` on withCodeRifts.\n\nIf the host requests an execution grant (opt-in `include_execution_grant`), the grant is bound to operation + target + after-payload (`scope_hash`) and is short-lived \u2014 never reuse it after the after-payload changes.\n\nAn ATOMIC-profile grant carries `state_nonce` and is single-use at the executor \u2014 if the executor has consumed the nonce, re-preflight; do not retry the same grant.\n\nWith a proven tenant\u2194repo binding you may request `derivation:"server"` instead of assembling `artifacts[]` yourself (`context.repository` + `context.base` + `context.head` required; caller-supplied artifacts are rejected on that path).\n\nA commit is only proven when an executor attestation verifies (customer-held executor key, `cas_evidence: executor_attested`); otherwise say "authorized, commit not proven".';
69854
+ exports2.POLICY_ABSENT_WARN = "CodeRifts policy text not detected in the system prompt. The agent will still see the tools, but measured evidence shows operation-scope misuse is markedly more likely without it. See https://github.com/coderifts/agent-guard#policy-delivery.";
69855
+ function textHasMarker(text) {
69856
+ return text.includes(exports2.POLICY_MARKER);
69857
+ }
69858
+ function contentHasMarker(content) {
69859
+ if (typeof content === "string")
69860
+ return textHasMarker(content);
69861
+ if (Array.isArray(content))
69862
+ return content.some(contentHasMarker);
69863
+ if (content && typeof content === "object") {
69864
+ const o = content;
69865
+ if (typeof o.text === "string" && textHasMarker(o.text))
69866
+ return true;
69867
+ if (typeof o.content === "string" && textHasMarker(o.content))
69868
+ return true;
69869
+ }
69870
+ return false;
69871
+ }
69872
+ function policyPresenceOf(text) {
69873
+ if (text == null)
69874
+ return "unknown";
69875
+ return textHasMarker(String(text)) ? "detected" : "absent";
69876
+ }
69877
+ function detectPolicyPresence(text) {
69878
+ return policyPresenceOf(text);
69879
+ }
69880
+ function appendPolicyToString(existing) {
69881
+ if (textHasMarker(existing))
69882
+ return existing;
69883
+ if (existing.trim() === "")
69884
+ return exports2.CODERIFTS_POLICY;
69885
+ return existing + "\n\n" + exports2.CODERIFTS_POLICY;
69886
+ }
69887
+ function withPolicy(input, opts) {
69888
+ const inject = opts?.injectPolicy !== false;
69889
+ if (typeof input === "string") {
69890
+ if (!inject)
69891
+ return input;
69892
+ return appendPolicyToString(input);
69893
+ }
69894
+ const copy = input.map((m) => ({ ...m }));
69895
+ if (!inject)
69896
+ return copy;
69897
+ if (copy.some((m) => contentHasMarker(m.content)))
69898
+ return copy;
69899
+ const sysIdx = copy.findIndex((m) => String(m.role).toLowerCase() === "system");
69900
+ if (sysIdx >= 0) {
69901
+ const sys = copy[sysIdx];
69902
+ if (typeof sys.content === "string") {
69903
+ copy[sysIdx] = { ...sys, content: appendPolicyToString(sys.content) };
69904
+ return copy;
69905
+ }
69906
+ return [{ role: "system", content: exports2.CODERIFTS_POLICY }, ...copy];
69907
+ }
69908
+ return [{ role: "system", content: exports2.CODERIFTS_POLICY }, ...copy];
69909
+ }
69910
+ var warnedThisProcess = false;
69911
+ function defaultWarn(msg) {
69912
+ console.warn(msg);
69913
+ }
69914
+ function warnPolicyAbsentOnce() {
69915
+ if (warnedThisProcess)
69916
+ return;
69917
+ warnedThisProcess = true;
69918
+ defaultWarn(exports2.POLICY_ABSENT_WARN);
69919
+ }
69920
+ function observePolicyPresence(text) {
69921
+ const presence = policyPresenceOf(text);
69922
+ if (presence === "absent")
69923
+ warnPolicyAbsentOnce();
69924
+ return presence;
69925
+ }
69926
+ function resetPolicyWarnForTests() {
69927
+ warnedThisProcess = false;
69928
+ }
69929
+ }
69930
+ });
69931
+
69932
+ // node_modules/@coderifts/agent-guard/dist/cjs/execution-grant.js
69933
+ var require_execution_grant2 = __commonJS({
69934
+ "node_modules/@coderifts/agent-guard/dist/cjs/execution-grant.js"(exports2) {
69935
+ "use strict";
69936
+ Object.defineProperty(exports2, "__esModule", { value: true });
69937
+ exports2.isExecutionGrantEnabled = isExecutionGrantEnabled;
69938
+ exports2.readExecutionGrantToken = readExecutionGrantToken;
69939
+ exports2.firstArtifactId = firstArtifactId;
69940
+ exports2.isSignerUnavailableError = isSignerUnavailableError;
69941
+ exports2.resolveStateNonceForCall = resolveStateNonceForCall;
69942
+ function isExecutionGrantEnabled(config) {
69943
+ return !!(config && config.executionGrant && config.executionGrant.enabled === true);
69944
+ }
69945
+ function readExecutionGrantToken(response) {
69946
+ if (!response || typeof response !== "object")
69947
+ return null;
69948
+ const g = response.execution_grant;
69949
+ return typeof g === "string" && g.length > 0 ? g : null;
69950
+ }
69951
+ function firstArtifactId(artifacts) {
69952
+ if (!Array.isArray(artifacts))
69953
+ return null;
69954
+ for (const a of artifacts) {
69955
+ if (a && typeof a === "object" && typeof a.id === "string") {
69956
+ const id = String(a.id).trim();
69957
+ if (id)
69958
+ return id;
69959
+ }
69960
+ }
69961
+ return null;
69962
+ }
69963
+ function isSignerUnavailableError(err) {
69964
+ if (!err || typeof err !== "object")
69965
+ return false;
69966
+ const e = err;
69967
+ if (e.code === "SIGNER_UNAVAILABLE")
69968
+ return true;
69969
+ if (e.body && e.body.code === "SIGNER_UNAVAILABLE")
69970
+ return true;
69971
+ return false;
69972
+ }
69973
+ async function resolveStateNonceForCall(config, call, artifacts) {
69974
+ const resolver = config.executionGrant && config.executionGrant.resolveStateNonce;
69975
+ if (typeof resolver !== "function")
69976
+ return { ok: true };
69977
+ try {
69978
+ const raw = await resolver({
69979
+ artifactId: firstArtifactId(artifacts) || firstArtifactId(call.artifacts),
69980
+ toolName: call.toolName,
69981
+ args: call.arguments
69982
+ });
69983
+ if (raw == null || raw === "")
69984
+ return { ok: true };
69985
+ if (typeof raw !== "string")
69986
+ return { ok: false };
69987
+ return { ok: true, nonce: raw };
69988
+ } catch {
69989
+ return { ok: false };
69990
+ }
69991
+ }
69992
+ }
69993
+ });
69994
+
69142
69995
  // node_modules/@coderifts/agent-guard/dist/cjs/guard.js
69143
69996
  var require_guard = __commonJS({
69144
69997
  "node_modules/@coderifts/agent-guard/dist/cjs/guard.js"(exports2) {
@@ -69152,11 +70005,15 @@ var require_guard = __commonJS({
69152
70005
  var enforcement_gate_js_1 = require_enforcement_gate();
69153
70006
  var execution_time_fingerprint_js_1 = require_execution_time_fingerprint();
69154
70007
  var execution_proof_js_1 = require_execution_proof();
70008
+ var coverage_observed_js_1 = require_coverage_observed();
69155
70009
  var freshness_js_1 = require_freshness();
69156
70010
  var conditional_write_js_1 = require_conditional_write();
69157
70011
  var commit_observation_js_1 = require_commit_observation();
69158
70012
  var cas_attestation_js_1 = require_cas_attestation();
69159
70013
  var monitoring_delivery_js_1 = require_monitoring_delivery();
70014
+ var monitoring_attestation_js_1 = require_monitoring_attestation2();
70015
+ var policy_js_1 = require_policy2();
70016
+ var execution_grant_js_1 = require_execution_grant2();
69160
70017
  var breakers = /* @__PURE__ */ new WeakMap();
69161
70018
  var nowMs = () => Date.now();
69162
70019
  var iso = () => (/* @__PURE__ */ new Date()).toISOString();
@@ -69208,7 +70065,10 @@ var require_guard = __commonJS({
69208
70065
  s.fails = s.fails.filter((x) => t - x < win);
69209
70066
  return s.fails.length >= (config.maxUnavailablePerWindow ?? 3);
69210
70067
  }
69211
- function classifyError(err, config) {
70068
+ function requestAsksForGrant(request) {
70069
+ return !!(request && typeof request === "object" && request.include_execution_grant === true);
70070
+ }
70071
+ function classifyError(err, config, grantRequested = false) {
69212
70072
  const e = err;
69213
70073
  const name = e?.name;
69214
70074
  const status = e?.status ?? e?.body?.status;
@@ -69222,6 +70082,9 @@ var require_guard = __commonJS({
69222
70082
  return { cause: "REQUEST_REJECTED", integrity: true };
69223
70083
  if (status === 400 || status === 401 || status === 409)
69224
70084
  return { cause: "REQUEST_REJECTED", integrity: true };
70085
+ if (grantRequested && ((0, execution_grant_js_1.isSignerUnavailableError)(err) || status === 503)) {
70086
+ return { cause: "SIGNER_UNAVAILABLE", integrity: true };
70087
+ }
69225
70088
  if (typeof status === "number" && status >= 500)
69226
70089
  return { cause: "SERVER_ERROR", integrity: false };
69227
70090
  if (name === "TypeError" || /fetch failed|network|ENOTFOUND|ECONNREFUSED|EAI_AGAIN/i.test(String(e?.message)))
@@ -69256,7 +70119,7 @@ var require_guard = __commonJS({
69256
70119
  const response = await withTimeout(config.client.authorizeChangeSet(request), Math.min(timeoutMs, remaining));
69257
70120
  return { ok: true, response };
69258
70121
  } catch (err) {
69259
- last = classifyError(err, config);
70122
+ last = classifyError(err, config, requestAsksForGrant(request));
69260
70123
  if (last.integrity)
69261
70124
  return { ok: false, ...last };
69262
70125
  }
@@ -69282,52 +70145,73 @@ var require_guard = __commonJS({
69282
70145
  return { verified: null, cause: "RECEIPT_UNVERIFIED" };
69283
70146
  }
69284
70147
  }
69285
- async function runEnforced(config, factory, approved, redacted, freshness, conditional_write, monitoring_delivery) {
70148
+ async function runEnforced(config, factory, approved, redacted, freshness, conditional_write, monitoring_delivery, monitoring_attestation, grantCtx, grantObs) {
69286
70149
  emit(config, { type: "execution_started", at: iso(), action: approved.action, decisionId: approved.envelope.decision_id });
69287
70150
  try {
69288
- const result = await factory(approved.envelope, redacted);
70151
+ const result = grantCtx ? await factory(approved.envelope, redacted, grantCtx) : await factory(approved.envelope, redacted);
69289
70152
  const base = { executionAttempted: true, executed: true, enforced: true, result, verdict: approved, preflighted: true };
69290
- return finishExecuted(config, base, freshness, conditional_write, redacted, result, monitoring_delivery);
70153
+ return finishExecuted(config, base, freshness, conditional_write, redacted, result, monitoring_delivery, monitoring_attestation, grantObs);
69291
70154
  } catch (error) {
69292
70155
  emit(config, { type: "factory_error", at: iso(), action: approved.action });
69293
70156
  const base = { executionAttempted: true, executed: false, enforced: true, error, verdict: approved, preflighted: true };
69294
- return finishExecuted(config, base, freshness, conditional_write, redacted, void 0, monitoring_delivery);
70157
+ return finishExecuted(config, base, freshness, conditional_write, redacted, void 0, monitoring_delivery, monitoring_attestation, grantObs);
69295
70158
  }
69296
70159
  }
69297
- async function runUnenforced(config, factory, envelope, verdict, preflighted, redacted, freshness, conditional_write, monitoring_delivery) {
70160
+ async function runUnenforced(config, factory, envelope, verdict, preflighted, redacted, freshness, conditional_write, monitoring_delivery, monitoring_attestation, grantCtx, grantObs) {
69298
70161
  emit(config, { type: "execution_started", at: iso() });
69299
70162
  try {
69300
- const result = await factory(envelope, redacted);
70163
+ const result = grantCtx ? await factory(envelope, redacted, grantCtx) : await factory(envelope, redacted);
69301
70164
  const base = { executionAttempted: true, executed: true, enforced: false, result, verdict, preflighted };
69302
- return finishExecuted(config, base, freshness, conditional_write, redacted, result, monitoring_delivery);
70165
+ return finishExecuted(config, base, freshness, conditional_write, redacted, result, monitoring_delivery, monitoring_attestation, grantObs);
69303
70166
  } catch (error) {
69304
70167
  emit(config, { type: "factory_error", at: iso() });
69305
70168
  const base = { executionAttempted: true, executed: false, enforced: false, error, verdict, preflighted };
69306
- return finishExecuted(config, base, freshness, conditional_write, redacted, void 0, monitoring_delivery);
70169
+ return finishExecuted(config, base, freshness, conditional_write, redacted, void 0, monitoring_delivery, monitoring_attestation, grantObs);
69307
70170
  }
69308
70171
  }
69309
- function blocked(verdict, preflighted, freshness, conditional_write, monitoring_delivery) {
70172
+ function attachPolicyPresence(outcome, config) {
70173
+ if (config.systemPrompt == null)
70174
+ return outcome;
70175
+ const policy_presence = (0, policy_js_1.observePolicyPresence)(config.systemPrompt);
70176
+ return { ...outcome, policy_presence };
70177
+ }
70178
+ function coverageSnap(config) {
70179
+ if (!config.coverageObserver)
70180
+ return {};
70181
+ return { coverageObserved: (0, coverage_observed_js_1.freezeCoverageObserved)(config.coverageObserver.snapshot()) };
70182
+ }
70183
+ function coverageOutcomeFieldsFrom(s) {
70184
+ return s.coverageObserved ? { coverage_observed: s.coverageObserved } : {};
70185
+ }
70186
+ function blocked(config, verdict, preflighted, freshness, conditional_write, monitoring_delivery, monitoring_attestation, grantObs) {
69310
70187
  const commit_observation = {
69311
70188
  status: "not_observed",
69312
70189
  observed_at: iso(),
69313
70190
  host_attestation: "absent"
69314
70191
  };
69315
70192
  const base = { executionAttempted: false, executed: false, enforced: false, verdict, preflighted };
69316
- return {
70193
+ const cov = coverageSnap(config);
70194
+ const out = {
69317
70195
  ...base,
69318
70196
  proof: (0, execution_proof_js_1.buildExecutionProof)({
69319
70197
  ...base,
69320
70198
  conditionalWriteBasis: conditional_write,
69321
70199
  commitObservation: commit_observation,
69322
- monitoringDelivery: monitoring_delivery
70200
+ monitoringDelivery: monitoring_delivery,
70201
+ ...monitoring_attestation ? { monitoringAttestation: monitoring_attestation } : {},
70202
+ ...cov
69323
70203
  }),
69324
70204
  freshness,
69325
70205
  conditional_write,
69326
70206
  commit_observation,
69327
- ...monitoring_delivery ? { monitoring_delivery } : {}
70207
+ ...monitoring_delivery ? { monitoring_delivery } : {},
70208
+ ...monitoring_attestation ? { monitoring_attestation } : {},
70209
+ ...coverageOutcomeFieldsFrom(cov),
70210
+ ...grantObs ? { execution_grant: grantObs } : {}
69328
70211
  };
70212
+ return attachPolicyPresence(out, config);
69329
70213
  }
69330
- async function finishExecuted(config, base, freshness, conditional_write, redacted, result, monitoring_delivery) {
70214
+ async function finishExecuted(config, base, freshness, conditional_write, redacted, result, monitoring_delivery, monitoring_attestation, grantObs) {
69331
70215
  const enabled = config.requireCommitObservation !== false;
69332
70216
  const commit_observation = await (0, commit_observation_js_1.observeCommit)({
69333
70217
  enabled,
@@ -69355,33 +70239,49 @@ var require_guard = __commonJS({
69355
70239
  token: commit_observation.token
69356
70240
  });
69357
70241
  }
69358
- const cas_evidence = result !== void 0 ? (0, cas_attestation_js_1.evaluateCasEvidence)(result, {
69359
- registry: config.executorAttestation && config.executorAttestation.registry
69360
- }) : void 0;
70242
+ const casOpts = {
70243
+ registry: config.executorAttestation && config.executorAttestation.registry,
70244
+ ...config.profile === "ENFORCING_STRICT" ? { profile: "ENFORCING_STRICT" } : {}
70245
+ };
70246
+ const cas_evidence = result !== void 0 ? (0, cas_attestation_js_1.evaluateCasEvidence)(result, casOpts) : void 0;
70247
+ const strictObs = config.profile === "ENFORCING_STRICT" ? (0, cas_attestation_js_1.strictCommitObservation)(result, cas_evidence, casOpts) : null;
70248
+ const cov = coverageSnap(config);
69361
70249
  const proof = (0, execution_proof_js_1.buildExecutionProof)({
69362
70250
  ...base,
69363
70251
  conditionalWriteBasis: conditional_write,
69364
70252
  commitObservation: commit_observation,
69365
70253
  monitoringDelivery: monitoring_delivery,
69366
- ...cas_evidence ? { casEvidence: cas_evidence } : {}
70254
+ ...monitoring_attestation ? { monitoringAttestation: monitoring_attestation } : {},
70255
+ ...cas_evidence ? { casEvidence: cas_evidence } : {},
70256
+ ...strictObs ? {
70257
+ commitLabel: strictObs.commit_label,
70258
+ commitEvidenceReason: strictObs.commit_evidence_reason
70259
+ } : {},
70260
+ ...cov
69367
70261
  });
69368
70262
  if (result !== void 0 && (0, cas_attestation_js_1.isExecuteIfUnchangedOutcome)(result)) {
69369
70263
  try {
69370
- (0, cas_attestation_js_1.buildCasAttestation)(proof, result, {
69371
- registry: config.executorAttestation && config.executorAttestation.registry
69372
- });
70264
+ (0, cas_attestation_js_1.buildCasAttestation)(proof, result, casOpts);
69373
70265
  } catch {
69374
70266
  }
69375
70267
  }
69376
- return {
70268
+ const out = {
69377
70269
  ...base,
69378
70270
  proof,
69379
70271
  freshness,
69380
70272
  conditional_write,
69381
70273
  commit_observation,
69382
70274
  ...monitoring_delivery ? { monitoring_delivery } : {},
69383
- ...cas_evidence ? { cas_evidence } : {}
70275
+ ...monitoring_attestation ? { monitoring_attestation } : {},
70276
+ ...cas_evidence ? { cas_evidence } : {},
70277
+ ...strictObs ? {
70278
+ commit_label: strictObs.commit_label,
70279
+ ...strictObs.commit_evidence_reason ? { commit_evidence_reason: strictObs.commit_evidence_reason } : {}
70280
+ } : {},
70281
+ ...coverageOutcomeFieldsFrom(cov),
70282
+ ...grantObs ? { execution_grant: grantObs } : {}
69384
70283
  };
70284
+ return attachPolicyPresence(out, config);
69385
70285
  }
69386
70286
  function preflightBeforeByIdFrom(arts) {
69387
70287
  const out = {};
@@ -69489,7 +70389,7 @@ var require_guard = __commonJS({
69489
70389
  const v = unavailableVerdict({ cause: "MISSING_ARTIFACT_CONTENT", failPolicy, resolution: "CLOSED", action: "STOP" }, count);
69490
70390
  const { basis } = freshnessFor(config, redacted, fctx, detection.artifacts);
69491
70391
  const { basis: cw } = conditionalWriteFor(config, redacted, cwctx);
69492
- return blocked(v, false, basis, cw);
70392
+ return blocked(config, v, false, basis, cw);
69493
70393
  }
69494
70394
  if (failPolicy === "lkg" && !config.lkg) {
69495
70395
  breakerRecord(config);
@@ -69501,10 +70401,23 @@ var require_guard = __commonJS({
69501
70401
  previous_receipt: resolvePreviousReceipt(config),
69502
70402
  idempotency_key: void 0
69503
70403
  };
70404
+ let grantObs;
70405
+ let grantForCall = null;
70406
+ if ((0, execution_grant_js_1.isExecutionGrantEnabled)(config)) {
70407
+ grantObs = { requested: true, arrived: false };
70408
+ const nonceRes = await (0, execution_grant_js_1.resolveStateNonceForCall)(config, redacted, detection.artifacts);
70409
+ if (!nonceRes.ok) {
70410
+ breakerRecord(config);
70411
+ return closedIntegrity(config, "EXECUTION_GRANT_NONCE_UNRESOLVABLE", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
70412
+ }
70413
+ request.include_execution_grant = true;
70414
+ if (nonceRes.nonce)
70415
+ request.state_nonce = nonceRes.nonce;
70416
+ }
69504
70417
  const cap = config.maxPayloadBytes ?? 1e6;
69505
70418
  if (Buffer.byteLength(JSON.stringify(request), "utf8") > cap) {
69506
70419
  breakerRecord(config);
69507
- return closedIntegrity(config, "PAYLOAD_TOO_LARGE", failPolicy, fctx, cwctx, redacted, detection.artifacts);
70420
+ return closedIntegrity(config, "PAYLOAD_TOO_LARGE", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69508
70421
  }
69509
70422
  emit(config, { type: "preflight_start", at: iso() });
69510
70423
  const pf = await preflightWithRetry(config, request);
@@ -69516,13 +70429,19 @@ var require_guard = __commonJS({
69516
70429
  if (pf.integrity) {
69517
70430
  emit(config, { type: "breaker_tripped", at: iso(), cause: pf.cause });
69518
70431
  const v2 = unavailableVerdict({ cause: pf.cause, failPolicy, resolution: "CLOSED", action: "STOP" }, count);
69519
- return blocked(v2, false, basis, cw);
70432
+ return blocked(config, v2, false, basis, cw, void 0, void 0, grantObs);
69520
70433
  }
69521
70434
  const availCause = pf.cause;
70435
+ if (grantObs && grantObs.requested) {
70436
+ if (breakerTripped(config))
70437
+ emit(config, { type: "breaker_tripped", at: iso(), cause: availCause });
70438
+ const v2 = unavailableVerdict({ cause: availCause, failPolicy, resolution: "CLOSED", action: "STOP" }, count);
70439
+ return blocked(config, v2, false, basis, cw, void 0, void 0, grantObs);
70440
+ }
69522
70441
  if (failPolicy === "open" && !breakerTripped(config)) {
69523
70442
  emit(config, { type: "preflight_unavailable", at: iso(), cause: availCause, action: "CONTINUE" });
69524
70443
  const v2 = unavailableVerdict({ cause: availCause, failPolicy: "open", resolution: "OPEN_PASSTHROUGH", action: "CONTINUE" }, count);
69525
- return runUnenforced(config, executeFactory, null, v2, false, redacted, basis, cw);
70444
+ return runUnenforced(config, executeFactory, null, v2, false, redacted, basis, cw, void 0, void 0, void 0, grantObs);
69526
70445
  }
69527
70446
  if (failPolicy === "lkg") {
69528
70447
  const lkg = await tryLkg(config, inputFp);
@@ -69535,25 +70454,25 @@ var require_guard = __commonJS({
69535
70454
  if (breakerTripped(config))
69536
70455
  emit(config, { type: "breaker_tripped", at: iso(), cause: availCause });
69537
70456
  const v = unavailableVerdict({ cause: availCause, failPolicy, resolution: "CLOSED", action: "STOP" }, count);
69538
- return blocked(v, false, basis, cw);
70457
+ return blocked(config, v, false, basis, cw, void 0, void 0, grantObs);
69539
70458
  }
69540
70459
  const rd = (0, read_decision_js_1.readDecision)(pf.response);
69541
70460
  if (rd.reason === "EXECUTION_ACTION_UNRECOGNISED") {
69542
70461
  breakerRecord(config);
69543
- return closedIntegrity(config, "EXECUTION_ACTION_UNRECOGNISED", failPolicy, fctx, cwctx, redacted, detection.artifacts);
70462
+ return closedIntegrity(config, "EXECUTION_ACTION_UNRECOGNISED", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69544
70463
  }
69545
70464
  if (rd.reason === "UNREADABLE_DECISION") {
69546
70465
  breakerRecord(config);
69547
- return closedIntegrity(config, "UNREADABLE_DECISION", failPolicy, fctx, cwctx, redacted, detection.artifacts);
70466
+ return closedIntegrity(config, "UNREADABLE_DECISION", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69548
70467
  }
69549
70468
  if (!rd.envelope) {
69550
70469
  breakerRecord(config);
69551
- return closedIntegrity(config, "SCHEMA_INVALID", failPolicy, fctx, cwctx, redacted, detection.artifacts);
70470
+ return closedIntegrity(config, "SCHEMA_INVALID", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69552
70471
  }
69553
70472
  const envelope = rd.envelope;
69554
70473
  if (!(0, read_decision_js_1.isClosedAction)(rd.executionAction)) {
69555
70474
  breakerRecord(config);
69556
- return closedIntegrity(config, "EXECUTION_ACTION_UNRECOGNISED", failPolicy, fctx, cwctx, redacted, detection.artifacts);
70475
+ return closedIntegrity(config, "EXECUTION_ACTION_UNRECOGNISED", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69557
70476
  }
69558
70477
  const closedAction = rd.executionAction;
69559
70478
  const expired = isExpired(envelope);
@@ -69565,22 +70484,31 @@ var require_guard = __commonJS({
69565
70484
  emit(config, { type: "preflight_result", at: iso(), action: closedAction, decisionId: envelope.decision_id });
69566
70485
  if (config.verifyReceipts !== false && !receiptVerified && envelope.receipt?.token) {
69567
70486
  breakerRecord(config);
69568
- return closedIntegrity(config, bindResult.cause ?? "RECEIPT_UNVERIFIED", failPolicy, fctx, cwctx, redacted, detection.artifacts);
70487
+ return closedIntegrity(config, bindResult.cause ?? "RECEIPT_UNVERIFIED", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69569
70488
  }
69570
70489
  const gate = (0, enforcement_gate_js_1.evaluateEnvelope)(pf.response, envelope, closedAction, detection.artifacts);
69571
70490
  if (gate.verdict === "fail-closed") {
69572
70491
  breakerRecord(config);
69573
- return closedIntegrity(config, gate.cause, failPolicy, fctx, cwctx, redacted, detection.artifacts);
70492
+ return closedIntegrity(config, gate.cause, failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69574
70493
  }
69575
70494
  if (gate.verdict === "block-strict") {
69576
70495
  const { basis } = freshnessFor(config, redacted, fctx, detection.artifacts);
69577
70496
  const { basis: cw } = conditionalWriteFor(config, redacted, cwctx);
69578
- return gate.decision === "BLOCK" ? blocked({ kind: "BLOCK", action: "STOP", envelope, receiptVerified }, true, basis, cw) : blocked({ kind: "APPROVAL", action: "REQUEST_APPROVAL", envelope, receiptVerified }, true, basis, cw);
70497
+ return gate.decision === "BLOCK" ? blocked(config, { kind: "BLOCK", action: "STOP", envelope, receiptVerified }, true, basis, cw, void 0, void 0, grantObs) : blocked(config, { kind: "APPROVAL", action: "REQUEST_APPROVAL", envelope, receiptVerified }, true, basis, cw, void 0, void 0, grantObs);
69579
70498
  }
69580
70499
  const kind = gate.kind;
70500
+ if (grantObs && grantObs.requested) {
70501
+ grantForCall = (0, execution_grant_js_1.readExecutionGrantToken)(pf.response);
70502
+ grantObs = { requested: true, arrived: !!grantForCall };
70503
+ if (!grantForCall) {
70504
+ breakerRecord(config);
70505
+ return closedIntegrity(config, "EXECUTION_GRANT_MISSING", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
70506
+ }
70507
+ }
70508
+ const grantCtx = grantObs ? { execution_grant: grantForCall } : void 0;
69581
70509
  if (expired) {
69582
70510
  breakerRecord(config);
69583
- return closedIntegrity(config, "SCHEMA_INVALID", failPolicy, fctx, cwctx, redacted, detection.artifacts);
70511
+ return closedIntegrity(config, "SCHEMA_INVALID", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69584
70512
  }
69585
70513
  const sinkWired = config.monitoringSinkWired === true && typeof config.onEvent === "function";
69586
70514
  if (kind === "MONITOR") {
@@ -69590,6 +70518,7 @@ var require_guard = __commonJS({
69590
70518
  emit(config, { type: "monitoring_unwired", at: iso(), decisionId: envelope.decision_id });
69591
70519
  }
69592
70520
  let monitoringDelivery;
70521
+ let monitoringAttestation;
69593
70522
  if (kind === "MONITOR") {
69594
70523
  if (!sinkWired) {
69595
70524
  monitoringDelivery = {
@@ -69617,31 +70546,37 @@ var require_guard = __commonJS({
69617
70546
  decisionId: envelope.decision_id,
69618
70547
  cause: monitoringDelivery.reason
69619
70548
  });
69620
- if ((0, monitoring_delivery_js_1.monitoringDeliveryFailClosed)(config)) {
69621
- breakerRecord(config);
69622
- return closedIntegrity(config, "MONITORING_UNWIRED", failPolicy, fctx, cwctx, redacted, detection.artifacts, monitoringDelivery);
69623
- }
69624
70549
  }
69625
70550
  }
70551
+ monitoringAttestation = await (0, monitoring_attestation_js_1.tryIssueMonitoringAttestation)({
70552
+ config: config.monitoringAttestation,
70553
+ delivery: monitoringDelivery,
70554
+ envelope,
70555
+ now: iso()
70556
+ });
70557
+ if (sinkWired && monitoringDelivery.status === "not_delivered" && (0, monitoring_delivery_js_1.monitoringDeliveryFailClosed)(config)) {
70558
+ breakerRecord(config);
70559
+ return closedIntegrity(config, "MONITORING_UNWIRED", failPolicy, fctx, cwctx, redacted, detection.artifacts, monitoringDelivery, monitoringAttestation, grantObs);
70560
+ }
69626
70561
  }
69627
70562
  const { basis: freshBasis, blockCause: freshBlock } = freshnessFor(config, redacted, fctx, detection.artifacts);
69628
70563
  if (freshBlock === "FRESHNESS_REQUIRED" || freshBlock === "FRESHNESS_FAILED") {
69629
70564
  breakerRecord(config);
69630
- return closedIntegrity(config, freshBlock, failPolicy, fctx, cwctx, redacted, detection.artifacts);
70565
+ return closedIntegrity(config, freshBlock, failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69631
70566
  }
69632
70567
  const { basis: cwBasis, blockCause: cwBlock } = conditionalWriteFor(config, redacted, cwctx);
69633
70568
  if (cwBlock === "CONDITIONAL_WRITE_REQUIRED") {
69634
70569
  breakerRecord(config);
69635
- return closedIntegrity(config, cwBlock, failPolicy, fctx, cwctx, redacted, detection.artifacts);
70570
+ return closedIntegrity(config, cwBlock, failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69636
70571
  }
69637
70572
  if (config.observeOnly) {
69638
70573
  emit(config, { type: "observe_only_passthrough", at: iso(), action: closedAction });
69639
70574
  const verdict = kind === "ALLOW" ? { kind: "ALLOW", action: "CONTINUE", envelope, receiptVerified } : { kind: "MONITOR", action: "CONTINUE_WITH_MONITORING", envelope, receiptVerified };
69640
- return runUnenforced(config, executeFactory, envelope, verdict, true, redacted, freshBasis, cwBasis, monitoringDelivery);
70575
+ return runUnenforced(config, executeFactory, envelope, verdict, true, redacted, freshBasis, cwBasis, monitoringDelivery, monitoringAttestation, grantCtx, grantObs);
69641
70576
  }
69642
70577
  if (kind === "MONITOR" && sinkWired && monitoringDelivery && monitoringDelivery.status === "not_delivered") {
69643
70578
  const degraded = { kind: "MONITOR", action: "CONTINUE_WITH_MONITORING", envelope, receiptVerified };
69644
- return runUnenforced(config, executeFactory, envelope, degraded, true, redacted, freshBasis, cwBasis, monitoringDelivery);
70579
+ return runUnenforced(config, executeFactory, envelope, degraded, true, redacted, freshBasis, cwBasis, monitoringDelivery, monitoringAttestation, grantCtx, grantObs);
69645
70580
  }
69646
70581
  const enforceable = receiptVerified && (kind === "ALLOW" || sinkWired);
69647
70582
  if (enforceable) {
@@ -69654,7 +70589,7 @@ var require_guard = __commonJS({
69654
70589
  cause: "requireExecutionStateMatch_false"
69655
70590
  });
69656
70591
  const offVerdict = kind === "ALLOW" ? { kind: "ALLOW", action: "CONTINUE", envelope, receiptVerified } : { kind: "MONITOR", action: "CONTINUE_WITH_MONITORING", envelope, receiptVerified };
69657
- return runUnenforced(config, executeFactory, envelope, offVerdict, true, redacted, freshBasis, cwBasis, monitoringDelivery);
70592
+ return runUnenforced(config, executeFactory, envelope, offVerdict, true, redacted, freshBasis, cwBasis, monitoringDelivery, monitoringAttestation, grantCtx, grantObs);
69658
70593
  }
69659
70594
  const et = (0, execution_time_fingerprint_js_1.checkExecutionTimeFingerprint)({
69660
70595
  artifacts: detection.artifacts,
@@ -69668,7 +70603,7 @@ var require_guard = __commonJS({
69668
70603
  const unmeasurable = (0, execution_time_fingerprint_js_1.isUnmeasurableExecutionStateReason)(et.reason);
69669
70604
  if (execStateMode === true) {
69670
70605
  breakerRecord(config);
69671
- return closedIntegrity(config, unmeasurable ? "EXECUTION_STATE_UNMEASURABLE" : "EXECUTION_STATE_DRIFT", failPolicy, fctx, cwctx, redacted, detection.artifacts);
70606
+ return closedIntegrity(config, unmeasurable ? "EXECUTION_STATE_UNMEASURABLE" : "EXECUTION_STATE_DRIFT", failPolicy, fctx, cwctx, redacted, detection.artifacts, void 0, void 0, grantObs);
69672
70607
  }
69673
70608
  if (unmeasurable) {
69674
70609
  emit(config, {
@@ -69691,21 +70626,21 @@ var require_guard = __commonJS({
69691
70626
  });
69692
70627
  }
69693
70628
  const warnVerdict = kind === "ALLOW" ? { kind: "ALLOW", action: "CONTINUE", envelope, receiptVerified } : { kind: "MONITOR", action: "CONTINUE_WITH_MONITORING", envelope, receiptVerified };
69694
- return runUnenforced(config, executeFactory, envelope, warnVerdict, true, redacted, freshBasis, cwBasis, monitoringDelivery);
70629
+ return runUnenforced(config, executeFactory, envelope, warnVerdict, true, redacted, freshBasis, cwBasis, monitoringDelivery, monitoringAttestation, grantCtx, grantObs);
69695
70630
  }
69696
70631
  const approved = kind === "ALLOW" ? { kind: "ALLOW", action: "CONTINUE", envelope, receiptVerified: true } : { kind: "MONITOR", action: "CONTINUE_WITH_MONITORING", envelope, receiptVerified: true };
69697
- return runEnforced(config, executeFactory, approved, redacted, freshBasis, cwBasis, monitoringDelivery);
70632
+ return runEnforced(config, executeFactory, approved, redacted, freshBasis, cwBasis, monitoringDelivery, monitoringAttestation, grantCtx, grantObs);
69698
70633
  }
69699
70634
  breakerRecord(config);
69700
- return closedIntegrity(config, receiptVerified ? "MONITORING_UNWIRED" : "RECEIPT_MISSING", failPolicy, fctx, cwctx, redacted, detection.artifacts, monitoringDelivery);
70635
+ return closedIntegrity(config, receiptVerified ? "MONITORING_UNWIRED" : "RECEIPT_MISSING", failPolicy, fctx, cwctx, redacted, detection.artifacts, monitoringDelivery, monitoringAttestation, grantObs);
69701
70636
  }
69702
- function closedIntegrity(config, cause, failPolicy, fctx, cwctx, redacted, arts, monitoring_delivery) {
70637
+ function closedIntegrity(config, cause, failPolicy, fctx, cwctx, redacted, arts, monitoring_delivery, monitoring_attestation, grantObs) {
69703
70638
  const count = breakers.get(config)?.fails.length ?? 1;
69704
70639
  emit(config, { type: "breaker_tripped", at: iso(), cause });
69705
70640
  const v = unavailableVerdict({ cause, failPolicy, resolution: "CLOSED", action: "STOP" }, count);
69706
70641
  const { basis } = freshnessFor(config, redacted, fctx, arts);
69707
70642
  const { basis: cw } = conditionalWriteFor(config, redacted, cwctx);
69708
- return blocked(v, false, basis, cw, monitoring_delivery);
70643
+ return blocked(config, v, false, basis, cw, monitoring_delivery, monitoring_attestation, grantObs);
69709
70644
  }
69710
70645
  function isExpired(envelope) {
69711
70646
  const exp = envelope.expires_at;
@@ -70133,6 +71068,114 @@ var require_session_taint = __commonJS({
70133
71068
  }
70134
71069
  });
70135
71070
 
71071
+ // node_modules/@coderifts/agent-guard/dist/cjs/coverage-attestation.js
71072
+ var require_coverage_attestation = __commonJS({
71073
+ "node_modules/@coderifts/agent-guard/dist/cjs/coverage-attestation.js"(exports2) {
71074
+ "use strict";
71075
+ Object.defineProperty(exports2, "__esModule", { value: true });
71076
+ exports2.COVERAGE_ATTEST_ENVELOPE_TAG = exports2.COVERAGE_ATTEST_SIGNING_PREFIX = exports2.COVERAGE_ATTEST_VERSION = void 0;
71077
+ exports2.coverageAttestSigningInput = coverageAttestSigningInput;
71078
+ exports2.tryIssueCoverageAttestation = tryIssueCoverageAttestation;
71079
+ exports2.kidFromCoverageAttestation = kidFromCoverageAttestation;
71080
+ exports2.COVERAGE_ATTEST_VERSION = "cr.coverage.attest.v1";
71081
+ exports2.COVERAGE_ATTEST_SIGNING_PREFIX = "crcovattest.v1";
71082
+ exports2.COVERAGE_ATTEST_ENVELOPE_TAG = "cr.coverage.attest.v1";
71083
+ var ENVELOPE_CLASSES = ["INCOMPLETE_OBSERVED", "UNKNOWN_OUTSIDE_SCOPE"];
71084
+ var NUL = "";
71085
+ function scalar(v) {
71086
+ return v == null ? "" : String(v);
71087
+ }
71088
+ function canonicalUngoverned(list) {
71089
+ return Array.isArray(list) ? list.map((s) => String(s)).join(NUL) : "";
71090
+ }
71091
+ function coverageAttestSigningInput(body) {
71092
+ const parts = [
71093
+ exports2.COVERAGE_ATTEST_SIGNING_PREFIX,
71094
+ scalar(body.kid),
71095
+ scalar(body.session_id),
71096
+ scalar(body.observed_class),
71097
+ body.governed_calls != null ? String(body.governed_calls) : "",
71098
+ body.total_calls != null ? String(body.total_calls) : "",
71099
+ canonicalUngoverned(body.ungoverned_tools),
71100
+ scalar(body.decision_id),
71101
+ scalar(body.receipt_digest),
71102
+ scalar(body.observed_at)
71103
+ ];
71104
+ return parts.join("|");
71105
+ }
71106
+ function b64url(buf) {
71107
+ return buf.toString("base64url");
71108
+ }
71109
+ function hasHalfB(cov) {
71110
+ return cov.class !== "UNKNOWN_OUTSIDE_SCOPE" && typeof cov.total_calls === "number";
71111
+ }
71112
+ async function tryIssueCoverageAttestation(args) {
71113
+ const cfg = args.config;
71114
+ if (!cfg || typeof cfg.kid !== "string" || !cfg.kid || typeof cfg.signer !== "function") {
71115
+ return void 0;
71116
+ }
71117
+ if (typeof cfg.sessionId !== "string" || cfg.sessionId.length === 0)
71118
+ return void 0;
71119
+ const cov = args.coverage;
71120
+ if (!cov || typeof cov !== "object")
71121
+ return void 0;
71122
+ if (typeof cov.governed_calls !== "number" || !Number.isInteger(cov.governed_calls) || cov.governed_calls < 0) {
71123
+ return void 0;
71124
+ }
71125
+ const halfB = hasHalfB(cov);
71126
+ const observed_class = halfB ? "INCOMPLETE_OBSERVED" : "UNKNOWN_OUTSIDE_SCOPE";
71127
+ if (!ENVELOPE_CLASSES.includes(observed_class))
71128
+ return void 0;
71129
+ const body = {
71130
+ v: exports2.COVERAGE_ATTEST_VERSION,
71131
+ kid: cfg.kid,
71132
+ session_id: cfg.sessionId,
71133
+ observed_class,
71134
+ governed_calls: cov.governed_calls,
71135
+ observed_at: args.now || (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "Z")
71136
+ };
71137
+ if (halfB) {
71138
+ const withTotals = cov;
71139
+ if (!Number.isInteger(withTotals.total_calls) || withTotals.total_calls < cov.governed_calls) {
71140
+ return void 0;
71141
+ }
71142
+ body.total_calls = withTotals.total_calls;
71143
+ body.ungoverned_tools = Array.isArray(withTotals.ungoverned_tools) ? withTotals.ungoverned_tools.map((s) => String(s)) : [];
71144
+ }
71145
+ if (typeof args.decisionId === "string" && args.decisionId)
71146
+ body.decision_id = args.decisionId;
71147
+ if (typeof args.receiptDigest === "string" && args.receiptDigest)
71148
+ body.receipt_digest = args.receiptDigest;
71149
+ const input = Buffer.from(coverageAttestSigningInput(body), "utf8");
71150
+ let sig;
71151
+ try {
71152
+ sig = await cfg.signer(input);
71153
+ } catch {
71154
+ return void 0;
71155
+ }
71156
+ if (sig == null)
71157
+ return void 0;
71158
+ const sigBuf = Buffer.isBuffer(sig) ? sig : Buffer.from(sig);
71159
+ if (sigBuf.length === 0)
71160
+ return void 0;
71161
+ return [
71162
+ exports2.COVERAGE_ATTEST_ENVELOPE_TAG,
71163
+ cfg.kid,
71164
+ b64url(Buffer.from(JSON.stringify(body), "utf8")),
71165
+ b64url(sigBuf)
71166
+ ].join("|");
71167
+ }
71168
+ function kidFromCoverageAttestation(token) {
71169
+ if (typeof token !== "string" || token.length === 0)
71170
+ return null;
71171
+ const parts = token.split("|");
71172
+ if (parts.length !== 4 || parts[0] !== exports2.COVERAGE_ATTEST_ENVELOPE_TAG)
71173
+ return null;
71174
+ return parts[1] || null;
71175
+ }
71176
+ }
71177
+ });
71178
+
70136
71179
  // node_modules/@coderifts/agent-guard/dist/cjs/final-answer-proof.js
70137
71180
  var require_final_answer_proof = __commonJS({
70138
71181
  "node_modules/@coderifts/agent-guard/dist/cjs/final-answer-proof.js"(exports2) {
@@ -70143,9 +71186,15 @@ var require_final_answer_proof = __commonJS({
70143
71186
  exports2.attachProofToAgentResponse = attachProofToAgentResponse;
70144
71187
  var execution_proof_js_1 = require_execution_proof();
70145
71188
  var monitoring_delivery_js_1 = require_monitoring_delivery();
71189
+ var monitoring_attestation_js_1 = require_monitoring_attestation2();
71190
+ var coverage_observed_js_1 = require_coverage_observed();
70146
71191
  function deriveProofBanner(proof) {
70147
71192
  if (!proof || typeof proof !== "object")
70148
71193
  return "NO_PREFLIGHT";
71194
+ if (proof.commit_label === "authorized_and_committed")
71195
+ return "AUTHORIZED_AND_COMMITTED";
71196
+ if (proof.commit_label === "authorized_not_committed")
71197
+ return "AUTHORIZED_NOT_COMMITTED";
70149
71198
  if (proof.currently_authorized === null) {
70150
71199
  return "NOT_EVALUATED_SKIPPED";
70151
71200
  }
@@ -70160,6 +71209,10 @@ var require_final_answer_proof = __commonJS({
70160
71209
  switch (banner) {
70161
71210
  case "ENFORCED":
70162
71211
  return "ENFORCED \u2014 receipt verified; call ran on the guarded path";
71212
+ case "AUTHORIZED_AND_COMMITTED":
71213
+ return "AUTHORIZED AND COMMITTED \u2014 executor-attested CAS (grant/receipt cross-checked)";
71214
+ case "AUTHORIZED_NOT_COMMITTED":
71215
+ return "authorized; commit not proven (no executor attestation)";
70163
71216
  case "AUTHORIZED":
70164
71217
  return "AUTHORIZED \u2014 receipt verified for this scope (not a claim of full host protection)";
70165
71218
  case "NOT_AUTHORIZED":
@@ -70286,7 +71339,13 @@ var require_final_answer_proof = __commonJS({
70286
71339
  if (co.token)
70287
71340
  lines.push(bullet(`token: ${co.token}`));
70288
71341
  const ce = proof.cas_evidence;
70289
- if (ce && ce.class === "executor_attested") {
71342
+ if (proof.commit_label === "authorized_not_committed") {
71343
+ lines.push(bullet("authorized; commit not proven (no executor attestation)"));
71344
+ if (proof.commit_evidence_reason) {
71345
+ lines.push(bullet(`reason: ${proof.commit_evidence_reason}`));
71346
+ }
71347
+ lines.push(bullet("Observed at T3, not atomic: another writer may act between write and observation; token-only adapters compare version token not content; host attestation is a host claim layered on the measurement."));
71348
+ } else if (ce && ce.class === "executor_attested") {
70290
71349
  const kid = ce.executor_kid != null ? ce.executor_kid : "\u2026";
70291
71350
  const st = ce.attest_status != null ? ce.attest_status : "ATTEST_VALID";
70292
71351
  lines.push(bullet(`committed \u2014 executor-attested (${st}, kid ${kid})`));
@@ -70302,8 +71361,19 @@ var require_final_answer_proof = __commonJS({
70302
71361
  const mdv = proof.monitoring_delivery;
70303
71362
  if (mdv && typeof mdv === "object" && typeof mdv.status === "string") {
70304
71363
  lines.push(h2("Monitoring delivery"));
70305
- lines.push(bullet((0, monitoring_delivery_js_1.formatMonitoringDeliveryLine)(mdv)));
71364
+ const attestedKid = (0, monitoring_attestation_js_1.kidFromMonitoringAttestation)(proof.monitoring_attestation);
71365
+ lines.push(bullet((0, monitoring_delivery_js_1.formatMonitoringDeliveryLine)(mdv, attestedKid)));
70306
71366
  lines.push(bullet("delivered_acked means the sink returned an ack \u2014 it does NOT mean a human saw the event."));
71367
+ if (attestedKid) {
71368
+ lines.push(bullet("attested means a holder of the monitoring key observed this delivery status \u2014 not that a human read the alert, and not that the sink is configured for the right audience."));
71369
+ }
71370
+ lines.push("");
71371
+ }
71372
+ const cov = proof.coverage_observed;
71373
+ if (cov && typeof cov === "object" && typeof cov.class === "string") {
71374
+ lines.push(h2("Coverage (observed)"));
71375
+ lines.push(bullet((0, coverage_observed_js_1.formatCoverageObservedLine)(cov)));
71376
+ lines.push(bullet(`class: ${cov.class}`));
70307
71377
  lines.push("");
70308
71378
  }
70309
71379
  lines.push(h2("Limits (non-claims \u2014 always true on this proof)"));
@@ -71625,6 +72695,64 @@ var require_auto_derive = __commonJS({
71625
72695
  }
71626
72696
  });
71627
72697
 
72698
+ // node_modules/@coderifts/agent-guard/dist/cjs/cas-adapters/fs-default-wire.js
72699
+ var require_fs_default_wire = __commonJS({
72700
+ "node_modules/@coderifts/agent-guard/dist/cjs/cas-adapters/fs-default-wire.js"(exports2) {
72701
+ "use strict";
72702
+ Object.defineProperty(exports2, "__esModule", { value: true });
72703
+ exports2.inferFsPathFromArgs = inferFsPathFromArgs;
72704
+ exports2.inferFullFileWriteContent = inferFullFileWriteContent;
72705
+ exports2.wrapWriteWithFsCas = wrapWriteWithFsCas;
72706
+ var cas_attestation_js_1 = require_cas_attestation();
72707
+ var fs_js_1 = require_fs();
72708
+ function inferFsPathFromArgs(args) {
72709
+ if (!args || typeof args !== "object")
72710
+ return null;
72711
+ const path = args.path;
72712
+ if (typeof path !== "string")
72713
+ return null;
72714
+ const trimmed = path.trim();
72715
+ if (!trimmed)
72716
+ return null;
72717
+ if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(trimmed))
72718
+ return null;
72719
+ return trimmed;
72720
+ }
72721
+ function inferFullFileWriteContent(args) {
72722
+ if (!args || typeof args !== "object")
72723
+ return null;
72724
+ const a = args;
72725
+ if (typeof a.contents === "string")
72726
+ return a.contents;
72727
+ if (typeof a.content === "string" && a.old_string == null && a.new_string == null) {
72728
+ return a.content;
72729
+ }
72730
+ return null;
72731
+ }
72732
+ async function wrapWriteWithFsCas(args, write) {
72733
+ const filePath = inferFsPathFromArgs(args);
72734
+ const content = inferFullFileWriteContent(args);
72735
+ if (filePath && content != null) {
72736
+ let expected;
72737
+ try {
72738
+ expected = await (0, fs_js_1.createFsVersionToken)(filePath);
72739
+ } catch {
72740
+ return write();
72741
+ }
72742
+ return (0, fs_js_1.writeFileIfUnchanged)({
72743
+ path: filePath,
72744
+ expected_token: expected,
72745
+ content
72746
+ });
72747
+ }
72748
+ const raw = await write();
72749
+ if ((0, cas_attestation_js_1.isExecuteIfUnchangedOutcome)(raw))
72750
+ return raw;
72751
+ return raw;
72752
+ }
72753
+ }
72754
+ });
72755
+
71628
72756
  // node_modules/@coderifts/agent-guard/dist/cjs/tool-registry.js
71629
72757
  var require_tool_registry = __commonJS({
71630
72758
  "node_modules/@coderifts/agent-guard/dist/cjs/tool-registry.js"(exports2) {
@@ -71637,6 +72765,7 @@ var require_tool_registry = __commonJS({
71637
72765
  var freshness_js_1 = require_freshness();
71638
72766
  var auto_recheck_js_1 = require_auto_recheck();
71639
72767
  var auto_derive_js_1 = require_auto_derive();
72768
+ var fs_default_wire_js_1 = require_fs_default_wire();
71640
72769
  var RegistryConstructionError = class extends Error {
71641
72770
  code;
71642
72771
  toolName;
@@ -71815,7 +72944,10 @@ var require_tool_registry = __commonJS({
71815
72944
  resolvePriorContent: guardCfg.resolvePriorContent
71816
72945
  });
71817
72946
  const fctx = await refreshContext(call);
71818
- const factory = async (_envelope, redacted) => rawExecute(redacted ? redacted.arguments : args);
72947
+ const factory = async (_envelope, redacted, execution) => {
72948
+ const rawArgs = redacted ? redacted.arguments : args;
72949
+ return (0, fs_default_wire_js_1.wrapWriteWithFsCas)(rawArgs, () => execution ? rawExecute(rawArgs, execution) : rawExecute(rawArgs));
72950
+ };
71819
72951
  const outcome = (0, auto_recheck_js_1.normalizeAutoRecheck)(guardCfg.autoRecheck) ? await (0, auto_recheck_js_1.runAutoRecheckLoop)({
71820
72952
  call,
71821
72953
  factory,
@@ -72719,6 +73851,7 @@ var require_with_coderifts = __commonJS({
72719
73851
  exports2.guardedFractionAmongRoutes = guardedFractionAmongRoutes;
72720
73852
  exports2.withCodeRifts = withCodeRifts;
72721
73853
  var tool_registry_js_1 = require_tool_registry();
73854
+ var coverage_observed_js_1 = require_coverage_observed();
72722
73855
  function foldTableSettledCalls(events) {
72723
73856
  const counts = { GUARDED: 0, PASSTHROUGH: 0, BYPASSED: 0 };
72724
73857
  for (const e of events) {
@@ -72745,6 +73878,7 @@ var require_with_coderifts = __commonJS({
72745
73878
  var RESIDUAL_CALLS_OUTSIDE_GUARDED_PATH = "calls_outside_guarded_path_invisible";
72746
73879
  var RESIDUAL_FORCED_READONLY = "composition_forced_readonly_on_heuristic_mutator";
72747
73880
  var RESIDUAL_UNKNOWN_READONLY = "composition_unknown_treated_as_readonly";
73881
+ var RESIDUAL_GRANT_BEARER_NO_STATE_NONCE = "execution_grant_bearer_no_state_nonce";
72748
73882
  var COVERAGE_STRENGTH = {
72749
73883
  COMPLETE: 3,
72750
73884
  PARTIAL: 2,
@@ -72757,6 +73891,20 @@ var require_with_coderifts = __commonJS({
72757
73891
  function isEnforcingStrict(input) {
72758
73892
  return input.profile === "ENFORCING_STRICT";
72759
73893
  }
73894
+ function enforcingStrictExecutionChainProblems(input) {
73895
+ const grant = input.executionGrant;
73896
+ const enabled = !!(grant && grant.enabled === true);
73897
+ if (enabled)
73898
+ return [];
73899
+ const what = grant === void 0 ? "executionGrant is absent" : "executionGrant.enabled is not true";
73900
+ return [
73901
+ `ENFORCING_STRICT requires the execution chain, but ${what}. Without a grant the guard authorizes a change but nothing binds the executor to it, so a commit can never be proven (the outcome stays authorized_not_committed / commit_evidence_missing). Add:
73902
+ executionGrant: { enabled: true }
73903
+ and, for the ATOMIC profile (single-use at the executor), also:
73904
+ executionGrant: { enabled: true, resolveStateNonce: ({ artifactId }) => nonceFor(artifactId) }
73905
+ A grant without resolveStateNonce is the BEARER profile: permitted under strict, and recorded as residual ${RESIDUAL_GRANT_BEARER_NO_STATE_NONCE}.`
73906
+ ];
73907
+ }
72760
73908
  function enforcingStrictWeakenFlags(input) {
72761
73909
  const flags = [];
72762
73910
  if (input.requireCoverage !== void 0) {
@@ -72924,6 +74072,23 @@ var require_with_coderifts = __commonJS({
72924
74072
  };
72925
74073
  return state;
72926
74074
  }
74075
+ function wrapForCoverageObserved(tool, observer) {
74076
+ const innerExecute = tool.execute;
74077
+ const shell = {
74078
+ name: tool.name,
74079
+ description: tool.description,
74080
+ inputSchema: tool.inputSchema,
74081
+ meta: tool.meta,
74082
+ _coderifts: tool._coderifts,
74083
+ execute: async (args) => {
74084
+ observer.recordGoverned(tool.name);
74085
+ return innerExecute(args);
74086
+ }
74087
+ };
74088
+ if (!Object.isFrozen(shell._coderifts))
74089
+ Object.freeze(shell._coderifts);
74090
+ return Object.freeze(shell);
74091
+ }
72927
74092
  function wrapForReceiptCursor(tool, cursor) {
72928
74093
  if (!tool._coderifts.guarded || !cursor.enabled)
72929
74094
  return tool;
@@ -72977,6 +74142,7 @@ var require_with_coderifts = __commonJS({
72977
74142
  if (typeof input.resolvePriorContent !== "function") {
72978
74143
  problems.push("ENFORCING_STRICT cannot be weakened: resolvePriorContent conflicts");
72979
74144
  }
74145
+ problems.push(...enforcingStrictExecutionChainProblems(input));
72980
74146
  }
72981
74147
  if (problems.length > 0) {
72982
74148
  throw new Error(`withCodeRifts: construction aborted \u2014 ${problems.length} condition(s):
@@ -72986,7 +74152,8 @@ var require_with_coderifts = __commonJS({
72986
74152
  const threadReceipts = input.threadReceipts !== false;
72987
74153
  const receiptCursor = createReceiptCursor(threadReceipts);
72988
74154
  const hostPreviousReceipt = input.previousReceipt;
72989
- const guard = { client: input.client, operation: input.operation };
74155
+ const coverageObserver = (0, coverage_observed_js_1.createCoverageObserver)();
74156
+ const guard = { client: input.client, operation: input.operation, coverageObserver };
72990
74157
  if (input.onEvent !== void 0) {
72991
74158
  guard.onEvent = input.onEvent;
72992
74159
  }
@@ -73040,6 +74207,15 @@ var require_with_coderifts = __commonJS({
73040
74207
  if (input.executorAttestation !== void 0) {
73041
74208
  guard.executorAttestation = input.executorAttestation;
73042
74209
  }
74210
+ if (input.monitoringAttestation !== void 0) {
74211
+ guard.monitoringAttestation = input.monitoringAttestation;
74212
+ }
74213
+ if (input.systemPrompt !== void 0) {
74214
+ guard.systemPrompt = input.systemPrompt;
74215
+ }
74216
+ if (input.executionGrant !== void 0) {
74217
+ guard.executionGrant = input.executionGrant;
74218
+ }
73043
74219
  const strict = isEnforcingStrict(input);
73044
74220
  if (strict) {
73045
74221
  guard.requireFreshness = true;
@@ -73057,6 +74233,7 @@ var require_with_coderifts = __commonJS({
73057
74233
  };
73058
74234
  const requireCoverage = strict ? "COMPLETE" : input.requireCoverage;
73059
74235
  const { tools, report } = (0, tool_registry_js_1.guardToolRegistry)(input.tools, config);
74236
+ coverageObserver.setTableNames(tools.map((t) => t.name));
73060
74237
  if (requireCoverage !== void 0) {
73061
74238
  const requiredRank = coverageRank(requireCoverage);
73062
74239
  const actualRank = coverageRank(report.coverage) ?? -1;
@@ -73072,6 +74249,12 @@ var require_with_coderifts = __commonJS({
73072
74249
  if (report.warnings.includes("unknown_treated_as_readonly")) {
73073
74250
  residuals.push(RESIDUAL_UNKNOWN_READONLY);
73074
74251
  }
74252
+ {
74253
+ const g = input.executionGrant;
74254
+ if (g && g.enabled === true && typeof g.resolveStateNonce !== "function") {
74255
+ residuals.push(RESIDUAL_GRANT_BEARER_NO_STATE_NONCE);
74256
+ }
74257
+ }
73075
74258
  const freshness_resolver_wired = typeof input.resolvePriorContent === "function";
73076
74259
  if (!freshness_resolver_wired) {
73077
74260
  residuals.push(RESIDUAL_FRESHNESS_NOT_CONFIGURED);
@@ -73085,9 +74268,13 @@ var require_with_coderifts = __commonJS({
73085
74268
  const composition_assurance = {
73086
74269
  coverage: "PARTIAL",
73087
74270
  inescapable_runtime: compositionInescapableRuntime,
73088
- residuals,
73089
- freshness_resolver_wired
74271
+ residuals: Object.freeze(residuals.slice()),
74272
+ freshness_resolver_wired,
74273
+ get observed_class() {
74274
+ return coverageObserver.snapshot().class;
74275
+ }
73090
74276
  };
74277
+ Object.freeze(composition_assurance);
73091
74278
  let toolsOut = tools;
73092
74279
  if (threadReceipts) {
73093
74280
  toolsOut = toolsOut.map((t) => wrapForReceiptCursor(t, receiptCursor));
@@ -73099,11 +74286,13 @@ var require_with_coderifts = __commonJS({
73099
74286
  } else if (threadReceipts) {
73100
74287
  toolsOut = Object.freeze(toolsOut);
73101
74288
  }
74289
+ toolsOut = Object.freeze(toolsOut.map((t) => wrapForCoverageObserved(t, coverageObserver)));
73102
74290
  const result = {
73103
74291
  tools: toolsOut,
73104
74292
  registry_report: report,
73105
74293
  composition_assurance,
73106
- receipt_thread: receiptCursor.handle
74294
+ receipt_thread: receiptCursor.handle,
74295
+ coverage_observed: coverageObserver.handle
73107
74296
  };
73108
74297
  if (input.repository !== void 0)
73109
74298
  result.repository = input.repository;
@@ -73112,6 +74301,73 @@ var require_with_coderifts = __commonJS({
73112
74301
  }
73113
74302
  });
73114
74303
 
74304
+ // node_modules/@coderifts/agent-guard/dist/cjs/gate-refusal.js
74305
+ var require_gate_refusal = __commonJS({
74306
+ "node_modules/@coderifts/agent-guard/dist/cjs/gate-refusal.js"(exports2) {
74307
+ "use strict";
74308
+ Object.defineProperty(exports2, "__esModule", { value: true });
74309
+ exports2.FRESHNESS_RESOLVER_FIX = void 0;
74310
+ exports2.verdictKind = verdictKind;
74311
+ exports2.verdictCause = verdictCause;
74312
+ exports2.freshnessRefusalTeaching = freshnessRefusalTeaching;
74313
+ exports2.formatGateRefusalBody = formatGateRefusalBody;
74314
+ exports2.formatGuardError = formatGuardError;
74315
+ exports2.FRESHNESS_RESOLVER_FIX = "pass resolvePriorContent (e.g. createFsPriorContentResolver()) to withCodeRifts / GuardConfig";
74316
+ function verdictKind(outcome) {
74317
+ const v = outcome.verdict;
74318
+ return v && typeof v === "object" && "kind" in v ? String(v.kind) : "UNKNOWN";
74319
+ }
74320
+ function verdictCause(outcome) {
74321
+ const v = outcome.verdict;
74322
+ if (v && typeof v === "object" && "cause" in v && typeof v.cause === "string") {
74323
+ return v.cause;
74324
+ }
74325
+ return void 0;
74326
+ }
74327
+ function freshnessRefusalTeaching(outcome) {
74328
+ const cause = verdictCause(outcome);
74329
+ const basis = outcome.freshness;
74330
+ const wiring = basis && typeof basis === "object" ? basis.wiring : void 0;
74331
+ const degradeReason = basis && basis.wiring === "DEGRADED" && basis.degrade ? basis.degrade.reason : void 0;
74332
+ const assessment = basis && basis.wiring === "ACTIVE" && basis.assessment ? basis.assessment.outcome : void 0;
74333
+ if (cause === "FRESHNESS_REQUIRED") {
74334
+ if (wiring === "NOT_CONFIGURED") {
74335
+ return `cause: FRESHNESS_REQUIRED \u2014 resolvePriorContent / prior-content resolver not configured. One-line fix: ${exports2.FRESHNESS_RESOLVER_FIX}.`;
74336
+ }
74337
+ if (wiring === "DEGRADED") {
74338
+ const why = degradeReason || "resolver_returned_empty";
74339
+ return `cause: FRESHNESS_REQUIRED \u2014 prior-content resolver is configured but DEGRADED (${why}). Fix the resolver so it returns current file bytes.`;
74340
+ }
74341
+ return `cause: FRESHNESS_REQUIRED \u2014 freshness measurement was required and was not ACTIVE. One-line fix: ${exports2.FRESHNESS_RESOLVER_FIX}.`;
74342
+ }
74343
+ if (cause === "FRESHNESS_FAILED") {
74344
+ const o = assessment || "UNKNOWN";
74345
+ return `cause: FRESHNESS_FAILED \u2014 prior-content measurement ran and fail-closed (${o}). Re-preflight with current bytes; do not retry the stale change-set.`;
74346
+ }
74347
+ return null;
74348
+ }
74349
+ function formatGateRefusalBody(outcome) {
74350
+ const kind = verdictKind(outcome);
74351
+ let body = `CodeRifts gate did not permit execution (verdict: ${kind}). No tool result was produced.`;
74352
+ const teach = freshnessRefusalTeaching(outcome);
74353
+ if (teach)
74354
+ body += ` ${teach}`;
74355
+ return body;
74356
+ }
74357
+ function formatGuardError(err) {
74358
+ if (err instanceof Error)
74359
+ return err.message || err.name || "Error";
74360
+ if (typeof err === "string")
74361
+ return err;
74362
+ try {
74363
+ return JSON.stringify(err);
74364
+ } catch {
74365
+ return String(err);
74366
+ }
74367
+ }
74368
+ }
74369
+ });
74370
+
73115
74371
  // node_modules/@coderifts/agent-guard/dist/cjs/adapters/openai.js
73116
74372
  var require_openai = __commonJS({
73117
74373
  "node_modules/@coderifts/agent-guard/dist/cjs/adapters/openai.js"(exports2) {
@@ -73125,6 +74381,7 @@ var require_openai = __commonJS({
73125
74381
  exports2.bindOpenAIGuardOutcome = bindOpenAIGuardOutcome;
73126
74382
  var with_coderifts_js_1 = require_with_coderifts();
73127
74383
  var final_answer_proof_js_1 = require_final_answer_proof();
74384
+ var gate_refusal_js_1 = require_gate_refusal();
73128
74385
  var EMPTY_PARAMETERS = Object.freeze({
73129
74386
  type: "object",
73130
74387
  properties: {}
@@ -73155,7 +74412,8 @@ var require_openai = __commonJS({
73155
74412
  protected_tools,
73156
74413
  registry_report: result.registry_report,
73157
74414
  composition_assurance: result.composition_assurance,
73158
- receipt_thread: result.receipt_thread
74415
+ receipt_thread: result.receipt_thread,
74416
+ coverage_observed: result.coverage_observed
73159
74417
  };
73160
74418
  if (result.repository !== void 0) {
73161
74419
  out.repository = result.repository;
@@ -73181,12 +74439,11 @@ var require_openai = __commonJS({
73181
74439
  if (outcome.executed === true) {
73182
74440
  body = serialize(outcome.result);
73183
74441
  } else if (outcome.executionAttempted === false) {
73184
- const kind = outcome.verdict && typeof outcome.verdict === "object" && "kind" in outcome.verdict ? String(outcome.verdict.kind) : "UNKNOWN";
73185
- body = `CodeRifts gate did not permit execution (verdict: ${kind}). No tool result was produced.`;
74442
+ body = (0, gate_refusal_js_1.formatGateRefusalBody)(outcome);
73186
74443
  } else {
73187
74444
  const err = "error" in outcome ? outcome.error : void 0;
73188
- const errText = formatGuardError(err);
73189
- const kind = outcome.verdict && typeof outcome.verdict === "object" && "kind" in outcome.verdict ? String(outcome.verdict.kind) : "UNKNOWN";
74445
+ const errText = (0, gate_refusal_js_1.formatGuardError)(err);
74446
+ const kind = (0, gate_refusal_js_1.verdictKind)(outcome);
73190
74447
  body = `Tool execution failed after gate decision (verdict: ${kind}): ${errText}`;
73191
74448
  }
73192
74449
  const content = args.attachProof === false ? body : (0, final_answer_proof_js_1.attachProofToAgentResponse)(body, outcome.proof);
@@ -73197,17 +74454,6 @@ var require_openai = __commonJS({
73197
74454
  };
73198
74455
  return msg;
73199
74456
  }
73200
- function formatGuardError(err) {
73201
- if (err instanceof Error)
73202
- return err.message || err.name || "Error";
73203
- if (typeof err === "string")
73204
- return err;
73205
- try {
73206
- return JSON.stringify(err);
73207
- } catch {
73208
- return String(err);
73209
- }
73210
- }
73211
74457
  }
73212
74458
  });
73213
74459
 
@@ -73224,6 +74470,7 @@ var require_anthropic = __commonJS({
73224
74470
  exports2.bindAnthropicGuardOutcome = bindAnthropicGuardOutcome;
73225
74471
  var with_coderifts_js_1 = require_with_coderifts();
73226
74472
  var final_answer_proof_js_1 = require_final_answer_proof();
74473
+ var gate_refusal_js_1 = require_gate_refusal();
73227
74474
  var EMPTY_INPUT_SCHEMA = Object.freeze({
73228
74475
  type: "object",
73229
74476
  properties: {}
@@ -73254,7 +74501,8 @@ var require_anthropic = __commonJS({
73254
74501
  protected_tools,
73255
74502
  registry_report: result.registry_report,
73256
74503
  composition_assurance: result.composition_assurance,
73257
- receipt_thread: result.receipt_thread
74504
+ receipt_thread: result.receipt_thread,
74505
+ coverage_observed: result.coverage_observed
73258
74506
  };
73259
74507
  if (result.repository !== void 0) {
73260
74508
  out.repository = result.repository;
@@ -73280,12 +74528,11 @@ var require_anthropic = __commonJS({
73280
74528
  if (outcome.executed === true) {
73281
74529
  body = serialize(outcome.result);
73282
74530
  } else if (outcome.executionAttempted === false) {
73283
- const kind = verdictKind(outcome);
73284
- body = `CodeRifts gate did not permit execution (verdict: ${kind}). No tool result was produced.`;
74531
+ body = (0, gate_refusal_js_1.formatGateRefusalBody)(outcome);
73285
74532
  } else {
73286
74533
  const err = "error" in outcome ? outcome.error : void 0;
73287
- const kind = verdictKind(outcome);
73288
- body = `Tool execution failed after gate decision (verdict: ${kind}): ${formatGuardError(err)}`;
74534
+ const kind = (0, gate_refusal_js_1.verdictKind)(outcome);
74535
+ body = `Tool execution failed after gate decision (verdict: ${kind}): ${(0, gate_refusal_js_1.formatGuardError)(err)}`;
73289
74536
  }
73290
74537
  const content = args.attachProof === false ? body : (0, final_answer_proof_js_1.attachProofToAgentResponse)(body, outcome.proof);
73291
74538
  const block = {
@@ -73295,20 +74542,6 @@ var require_anthropic = __commonJS({
73295
74542
  };
73296
74543
  return block;
73297
74544
  }
73298
- function verdictKind(outcome) {
73299
- return outcome.verdict && typeof outcome.verdict === "object" && "kind" in outcome.verdict ? String(outcome.verdict.kind) : "UNKNOWN";
73300
- }
73301
- function formatGuardError(err) {
73302
- if (err instanceof Error)
73303
- return err.message || err.name || "Error";
73304
- if (typeof err === "string")
73305
- return err;
73306
- try {
73307
- return JSON.stringify(err);
73308
- } catch {
73309
- return String(err);
73310
- }
73311
- }
73312
74545
  }
73313
74546
  });
73314
74547
 
@@ -73317,34 +74550,65 @@ var require_langgraph = __commonJS({
73317
74550
  "node_modules/@coderifts/agent-guard/dist/cjs/adapters/langgraph.js"(exports2) {
73318
74551
  "use strict";
73319
74552
  Object.defineProperty(exports2, "__esModule", { value: true });
74553
+ exports2.LangGraphToolsNotStructuredError = void 0;
74554
+ exports2.isLangGraphReactAgentTool = isLangGraphReactAgentTool;
73320
74555
  exports2.protectedToolToLangGraph = protectedToolToLangGraph;
73321
74556
  exports2.toLangGraphTools = toLangGraphTools;
74557
+ exports2.bindLangGraphTools = bindLangGraphTools;
73322
74558
  exports2.withCodeRiftsLangGraph = withCodeRiftsLangGraph;
73323
74559
  exports2.langGraphToolAdapter = langGraphToolAdapter;
73324
74560
  exports2.defaultSerializeLangGraphToolResult = defaultSerializeLangGraphToolResult;
73325
74561
  exports2.bindLangGraphGuardOutcome = bindLangGraphGuardOutcome;
73326
74562
  var with_coderifts_js_1 = require_with_coderifts();
73327
74563
  var final_answer_proof_js_1 = require_final_answer_proof();
74564
+ var gate_refusal_js_1 = require_gate_refusal();
74565
+ var LangGraphToolsNotStructuredError = class extends Error {
74566
+ constructor(message) {
74567
+ super(message ?? "withCodeRiftsLangGraph() tools are not StructuredTool-compatible for createReactAgent. createReactAgent (@langchain/langgraph) requires StructuredToolInterface | DynamicTool | RunnableToolLike (name, description, schema, invoke, lc_runnable). Fix: wrap with tool() from @langchain/core/tools \u2014 see README (LangChain / LangGraph).");
74568
+ this.name = "LangGraphToolsNotStructuredError";
74569
+ }
74570
+ };
74571
+ exports2.LangGraphToolsNotStructuredError = LangGraphToolsNotStructuredError;
74572
+ function isLangGraphReactAgentTool(t) {
74573
+ if (!t || typeof t !== "object")
74574
+ return false;
74575
+ const o = t;
74576
+ return typeof o.name === "string" && o.name.length > 0 && typeof o.description === "string" && o.schema != null && typeof o.schema === "object" && !Array.isArray(o.schema) && typeof o.invoke === "function" && typeof o.func === "function" && o.lc_runnable === true;
74577
+ }
73328
74578
  var EMPTY_SCHEMA = Object.freeze({
73329
74579
  type: "object",
73330
74580
  properties: {}
73331
74581
  });
73332
74582
  function protectedToolToLangGraph(tool) {
73333
74583
  const schema = tool.inputSchema != null && typeof tool.inputSchema === "object" && !Array.isArray(tool.inputSchema) ? tool.inputSchema : { ...EMPTY_SCHEMA };
73334
- const guarded = (args) => Promise.resolve(tool.execute(args));
74584
+ const guarded = (args, _config) => Promise.resolve().then(() => tool.execute(args));
74585
+ const description = tool.description != null && tool.description !== "" ? tool.description : tool.name;
73335
74586
  const out = {
73336
74587
  name: tool.name,
74588
+ description,
73337
74589
  schema,
73338
74590
  func: guarded,
73339
- invoke: guarded
74591
+ invoke: guarded,
74592
+ lc_runnable: true
73340
74593
  };
73341
- if (tool.description != null && tool.description !== "") {
73342
- out.description = tool.description;
74594
+ if (!isLangGraphReactAgentTool(out)) {
74595
+ throw new LangGraphToolsNotStructuredError(`protectedToolToLangGraph(${JSON.stringify(tool.name)}): tool is not createReactAgent-consumable. Fix: wrap with tool() from @langchain/core/tools \u2014 see README (LangChain / LangGraph).`);
73343
74596
  }
73344
74597
  return out;
73345
74598
  }
73346
74599
  function toLangGraphTools(protectedTools) {
73347
- return protectedTools.map(protectedToolToLangGraph);
74600
+ return bindLangGraphTools(protectedTools.map(protectedToolToLangGraph));
74601
+ }
74602
+ function bindLangGraphTools(tools) {
74603
+ const out = [];
74604
+ for (const t of tools) {
74605
+ if (!isLangGraphReactAgentTool(t)) {
74606
+ const n = t && typeof t === "object" && "name" in t ? String(t.name) : "?";
74607
+ throw new LangGraphToolsNotStructuredError(`bindLangGraphTools: ${JSON.stringify(n)} is not StructuredTool-compatible for createReactAgent. Fix: wrap with tool() from @langchain/core/tools \u2014 see README (LangChain / LangGraph).`);
74608
+ }
74609
+ out.push(t);
74610
+ }
74611
+ return out;
73348
74612
  }
73349
74613
  function withCodeRiftsLangGraph(input) {
73350
74614
  const core = (0, with_coderifts_js_1.withCodeRifts)(input);
@@ -73358,7 +74622,8 @@ var require_langgraph = __commonJS({
73358
74622
  protected_tools,
73359
74623
  registry_report: result.registry_report,
73360
74624
  composition_assurance: result.composition_assurance,
73361
- receipt_thread: result.receipt_thread
74625
+ receipt_thread: result.receipt_thread,
74626
+ coverage_observed: result.coverage_observed
73362
74627
  };
73363
74628
  if (result.repository !== void 0) {
73364
74629
  out.repository = result.repository;
@@ -73384,12 +74649,11 @@ var require_langgraph = __commonJS({
73384
74649
  if (outcome.executed === true) {
73385
74650
  body = serialize(outcome.result);
73386
74651
  } else if (outcome.executionAttempted === false) {
73387
- const kind = verdictKind(outcome);
73388
- body = `CodeRifts gate did not permit execution (verdict: ${kind}). No tool result was produced.`;
74652
+ body = (0, gate_refusal_js_1.formatGateRefusalBody)(outcome);
73389
74653
  } else {
73390
74654
  const err = "error" in outcome ? outcome.error : void 0;
73391
- const kind = verdictKind(outcome);
73392
- body = `Tool execution failed after gate decision (verdict: ${kind}): ${formatGuardError(err)}`;
74655
+ const kind = (0, gate_refusal_js_1.verdictKind)(outcome);
74656
+ body = `Tool execution failed after gate decision (verdict: ${kind}): ${(0, gate_refusal_js_1.formatGuardError)(err)}`;
73393
74657
  }
73394
74658
  const content = args.attachProof === false ? body : (0, final_answer_proof_js_1.attachProofToAgentResponse)(body, outcome.proof);
73395
74659
  const msg = {
@@ -73401,20 +74665,6 @@ var require_langgraph = __commonJS({
73401
74665
  }
73402
74666
  return msg;
73403
74667
  }
73404
- function verdictKind(outcome) {
73405
- return outcome.verdict && typeof outcome.verdict === "object" && "kind" in outcome.verdict ? String(outcome.verdict.kind) : "UNKNOWN";
73406
- }
73407
- function formatGuardError(err) {
73408
- if (err instanceof Error)
73409
- return err.message || err.name || "Error";
73410
- if (typeof err === "string")
73411
- return err;
73412
- try {
73413
- return JSON.stringify(err);
73414
- } catch {
73415
- return String(err);
73416
- }
73417
- }
73418
74668
  }
73419
74669
  });
73420
74670
 
@@ -73431,6 +74681,7 @@ var require_gemini = __commonJS({
73431
74681
  exports2.bindGeminiGuardOutcome = bindGeminiGuardOutcome;
73432
74682
  var with_coderifts_js_1 = require_with_coderifts();
73433
74683
  var final_answer_proof_js_1 = require_final_answer_proof();
74684
+ var gate_refusal_js_1 = require_gate_refusal();
73434
74685
  var EMPTY_PARAMETERS = Object.freeze({
73435
74686
  type: "object",
73436
74687
  properties: {}
@@ -73465,7 +74716,8 @@ var require_gemini = __commonJS({
73465
74716
  protected_tools,
73466
74717
  registry_report: result.registry_report,
73467
74718
  composition_assurance: result.composition_assurance,
73468
- receipt_thread: result.receipt_thread
74719
+ receipt_thread: result.receipt_thread,
74720
+ coverage_observed: result.coverage_observed
73469
74721
  };
73470
74722
  if (result.repository !== void 0) {
73471
74723
  out.repository = result.repository;
@@ -73495,15 +74747,12 @@ var require_gemini = __commonJS({
73495
74747
  if (outcome.executed === true) {
73496
74748
  base = { result: serialize(outcome.result) };
73497
74749
  } else if (outcome.executionAttempted === false) {
73498
- const kind = verdictKind(outcome);
73499
- base = {
73500
- gate_message: `CodeRifts gate did not permit execution (verdict: ${kind}). No tool result was produced.`
73501
- };
74750
+ base = { gate_message: (0, gate_refusal_js_1.formatGateRefusalBody)(outcome) };
73502
74751
  } else {
73503
74752
  const err = "error" in outcome ? outcome.error : void 0;
73504
- const kind = verdictKind(outcome);
74753
+ const kind = (0, gate_refusal_js_1.verdictKind)(outcome);
73505
74754
  base = {
73506
- gate_message: `Tool execution failed after gate decision (verdict: ${kind}): ${formatGuardError(err)}`
74755
+ gate_message: `Tool execution failed after gate decision (verdict: ${kind}): ${(0, gate_refusal_js_1.formatGuardError)(err)}`
73507
74756
  };
73508
74757
  }
73509
74758
  const bound = args.attachProof === false ? base : (0, final_answer_proof_js_1.attachProofToAgentResponse)(base, outcome.proof);
@@ -73515,20 +74764,6 @@ var require_gemini = __commonJS({
73515
74764
  };
73516
74765
  return part;
73517
74766
  }
73518
- function verdictKind(outcome) {
73519
- return outcome.verdict && typeof outcome.verdict === "object" && "kind" in outcome.verdict ? String(outcome.verdict.kind) : "UNKNOWN";
73520
- }
73521
- function formatGuardError(err) {
73522
- if (err instanceof Error)
73523
- return err.message || err.name || "Error";
73524
- if (typeof err === "string")
73525
- return err;
73526
- try {
73527
- return JSON.stringify(err);
73528
- } catch {
73529
- return String(err);
73530
- }
73531
- }
73532
74767
  }
73533
74768
  });
73534
74769
 
@@ -73824,19 +75059,253 @@ var require_execute_tool_call = __commonJS({
73824
75059
  }
73825
75060
  });
73826
75061
 
75062
+ // node_modules/@coderifts/agent-guard/dist/cjs/toolset-attestation.js
75063
+ var require_toolset_attestation = __commonJS({
75064
+ "node_modules/@coderifts/agent-guard/dist/cjs/toolset-attestation.js"(exports2) {
75065
+ "use strict";
75066
+ Object.defineProperty(exports2, "__esModule", { value: true });
75067
+ exports2.TOOLSET_ATTEST_STATEMENT = exports2.TOOLSET_ATTEST_ENVELOPE_TAG = exports2.TOOLSET_ATTEST_SIGNING_PREFIX = exports2.TOOLSET_ATTEST_VERSION = void 0;
75068
+ exports2.computeToolsetDigest = computeToolsetDigest;
75069
+ exports2.declarationEntriesFromTools = declarationEntriesFromTools;
75070
+ exports2.toolsetAttestSigningInput = toolsetAttestSigningInput;
75071
+ exports2.tryIssueToolsetAttestation = tryIssueToolsetAttestation;
75072
+ exports2.kidFromToolsetAttestation = kidFromToolsetAttestation;
75073
+ var node_crypto_1 = require("node:crypto");
75074
+ exports2.TOOLSET_ATTEST_VERSION = "cr.toolset.attest.v1";
75075
+ exports2.TOOLSET_ATTEST_SIGNING_PREFIX = "crtoolsetattest.v1";
75076
+ exports2.TOOLSET_ATTEST_ENVELOPE_TAG = "cr.toolset.attest.v1";
75077
+ exports2.TOOLSET_ATTEST_STATEMENT = "this is the complete set of tools that can mutate a governed target";
75078
+ var ENVELOPE_CLASSES = ["mutating", "readonly"];
75079
+ var MAX_ENTRIES = 512;
75080
+ var scalar = (v) => v == null ? "" : String(v);
75081
+ var optional = (v) => v != null && String(v).length > 0 ? String(v) : "";
75082
+ function b64url(buf) {
75083
+ return buf.toString("base64url");
75084
+ }
75085
+ function sha256hex(s) {
75086
+ return (0, node_crypto_1.createHash)("sha256").update(s, "utf8").digest("hex");
75087
+ }
75088
+ function toEnvelopeClass(cls) {
75089
+ return cls === "readonly" ? "readonly" : "mutating";
75090
+ }
75091
+ function stableStringify(value) {
75092
+ if (value === null || typeof value !== "object")
75093
+ return JSON.stringify(value) ?? "null";
75094
+ if (Array.isArray(value))
75095
+ return "[" + value.map(stableStringify).join(",") + "]";
75096
+ const obj = value;
75097
+ const keys = Object.keys(obj).sort();
75098
+ return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
75099
+ }
75100
+ function computeToolsetDigest(entries) {
75101
+ if (!Array.isArray(entries))
75102
+ return { ok: false, reason: "entries_not_array" };
75103
+ if (entries.length === 0)
75104
+ return { ok: false, reason: "entries_empty" };
75105
+ if (entries.length > MAX_ENTRIES)
75106
+ return { ok: false, reason: "entries_too_many" };
75107
+ const seen = /* @__PURE__ */ new Set();
75108
+ const rows = [];
75109
+ for (const e of entries) {
75110
+ if (!e || typeof e !== "object")
75111
+ return { ok: false, reason: "entry_not_object" };
75112
+ const name = e.name;
75113
+ const cls = e.mutation_class;
75114
+ const sd = e.input_schema_digest;
75115
+ if (typeof name !== "string" || !name || name.length > 128)
75116
+ return { ok: false, reason: "bad_entry_name" };
75117
+ if (name.includes("|"))
75118
+ return { ok: false, reason: "delimiter_in_entry_name" };
75119
+ if (!ENVELOPE_CLASSES.includes(cls))
75120
+ return { ok: false, reason: "bad_mutation_class" };
75121
+ if (sd != null) {
75122
+ if (typeof sd !== "string" || !sd.startsWith("sha256:") || sd.includes("|")) {
75123
+ return { ok: false, reason: "bad_input_schema_digest" };
75124
+ }
75125
+ }
75126
+ if (seen.has(name))
75127
+ return { ok: false, reason: "duplicate_entry_name" };
75128
+ seen.add(name);
75129
+ rows.push([name, cls, sd == null ? "" : sd]);
75130
+ }
75131
+ rows.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
75132
+ const canonical = rows.map((r) => r.join(" ")).join("");
75133
+ return {
75134
+ ok: true,
75135
+ digest: "sha256:" + sha256hex(canonical),
75136
+ tool_count: rows.length,
75137
+ mutating_count: rows.filter((r) => r[1] === "mutating").length
75138
+ };
75139
+ }
75140
+ function declarationEntriesFromTools(tools) {
75141
+ const out = [];
75142
+ for (const t of tools) {
75143
+ if (!t || typeof t.name !== "string" || !t.name)
75144
+ continue;
75145
+ const entry = {
75146
+ name: t.name,
75147
+ mutation_class: toEnvelopeClass(t._coderifts.mutationClass)
75148
+ };
75149
+ if (t.inputSchema !== void 0) {
75150
+ entry.input_schema_digest = "sha256:" + sha256hex(stableStringify(t.inputSchema));
75151
+ }
75152
+ out.push(entry);
75153
+ }
75154
+ return out;
75155
+ }
75156
+ function toolsetAttestSigningInput(body) {
75157
+ const parts = [
75158
+ exports2.TOOLSET_ATTEST_SIGNING_PREFIX,
75159
+ scalar(body.kid),
75160
+ scalar(body.declarer),
75161
+ scalar(body.statement),
75162
+ scalar(body.set_digest),
75163
+ scalar(body.declared_at),
75164
+ optional(body.session_id),
75165
+ optional(body.receipt_digest),
75166
+ optional(body.framework),
75167
+ optional(body.framework_version),
75168
+ optional(body.guard_version),
75169
+ body.tool_count == null ? "" : String(body.tool_count),
75170
+ body.mutating_count == null ? "" : String(body.mutating_count),
75171
+ optional(body.scope_note)
75172
+ ];
75173
+ return parts.join("|");
75174
+ }
75175
+ var SIGNED_STRING_FIELDS = [
75176
+ "kid",
75177
+ "declarer",
75178
+ "statement",
75179
+ "set_digest",
75180
+ "declared_at",
75181
+ "session_id",
75182
+ "receipt_digest",
75183
+ "scope_note",
75184
+ "framework",
75185
+ "framework_version",
75186
+ "guard_version"
75187
+ ];
75188
+ function fieldHasDelimiter(body) {
75189
+ for (const k of SIGNED_STRING_FIELDS) {
75190
+ const v = body[k];
75191
+ if (typeof v === "string" && v.includes("|"))
75192
+ return true;
75193
+ }
75194
+ return false;
75195
+ }
75196
+ async function tryIssueToolsetAttestation(args) {
75197
+ const cfg = args.config;
75198
+ if (!cfg || typeof cfg.kid !== "string" || !cfg.kid || typeof cfg.signer !== "function") {
75199
+ return void 0;
75200
+ }
75201
+ if (typeof cfg.declarer !== "string" || cfg.declarer.length === 0)
75202
+ return void 0;
75203
+ const hasFw = typeof cfg.framework === "string" && cfg.framework.length > 0;
75204
+ const hasFwV = typeof cfg.frameworkVersion === "string" && cfg.frameworkVersion.length > 0;
75205
+ if (hasFw !== hasFwV)
75206
+ return void 0;
75207
+ const tools = args.tools;
75208
+ if (!Array.isArray(tools) || tools.length === 0)
75209
+ return void 0;
75210
+ const entries = declarationEntriesFromTools(tools);
75211
+ const digest = computeToolsetDigest(entries);
75212
+ if (!digest.ok)
75213
+ return void 0;
75214
+ const body = {
75215
+ v: exports2.TOOLSET_ATTEST_VERSION,
75216
+ kid: cfg.kid,
75217
+ declarer: cfg.declarer,
75218
+ statement: exports2.TOOLSET_ATTEST_STATEMENT,
75219
+ set_digest: digest.digest,
75220
+ declared_at: args.now || (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "Z"),
75221
+ tool_count: digest.tool_count,
75222
+ mutating_count: digest.mutating_count
75223
+ };
75224
+ if (typeof cfg.sessionId === "string" && cfg.sessionId)
75225
+ body.session_id = cfg.sessionId;
75226
+ if (typeof args.receiptDigest === "string" && args.receiptDigest)
75227
+ body.receipt_digest = args.receiptDigest;
75228
+ if (hasFw) {
75229
+ body.framework = cfg.framework;
75230
+ body.framework_version = cfg.frameworkVersion;
75231
+ }
75232
+ if (typeof args.guardVersion === "string" && args.guardVersion)
75233
+ body.guard_version = args.guardVersion;
75234
+ if (typeof args.scopeNote === "string" && args.scopeNote)
75235
+ body.scope_note = args.scopeNote;
75236
+ if (fieldHasDelimiter(body))
75237
+ return void 0;
75238
+ const input = Buffer.from(toolsetAttestSigningInput(body), "utf8");
75239
+ let sig;
75240
+ try {
75241
+ sig = await cfg.signer(input);
75242
+ } catch {
75243
+ return void 0;
75244
+ }
75245
+ if (sig == null)
75246
+ return void 0;
75247
+ const sigBuf = Buffer.isBuffer(sig) ? sig : Buffer.from(sig);
75248
+ if (sigBuf.length === 0)
75249
+ return void 0;
75250
+ return [
75251
+ exports2.TOOLSET_ATTEST_ENVELOPE_TAG,
75252
+ cfg.kid,
75253
+ b64url(Buffer.from(JSON.stringify(body), "utf8")),
75254
+ b64url(sigBuf)
75255
+ ].join("|");
75256
+ }
75257
+ function kidFromToolsetAttestation(token) {
75258
+ if (typeof token !== "string" || token.length === 0)
75259
+ return null;
75260
+ const parts = token.split("|");
75261
+ if (parts.length !== 4 || parts[0] !== exports2.TOOLSET_ATTEST_ENVELOPE_TAG)
75262
+ return null;
75263
+ return parts[1] || null;
75264
+ }
75265
+ }
75266
+ });
75267
+
73827
75268
  // node_modules/@coderifts/agent-guard/dist/cjs/index.js
73828
75269
  var require_cjs4 = __commonJS({
73829
75270
  "node_modules/@coderifts/agent-guard/dist/cjs/index.js"(exports2) {
73830
75271
  "use strict";
73831
75272
  Object.defineProperty(exports2, "__esModule", { value: true });
73832
- exports2.freshnessAllowsEnforce = exports2.computePathSetTreeHash = exports2.contentByteIdentical = exports2.assessWriteStylePrior = exports2.assessFreshness = exports2.deriveProofBanner = exports2.attachProofToAgentResponse = exports2.renderFinalAnswerProof = exports2.EXECUTION_PROOF_SPEC = exports2.assertEnforcedReceiptInvariant = exports2.hashExecutionResult = exports2.buildExecutionProof = exports2.DEFAULT_MONITORING_SINK_TIMEOUT_MS = exports2.ackBytes = exports2.verifyAckHmac = exports2.monitoringDeliveryFailClosed = exports2.formatMonitoringDeliveryLine = exports2.deliverMonitoring = exports2.hashObservedContent = exports2.observeCommit = exports2.deriveKeySignal = exports2.pathClass = exports2.classifyCommand = exports2.projectState = exports2.emptySessionState = exports2.computeTainted = exports2.evaluate = exports2.updateSession = exports2.SESSION_TAINT_VERSION = exports2.SessionTaintTracker = exports2.readDecision = exports2.EXECUTION_TIME_FP_REASONS = exports2.EXECUTION_STATE_UNMEASURABLE_NOTE = exports2.isUnmeasurableExecutionStateReason = exports2.computeCanonicalBundleFingerprint = exports2.authorizedFingerprintFromEnvelope = exports2.checkExecutionTimeFingerprint = exports2.computeBundleFingerprint = exports2.computeArtifactDigest = exports2.evaluateEnvelope = exports2.RECEIPT_PREV_NULL = exports2.decodeReceiptBodyPrev = exports2.previousReceiptCommitment = exports2.verifyReceiptChainLinkage = exports2.canonicalJson = exports2.computeBodyHash = exports2.bindReceiptToEnvelope = exports2.DETECTOR_VERSION = exports2.builtinDetector = exports2.guardToolCall = void 0;
73833
- exports2.RegistryConstructionError = exports2.guardToolRegistry = exports2.globToRegExp = exports2.matchGlob = exports2.blobMapKey = exports2.classifyByName = exports2.resolveArtifacts = exports2.REMEDIATION_LOOP_ATTESTATION_SPEC = exports2.isCasAttestation = exports2.readPriorBlockRemediation = exports2.readRemediationTransaction = exports2.buildRemediationLoopAttestation = exports2.CAS_ATTESTATION_SPEC = exports2.extractExecutorAttestationToken = exports2.evaluateCasEvidence = exports2.isExecuteIfUnchangedOutcome = exports2.isGuardExecutionProof = exports2.buildCasAttestation = exports2.REGISTRY_ABSENT_TOKEN = exports2.REGISTRY_VERSION_TOKEN_PREFIX = exports2.registryTokenRaw = exports2.writeRegistryIfUnchanged = exports2.createRegistryVersionToken = exports2.DB_ABSENT_TOKEN = exports2.DB_VERSION_TOKEN_PREFIX = exports2.dbTokenRaw = exports2.writeDbIfUnchanged = exports2.createDbVersionToken = exports2.API_ABSENT_TOKEN = exports2.API_VERSION_TOKEN_PREFIX = exports2.apiTokenRaw = exports2.writeApiIfUnchanged = exports2.createApiVersionToken = exports2.FS_ABSENT_TOKEN = exports2.FS_VERSION_TOKEN_PREFIX = exports2.fsTokenContentHash = exports2.createFsPriorContentResolver = exports2.writeFileIfUnchanged = exports2.readVersionedFile = exports2.createFsVersionToken = exports2.StaleVersionTokenAbort = exports2.executeIfUnchanged = exports2.RESIDUAL_UNCONDITIONAL_WRITE = exports2.conditionalWriteResidual = exports2.tokensEqual = exports2.buildConditionalWriteBasis = exports2.buildFreshnessBasis = exports2.collectFreshnessCallContext = exports2.artifactIdsForResolve = exports2.isWriteStyleCall = void 0;
73834
- exports2.executeLangGraphToolCall = exports2.executeGeminiToolCall = exports2.executeAnthropicToolCall = exports2.executeOpenAIToolCall = exports2.executeProtectedTool = exports2.defaultSerializeGeminiToolResult = exports2.bindGeminiGuardOutcome = exports2.protectedToolToFunctionDeclaration = exports2.toGeminiTools = exports2.geminiToolAdapter = exports2.withCodeRiftsGemini = exports2.defaultSerializeLangGraphToolResult = exports2.bindLangGraphGuardOutcome = exports2.protectedToolToLangGraph = exports2.toLangGraphTools = exports2.langGraphToolAdapter = exports2.withCodeRiftsLangGraph = exports2.defaultSerializeAnthropicToolResult = exports2.bindAnthropicGuardOutcome = exports2.protectedToolToAnthropic = exports2.toAnthropicTools = exports2.anthropicToolAdapter = exports2.withCodeRiftsAnthropic = exports2.defaultSerializeOpenAIToolResult = exports2.bindOpenAIGuardOutcome = exports2.protectedToolToOpenAI = exports2.toOpenAITools = exports2.openAIToolAdapter = exports2.withCodeRiftsOpenAI = exports2.guardedFractionAmongRoutes = exports2.foldTableSettledCalls = exports2.withCodeRifts = exports2.AUTO_DERIVE_READ_TIMEOUT_MS = exports2.AUTO_DERIVE_SOURCE = exports2.defaultFsReader = exports2.normalizeAutoDerive = exports2.runAutoDerive = exports2.AUTO_RECHECK_MAX_CAP = exports2.clampMaxAttempts = exports2.normalizeAutoRecheck = exports2.runAutoRecheckLoop = exports2.coverageReport = exports2.DEPLOY_REPAIRABLE_REASONS = exports2.bindDeploy = exports2.verifyDeployReceiptToken = exports2.DEPLOY_RECEIPT_VIEW_SPEC = exports2.isVerifiedDeployReceiptView = exports2.asVerifiedDeployReceiptView = exports2.deployGate = exports2.gateDecision = void 0;
73835
- exports2.surfaceEnvelopeFields = exports2.isGuardOutcome = void 0;
75273
+ exports2.monitorAttestSigningInput = exports2.kidFromMonitoringAttestation = exports2.tryIssueMonitoringAttestation = exports2.DEFAULT_MONITORING_SINK_TIMEOUT_MS = exports2.ackBytes = exports2.verifyAckHmac = exports2.monitoringDeliveryFailClosed = exports2.formatMonitoringDeliveryLine = exports2.deliverMonitoring = exports2.hashObservedContent = exports2.observeCommit = exports2.deriveKeySignal = exports2.pathClass = exports2.classifyCommand = exports2.projectState = exports2.emptySessionState = exports2.computeTainted = exports2.evaluate = exports2.updateSession = exports2.SESSION_TAINT_VERSION = exports2.SessionTaintTracker = exports2.readDecision = exports2.EXECUTION_TIME_FP_REASONS = exports2.EXECUTION_STATE_UNMEASURABLE_NOTE = exports2.isUnmeasurableExecutionStateReason = exports2.computeCanonicalBundleFingerprint = exports2.authorizedFingerprintFromEnvelope = exports2.checkExecutionTimeFingerprint = exports2.computeBundleFingerprint = exports2.computeArtifactDigest = exports2.evaluateEnvelope = exports2.RECEIPT_PREV_NULL = exports2.decodeReceiptBodyPrev = exports2.previousReceiptCommitment = exports2.verifyReceiptChainLinkage = exports2.canonicalJson = exports2.computeBodyHash = exports2.bindReceiptToEnvelope = exports2.DETECTOR_VERSION = exports2.builtinDetector = exports2.resetPolicyWarnForTests = exports2.warnPolicyAbsentOnce = exports2.observePolicyPresence = exports2.detectPolicyPresence = exports2.policyPresenceOf = exports2.withPolicy = exports2.POLICY_ABSENT_WARN = exports2.POLICY_MARKER = exports2.CODERIFTS_POLICY = exports2.guardToolCall = void 0;
75274
+ exports2.createRegistryVersionToken = exports2.DB_ABSENT_TOKEN = exports2.DB_VERSION_TOKEN_PREFIX = exports2.dbTokenRaw = exports2.writeDbIfUnchanged = exports2.createDbVersionToken = exports2.API_ABSENT_TOKEN = exports2.API_VERSION_TOKEN_PREFIX = exports2.apiTokenRaw = exports2.writeApiIfUnchanged = exports2.createApiVersionToken = exports2.FS_ABSENT_TOKEN = exports2.FS_VERSION_TOKEN_PREFIX = exports2.fsTokenContentHash = exports2.createFsPriorContentResolver = exports2.writeFileIfUnchanged = exports2.readVersionedFile = exports2.createFsVersionToken = exports2.StaleVersionTokenAbort = exports2.executeIfUnchanged = exports2.RESIDUAL_UNCONDITIONAL_WRITE = exports2.conditionalWriteResidual = exports2.tokensEqual = exports2.buildConditionalWriteBasis = exports2.buildFreshnessBasis = exports2.collectFreshnessCallContext = exports2.artifactIdsForResolve = exports2.isWriteStyleCall = exports2.freshnessAllowsEnforce = exports2.computePathSetTreeHash = exports2.contentByteIdentical = exports2.assessWriteStylePrior = exports2.assessFreshness = exports2.deriveProofBanner = exports2.attachProofToAgentResponse = exports2.renderFinalAnswerProof = exports2.EXECUTION_PROOF_SPEC = exports2.assertEnforcedReceiptInvariant = exports2.hashExecutionResult = exports2.buildExecutionProof = exports2.COVERAGE_ATTEST_ENVELOPE_TAG = exports2.COVERAGE_ATTEST_SIGNING_PREFIX = exports2.COVERAGE_ATTEST_VERSION = exports2.coverageAttestSigningInput = exports2.kidFromCoverageAttestation = exports2.tryIssueCoverageAttestation = exports2.MONITOR_ATTEST_ENVELOPE_TAG = exports2.MONITOR_ATTEST_SIGNING_PREFIX = exports2.MONITOR_ATTEST_VERSION = exports2.receiptDigestOfToken = void 0;
75275
+ exports2.formatCoverageObservedLine = exports2.freezeCoverageObserved = exports2.createCoverageObserver = exports2.readExecutionGrantToken = exports2.isExecutionGrantEnabled = exports2.guardedFractionAmongRoutes = exports2.foldTableSettledCalls = exports2.withCodeRifts = exports2.AUTO_DERIVE_READ_TIMEOUT_MS = exports2.AUTO_DERIVE_SOURCE = exports2.defaultFsReader = exports2.normalizeAutoDerive = exports2.runAutoDerive = exports2.AUTO_RECHECK_MAX_CAP = exports2.clampMaxAttempts = exports2.normalizeAutoRecheck = exports2.runAutoRecheckLoop = exports2.coverageReport = exports2.DEPLOY_REPAIRABLE_REASONS = exports2.bindDeploy = exports2.verifyDeployReceiptToken = exports2.DEPLOY_RECEIPT_VIEW_SPEC = exports2.isVerifiedDeployReceiptView = exports2.asVerifiedDeployReceiptView = exports2.deployGate = exports2.gateDecision = exports2.RegistryConstructionError = exports2.guardToolRegistry = exports2.globToRegExp = exports2.matchGlob = exports2.blobMapKey = exports2.classifyByName = exports2.resolveArtifacts = exports2.REMEDIATION_LOOP_ATTESTATION_SPEC = exports2.isCasAttestation = exports2.readPriorBlockRemediation = exports2.readRemediationTransaction = exports2.buildRemediationLoopAttestation = exports2.COMMIT_EVIDENCE_MISSING = exports2.CAS_ATTESTATION_SPEC = exports2.strictCommitObservation = exports2.extractExecutorAttestationToken = exports2.evaluateCasEvidence = exports2.isExecuteIfUnchangedOutcome = exports2.isGuardExecutionProof = exports2.buildCasAttestation = exports2.REGISTRY_ABSENT_TOKEN = exports2.REGISTRY_VERSION_TOKEN_PREFIX = exports2.registryTokenRaw = exports2.writeRegistryIfUnchanged = void 0;
75276
+ exports2.kidFromToolsetAttestation = exports2.tryIssueToolsetAttestation = exports2.toolsetAttestSigningInput = exports2.declarationEntriesFromTools = exports2.computeToolsetDigest = exports2.TOOLSET_ATTEST_STATEMENT = exports2.TOOLSET_ATTEST_ENVELOPE_TAG = exports2.TOOLSET_ATTEST_SIGNING_PREFIX = exports2.TOOLSET_ATTEST_VERSION = exports2.surfaceEnvelopeFields = exports2.isGuardOutcome = exports2.executeLangGraphToolCall = exports2.executeGeminiToolCall = exports2.executeAnthropicToolCall = exports2.executeOpenAIToolCall = exports2.executeProtectedTool = exports2.defaultSerializeGeminiToolResult = exports2.bindGeminiGuardOutcome = exports2.protectedToolToFunctionDeclaration = exports2.toGeminiTools = exports2.geminiToolAdapter = exports2.withCodeRiftsGemini = exports2.wrapWriteWithFsCas = exports2.inferFullFileWriteContent = exports2.inferFsPathFromArgs = exports2.FRESHNESS_RESOLVER_FIX = exports2.freshnessRefusalTeaching = exports2.formatGateRefusalBody = exports2.defaultSerializeLangGraphToolResult = exports2.bindLangGraphGuardOutcome = exports2.LangGraphToolsNotStructuredError = exports2.isLangGraphReactAgentTool = exports2.bindLangGraphTools = exports2.protectedToolToLangGraph = exports2.toLangGraphTools = exports2.langGraphToolAdapter = exports2.withCodeRiftsLangGraph = exports2.defaultSerializeAnthropicToolResult = exports2.bindAnthropicGuardOutcome = exports2.protectedToolToAnthropic = exports2.toAnthropicTools = exports2.anthropicToolAdapter = exports2.withCodeRiftsAnthropic = exports2.defaultSerializeOpenAIToolResult = exports2.bindOpenAIGuardOutcome = exports2.protectedToolToOpenAI = exports2.toOpenAITools = exports2.openAIToolAdapter = exports2.withCodeRiftsOpenAI = void 0;
73836
75277
  var guard_js_1 = require_guard();
73837
75278
  Object.defineProperty(exports2, "guardToolCall", { enumerable: true, get: function() {
73838
75279
  return guard_js_1.guardToolCall;
73839
75280
  } });
75281
+ var policy_js_1 = require_policy2();
75282
+ Object.defineProperty(exports2, "CODERIFTS_POLICY", { enumerable: true, get: function() {
75283
+ return policy_js_1.CODERIFTS_POLICY;
75284
+ } });
75285
+ Object.defineProperty(exports2, "POLICY_MARKER", { enumerable: true, get: function() {
75286
+ return policy_js_1.POLICY_MARKER;
75287
+ } });
75288
+ Object.defineProperty(exports2, "POLICY_ABSENT_WARN", { enumerable: true, get: function() {
75289
+ return policy_js_1.POLICY_ABSENT_WARN;
75290
+ } });
75291
+ Object.defineProperty(exports2, "withPolicy", { enumerable: true, get: function() {
75292
+ return policy_js_1.withPolicy;
75293
+ } });
75294
+ Object.defineProperty(exports2, "policyPresenceOf", { enumerable: true, get: function() {
75295
+ return policy_js_1.policyPresenceOf;
75296
+ } });
75297
+ Object.defineProperty(exports2, "detectPolicyPresence", { enumerable: true, get: function() {
75298
+ return policy_js_1.detectPolicyPresence;
75299
+ } });
75300
+ Object.defineProperty(exports2, "observePolicyPresence", { enumerable: true, get: function() {
75301
+ return policy_js_1.observePolicyPresence;
75302
+ } });
75303
+ Object.defineProperty(exports2, "warnPolicyAbsentOnce", { enumerable: true, get: function() {
75304
+ return policy_js_1.warnPolicyAbsentOnce;
75305
+ } });
75306
+ Object.defineProperty(exports2, "resetPolicyWarnForTests", { enumerable: true, get: function() {
75307
+ return policy_js_1.resetPolicyWarnForTests;
75308
+ } });
73840
75309
  var detector_js_1 = require_detector();
73841
75310
  Object.defineProperty(exports2, "builtinDetector", { enumerable: true, get: function() {
73842
75311
  return detector_js_1.builtinDetector;
@@ -73957,6 +75426,47 @@ var require_cjs4 = __commonJS({
73957
75426
  Object.defineProperty(exports2, "DEFAULT_MONITORING_SINK_TIMEOUT_MS", { enumerable: true, get: function() {
73958
75427
  return monitoring_delivery_js_1.DEFAULT_MONITORING_SINK_TIMEOUT_MS;
73959
75428
  } });
75429
+ var monitoring_attestation_js_1 = require_monitoring_attestation2();
75430
+ Object.defineProperty(exports2, "tryIssueMonitoringAttestation", { enumerable: true, get: function() {
75431
+ return monitoring_attestation_js_1.tryIssueMonitoringAttestation;
75432
+ } });
75433
+ Object.defineProperty(exports2, "kidFromMonitoringAttestation", { enumerable: true, get: function() {
75434
+ return monitoring_attestation_js_1.kidFromMonitoringAttestation;
75435
+ } });
75436
+ Object.defineProperty(exports2, "monitorAttestSigningInput", { enumerable: true, get: function() {
75437
+ return monitoring_attestation_js_1.monitorAttestSigningInput;
75438
+ } });
75439
+ Object.defineProperty(exports2, "receiptDigestOfToken", { enumerable: true, get: function() {
75440
+ return monitoring_attestation_js_1.receiptDigestOfToken;
75441
+ } });
75442
+ Object.defineProperty(exports2, "MONITOR_ATTEST_VERSION", { enumerable: true, get: function() {
75443
+ return monitoring_attestation_js_1.MONITOR_ATTEST_VERSION;
75444
+ } });
75445
+ Object.defineProperty(exports2, "MONITOR_ATTEST_SIGNING_PREFIX", { enumerable: true, get: function() {
75446
+ return monitoring_attestation_js_1.MONITOR_ATTEST_SIGNING_PREFIX;
75447
+ } });
75448
+ Object.defineProperty(exports2, "MONITOR_ATTEST_ENVELOPE_TAG", { enumerable: true, get: function() {
75449
+ return monitoring_attestation_js_1.MONITOR_ATTEST_ENVELOPE_TAG;
75450
+ } });
75451
+ var coverage_attestation_js_1 = require_coverage_attestation();
75452
+ Object.defineProperty(exports2, "tryIssueCoverageAttestation", { enumerable: true, get: function() {
75453
+ return coverage_attestation_js_1.tryIssueCoverageAttestation;
75454
+ } });
75455
+ Object.defineProperty(exports2, "kidFromCoverageAttestation", { enumerable: true, get: function() {
75456
+ return coverage_attestation_js_1.kidFromCoverageAttestation;
75457
+ } });
75458
+ Object.defineProperty(exports2, "coverageAttestSigningInput", { enumerable: true, get: function() {
75459
+ return coverage_attestation_js_1.coverageAttestSigningInput;
75460
+ } });
75461
+ Object.defineProperty(exports2, "COVERAGE_ATTEST_VERSION", { enumerable: true, get: function() {
75462
+ return coverage_attestation_js_1.COVERAGE_ATTEST_VERSION;
75463
+ } });
75464
+ Object.defineProperty(exports2, "COVERAGE_ATTEST_SIGNING_PREFIX", { enumerable: true, get: function() {
75465
+ return coverage_attestation_js_1.COVERAGE_ATTEST_SIGNING_PREFIX;
75466
+ } });
75467
+ Object.defineProperty(exports2, "COVERAGE_ATTEST_ENVELOPE_TAG", { enumerable: true, get: function() {
75468
+ return coverage_attestation_js_1.COVERAGE_ATTEST_ENVELOPE_TAG;
75469
+ } });
73960
75470
  var execution_proof_js_1 = require_execution_proof();
73961
75471
  Object.defineProperty(exports2, "buildExecutionProof", { enumerable: true, get: function() {
73962
75472
  return execution_proof_js_1.buildExecutionProof;
@@ -74113,9 +75623,15 @@ var require_cjs4 = __commonJS({
74113
75623
  Object.defineProperty(exports2, "extractExecutorAttestationToken", { enumerable: true, get: function() {
74114
75624
  return cas_attestation_js_1.extractExecutorAttestationToken;
74115
75625
  } });
75626
+ Object.defineProperty(exports2, "strictCommitObservation", { enumerable: true, get: function() {
75627
+ return cas_attestation_js_1.strictCommitObservation;
75628
+ } });
74116
75629
  Object.defineProperty(exports2, "CAS_ATTESTATION_SPEC", { enumerable: true, get: function() {
74117
75630
  return cas_attestation_js_1.CAS_ATTESTATION_SPEC;
74118
75631
  } });
75632
+ Object.defineProperty(exports2, "COMMIT_EVIDENCE_MISSING", { enumerable: true, get: function() {
75633
+ return cas_attestation_js_1.COMMIT_EVIDENCE_MISSING;
75634
+ } });
74119
75635
  var remediation_loop_attestation_js_1 = require_remediation_loop_attestation();
74120
75636
  Object.defineProperty(exports2, "buildRemediationLoopAttestation", { enumerable: true, get: function() {
74121
75637
  return remediation_loop_attestation_js_1.buildRemediationLoopAttestation;
@@ -74227,6 +75743,23 @@ var require_cjs4 = __commonJS({
74227
75743
  Object.defineProperty(exports2, "guardedFractionAmongRoutes", { enumerable: true, get: function() {
74228
75744
  return with_coderifts_js_1.guardedFractionAmongRoutes;
74229
75745
  } });
75746
+ var execution_grant_js_1 = require_execution_grant2();
75747
+ Object.defineProperty(exports2, "isExecutionGrantEnabled", { enumerable: true, get: function() {
75748
+ return execution_grant_js_1.isExecutionGrantEnabled;
75749
+ } });
75750
+ Object.defineProperty(exports2, "readExecutionGrantToken", { enumerable: true, get: function() {
75751
+ return execution_grant_js_1.readExecutionGrantToken;
75752
+ } });
75753
+ var coverage_observed_js_1 = require_coverage_observed();
75754
+ Object.defineProperty(exports2, "createCoverageObserver", { enumerable: true, get: function() {
75755
+ return coverage_observed_js_1.createCoverageObserver;
75756
+ } });
75757
+ Object.defineProperty(exports2, "freezeCoverageObserved", { enumerable: true, get: function() {
75758
+ return coverage_observed_js_1.freezeCoverageObserved;
75759
+ } });
75760
+ Object.defineProperty(exports2, "formatCoverageObservedLine", { enumerable: true, get: function() {
75761
+ return coverage_observed_js_1.formatCoverageObservedLine;
75762
+ } });
74230
75763
  var openai_js_1 = require_openai();
74231
75764
  Object.defineProperty(exports2, "withCodeRiftsOpenAI", { enumerable: true, get: function() {
74232
75765
  return openai_js_1.withCodeRiftsOpenAI;
@@ -74278,12 +75811,41 @@ var require_cjs4 = __commonJS({
74278
75811
  Object.defineProperty(exports2, "protectedToolToLangGraph", { enumerable: true, get: function() {
74279
75812
  return langgraph_js_1.protectedToolToLangGraph;
74280
75813
  } });
75814
+ Object.defineProperty(exports2, "bindLangGraphTools", { enumerable: true, get: function() {
75815
+ return langgraph_js_1.bindLangGraphTools;
75816
+ } });
75817
+ Object.defineProperty(exports2, "isLangGraphReactAgentTool", { enumerable: true, get: function() {
75818
+ return langgraph_js_1.isLangGraphReactAgentTool;
75819
+ } });
75820
+ Object.defineProperty(exports2, "LangGraphToolsNotStructuredError", { enumerable: true, get: function() {
75821
+ return langgraph_js_1.LangGraphToolsNotStructuredError;
75822
+ } });
74281
75823
  Object.defineProperty(exports2, "bindLangGraphGuardOutcome", { enumerable: true, get: function() {
74282
75824
  return langgraph_js_1.bindLangGraphGuardOutcome;
74283
75825
  } });
74284
75826
  Object.defineProperty(exports2, "defaultSerializeLangGraphToolResult", { enumerable: true, get: function() {
74285
75827
  return langgraph_js_1.defaultSerializeLangGraphToolResult;
74286
75828
  } });
75829
+ var gate_refusal_js_1 = require_gate_refusal();
75830
+ Object.defineProperty(exports2, "formatGateRefusalBody", { enumerable: true, get: function() {
75831
+ return gate_refusal_js_1.formatGateRefusalBody;
75832
+ } });
75833
+ Object.defineProperty(exports2, "freshnessRefusalTeaching", { enumerable: true, get: function() {
75834
+ return gate_refusal_js_1.freshnessRefusalTeaching;
75835
+ } });
75836
+ Object.defineProperty(exports2, "FRESHNESS_RESOLVER_FIX", { enumerable: true, get: function() {
75837
+ return gate_refusal_js_1.FRESHNESS_RESOLVER_FIX;
75838
+ } });
75839
+ var fs_default_wire_js_1 = require_fs_default_wire();
75840
+ Object.defineProperty(exports2, "inferFsPathFromArgs", { enumerable: true, get: function() {
75841
+ return fs_default_wire_js_1.inferFsPathFromArgs;
75842
+ } });
75843
+ Object.defineProperty(exports2, "inferFullFileWriteContent", { enumerable: true, get: function() {
75844
+ return fs_default_wire_js_1.inferFullFileWriteContent;
75845
+ } });
75846
+ Object.defineProperty(exports2, "wrapWriteWithFsCas", { enumerable: true, get: function() {
75847
+ return fs_default_wire_js_1.wrapWriteWithFsCas;
75848
+ } });
74287
75849
  var gemini_js_1 = require_gemini();
74288
75850
  Object.defineProperty(exports2, "withCodeRiftsGemini", { enumerable: true, get: function() {
74289
75851
  return gemini_js_1.withCodeRiftsGemini;
@@ -74325,6 +75887,34 @@ var require_cjs4 = __commonJS({
74325
75887
  Object.defineProperty(exports2, "surfaceEnvelopeFields", { enumerable: true, get: function() {
74326
75888
  return execute_tool_call_js_1.surfaceEnvelopeFields;
74327
75889
  } });
75890
+ var toolset_attestation_js_1 = require_toolset_attestation();
75891
+ Object.defineProperty(exports2, "TOOLSET_ATTEST_VERSION", { enumerable: true, get: function() {
75892
+ return toolset_attestation_js_1.TOOLSET_ATTEST_VERSION;
75893
+ } });
75894
+ Object.defineProperty(exports2, "TOOLSET_ATTEST_SIGNING_PREFIX", { enumerable: true, get: function() {
75895
+ return toolset_attestation_js_1.TOOLSET_ATTEST_SIGNING_PREFIX;
75896
+ } });
75897
+ Object.defineProperty(exports2, "TOOLSET_ATTEST_ENVELOPE_TAG", { enumerable: true, get: function() {
75898
+ return toolset_attestation_js_1.TOOLSET_ATTEST_ENVELOPE_TAG;
75899
+ } });
75900
+ Object.defineProperty(exports2, "TOOLSET_ATTEST_STATEMENT", { enumerable: true, get: function() {
75901
+ return toolset_attestation_js_1.TOOLSET_ATTEST_STATEMENT;
75902
+ } });
75903
+ Object.defineProperty(exports2, "computeToolsetDigest", { enumerable: true, get: function() {
75904
+ return toolset_attestation_js_1.computeToolsetDigest;
75905
+ } });
75906
+ Object.defineProperty(exports2, "declarationEntriesFromTools", { enumerable: true, get: function() {
75907
+ return toolset_attestation_js_1.declarationEntriesFromTools;
75908
+ } });
75909
+ Object.defineProperty(exports2, "toolsetAttestSigningInput", { enumerable: true, get: function() {
75910
+ return toolset_attestation_js_1.toolsetAttestSigningInput;
75911
+ } });
75912
+ Object.defineProperty(exports2, "tryIssueToolsetAttestation", { enumerable: true, get: function() {
75913
+ return toolset_attestation_js_1.tryIssueToolsetAttestation;
75914
+ } });
75915
+ Object.defineProperty(exports2, "kidFromToolsetAttestation", { enumerable: true, get: function() {
75916
+ return toolset_attestation_js_1.kidFromToolsetAttestation;
75917
+ } });
74328
75918
  }
74329
75919
  });
74330
75920
 
@@ -202426,7 +204016,7 @@ var require_clock_skew_leeway = __commonJS({
202426
204016
  });
202427
204017
 
202428
204018
  // ../../src/verdict-core/execution-grant.js
202429
- var require_execution_grant2 = __commonJS({
204019
+ var require_execution_grant3 = __commonJS({
202430
204020
  "../../src/verdict-core/execution-grant.js"(exports2, module2) {
202431
204021
  "use strict";
202432
204022
  var crypto = require("node:crypto");
@@ -203700,7 +205290,7 @@ var require_change_set = __commonJS({
203700
205290
  const {
203701
205291
  issueExecutionGrant,
203702
205292
  afterPayloadCanonical
203703
- } = require_execution_grant2();
205293
+ } = require_execution_grant3();
203704
205294
  const grantTarget = nonEmptyStr(context.target_id) || artifactDigest;
203705
205295
  const stateNonce = typeof input.state_nonce === "string" && input.state_nonce.length > 0 ? input.state_nonce : null;
203706
205296
  executionGrant = issueExecutionGrant({
@@ -210176,6 +211766,20 @@ var require_mcp_repo_config = __commonJS({
210176
211766
  }
210177
211767
  });
210178
211768
 
211769
+ // src/generated/gate-pin.json
211770
+ var require_gate_pin = __commonJS({
211771
+ "src/generated/gate-pin.json"(exports2, module2) {
211772
+ module2.exports = {
211773
+ repo: "coderifts/contract-gate",
211774
+ sha: "e5b6315e38c66a2274583ddf4d7be11515180326",
211775
+ tag: "v0.5.0",
211776
+ resolved_from: "https://github.com/coderifts/contract-gate refs/tags/v0",
211777
+ resolved_at: "2026-08-26T08:37:01Z",
211778
+ note: "STRICT template pins this full commit SHA (GitHub: only a full SHA is immutable). v0 is a tag we move on every release, so it is NOT a pin. Re-run scripts/generate-gate-pin.js on each gate release; Dependabot bumps adopters."
211779
+ };
211780
+ }
211781
+ });
211782
+
210179
211783
  // src/contract-gate-workflow.js
210180
211784
  var require_contract_gate_workflow = __commonJS({
210181
211785
  "src/contract-gate-workflow.js"(exports2, module2) {
@@ -210184,6 +211788,13 @@ var require_contract_gate_workflow = __commonJS({
210184
211788
  var path = require("path");
210185
211789
  var WORKFLOW_REL = ".github/workflows/coderifts.yml";
210186
211790
  var GATE_ACTION = "coderifts/contract-gate@v0";
211791
+ var GATE_PIN = require_gate_pin();
211792
+ if (typeof GATE_PIN.sha !== "string" || !/^[0-9a-f]{40}$/.test(GATE_PIN.sha)) {
211793
+ throw new Error(
211794
+ "contract-gate-workflow: generated/gate-pin.json carries no valid 40-hex sha \u2014 re-run scripts/generate-gate-pin.js. Refusing to emit an unpinned STRICT workflow."
211795
+ );
211796
+ }
211797
+ var GATE_ACTION_STRICT = `coderifts/contract-gate@${GATE_PIN.sha}` + (GATE_PIN.tag ? ` # ${GATE_PIN.tag}` : " # (no semver tag shares this commit)");
210187
211798
  var ENFORCEMENT_DOC = "https://github.com/coderifts/contract-gate/blob/main/ENFORCEMENT.md";
210188
211799
  var WORKFLOW_BODY = `# Written by \`coderifts init --agents\`. Re-run is a no-op when this file already exists.
210189
211800
  #
@@ -210193,6 +211804,10 @@ var require_contract_gate_workflow = __commonJS({
210193
211804
  # Turn the check on in repo settings to enforce (${ENFORCEMENT_DOC}).
210194
211805
  #
210195
211806
  # Copied from the gate repo example (examples/contract-gate.yml) \u2014 action at @v0.
211807
+ # @v0 is a MOVING tag on purpose: this default template trades immutability for easy updates,
211808
+ # so you get gate fixes without editing this file. It is NOT a security pin. If you need one,
211809
+ # use \`coderifts init --agents --strict\`, which pins a full commit SHA. Do not "fix" this to a
211810
+ # SHA and do not "fix" strict back to a tag \u2014 the difference is deliberate.
210196
211811
  name: CodeRifts Contract Gate
210197
211812
 
210198
211813
  # Run on EVERY pull request. Do NOT add paths: filters \u2014 a required check that
@@ -210226,13 +211841,16 @@ jobs:
210226
211841
  `;
210227
211842
  var STRICT_WORKFLOW_BODY = `# Written by \`coderifts init --agents --strict\`. Re-run is a no-op when this file already exists.
210228
211843
  #
210229
- # STRICT template: require-verified-monitoring is ON.
211844
+ # STRICT template: require-verified-monitoring is ON, and the action is pinned to a FULL COMMIT
211845
+ # SHA. GitHub: only a full commit SHA is immutable. \`@v0\` is a tag CodeRifts moves on every
211846
+ # release, so it is not a pin \u2014 the default (non-strict) template stays on \`@v0\` on purpose,
211847
+ # because easy updates are the point there. Do not "fix" the difference. Dependabot bumps this SHA.
210230
211848
  # This workflow POSTS the Check Run named exactly:
210231
211849
  # CodeRifts / contract-gate
210232
211850
  # It does NOT enable branch protection and it does NOT make that check required.
210233
211851
  # Turn the check on in repo settings to enforce (${ENFORCEMENT_DOC}).
210234
211852
  #
210235
- # Copied from the gate repo example (examples/contract-gate.yml) \u2014 action at @v0.
211853
+ # Copied from the gate repo example (examples/contract-gate.yml) \u2014 action pinned to a full SHA.
210236
211854
  name: CodeRifts Contract Gate
210237
211855
 
210238
211856
  # Run on EVERY pull request. Do NOT add paths: filters \u2014 a required check that
@@ -210253,7 +211871,7 @@ jobs:
210253
211871
  # REQUIRED: the gate derives the change set from git diff base...head.
210254
211872
  fetch-depth: 0
210255
211873
 
210256
- - uses: ${GATE_ACTION}
211874
+ - uses: ${GATE_ACTION_STRICT}
210257
211875
  with:
210258
211876
  api-key: \${{ secrets.CODERIFTS_API_KEY }}
210259
211877
  # api-url: https://app.coderifts.com # override only for self-hosted
@@ -210307,6 +211925,8 @@ jobs:
210307
211925
  WORKFLOW_BODY,
210308
211926
  STRICT_WORKFLOW_BODY,
210309
211927
  GATE_ACTION,
211928
+ GATE_ACTION_STRICT,
211929
+ GATE_PIN,
210310
211930
  ENFORCEMENT_DOC,
210311
211931
  writeContractGateWorkflow,
210312
211932
  workflowPresent