@ironbee-ai/cli 0.25.1 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/clients/claude/agents/ironbee-verifier.md +33 -0
  3. package/dist/clients/claude/commands/ironbee-verify.md +1 -0
  4. package/dist/clients/claude/hooks/activity-start.js +1 -1
  5. package/dist/clients/claude/hooks/session-end.js +1 -1
  6. package/dist/clients/claude/hooks/subagent-start.js +1 -0
  7. package/dist/clients/claude/hooks/subagent-stop.js +1 -0
  8. package/dist/clients/claude/hooks/verify-gate.js +4 -4
  9. package/dist/clients/claude/index.js +6 -6
  10. package/dist/clients/claude/platforms/skill.android.md +2 -0
  11. package/dist/clients/claude/platforms/skill.backend.md +2 -0
  12. package/dist/clients/claude/platforms/skill.browser.md +2 -0
  13. package/dist/clients/claude/platforms/skill.node.md +2 -0
  14. package/dist/clients/claude/rules/ironbee-verification.md +2 -1
  15. package/dist/clients/claude/skills/ironbee-verification.md +5 -0
  16. package/dist/clients/codex/agents/ironbee-verifier.md +75 -26
  17. package/dist/clients/codex/commands/ironbee-verify/SKILL.md +38 -61
  18. package/dist/clients/codex/index.js +2 -2
  19. package/dist/clients/codex/platforms/skill.android.md +2 -0
  20. package/dist/clients/codex/platforms/skill.backend.md +2 -0
  21. package/dist/clients/codex/platforms/skill.browser.md +2 -0
  22. package/dist/clients/codex/platforms/skill.node.md +2 -0
  23. package/dist/clients/codex/rules/ironbee-verification.md +10 -24
  24. package/dist/clients/codex/skills/ironbee-verification.md +40 -68
  25. package/dist/clients/codex/util.js +32 -22
  26. package/dist/clients/cursor/platforms/skill.android.md +2 -0
  27. package/dist/clients/cursor/platforms/skill.backend.md +2 -0
  28. package/dist/clients/cursor/platforms/skill.browser.md +2 -0
  29. package/dist/clients/cursor/platforms/skill.node.md +2 -0
  30. package/dist/clients/cursor/skills/ironbee-verification.md +21 -0
  31. package/dist/commands/hook.js +14 -14
  32. package/dist/commands/update.js +1 -1
  33. package/dist/hooks/core/activity-end.js +1 -1
  34. package/dist/hooks/core/activity-participants.js +1 -0
  35. package/dist/hooks/core/activity.js +1 -1
  36. package/dist/hooks/core/session-state.js +1 -1
  37. package/dist/hooks/core/submit-verdict.js +2 -2
  38. package/dist/hooks/core/verification-lifecycle.js +1 -1
  39. package/dist/hooks/core/verify-gate.js +24 -24
  40. package/dist/lib/config.js +1 -1
  41. package/dist/lib/install-version.js +1 -1
  42. package/dist/lib/platform-section.js +3 -3
  43. package/package.json +1 -1
@@ -13,6 +13,8 @@ The **backend protocol cycle** verifies backend changes by driving real protocol
13
13
 
14
14
  You can satisfy the cycle via **protocol-call evidence** (you drive the request yourself), **log evidence** (something else drives the request, you read the resulting logs), **DB evidence** (you inspect database state directly), or any combination. Pick whichever fits the task; one is enough.
15
15
 
16
+ **Batch (speed):** group consecutive `bedt_*` steps into one `MCP:bedt_execute` — e.g. a POST then a GET that reuses the created id (bind the first call's result: `const r = callTool('bedt_request_http', {…POST…}); callTool('bedt_request_http', { /* GET using an id from r */ })`), register-source + read, or db-connect + query. Keep a step standalone only when you must inspect its result to DECIDE what to do next, not just to pass a value along.
17
+
16
18
  ### Path A — Protocol-call evidence
17
19
 
18
20
  1. **Confirm a backend service is running** (the user's dev server, Docker compose, k8s port-forward, …). The agent itself does not start the service — ask the user if uncertain.
@@ -14,6 +14,8 @@
14
14
 
15
15
  All four tools are MANDATORY (the stop hook checks each). Functional interaction is expected for every verification.
16
16
 
17
+ **Batch (speed):** navigate (step 1) is standalone — read the ARIA snapshot it returns to decide your interactions. Then run steps 2–5 in ONE `MCP:bdt_execute` batch — `callTool('bdt_interaction_…', …)` for each interaction, `callTool('bdt_content_take-screenshot', …)`, `callTool('bdt_a11y_take-aria-snapshot', …)`, `callTool('bdt_o11y_get-console-messages', …)` — instead of four separate turns. Screenshot/aria/console capture the state AFTER the batched interactions, so batch interactions that lead to ONE state you want to assert; to assert an intermediate state (e.g. a modal that opens then closes) take a screenshot/snapshot at that point too — interleave it in the batch or split into two. The interaction is what makes the evidence meaningful: a batch of just the four evidence tools with no real interaction passes the tool-presence check but verifies nothing. If you must judge the screenshot's pixels, take that one standalone with `includeBase64: true`.
18
+
17
19
  ### Verdict fields
18
20
  The verdict is platform-agnostic — you submit only semantic judgment:
19
21
 
@@ -31,6 +31,8 @@ If you see `pom.xml`, `build.gradle`, `requirements.txt`, `pyproject.toml`, `go.
31
31
  - Read errors: `MCP:ndt_debug_get-logs` with the error-level filter.
32
32
  4. **Disconnect** (optional): `MCP:ndt_debug_disconnect`.
33
33
 
34
+ **Batch (speed):** connect (step 2) is standalone discovery. Batch consecutive `ndt_*` calls in one `MCP:ndt_execute` — set several probes together, then later read snapshots/logs together. The exercise step is ALWAYS separate: whatever triggers the code path (a browser/backend call on another server, a CLI command, the user) can't share an `ndt_*` batch — so node runs as set probes (batch) → exercise (separate) → read snapshots (batch).
35
+
34
36
  ### Verdict fields
35
37
  The verdict is platform-agnostic — you submit only semantic judgment:
36
38
 
@@ -55,10 +55,31 @@ If already running, skip start. If the build fails, fix it before proceeding.
55
55
  - Pass → `{ "session_id": "...", "status": "pass", "checks": [...] }`
56
56
  - Fail → add `"issues": [...]` describing what failed.
57
57
  - Pass after a previous fail → add `"fixes": [...]` describing what was repaired.
58
+ - **A FALSE failure is a FAIL — not "verified failure handling".** When you exercise a negative path, separate an EXPECTED negative test (you deliberately fed invalid input — bad card, missing auth, malformed payload — and it correctly failed → supports a `pass`) from a FALSE failure (a VALID, in-scope operation that SHOULD succeed but errors out → a DEFECT). Report a false failure as `status: "fail"` (or at minimum non-empty `issues`), never as a passing "failure path verified". Passing a run whose own evidence shows a legitimate operation breaking is a false pass.
58
59
  - **Nothing to verify? Use N/A — never fake evidence.** When the change has no runtime surface (type-only edit, behavior-neutral refactor, config/docs that still tripped a cycle): global `{ "session_id": "...", "status": "not_applicable", "reason": ["why there's no runtime surface"] }` (no `checks`), or per-platform on a pass/fail verdict `"not_applicable_cycles": ["browser"], "reason": ["server-only change"]` to exempt some cycles while verifying others. `reason` is REQUIRED (recorded + observable); strict mode rejects N/A. Base "nothing to verify" on the FULL change set (the change is often already COMMITTED) — check `git diff HEAD~1 HEAD --stat`, not just a clean `git status`, before declaring N/A.
59
60
  - **The stop hook enforces that you called the required tools for every active (non-exempt) cycle and that a pass/fail verdict carries non-empty `checks`.**
60
61
  8. If failed → fix → rebuild → go back to step 2 → repeat until pass.
61
62
 
63
+ ## Speed — batch your tool calls (fewer LLM round-trips)
64
+
65
+ Each tool call is a separate LLM round-trip, and that round-trip — not the tool's execution
66
+ — is the dominant cost of a verification. Drive the tools in as few turns as you can:
67
+
68
+ - **Batch a scope's work into ONE `MCP:*_execute` call.** Each cycle exposes a batch tool
69
+ (`MCP:bdt_execute` / `MCP:ndt_execute` / `MCP:bedt_execute` / `MCP:adt_execute`) that runs
70
+ many steps in one turn — nest each as a `callTool('<tool>', { … })`. A batch nests only
71
+ that cycle's own tools (you can't mix servers in one `*_execute`). It's a JS sandbox, so a later step
72
+ can reuse a value an earlier `callTool` returned
73
+ (`const r = callTool(…); callTool(…, { /* a field from r */ })`); and `*_execute` STOPS at
74
+ the first failing nested call, so the rest don't run. Nested calls are credited to the gate like
75
+ standalone calls — but authoring the batch is not the work: read each result and confirm
76
+ real evidence came back (a batch whose interaction failed has no screenshot/snapshot
77
+ behind it). See each platform section for that cycle's concrete batch shape, including any
78
+ cycle-specific screenshot or recording handling.
79
+ - **Discovery stays standalone — you can't batch what you haven't seen.** The step that
80
+ reveals what to do (navigate / connect / snapshot) runs first and on its own; you read its
81
+ result, THEN batch the actions it told you to take.
82
+
62
83
  <!--IRONBEE:PLATFORM:browser-->
63
84
  <!--/IRONBEE:PLATFORM:browser-->
64
85
 
@@ -1,24 +1,24 @@
1
- "use strict";var g=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var b=(i,e)=>g(i,"name",{value:e,configurable:!0});var x=(i,e)=>{for(var t in e)g(i,t,{get:e[t],enumerable:!0})},P=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of j(e))!C.call(i,n)&&n!==t&&g(i,n,{get:()=>e[n],enumerable:!(o=N(e,n))||o.enumerable});return i};var D=i=>P(g({},"__esModule",{value:!0}),i);var _={};x(_,{hookCommand:()=>r});module.exports=D(_);var w=require("commander"),h=require("../clients/registry"),k=require("../hooks/core/submit-verdict"),y=require("../hooks/core/verification-lifecycle"),u=require("../lib/config"),l=require("../lib/logger"),d=require("../lib/output"),m=require("../lib/stdin"),S=require("../hooks/core/session-state"),f=require("../clients/session-id"),v=require("../clients/agent-project-dir");function p(i,e){return(0,u.getVerificationEnabled)((0,u.loadConfig)(i))?!1:(l.logger.debug(`${e}: verification is disabled \u2014 silent no-op`),!0)}b(p,"isVerificationDisabled");function s(i){const e=i??process.env.IRONBEE_CLIENT;e||(process.stderr.write(`Error: client not specified. Use --client <name> or set IRONBEE_CLIENT env var.
2
- `),process.exit(1));const t=(0,h.findClient)(e);return t||(process.stderr.write(`Error: unknown client "${e}". Run \`ironbee install\` to set up.
3
- `),process.exit(1)),t}b(s,"resolveClient");const r=new w.Command("hook").description("Internal hook runners (invoked by the AI coding client)");r.command("verify-gate").description("Stop hook \u2014 gates task completion until browser verification passes").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runVerifyGate(t)}),r.command("clear-verdict").description("PostToolUse hook \u2014 clears stale verdict after code edits").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runClearVerdict(t)}),r.command("track-action").description("PostToolUse hook \u2014 tracks browser-devtools tool calls in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackAction(t)}),r.command("track-action-monitor").description("PostToolUse hook (monitoring-only mode) \u2014 submits send_event jobs for non-devtools tools and falls back to starting an activity if needed").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackActionMonitor(t)}),r.command("track-action-pre").description("Codex PreToolUse hook \u2014 stashes a hrtime timestamp keyed by tool_use_id so the matching PostToolUse can derive tool_call.duration (Codex hook stdin does not carry duration_ms). No-op on Claude/Cursor \u2014 their hosts provide duration natively.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackActionPre(t)}),r.command("subagent-start").description("Codex SubagentStart hook \u2014 writes the agent_id \u2192 parent session_id bridge (codex-threads.json) so a delegated verifier sub-agent's agent-Bash commands resolve the session from CODEX_THREAD_ID. Codex-only.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSubagentStart?.(t)}),r.command("subagent-stop").description("Codex SubagentStop hook \u2014 prunes the thread map entry and records the sub-agent's agent_transcript_path for the analytics sub-agent fold. Codex-only.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSubagentStop?.(t)}),r.command("activity-end").description("Stop hook (monitoring-only mode) \u2014 closes the active activity and triggers a background queue flush").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runActivityEnd(t)}),r.command("session-start").description("SessionStart hook \u2014 records session start in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSessionStart(t)}),r.command("session-status").description("Statusline command (Claude) \u2014 emits a session_status event and chains the user's original statusline").action(async()=>{await(0,h.findClient)("claude")?.runSessionStatus?.()}),r.command("require-verdict").description("PreToolUse hook \u2014 blocks file edits until verdict is submitted after browser tool usage").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").option("--soft","non-blocking assist-mode variant: stash file_change state but never block the edit").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runRequireVerdict(t,{soft:i.soft===!0})}),r.command("session-end").description("SessionEnd hook \u2014 records session end in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSessionEnd(t)}),r.command("activity-start").description("UserPromptSubmit/beforeSubmitPrompt hook \u2014 starts activity tracking on each agent turn").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runActivityStart(t)}),r.command("require-verification").description("PreToolUse hook \u2014 blocks browser tools until verification-start is called").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").option("--soft","non-blocking assist-mode variant: inject _metadata but never block the devtools call").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runRequireVerification(t,{soft:i.soft===!0})}),r.command("verification-start").description(`Start a verification cycle (called by agent via Bash). Optional --intent flag: "fix" arms the verify-gate's fix-until-pass backstop (a fail verdict keeps blocking even in a zero-edit window); "report" or omitted = verify-only run (clears any stale intent \u2014 "report" is a tolerated alias of omitting the flag, mirroring the command's mode token).`).option("--intent <mode>",'declared intent of this verification run: "fix" or "report"').action(async i=>{const e=(0,v.resolveAgentProjectDir)();if(p(e,"verification-start")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
1
+ "use strict";var p=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var b=(i,e)=>p(i,"name",{value:e,configurable:!0});var P=(i,e)=>{for(var t in e)p(i,t,{get:e[t],enumerable:!0})},x=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of N(e))!C.call(i,n)&&n!==t&&p(i,n,{get:()=>e[n],enumerable:!(o=j(e,n))||o.enumerable});return i};var D=i=>x(p({},"__esModule",{value:!0}),i);var _={};P(_,{hookCommand:()=>r});module.exports=D(_);var I=require("commander"),E=require("../clients/registry"),S=require("../hooks/core/submit-verdict"),h=require("../hooks/core/verification-lifecycle"),u=require("../lib/config"),l=require("../lib/logger"),d=require("../lib/output"),m=require("../lib/stdin"),k=require("../hooks/core/session-state"),v=require("../clients/session-id"),f=require("../clients/agent-project-dir");function g(i,e){return(0,u.getVerificationEnabled)((0,u.loadConfig)(i))?!1:(l.logger.debug(`${e}: verification is disabled \u2014 silent no-op`),!0)}b(g,"isVerificationDisabled");function s(i){const e=i??process.env.IRONBEE_CLIENT;e||(process.stderr.write(`Error: client not specified. Use --client <name> or set IRONBEE_CLIENT env var.
2
+ `),process.exit(1));const t=(0,E.findClient)(e);return t||(process.stderr.write(`Error: unknown client "${e}". Run \`ironbee install\` to set up.
3
+ `),process.exit(1)),t}b(s,"resolveClient");const r=new I.Command("hook").description("Internal hook runners (invoked by the AI coding client)");r.command("verify-gate").description("Stop hook \u2014 gates task completion until browser verification passes").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runVerifyGate(t)}),r.command("clear-verdict").description("PostToolUse hook \u2014 clears stale verdict after code edits").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runClearVerdict(t)}),r.command("track-action").description("PostToolUse hook \u2014 tracks browser-devtools tool calls in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackAction(t)}),r.command("track-action-monitor").description("PostToolUse hook (monitoring-only mode) \u2014 submits send_event jobs for non-devtools tools and falls back to starting an activity if needed").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackActionMonitor(t)}),r.command("track-action-pre").description("Codex PreToolUse hook \u2014 stashes a hrtime timestamp keyed by tool_use_id so the matching PostToolUse can derive tool_call.duration (Codex hook stdin does not carry duration_ms). No-op on Claude/Cursor \u2014 their hosts provide duration natively.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackActionPre(t)}),r.command("subagent-start").description("SubagentStart hook \u2014 dispatched per client via IClient.runSubagentStart. Codex: writes the agent_id \u2192 parent session_id bridge (codex-threads.json). Claude: joins the sub-agent as an activity participant so the activity closes only when the last participant (main + all sub-agents) leaves.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSubagentStart?.(t)}),r.command("subagent-stop").description("SubagentStop hook \u2014 dispatched per client via IClient.runSubagentStop. Codex: prune the thread map + record the sub-agent's agent_transcript_path for the analytics fold. Claude: backstop that closes a verifier-owned activity/cycle the sub-agent left open without a verdict.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSubagentStop?.(t)}),r.command("activity-end").description("Stop hook (monitoring-only mode) \u2014 closes the active activity and triggers a background queue flush").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runActivityEnd(t)}),r.command("session-start").description("SessionStart hook \u2014 records session start in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSessionStart(t)}),r.command("session-status").description("Statusline command (Claude) \u2014 emits a session_status event and chains the user's original statusline").action(async()=>{await(0,E.findClient)("claude")?.runSessionStatus?.()}),r.command("require-verdict").description("PreToolUse hook \u2014 blocks file edits until verdict is submitted after browser tool usage").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").option("--soft","non-blocking assist-mode variant: stash file_change state but never block the edit").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runRequireVerdict(t,{soft:i.soft===!0})}),r.command("session-end").description("SessionEnd hook \u2014 records session end in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSessionEnd(t)}),r.command("activity-start").description("UserPromptSubmit/beforeSubmitPrompt hook \u2014 starts activity tracking on each agent turn").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runActivityStart(t)}),r.command("require-verification").description("PreToolUse hook \u2014 blocks browser tools until verification-start is called").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").option("--soft","non-blocking assist-mode variant: inject _metadata but never block the devtools call").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runRequireVerification(t,{soft:i.soft===!0})}),r.command("verification-start").description(`Start a verification cycle (called by agent via Bash). Optional --intent flag: "fix" arms the verify-gate's fix-until-pass backstop (a fail verdict keeps blocking even in a zero-edit window); "report" or omitted = verify-only run (clears any stale intent \u2014 "report" is a tolerated alias of omitting the flag, mirroring the command's mode token).`).option("--intent <mode>",'declared intent of this verification run: "fix" or "report"').action(async i=>{const e=(0,f.resolveAgentProjectDir)();if(g(e,"verification-start")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
4
4
  `,0);return}i.intent!==void 0&&i.intent!=="fix"&&i.intent!=="report"&&(process.stderr.write(`Error: --intent must be "fix" or "report".
5
5
  `),process.exit(1));const t=i.intent;let o;try{o=JSON.parse((0,m.readStdin)())}catch{process.stderr.write(`Error: no JSON provided via stdin.
6
- `),process.exit(1)}const n=(0,f.resolveAgentSessionId)(o,e);n||(process.stderr.write(`Error: JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
7
- `),process.exit(1));const c=`${e}/.ironbee/sessions/${n}`;(0,l.setLogFile)(`${c}/session.log`);const a=(0,u.isRecordingEnabled)(e),I=await(0,y.startVerification)({sessionId:n,sessionDir:c,actionsFile:`${c}/actions.jsonl`,recordingEnabled:a,intent:t}),E={verification_id:I.verificationId,trace_id:I.traceId};a&&(E.recording_required=!0,E.message="Recording is required. Call bdt_content_start-recording BEFORE using any other browser tools."),(0,d.writeAndExit)(JSON.stringify(E)+`
8
- `,0)}),r.command("verification-end").description("End a verification cycle (called by agent via Bash)").action(async()=>{const i=(0,v.resolveAgentProjectDir)();if(p(i,"verification-end")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
6
+ `),process.exit(1)}const n=(0,v.resolveAgentSessionId)(o,e);n||(process.stderr.write(`Error: JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
7
+ `),process.exit(1));const c=`${e}/.ironbee/sessions/${n}`;(0,l.setLogFile)(`${c}/session.log`);const a=(0,u.isRecordingEnabled)(e),w=await(0,h.startVerification)({sessionId:n,sessionDir:c,actionsFile:`${c}/actions.jsonl`,recordingEnabled:a,intent:t}),y={verification_id:w.verificationId,trace_id:w.traceId};a&&(y.recording_required=!0,y.message="Recording is required. Call bdt_content_start-recording BEFORE using any other browser tools."),(0,d.writeAndExit)(JSON.stringify(y)+`
8
+ `,0)}),r.command("verification-end").description("End a verification cycle (called by agent via Bash)").action(async()=>{const i=(0,f.resolveAgentProjectDir)();if(g(i,"verification-end")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
9
9
  `,0);return}let e;try{e=JSON.parse((0,m.readStdin)())}catch{process.stderr.write(`Error: no JSON provided via stdin.
10
- `),process.exit(1)}const t=(0,f.resolveAgentSessionId)(e,i);t||(process.stderr.write(`Error: JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
11
- `),process.exit(1));const o=`${i}/.ironbee/sessions/${t}`;(0,l.setLogFile)(`${o}/session.log`);const n=await(0,y.endVerification)({sessionId:t,sessionDir:o,actionsFile:`${o}/actions.jsonl`});n.success?(0,d.writeAndExit)(JSON.stringify({verification_id:n.verificationId,trace_id:n.traceId})+`
10
+ `),process.exit(1)}const t=(0,v.resolveAgentSessionId)(e,i);t||(process.stderr.write(`Error: JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
11
+ `),process.exit(1));const o=`${i}/.ironbee/sessions/${t}`;(0,l.setLogFile)(`${o}/session.log`);const n=await(0,h.endVerification)({sessionId:t,sessionDir:o,actionsFile:`${o}/actions.jsonl`});n.success?(0,d.writeAndExit)(JSON.stringify({verification_id:n.verificationId,trace_id:n.traceId})+`
12
12
  `,0):(process.stderr.write(n.message+`
13
- `),process.exit(1))}),r.command("submit-verdict").description("Submit verification verdict (called by agent via Bash)").option("--project-dir <dir>","project directory (overrides env vars)").action(async i=>{const e=(0,v.resolveAgentProjectDir)(i.projectDir);if(p(e,"submit-verdict")){(0,d.writeAndExit)(`verification is disabled in this project; verdict ignored
13
+ `),process.exit(1))}),r.command("submit-verdict").description("Submit verification verdict (called by agent via Bash)").option("--project-dir <dir>","project directory (overrides env vars)").action(async i=>{const e=(0,f.resolveAgentProjectDir)(i.projectDir);if(g(e,"submit-verdict")){(0,d.writeAndExit)(`verification is disabled in this project; verdict ignored
14
14
  `,0);return}let t;try{t=(0,m.readStdin)()}catch{process.stderr.write(`Error: no verdict JSON provided via stdin.
15
15
  `),process.exit(1)}let o;try{o=JSON.parse(t)}catch{process.stderr.write(`Error: verdict is not valid JSON.
16
- `),process.exit(1)}const n=(0,f.resolveAgentSessionId)(o,e);n||(process.stderr.write(`Error: verdict JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
17
- `),process.exit(1));const c=`${e}/.ironbee/sessions/${n}`;(0,l.setLogFile)(`${c}/session.log`);const a=await(0,k.runSubmitVerdict)({sessionId:n,sessionDir:c,verdictFile:`${c}/verdict.json`,actionsFile:`${c}/actions.jsonl`,verdictJson:t,projectDir:e});a.success?(0,d.writeAndExit)(a.message+`
16
+ `),process.exit(1)}const n=(0,v.resolveAgentSessionId)(o,e);n||(process.stderr.write(`Error: verdict JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
17
+ `),process.exit(1));const c=`${e}/.ironbee/sessions/${n}`;(0,l.setLogFile)(`${c}/session.log`);const a=await(0,S.runSubmitVerdict)({sessionId:n,sessionDir:c,verdictFile:`${c}/verdict.json`,actionsFile:`${c}/actions.jsonl`,verdictJson:t,projectDir:e});a.success?(0,d.writeAndExit)(a.message+`
18
18
  `,0):(process.stderr.write(a.message+`
19
- `),process.exit(1))}),r.command("record-fix").description("Record what was fixed after a fail verdict (called by agent via Bash). Stashed locally in state.json; merged into the next pass verdict's fixes. Emits no collector event.").action(async()=>{const i=(0,v.resolveAgentProjectDir)();if(p(i,"record-fix")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
19
+ `),process.exit(1))}),r.command("record-fix").description("Record what was fixed after a fail verdict (called by agent via Bash). Stashed locally in state.json; merged into the next pass verdict's fixes. Emits no collector event.").action(async()=>{const i=(0,f.resolveAgentProjectDir)();if(g(i,"record-fix")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
20
20
  `,0);return}let e;try{e=JSON.parse((0,m.readStdin)())}catch{process.stderr.write(`Error: no JSON provided via stdin.
21
- `),process.exit(1)}const t=(0,f.resolveAgentSessionId)(e,i);t||(process.stderr.write(`Error: JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
21
+ `),process.exit(1)}const t=(0,v.resolveAgentSessionId)(e,i);t||(process.stderr.write(`Error: JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
22
22
  `),process.exit(1));const o=e.fixes,n=Array.isArray(o)?o.filter(a=>typeof a=="string"&&a.length>0):[];n.length===0&&(process.stderr.write(`Error: JSON must include a non-empty "fixes" array of strings.
23
- `),process.exit(1));const c=`${i}/.ironbee/sessions/${t}`;(0,l.setLogFile)(`${c}/session.log`),(0,S.addPendingFixes)(c,n),l.logger.debug(`record-fix: session=${t} recorded ${n.length} fix note(s)`),(0,d.writeAndExit)(JSON.stringify({recorded:n.length})+`
23
+ `),process.exit(1));const c=`${i}/.ironbee/sessions/${t}`;(0,l.setLogFile)(`${c}/session.log`),(0,k.addPendingFixes)(c,n),l.logger.debug(`record-fix: session=${t} recorded ${n.length} fix note(s)`),(0,d.writeAndExit)(JSON.stringify({recorded:n.length})+`
24
24
  `,0)});0&&(module.exports={hookCommand});
@@ -1 +1 @@
1
- "use strict";var P=Object.create;var c=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var o=(t,n)=>c(t,"name",{value:n,configurable:!0});var T=(t,n)=>{for(var e in n)c(t,e,{get:n[e],enumerable:!0})},h=(t,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of C(n))!k.call(t,a)&&a!==e&&c(t,a,{get:()=>n[a],enumerable:!(i=$(n,a))||i.enumerable});return t};var S=(t,n,e)=>(e=t!=null?P(A(t)):{},h(n||!t||!t.__esModule?c(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>h(c({},"__esModule",{value:!0}),t);var E={};T(E,{deriveInstallPrefix:()=>d,derivePrefixFromBinary:()=>x,detectPrefixMismatch:()=>y,detectShadowOnPath:()=>v,updateCommand:()=>_});module.exports=B(E);var w=require("commander"),g=require("child_process"),l=require("fs"),s=S(require("path")),r=require("../lib/output"),f=require("../lib/version");function d(t){let n=t;for(;;){const e=s.dirname(n);if(e===n)return null;if(s.basename(n)==="node_modules")return s.basename(e)==="lib"?s.dirname(e):e;n=e}}o(d,"deriveInstallPrefix");function M(){try{const n=((0,g.execSync)("npm config get prefix",{encoding:"utf-8",stdio:["ignore","pipe","ignore"]})??"").toString().trim();return n.length>0?n:null}catch{return null}}o(M,"getNpmConfiguredPrefix");function u(t){let n;try{n=(0,l.realpathSync)(t)}catch{n=s.resolve(t)}for(;n.length>1&&(n.endsWith("/")||n.endsWith(s.sep));)n=n.slice(0,-1);return process.platform==="win32"?n.toLowerCase():n}o(u,"normalizeForCompare");function y(t,n){const e=d(t);return!e||!n||u(e)===u(n)?null:{running:e,npm:n}}o(y,"detectPrefixMismatch");function x(t){if(!t)return null;const n=s.dirname(t);return process.platform!=="win32"&&s.basename(n)==="bin"?s.dirname(n):n}o(x,"derivePrefixFromBinary");function I(t){const n=process.env.PATH??"";if(n.length===0)return null;const e=process.platform==="win32"?";":":",i=n.split(e),a=process.platform==="win32"?(process.env.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";"):[""];for(const p of i)if(p.length!==0)for(const b of a){const m=s.join(p,t+b);try{return(0,l.accessSync)(m,l.constants.X_OK),m}catch{}}return null}o(I,"findFirstPathBinary");function v(t,n){const e=d(t);if(!e||!n)return null;const i=x(n);return!i||u(e)===u(i)?null:{shadowBinary:n,shadowPrefix:i,runningPrefix:e}}o(v,"detectShadowOnPath");function O(t){const n=process.platform==="win32"?`del "${t.shadowBinary}"`:`rm "${t.shadowBinary}"`;r.log.blank(),r.log.warn(r.pc.bold("Another IronBee install is earlier on your PATH")),r.log.warn(` PATH-resolved binary: ${r.pc.cyan(t.shadowBinary)}`),r.log.warn(` This update is for: ${r.pc.cyan(t.runningPrefix)}`),r.log.warn("After install, your shell will keep resolving the OLDER one."),r.log.warn("To fix, either:"),r.log.warn(` 1) Remove the shadow: ${r.pc.cyan(n)}`),r.log.warn(" 2) Or install to the shadow's location:"),r.log.warn(` ${r.pc.cyan(`npm install -g --prefix "${t.shadowPrefix}" @ironbee-ai/cli@latest`)}`),r.log.blank()}o(O,"warnPathShadow");function L(t){r.log.blank(),r.log.warn(r.pc.bold("Install location mismatch detected")),r.log.warn(` Active IronBee runs from: ${r.pc.cyan(t.running)}`),r.log.warn(` npm install will write to: ${r.pc.cyan(t.npm)}`),r.log.warn("After install, your shell may keep resolving the OLD version on PATH."),r.log.warn("To make the new version take effect, either:"),r.log.warn(` 1) Align npm prefix: ${r.pc.cyan(`npm config set prefix "${t.running}"`)}`),r.log.warn(" 2) Or install directly to the active location:"),r.log.warn(` ${r.pc.cyan(`npm install -g --prefix "${t.running}" @ironbee-ai/cli@latest`)}`),r.log.blank()}o(L,"warnPrefixMismatch");const _=new w.Command("update").description("Update IronBee CLI to the latest version").action(async()=>{const t=(0,f.getLocalVersion)();r.log.info(`Current version: ${r.pc.bold(t)}`),r.log.step("Checking npm registry...");const n=await(0,f.fetchLatestVersion)();if(n||(r.log.error("Could not reach npm registry. Check your internet connection."),process.exit(1)),n===t){r.log.success(`Already on the latest version (${r.pc.bold(t)})`);return}r.log.info(`New version available: ${r.pc.dim(t)} ${r.pc.yellow("\u2192")} ${r.pc.green(r.pc.bold(n))}`);const e=y(__dirname,M());e&&L(e);const i=v(__dirname,I("ironbee"));i&&O(i),r.log.step(`Running ${r.pc.cyan("npm install -g @ironbee-ai/cli@latest")}...`);try{(0,g.execSync)("npm install -g @ironbee-ai/cli@latest",{stdio:"inherit"}),r.log.blank(),r.log.success(`Updated to ${r.pc.green(r.pc.bold(n))}`),r.log.step("Restart your AI coding client to use the new version.")}catch{r.log.blank(),r.log.error("Update failed. Try running manually:"),console.log(` ${r.pc.cyan("npm install -g @ironbee-ai/cli@latest")}`),process.exit(1)}});0&&(module.exports={deriveInstallPrefix,derivePrefixFromBinary,detectPrefixMismatch,detectShadowOnPath,updateCommand});
1
+ "use strict";var P=Object.create;var c=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var o=(t,n)=>c(t,"name",{value:n,configurable:!0});var T=(t,n)=>{for(var e in n)c(t,e,{get:n[e],enumerable:!0})},h=(t,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of C(n))!k.call(t,a)&&a!==e&&c(t,a,{get:()=>n[a],enumerable:!(i=$(n,a))||i.enumerable});return t};var S=(t,n,e)=>(e=t!=null?P(A(t)):{},h(n||!t||!t.__esModule?c(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>h(c({},"__esModule",{value:!0}),t);var E={};T(E,{deriveInstallPrefix:()=>d,derivePrefixFromBinary:()=>x,detectPrefixMismatch:()=>y,detectShadowOnPath:()=>v,updateCommand:()=>_});module.exports=B(E);var w=require("commander"),g=require("child_process"),l=require("fs"),s=S(require("path")),r=require("../lib/output"),f=require("../lib/version");function d(t){let n=t;for(;;){const e=s.dirname(n);if(e===n)return null;if(s.basename(n)==="node_modules")return s.basename(e)==="lib"?s.dirname(e):e;n=e}}o(d,"deriveInstallPrefix");function M(){try{const n=((0,g.execSync)("npm config get prefix",{encoding:"utf-8",stdio:["ignore","pipe","ignore"]})??"").toString().trim();return n.length>0?n:null}catch{return null}}o(M,"getNpmConfiguredPrefix");function u(t){let n;try{n=(0,l.realpathSync)(t)}catch{n=s.resolve(t)}for(;n.length>1&&(n.endsWith("/")||n.endsWith(s.sep));)n=n.slice(0,-1);return process.platform==="win32"?n.toLowerCase():n}o(u,"normalizeForCompare");function y(t,n){const e=d(t);return!e||!n||u(e)===u(n)?null:{running:e,npm:n}}o(y,"detectPrefixMismatch");function x(t){if(!t)return null;const n=s.dirname(t);return process.platform!=="win32"&&s.basename(n)==="bin"?s.dirname(n):n}o(x,"derivePrefixFromBinary");function I(t){const n=process.env.PATH??"";if(n.length===0)return null;const e=process.platform==="win32"?";":":",i=n.split(e),a=process.platform==="win32"?(process.env.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";"):[""];for(const p of i)if(p.length!==0)for(const b of a){const m=s.join(p,t+b);try{return(0,l.accessSync)(m,l.constants.X_OK),m}catch{}}return null}o(I,"findFirstPathBinary");function v(t,n){const e=d(t);if(!e||!n)return null;const i=x(n);return!i||u(e)===u(i)?null:{shadowBinary:n,shadowPrefix:i,runningPrefix:e}}o(v,"detectShadowOnPath");function O(t){const n=process.platform==="win32"?`del "${t.shadowBinary}"`:`rm "${t.shadowBinary}"`;r.log.blank(),r.log.warn(r.pc.bold("Another IronBee install is earlier on your PATH")),r.log.warn(` PATH-resolved binary: ${r.pc.cyan(t.shadowBinary)}`),r.log.warn(` This update is for: ${r.pc.cyan(t.runningPrefix)}`),r.log.warn("After install, your shell will keep resolving the OLDER one."),r.log.warn("To fix, either:"),r.log.warn(` 1) Remove the shadow: ${r.pc.cyan(n)}`),r.log.warn(" 2) Or install to the shadow's location:"),r.log.warn(` ${r.pc.cyan(`npm install -g --foreground-scripts --prefix "${t.shadowPrefix}" @ironbee-ai/cli@latest`)}`),r.log.blank()}o(O,"warnPathShadow");function L(t){r.log.blank(),r.log.warn(r.pc.bold("Install location mismatch detected")),r.log.warn(` Active IronBee runs from: ${r.pc.cyan(t.running)}`),r.log.warn(` npm install will write to: ${r.pc.cyan(t.npm)}`),r.log.warn("After install, your shell may keep resolving the OLD version on PATH."),r.log.warn("To make the new version take effect, either:"),r.log.warn(` 1) Align npm prefix: ${r.pc.cyan(`npm config set prefix "${t.running}"`)}`),r.log.warn(" 2) Or install directly to the active location:"),r.log.warn(` ${r.pc.cyan(`npm install -g --foreground-scripts --prefix "${t.running}" @ironbee-ai/cli@latest`)}`),r.log.blank()}o(L,"warnPrefixMismatch");const _=new w.Command("update").description("Update IronBee CLI to the latest version").action(async()=>{const t=(0,f.getLocalVersion)();r.log.info(`Current version: ${r.pc.bold(t)}`),r.log.step("Checking npm registry...");const n=await(0,f.fetchLatestVersion)();if(n||(r.log.error("Could not reach npm registry. Check your internet connection."),process.exit(1)),n===t){r.log.success(`Already on the latest version (${r.pc.bold(t)})`);return}r.log.info(`New version available: ${r.pc.dim(t)} ${r.pc.yellow("\u2192")} ${r.pc.green(r.pc.bold(n))}`);const e=y(__dirname,M());e&&L(e);const i=v(__dirname,I("ironbee"));i&&O(i),r.log.step(`Running ${r.pc.cyan("npm install -g --foreground-scripts @ironbee-ai/cli@latest")}...`);try{(0,g.execSync)("npm install -g --foreground-scripts @ironbee-ai/cli@latest",{stdio:"inherit"}),r.log.blank(),r.log.success(`Updated to ${r.pc.green(r.pc.bold(n))}`),r.log.step("Restart your AI coding client to use the new version.")}catch{r.log.blank(),r.log.error("Update failed. Try running manually:"),console.log(` ${r.pc.cyan("npm install -g --foreground-scripts @ironbee-ai/cli@latest")}`),process.exit(1)}});0&&(module.exports={deriveInstallPrefix,derivePrefixFromBinary,detectPrefixMismatch,detectShadowOnPath,updateCommand});
@@ -1 +1 @@
1
- "use strict";var r=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var c=(t,i)=>r(t,"name",{value:i,configurable:!0});var f=(t,i)=>{for(var o in i)r(t,o,{get:i[o],enumerable:!0})},m=(t,i,o,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of u(i))!g.call(t,n)&&n!==o&&r(t,n,{get:()=>i[n],enumerable:!(s=d(i,n))||s.enumerable});return t};var y=t=>m(r({},"__esModule",{value:!0}),t);var v={};f(v,{runActivityEnd:()=>I});module.exports=y(v);var a=require("./activity"),p=require("./session-state"),e=require("../../queue");async function I(t){const{sessionDir:i,actionsFile:o,projectDir:s,sessionId:n}=t;await(0,p.closeOpenCycles)(i,o,"stop");const l=await(0,a.endActivity)({sessionDir:i,actionsFile:o});return(0,e.flushInBackground)(s,n),(0,e.flushStragglersInBackground)(s,n),l}c(I,"runActivityEnd");0&&(module.exports={runActivityEnd});
1
+ "use strict";var r=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var c=(t,i)=>r(t,"name",{value:i,configurable:!0});var u=(t,i)=>{for(var s in i)r(t,s,{get:i[s],enumerable:!0})},g=(t,i,s,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of d(i))!f.call(t,o)&&o!==s&&r(t,o,{get:()=>i[o],enumerable:!(n=m(i,o))||n.enumerable});return t};var y=t=>g(r({},"__esModule",{value:!0}),t);var v={};u(v,{runActivityEnd:()=>A});module.exports=y(v);var a=require("./activity"),p=require("./activity-participants"),l=require("./session-state"),e=require("../../queue");async function A(t){const{sessionDir:i,actionsFile:s,projectDir:n,sessionId:o}=t,I=await(0,a.closeActivityIfLastParticipant)({sessionDir:i,actionsFile:s},p.MAIN_PARTICIPANT_ID,()=>(0,l.closeOpenCycles)(i,s,"stop"));return(0,e.flushInBackground)(n,o),(0,e.flushStragglersInBackground)(n,o),I}c(A,"runActivityEnd");0&&(module.exports={runActivityEnd});
@@ -0,0 +1 @@
1
+ "use strict";var g=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var e=(t,n)=>g(t,"name",{value:n,configurable:!0});var A=(t,n)=>{for(var r in n)g(t,r,{get:n[r],enumerable:!0})},P=(t,n,r,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of w(n))!$.call(t,o)&&o!==r&&g(t,o,{get:()=>n[o],enumerable:!(c=h(n,o))||c.enumerable});return t};var x=t=>P(g({},"__esModule",{value:!0}),t);var R={};A(R,{MAIN_PARTICIPANT_ID:()=>b,PARTICIPANT_TTL_MS:()=>l,anyActiveParticipants:()=>C,anyNonMainParticipants:()=>N,claimActivityClose:()=>D,clearActivityParticipants:()=>I,enterActivity:()=>T,isParticipantPresent:()=>_,leaveActivity:()=>k,releaseActivityClose:()=>M});module.exports=x(R);var i=require("fs"),u=require("path"),s=require("../../lib/logger");const S="activity",f=".participant",p="closing-",b="main",l=900*1e3;function a(t){return(0,u.join)(t,S)}e(a,"activityDir");function d(t){return t.replace(/[^a-zA-Z0-9_-]/g,"_")}e(d,"sanitize");function m(t,n){return(0,u.join)(a(t),`${d(n)}${f}`)}e(m,"participantPath");function v(t,n){return(0,u.join)(a(t),`${p}${d(n)}`)}e(v,"closingPath");function T(t,n){if(n)try{(0,i.mkdirSync)(a(t),{recursive:!0}),(0,i.writeFileSync)(m(t,n),String(Date.now()))}catch(r){s.logger.debug(`enter-activity failed for ${n}: ${r}`)}}e(T,"enterActivity");function k(t,n){if(n)try{const r=m(t,n);(0,i.existsSync)(r)&&(0,i.unlinkSync)(r)}catch(r){s.logger.debug(`leave-activity failed for ${n}: ${r}`)}}e(k,"leaveActivity");function _(t,n,r=l){const c=m(t,n);if(!(0,i.existsSync)(c))return!1;try{return Date.now()-(0,i.statSync)(c).mtimeMs<=r}catch{return!1}}e(_,"isParticipantPresent");function C(t,n=l){const r=a(t);if(!(0,i.existsSync)(r))return!1;try{const c=Date.now();for(const o of(0,i.readdirSync)(r))if(o.endsWith(f))try{if(c-(0,i.statSync)((0,u.join)(r,o)).mtimeMs<=n)return!0}catch{}return!1}catch(c){return s.logger.debug(`any-active-participants failed: ${c}`),!1}}e(C,"anyActiveParticipants");function N(t,n=l){const r=a(t);if(!(0,i.existsSync)(r))return!1;const c=`${d(b)}${f}`;try{const o=Date.now();for(const y of(0,i.readdirSync)(r))if(!(!y.endsWith(f)||y===c))try{if(o-(0,i.statSync)((0,u.join)(r,y)).mtimeMs<=n)return!0}catch{}return!1}catch(o){return s.logger.debug(`any-non-main-participants failed: ${o}`),!1}}e(N,"anyNonMainParticipants");function D(t,n){if(!n)return!1;try{return(0,i.mkdirSync)(a(t),{recursive:!0}),(0,i.writeFileSync)(v(t,n),String(Date.now()),{flag:"wx"}),!0}catch(r){return s.logger.debug(`claim-activity-close not won for ${n}: ${r?.code??r}`),!1}}e(D,"claimActivityClose");function M(t,n){if(n)try{const r=v(t,n);(0,i.existsSync)(r)&&(0,i.unlinkSync)(r)}catch(r){s.logger.debug(`release-activity-close failed for ${n}: ${r}`)}}e(M,"releaseActivityClose");function I(t){const n=a(t);if((0,i.existsSync)(n))try{for(const r of(0,i.readdirSync)(n))if(r.endsWith(f)||r.startsWith(p))try{(0,i.unlinkSync)((0,u.join)(n,r))}catch{}}catch(r){s.logger.debug(`clear-activity-participants failed: ${r}`)}}e(I,"clearActivityParticipants");0&&(module.exports={MAIN_PARTICIPANT_ID,PARTICIPANT_TTL_MS,anyActiveParticipants,anyNonMainParticipants,claimActivityClose,clearActivityParticipants,enterActivity,isParticipantPresent,leaveActivity,releaseActivityClose});
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var y=(i,t)=>a(i,"name",{value:t,configurable:!0});var f=(i,t)=>{for(var e in t)a(i,e,{get:t[e],enumerable:!0})},g=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!m.call(i,n)&&n!==e&&a(i,n,{get:()=>t[n],enumerable:!(r=A(t,n))||r.enumerable});return i};var l=i=>g(a({},"__esModule",{value:!0}),i);var w={};f(w,{endActivity:()=>I,startActivity:()=>D});module.exports=l(w);var d=require("crypto"),v=require("../../lib/logger"),c=require("./session-state"),o=require("./actions");async function D(i){const{sessionDir:t,actionsFile:e,source:r}=i;if((0,c.isActive)(t))return;const n=(0,d.randomUUID)();(0,c.setActiveActivity)(t,n);const s={...(0,o.baseFields)(e),type:"activity_start",timestamp:Date.now(),activity_id:n,source:r};await(0,o.appendAction)(e,s),v.logger.debug(`activity-start: ${n} source=${r??"unknown"}`)}y(D,"startActivity");async function I(i){const{sessionDir:t,actionsFile:e}=i;if(!(0,c.isActive)(t))return!1;const r=(0,c.getActiveActivityId)(t);(0,c.clearActiveActivity)(t);const n=Date.now(),s=(0,o.findDurationSinceLastAction)(e,"activity_start",n),u={...(0,o.baseFields)(e),type:"activity_end",timestamp:n,activity_id:r,duration:s};return await(0,o.appendAction)(e,u),v.logger.debug(`activity-end: ${r??""} duration=${s??"unknown"}`),!0}y(I,"endActivity");0&&(module.exports={endActivity,startActivity});
1
+ "use strict";var y=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var A=(n,t)=>y(n,"name",{value:t,configurable:!0});var I=(n,t)=>{for(var e in t)y(n,e,{get:t[e],enumerable:!0})},D=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of l(t))!g.call(n,r)&&r!==e&&y(n,r,{get:()=>t[r],enumerable:!(i=m(t,r))||i.enumerable});return n};var w=n=>D(y({},"__esModule",{value:!0}),n);var _={};I(_,{closeActivityIfLastParticipant:()=>P,endActivity:()=>f,startActivity:()=>b});module.exports=w(_);var u=require("crypto"),d=require("../../lib/logger"),o=require("./session-state"),c=require("./activity-participants"),a=require("./actions");async function b(n){const{sessionDir:t,actionsFile:e,source:i}=n,r=(0,o.isActive)(t);if((i==="user_prompt"||!r)&&(0,c.enterActivity)(t,c.MAIN_PARTICIPANT_ID),r)return;const s=(0,u.randomUUID)();(0,o.setActiveActivity)(t,s);const v={...(0,a.baseFields)(e),type:"activity_start",timestamp:Date.now(),activity_id:s,source:i};await(0,a.appendAction)(e,v),d.logger.debug(`activity-start: ${s} source=${i??"unknown"}`)}A(b,"startActivity");async function P(n,t,e){const{sessionDir:i}=n;if((0,c.leaveActivity)(i,t),(0,c.anyActiveParticipants)(i)||!(0,o.isActive)(i))return!1;const r=(0,o.getActiveActivityId)(i);if(!(0,c.claimActivityClose)(i,r))return!1;e&&await e();const s=await f(n);return s&&(0,c.releaseActivityClose)(i,r),s}A(P,"closeActivityIfLastParticipant");async function f(n,t){const{sessionDir:e,actionsFile:i}=n;if(!(0,o.isActive)(e))return!1;const r=(0,o.getActiveActivityId)(e);(0,o.clearActiveActivity)(e);const s=Date.now(),v=(0,a.findDurationSinceLastAction)(i,"activity_start",s),p={...(0,a.baseFields)(i),type:"activity_end",timestamp:s,activity_id:r,duration:v,...t?{reason:t}:{}};return await(0,a.appendAction)(i,p),d.logger.debug(`activity-end: ${r??""} duration=${v??"unknown"}${t?` reason=${t}`:""}`),!0}A(f,"endActivity");0&&(module.exports={closeActivityIfLastParticipant,endActivity,startActivity});
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var a=(i,e)=>g(i,"name",{value:e,configurable:!0});var h=(i,e)=>{for(var n in e)g(i,n,{get:e[n],enumerable:!0})},_=(i,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A(e))!m.call(i,r)&&r!==n&&g(i,r,{get:()=>e[r],enumerable:!(t=x(e,r))||t.enumerable});return i};var V=i=>_(g({},"__esModule",{value:!0}),i);var pt={};h(pt,{addPendingFixes:()=>nt,clearActiveActivity:()=>ut,clearActiveFix:()=>k,clearActiveVerification:()=>P,clearPendingFixes:()=>rt,clearVerifyIntent:()=>st,closeOpenCycles:()=>ft,generateTraceId:()=>b,getActiveActivityId:()=>H,getActiveFixId:()=>U,getActiveTraceId:()=>E,getActiveVerificationId:()=>T,getChainedStatusLine:()=>Z,getContextInjectedVerificationId:()=>tt,getLastVerdictStatus:()=>L,getPendingFixes:()=>it,getPhase:()=>z,getRetries:()=>F,getUsagePlan:()=>X,getUsageType:()=>Q,getUserEmail:()=>K,getVerifyIntent:()=>at,incrementRetries:()=>R,isActive:()=>W,isFailLikeVerdictStatus:()=>ot,isRecordingActive:()=>N,isRecordingRequired:()=>O,readState:()=>c,reconcileAbandonedActivity:()=>gt,reconcileForCompact:()=>vt,reconcileSessionState:()=>lt,resetRetries:()=>$,setActive:()=>G,setActiveActivity:()=>dt,setActiveFix:()=>j,setActiveVerification:()=>w,setChainedStatusLine:()=>D,setContextInjectedVerificationId:()=>et,setLastVerdictStatus:()=>q,setPhase:()=>C,setRecordingActive:()=>B,setRecordingRequired:()=>J,setUsage:()=>Y,setUserEmail:()=>M,setVerifyIntent:()=>ct,writeState:()=>u});module.exports=V(pt);var S=require("crypto"),l=require("fs"),p=require("path"),f=require("../../lib/logger"),v=require("../../lib/atomic"),d=require("./actions");const y="state.json",I={retries:0,activeVerificationId:null,activeTraceId:null,lastVerdictStatus:null,activeFixId:null,activeActivityId:null,phase:null,recordingRequired:!1,recordingActive:!1,active:!1,userEmail:null,usageType:null,usagePlan:null,chainedStatusLine:null,contextInjectedVerificationId:null,pendingFixes:[],verifyIntent:null};function b(){return(0,S.randomBytes)(16).toString("hex")}a(b,"generateTraceId");function c(i){const e=(0,p.join)(i,y);if(!(0,l.existsSync)(e))return{...I};try{const n=(0,l.readFileSync)(e,"utf-8"),t=JSON.parse(n),r=["coding","verifying","fixing"],s=["api","subscription"];return{retries:typeof t.retries=="number"?t.retries:0,activeVerificationId:typeof t.activeVerificationId=="string"?t.activeVerificationId:null,activeTraceId:typeof t.activeTraceId=="string"?t.activeTraceId:null,lastVerdictStatus:typeof t.lastVerdictStatus=="string"?t.lastVerdictStatus:null,activeFixId:typeof t.activeFixId=="string"?t.activeFixId:null,activeActivityId:typeof t.activeActivityId=="string"?t.activeActivityId:null,phase:typeof t.phase=="string"&&r.includes(t.phase)?t.phase:null,recordingRequired:typeof t.recordingRequired=="boolean"?t.recordingRequired:!1,recordingActive:typeof t.recordingActive=="boolean"?t.recordingActive:!1,active:typeof t.active=="boolean"?t.active:!1,userEmail:typeof t.userEmail=="string"?t.userEmail:null,usageType:typeof t.usageType=="string"&&s.includes(t.usageType)?t.usageType:null,usagePlan:typeof t.usagePlan=="string"&&t.usagePlan.length>0?t.usagePlan:null,chainedStatusLine:typeof t.chainedStatusLine=="string"&&t.chainedStatusLine.length>0?t.chainedStatusLine:null,contextInjectedVerificationId:typeof t.contextInjectedVerificationId=="string"?t.contextInjectedVerificationId:null,pendingFixes:Array.isArray(t.pendingFixes)?t.pendingFixes.filter(o=>typeof o=="string"&&o.length>0):[],verifyIntent:typeof t.verifyIntent=="string"&&t.verifyIntent.length>0?t.verifyIntent:null}}catch(n){return f.logger.debug(`failed to read state from ${e}: ${n}`),{...I}}}a(c,"readState");function u(i,e){const n=(0,p.join)(i,y);try{(0,l.mkdirSync)(i,{recursive:!0});const t=`${n}.tmp.${process.pid}.${Date.now()}`,r=JSON.stringify(e,null,2);try{(0,l.writeFileSync)(t,r),(0,v.renameWithRetry)(t,n)}catch(s){try{(0,l.existsSync)(t)&&(0,l.unlinkSync)(t)}catch{}throw s}(0,v.sweepStaleTmpFiles)(n)}catch(t){f.logger.debug(`failed to write state to ${n}: ${t}`)}}a(u,"writeState");function T(i){return c(i).activeVerificationId??void 0}a(T,"getActiveVerificationId");function w(i,e,n){const t=c(i);t.activeVerificationId=e,t.activeTraceId=n,t.phase="verifying",u(i,t)}a(w,"setActiveVerification");function E(i){return c(i).activeTraceId??void 0}a(E,"getActiveTraceId");function P(i){const e=c(i);e.activeVerificationId=null,e.activeTraceId=null,e.phase="coding",u(i,e)}a(P,"clearActiveVerification");function F(i){return c(i).retries}a(F,"getRetries");function R(i){const e=c(i);return e.retries=e.retries+1,u(i,e),e.retries}a(R,"incrementRetries");function $(i){const e=c(i);e.retries=0,u(i,e)}a($,"resetRetries");function L(i){return c(i).lastVerdictStatus??void 0}a(L,"getLastVerdictStatus");function q(i,e){const n=c(i);n.lastVerdictStatus=e,u(i,n)}a(q,"setLastVerdictStatus");function j(i,e){const n=c(i);n.activeFixId=e,u(i,n)}a(j,"setActiveFix");function U(i){return c(i).activeFixId??void 0}a(U,"getActiveFixId");function k(i){const e=c(i);e.activeFixId=null,u(i,e)}a(k,"clearActiveFix");function C(i,e){const n=c(i);n.phase=e,u(i,n)}a(C,"setPhase");function z(i){return c(i).phase}a(z,"getPhase");function O(i){return c(i).recordingRequired}a(O,"isRecordingRequired");function J(i,e){const n=c(i);n.recordingRequired=e,u(i,n)}a(J,"setRecordingRequired");function N(i){return c(i).recordingActive}a(N,"isRecordingActive");function B(i,e){const n=c(i);n.recordingActive=e,u(i,n)}a(B,"setRecordingActive");function W(i){return c(i).active}a(W,"isActive");function G(i,e){const n=c(i);n.active=e,e||(n.activeActivityId=null),u(i,n)}a(G,"setActive");function H(i){return c(i).activeActivityId??void 0}a(H,"getActiveActivityId");function K(i){return c(i).userEmail??void 0}a(K,"getUserEmail");function M(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.userEmail!==n&&(t.userEmail=n,u(i,t))}a(M,"setUserEmail");function Q(i){return c(i).usageType??void 0}a(Q,"getUsageType");function X(i){return c(i).usagePlan??void 0}a(X,"getUsagePlan");function Y(i,e){const n=e.usage_type==="api"||e.usage_type==="subscription"?e.usage_type:null,t=typeof e.usage_plan=="string"&&e.usage_plan.length>0?e.usage_plan:null,r=c(i);r.usageType===n&&r.usagePlan===t||(r.usageType=n,r.usagePlan=t,u(i,r))}a(Y,"setUsage");function Z(i){return c(i).chainedStatusLine??void 0}a(Z,"getChainedStatusLine");function D(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.chainedStatusLine!==n&&(t.chainedStatusLine=n,u(i,t))}a(D,"setChainedStatusLine");function tt(i){return c(i).contextInjectedVerificationId??void 0}a(tt,"getContextInjectedVerificationId");function et(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.contextInjectedVerificationId!==n&&(t.contextInjectedVerificationId=n,u(i,t))}a(et,"setContextInjectedVerificationId");function it(i){return c(i).pendingFixes}a(it,"getPendingFixes");function nt(i,e){const n=e.filter(o=>typeof o=="string"&&o.length>0);if(n.length===0)return;const t=c(i),r=new Set(t.pendingFixes),s=[...t.pendingFixes];for(const o of n)r.has(o)||(r.add(o),s.push(o));s.length!==t.pendingFixes.length&&(t.pendingFixes=s,u(i,t))}a(nt,"addPendingFixes");function rt(i){const e=c(i);e.pendingFixes.length!==0&&(e.pendingFixes=[],u(i,e))}a(rt,"clearPendingFixes");function at(i){return c(i).verifyIntent}a(at,"getVerifyIntent");function ct(i,e){const n=c(i);n.verifyIntent!==e&&(n.verifyIntent=e,u(i,n))}a(ct,"setVerifyIntent");function st(i){const e=c(i);e.verifyIntent!==null&&(e.verifyIntent=null,u(i,e))}a(st,"clearVerifyIntent");function ot(i){return i==="fail"||i==="fail_reported"}a(ot,"isFailLikeVerdictStatus");function dt(i,e){const n=c(i);n.activeActivityId=e,n.active=!0,u(i,n)}a(dt,"setActiveActivity");function ut(i){const e=c(i);e.activeActivityId=null,e.active=!1,u(i,e)}a(ut,"clearActiveActivity");async function ft(i,e,n){const t=c(i);let r=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:n};await(0,d.appendAction)(e,o),f.logger.debug(`close-open-cycles: ended verification ${t.activeVerificationId} (${n})`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:n};await(0,d.appendAction)(e,o),f.logger.debug(`close-open-cycles: ended fix ${t.activeFixId} (${n})`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(ft,"closeOpenCycles");async function lt(i,e,n){const t=c(i);let r=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"session_reconcile"};await n(e,o),f.logger.debug(`reconcile: ended abandoned verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"session_reconcile"};await n(e,o),f.logger.debug(`reconcile: ended abandoned fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}if(t.active){const s=Date.now(),o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"session_reconcile"};await n(e,o),f.logger.debug(`reconcile: ended abandoned activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(lt,"reconcileSessionState");async function gt(i,e,n){const t=c(i);if(!t.active&&!t.activeVerificationId&&!t.activeFixId&&t.verifyIntent===null)return;let r=!1;const s=(0,d.findLastActionTimestamp)(e)??Date.now();if(t.activeVerificationId){const o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"interrupt_inferred"};await n(e,o),f.logger.debug(`interrupt-reconcile: ended verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"interrupt_inferred"};await n(e,o),f.logger.debug(`interrupt-reconcile: ended fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}if(t.active){const o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"interrupt_inferred"};await n(e,o),f.logger.debug(`interrupt-reconcile: ended activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(gt,"reconcileAbandonedActivity");async function vt(i,e,n){const t=c(i);let r=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"compact"};await n(e,o),f.logger.debug(`compact-reconcile: ended verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"compact"};await n(e,o),f.logger.debug(`compact-reconcile: ended fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}if(t.active){const s=Date.now(),o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"compact"};await n(e,o),f.logger.debug(`compact-reconcile: ended activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(vt,"reconcileForCompact");0&&(module.exports={addPendingFixes,clearActiveActivity,clearActiveFix,clearActiveVerification,clearPendingFixes,clearVerifyIntent,closeOpenCycles,generateTraceId,getActiveActivityId,getActiveFixId,getActiveTraceId,getActiveVerificationId,getChainedStatusLine,getContextInjectedVerificationId,getLastVerdictStatus,getPendingFixes,getPhase,getRetries,getUsagePlan,getUsageType,getUserEmail,getVerifyIntent,incrementRetries,isActive,isFailLikeVerdictStatus,isRecordingActive,isRecordingRequired,readState,reconcileAbandonedActivity,reconcileForCompact,reconcileSessionState,resetRetries,setActive,setActiveActivity,setActiveFix,setActiveVerification,setChainedStatusLine,setContextInjectedVerificationId,setLastVerdictStatus,setPhase,setRecordingActive,setRecordingRequired,setUsage,setUserEmail,setVerifyIntent,writeState});
1
+ "use strict";var v=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var a=(i,e)=>v(i,"name",{value:e,configurable:!0});var h=(i,e)=>{for(var n in e)v(i,n,{get:e[n],enumerable:!0})},_=(i,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!V.call(i,r)&&r!==n&&v(i,r,{get:()=>e[r],enumerable:!(t=A(e,r))||t.enumerable});return i};var b=i=>_(v({},"__esModule",{value:!0}),i);var St={};h(St,{addPendingFixes:()=>ct,clearActiveActivity:()=>gt,clearActiveFix:()=>z,clearActiveVerification:()=>F,clearPendingFixes:()=>st,clearVerifyIntent:()=>ut,closeOpenCycles:()=>vt,generateTraceId:()=>T,getActiveActivityId:()=>Q,getActiveFixId:()=>C,getActiveTraceId:()=>E,getActiveVerificationId:()=>w,getChainedStatusLine:()=>et,getContextInjectedVerificationId:()=>nt,getLastVerdictHadIssues:()=>U,getLastVerdictStatus:()=>q,getPendingFixes:()=>at,getPhase:()=>O,getRetries:()=>R,getUsagePlan:()=>D,getUsageType:()=>Z,getUserEmail:()=>X,getVerifyIntent:()=>ot,incrementRetries:()=>L,isActive:()=>G,isFailLikeVerdictStatus:()=>lt,isRecordingActive:()=>M,isRecordingRequired:()=>J,readState:()=>c,reconcileAbandonedActivity:()=>yt,reconcileForCompact:()=>It,reconcileSessionState:()=>pt,resetRetries:()=>$,setActive:()=>K,setActiveActivity:()=>ft,setActiveFix:()=>k,setActiveVerification:()=>P,setChainedStatusLine:()=>it,setContextInjectedVerificationId:()=>rt,setLastVerdictHadIssues:()=>H,setLastVerdictStatus:()=>j,setPhase:()=>N,setRecordingActive:()=>W,setRecordingRequired:()=>B,setUsage:()=>tt,setUserEmail:()=>Y,setVerifyIntent:()=>dt,writeState:()=>u});module.exports=b(St);var x=require("crypto"),f=require("fs"),y=require("path"),l=require("../../lib/logger"),g=require("./activity-participants"),p=require("../../lib/atomic"),d=require("./actions");const I="state.json",S={retries:0,activeVerificationId:null,activeTraceId:null,lastVerdictStatus:null,lastVerdictHadIssues:!1,activeFixId:null,activeActivityId:null,phase:null,recordingRequired:!1,recordingActive:!1,active:!1,userEmail:null,usageType:null,usagePlan:null,chainedStatusLine:null,contextInjectedVerificationId:null,pendingFixes:[],verifyIntent:null};function T(){return(0,x.randomBytes)(16).toString("hex")}a(T,"generateTraceId");function c(i){const e=(0,y.join)(i,I);if(!(0,f.existsSync)(e))return{...S};try{const n=(0,f.readFileSync)(e,"utf-8"),t=JSON.parse(n),r=["coding","verifying","fixing"],s=["api","subscription"];return{retries:typeof t.retries=="number"?t.retries:0,activeVerificationId:typeof t.activeVerificationId=="string"?t.activeVerificationId:null,activeTraceId:typeof t.activeTraceId=="string"?t.activeTraceId:null,lastVerdictStatus:typeof t.lastVerdictStatus=="string"?t.lastVerdictStatus:null,lastVerdictHadIssues:typeof t.lastVerdictHadIssues=="boolean"?t.lastVerdictHadIssues:!1,activeFixId:typeof t.activeFixId=="string"?t.activeFixId:null,activeActivityId:typeof t.activeActivityId=="string"?t.activeActivityId:null,phase:typeof t.phase=="string"&&r.includes(t.phase)?t.phase:null,recordingRequired:typeof t.recordingRequired=="boolean"?t.recordingRequired:!1,recordingActive:typeof t.recordingActive=="boolean"?t.recordingActive:!1,active:typeof t.active=="boolean"?t.active:!1,userEmail:typeof t.userEmail=="string"?t.userEmail:null,usageType:typeof t.usageType=="string"&&s.includes(t.usageType)?t.usageType:null,usagePlan:typeof t.usagePlan=="string"&&t.usagePlan.length>0?t.usagePlan:null,chainedStatusLine:typeof t.chainedStatusLine=="string"&&t.chainedStatusLine.length>0?t.chainedStatusLine:null,contextInjectedVerificationId:typeof t.contextInjectedVerificationId=="string"?t.contextInjectedVerificationId:null,pendingFixes:Array.isArray(t.pendingFixes)?t.pendingFixes.filter(o=>typeof o=="string"&&o.length>0):[],verifyIntent:typeof t.verifyIntent=="string"&&t.verifyIntent.length>0?t.verifyIntent:null}}catch(n){return l.logger.debug(`failed to read state from ${e}: ${n}`),{...S}}}a(c,"readState");function u(i,e){const n=(0,y.join)(i,I);try{(0,f.mkdirSync)(i,{recursive:!0});const t=`${n}.tmp.${process.pid}.${Date.now()}`,r=JSON.stringify(e,null,2);try{(0,f.writeFileSync)(t,r),(0,p.renameWithRetry)(t,n)}catch(s){try{(0,f.existsSync)(t)&&(0,f.unlinkSync)(t)}catch{}throw s}(0,p.sweepStaleTmpFiles)(n)}catch(t){l.logger.debug(`failed to write state to ${n}: ${t}`)}}a(u,"writeState");function w(i){return c(i).activeVerificationId??void 0}a(w,"getActiveVerificationId");function P(i,e,n){const t=c(i);t.activeVerificationId=e,t.activeTraceId=n,t.phase="verifying",u(i,t)}a(P,"setActiveVerification");function E(i){return c(i).activeTraceId??void 0}a(E,"getActiveTraceId");function F(i){const e=c(i);e.activeVerificationId=null,e.activeTraceId=null,e.phase="coding",u(i,e)}a(F,"clearActiveVerification");function R(i){return c(i).retries}a(R,"getRetries");function L(i){const e=c(i);return e.retries=e.retries+1,u(i,e),e.retries}a(L,"incrementRetries");function $(i){const e=c(i);e.retries=0,u(i,e)}a($,"resetRetries");function q(i){return c(i).lastVerdictStatus??void 0}a(q,"getLastVerdictStatus");function j(i,e){const n=c(i);n.lastVerdictStatus=e,u(i,n)}a(j,"setLastVerdictStatus");function U(i){return c(i).lastVerdictHadIssues===!0}a(U,"getLastVerdictHadIssues");function H(i,e){const n=c(i);n.lastVerdictHadIssues=e,u(i,n)}a(H,"setLastVerdictHadIssues");function k(i,e){const n=c(i);n.activeFixId=e,u(i,n)}a(k,"setActiveFix");function C(i){return c(i).activeFixId??void 0}a(C,"getActiveFixId");function z(i){const e=c(i);e.activeFixId=null,u(i,e)}a(z,"clearActiveFix");function N(i,e){const n=c(i);n.phase=e,u(i,n)}a(N,"setPhase");function O(i){return c(i).phase}a(O,"getPhase");function J(i){return c(i).recordingRequired}a(J,"isRecordingRequired");function B(i,e){const n=c(i);n.recordingRequired=e,u(i,n)}a(B,"setRecordingRequired");function M(i){return c(i).recordingActive}a(M,"isRecordingActive");function W(i,e){const n=c(i);n.recordingActive=e,u(i,n)}a(W,"setRecordingActive");function G(i){return c(i).active}a(G,"isActive");function K(i,e){const n=c(i);n.active=e,e||(n.activeActivityId=null),u(i,n)}a(K,"setActive");function Q(i){return c(i).activeActivityId??void 0}a(Q,"getActiveActivityId");function X(i){return c(i).userEmail??void 0}a(X,"getUserEmail");function Y(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.userEmail!==n&&(t.userEmail=n,u(i,t))}a(Y,"setUserEmail");function Z(i){return c(i).usageType??void 0}a(Z,"getUsageType");function D(i){return c(i).usagePlan??void 0}a(D,"getUsagePlan");function tt(i,e){const n=e.usage_type==="api"||e.usage_type==="subscription"?e.usage_type:null,t=typeof e.usage_plan=="string"&&e.usage_plan.length>0?e.usage_plan:null,r=c(i);r.usageType===n&&r.usagePlan===t||(r.usageType=n,r.usagePlan=t,u(i,r))}a(tt,"setUsage");function et(i){return c(i).chainedStatusLine??void 0}a(et,"getChainedStatusLine");function it(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.chainedStatusLine!==n&&(t.chainedStatusLine=n,u(i,t))}a(it,"setChainedStatusLine");function nt(i){return c(i).contextInjectedVerificationId??void 0}a(nt,"getContextInjectedVerificationId");function rt(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.contextInjectedVerificationId!==n&&(t.contextInjectedVerificationId=n,u(i,t))}a(rt,"setContextInjectedVerificationId");function at(i){return c(i).pendingFixes}a(at,"getPendingFixes");function ct(i,e){const n=e.filter(o=>typeof o=="string"&&o.length>0);if(n.length===0)return;const t=c(i),r=new Set(t.pendingFixes),s=[...t.pendingFixes];for(const o of n)r.has(o)||(r.add(o),s.push(o));s.length!==t.pendingFixes.length&&(t.pendingFixes=s,u(i,t))}a(ct,"addPendingFixes");function st(i){const e=c(i);e.pendingFixes.length!==0&&(e.pendingFixes=[],u(i,e))}a(st,"clearPendingFixes");function ot(i){return c(i).verifyIntent}a(ot,"getVerifyIntent");function dt(i,e){const n=c(i);n.verifyIntent!==e&&(n.verifyIntent=e,u(i,n))}a(dt,"setVerifyIntent");function ut(i){const e=c(i);e.verifyIntent!==null&&(e.verifyIntent=null,u(i,e))}a(ut,"clearVerifyIntent");function lt(i){return i==="fail"||i==="fail_reported"}a(lt,"isFailLikeVerdictStatus");function ft(i,e){const n=c(i);n.activeActivityId=e,n.active=!0,u(i,n)}a(ft,"setActiveActivity");function gt(i){const e=c(i);e.activeActivityId=null,e.active=!1,u(i,e)}a(gt,"clearActiveActivity");async function vt(i,e,n){const t=c(i);let r=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:n};await(0,d.appendAction)(e,o),l.logger.debug(`close-open-cycles: ended verification ${t.activeVerificationId} (${n})`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:n};await(0,d.appendAction)(e,o),l.logger.debug(`close-open-cycles: ended fix ${t.activeFixId} (${n})`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(vt,"closeOpenCycles");async function pt(i,e,n){const t=c(i);let r=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"session_reconcile"};await n(e,o),l.logger.debug(`reconcile: ended abandoned verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"session_reconcile"};await n(e,o),l.logger.debug(`reconcile: ended abandoned fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}if(t.active){const s=Date.now(),o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"session_reconcile"};await n(e,o),l.logger.debug(`reconcile: ended abandoned activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,(0,g.clearActivityParticipants)(i),r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(pt,"reconcileSessionState");async function yt(i,e,n){const t=c(i);if(!t.active&&!t.activeVerificationId&&!t.activeFixId&&t.verifyIntent===null||!(0,g.isParticipantPresent)(i,g.MAIN_PARTICIPANT_ID)&&(0,g.anyActiveParticipants)(i))return;let r=!1;const s=(0,d.findLastActionTimestamp)(e)??Date.now();if(t.activeVerificationId){const o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"interrupt_inferred"};await n(e,o),l.logger.debug(`interrupt-reconcile: ended verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"interrupt_inferred"};await n(e,o),l.logger.debug(`interrupt-reconcile: ended fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}if(t.active){const o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"interrupt_inferred"};await n(e,o),l.logger.debug(`interrupt-reconcile: ended activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,(0,g.clearActivityParticipants)(i),r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(yt,"reconcileAbandonedActivity");async function It(i,e,n){const t=c(i);let r=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"compact"};await n(e,o),l.logger.debug(`compact-reconcile: ended verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"compact"};await n(e,o),l.logger.debug(`compact-reconcile: ended fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}if(t.active){const s=Date.now(),o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"compact"};await n(e,o),l.logger.debug(`compact-reconcile: ended activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,(0,g.clearActivityParticipants)(i),r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(It,"reconcileForCompact");0&&(module.exports={addPendingFixes,clearActiveActivity,clearActiveFix,clearActiveVerification,clearPendingFixes,clearVerifyIntent,closeOpenCycles,generateTraceId,getActiveActivityId,getActiveFixId,getActiveTraceId,getActiveVerificationId,getChainedStatusLine,getContextInjectedVerificationId,getLastVerdictHadIssues,getLastVerdictStatus,getPendingFixes,getPhase,getRetries,getUsagePlan,getUsageType,getUserEmail,getVerifyIntent,incrementRetries,isActive,isFailLikeVerdictStatus,isRecordingActive,isRecordingRequired,readState,reconcileAbandonedActivity,reconcileForCompact,reconcileSessionState,resetRetries,setActive,setActiveActivity,setActiveFix,setActiveVerification,setChainedStatusLine,setContextInjectedVerificationId,setLastVerdictHadIssues,setLastVerdictStatus,setPhase,setRecordingActive,setRecordingRequired,setUsage,setUserEmail,setVerifyIntent,writeState});
@@ -1,8 +1,8 @@
1
- "use strict";var m=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var _=(c,r)=>m(c,"name",{value:r,configurable:!0});var I=(c,r)=>{for(var i in r)m(c,i,{get:r[i],enumerable:!0})},S=(c,r,i,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of T(r))!$.call(c,n)&&n!==i&&m(c,n,{get:()=>r[n],enumerable:!(o=F(r,n))||o.enumerable});return c};var k=c=>S(m({},"__esModule",{value:!0}),c);var P={};I(P,{runSubmitVerdict:()=>N});module.exports=k(P);var y=require("fs"),w=require("path"),u=require("../../lib/logger"),d=require("../../lib/config"),x=require("../../lib/recording-tools"),V=require("../../lib/telemetry"),a=require("./actions"),e=require("./session-state");function J(c,r){const i=(0,e.getPendingFixes)(c);if(i.length>0)return i;const o=(0,a.summarizeFixFileChanges)((0,a.getFileChangesSinceLastFailVerdict)(r));return o.length>0?o:["re-verified after a prior failure (no tracked code changes in this fix cycle)"]}_(J,"deriveFixes");async function N(c){const{sessionId:r,sessionDir:i,verdictFile:o,actionsFile:n,verdictJson:C,projectDir:E}=c;let t;try{t=JSON.parse(C)}catch(s){return u.logger.debug(`submit-verdict: invalid JSON: ${s}`),{success:!1,message:"REJECTED: verdict is not valid JSON."}}if(t.status!=="pass"&&t.status!=="fail"&&t.status!=="not_applicable")return{success:!1,message:`REJECTED: status must be "pass", "fail", or "not_applicable", got "${t.status}".`};const f=t.status==="not_applicable",g=Array.isArray(t.not_applicable_cycles)?t.not_applicable_cycles:[],b=g.length>0;if(f&&b)return{success:!1,message:'REJECTED: do not combine not_applicable_cycles with status "not_applicable" (global N/A already exempts every cycle). Use status "not_applicable" for the whole change, OR a pass/fail status with not_applicable_cycles for a subset.'};if(b){const s=g.filter(l=>!d.ALL_CYCLES.includes(l));if(s.length>0)return{success:!1,message:`REJECTED: unknown cycle name(s) in not_applicable_cycles: ${s.join(", ")}. Valid: ${d.ALL_CYCLES.join(" / ")}.`}}if(f||b){if((0,e.isFailLikeVerdictStatus)((0,e.getLastVerdictStatus)(i)))return{success:!1,message:"REJECTED: you reported a fail \u2014 N/A cannot reclassify it. Fix the issues and re-verify, or report the fail again."};if(!Array.isArray(t.reason)||t.reason.length===0)return{success:!1,message:`REJECTED: ${f?'status "not_applicable"':"not_applicable_cycles"} requires a non-empty "reason" array explaining why there is no runtime surface to verify.`};if(E!==void 0&&(0,d.getVerificationStrict)((0,d.loadConfig)(E)))return{success:!1,message:"REJECTED: strict mode \u2014 N/A is not accepted. Verify the change with the required tools, or report a fail."}}if(!f&&(!Array.isArray(t.checks)||t.checks.length===0))return{success:!1,message:"REJECTED: checks must be a non-empty array describing what you functionally tested."};if(t.status==="fail"&&(!Array.isArray(t.issues)||t.issues.length===0))return{success:!1,message:'REJECTED: when status is "fail", issues must be a non-empty array describing what failed.'};if(t.status==="pass"&&(0,e.isFailLikeVerdictStatus)((0,e.getLastVerdictStatus)(i))&&(!Array.isArray(t.fixes)||t.fixes.length===0)&&(t.fixes=J(i,n)),(0,e.isRecordingRequired)(i)&&(0,e.isRecordingActive)(i))return{success:!1,message:`REJECTED: recording is still active.
1
+ "use strict";var m=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var _=(c,r)=>m(c,"name",{value:r,configurable:!0});var $=(c,r)=>{for(var s in r)m(c,s,{get:r[s],enumerable:!0})},S=(c,r,s,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of T(r))!I.call(c,n)&&n!==s&&m(c,n,{get:()=>r[n],enumerable:!(o=F(r,n))||o.enumerable});return c};var k=c=>S(m({},"__esModule",{value:!0}),c);var N={};$(N,{runSubmitVerdict:()=>L});module.exports=k(N);var y=require("fs"),w=require("path"),d=require("../../lib/logger"),u=require("../../lib/config"),x=require("../../lib/recording-tools"),V=require("../../lib/telemetry"),a=require("./actions"),e=require("./session-state");function J(c,r){const s=(0,e.getPendingFixes)(c);if(s.length>0)return s;const o=(0,a.summarizeFixFileChanges)((0,a.getFileChangesSinceLastFailVerdict)(r));return o.length>0?o:["re-verified after a prior failure (no tracked code changes in this fix cycle)"]}_(J,"deriveFixes");async function L(c){const{sessionId:r,sessionDir:s,verdictFile:o,actionsFile:n,verdictJson:C,projectDir:E}=c;let t;try{t=JSON.parse(C)}catch(i){return d.logger.debug(`submit-verdict: invalid JSON: ${i}`),{success:!1,message:"REJECTED: verdict is not valid JSON."}}if(t.status!=="pass"&&t.status!=="fail"&&t.status!=="not_applicable")return{success:!1,message:`REJECTED: status must be "pass", "fail", or "not_applicable", got "${t.status}".`};const f=t.status==="not_applicable",g=Array.isArray(t.not_applicable_cycles)?t.not_applicable_cycles:[],b=g.length>0;if(f&&b)return{success:!1,message:'REJECTED: do not combine not_applicable_cycles with status "not_applicable" (global N/A already exempts every cycle). Use status "not_applicable" for the whole change, OR a pass/fail status with not_applicable_cycles for a subset.'};if(b){const i=g.filter(l=>!u.ALL_CYCLES.includes(l));if(i.length>0)return{success:!1,message:`REJECTED: unknown cycle name(s) in not_applicable_cycles: ${i.join(", ")}. Valid: ${u.ALL_CYCLES.join(" / ")}.`}}if(f||b){if((0,e.isFailLikeVerdictStatus)((0,e.getLastVerdictStatus)(s)))return{success:!1,message:"REJECTED: you reported a fail \u2014 N/A cannot reclassify it. Fix the issues and re-verify, or report the fail again."};if(!Array.isArray(t.reason)||t.reason.length===0)return{success:!1,message:`REJECTED: ${f?'status "not_applicable"':"not_applicable_cycles"} requires a non-empty "reason" array explaining why there is no runtime surface to verify.`};if(E!==void 0&&(0,u.getVerificationStrict)((0,u.loadConfig)(E)))return{success:!1,message:"REJECTED: strict mode \u2014 N/A is not accepted. Verify the change with the required tools, or report a fail."}}if(!f&&(!Array.isArray(t.checks)||t.checks.length===0))return{success:!1,message:"REJECTED: checks must be a non-empty array describing what you functionally tested."};if(t.status==="fail"&&(!Array.isArray(t.issues)||t.issues.length===0))return{success:!1,message:'REJECTED: when status is "fail", issues must be a non-empty array describing what failed.'};if(t.status==="pass"&&(0,e.isFailLikeVerdictStatus)((0,e.getLastVerdictStatus)(s))&&(!Array.isArray(t.fixes)||t.fixes.length===0)&&(t.fixes=J(s,n)),(0,e.isRecordingRequired)(s)&&(0,e.isRecordingActive)(s))return{success:!1,message:`REJECTED: recording is still active.
2
2
 
3
3
  1. Stop recording first:
4
4
  ${(0,x.listRecordingCycleTools)().map(l=>` ${l.stopTool} (${l.cycle} cycle)`).join(`
5
5
  `)}
6
6
  2. Then re-run the same submit-verdict command.
7
7
 
8
- Recording start/stop must bracket the verification flow \u2014 start before devtools tools, stop before submit-verdict.`};try{(0,y.mkdirSync)((0,w.dirname)(o),{recursive:!0}),(0,y.writeFileSync)(o,JSON.stringify(t,null,2))}catch(s){return u.logger.debug(`submit-verdict: failed to write ${o}: ${s}`),{success:!1,message:`REJECTED: failed to write verdict file: ${s}`}}(0,e.setLastVerdictStatus)(i,t.status),(0,e.clearPendingFixes)(i),(0,e.isRecordingRequired)(i)&&(0,e.setRecordingRequired)(i,!1);const v=(0,e.getActiveActivityId)(i),h=(0,e.getActiveFixId)(i);if(h){const s=Date.now(),l={...(0,a.baseFields)(n),type:"fix_end",timestamp:s,fix_id:h,activity_id:v,duration:(0,a.findDurationSinceLastAction)(n,"fix_start",s)};await(0,a.appendAction)(n,l),(0,e.clearActiveFix)(i),(0,e.setPhase)(i,"coding"),u.logger.debug(`fix-end (verdict): ${h}`)}const p=(0,e.getActiveVerificationId)(i),A=(0,e.getActiveTraceId)(i);if(p){const s=Date.now(),l={...(0,a.baseFields)(n),type:"verification_end",timestamp:s,verification_id:p,activity_id:v,trace_id:A,duration:(0,a.findDurationSinceLastAction)(n,"verification_start",s),status:t.status};await(0,a.appendAction)(n,l),(0,e.clearActiveVerification)(i),u.logger.debug(`verification-end (auto): ${p} trace=${A}`)}const R=t,D={...(0,a.baseFields)(n),type:"verdict_write",timestamp:Date.now(),verification_id:p,activity_id:v,trace_id:A,verdict:R};if(await(0,a.appendAction)(n,D),await(0,V.trackVerdictWrite)(r,t.status,E),u.logger.debug(`submit-verdict: session=${r} status=${t.status}`),t.status==="pass"){const s=t.fixes?.length?` Fixes: ${t.fixes.join(", ")}`:"";return{success:!0,message:`VERDICT ACCEPTED: pass.${g.length>0?` (N/A cycles: ${g.join(", ")})`:""}${s}`}}return t.status==="not_applicable"?{success:!0,message:`VERDICT ACCEPTED: not_applicable. ${(t.reason??[]).join(", ")}`}:{success:!0,message:`VERDICT ACCEPTED: fail. Issues: ${(t.issues??[]).join(", ")}. Fix and re-verify.`}}_(N,"runSubmitVerdict");0&&(module.exports={runSubmitVerdict});
8
+ Recording start/stop must bracket the verification flow \u2014 start before devtools tools, stop before submit-verdict.`};try{(0,y.mkdirSync)((0,w.dirname)(o),{recursive:!0}),(0,y.writeFileSync)(o,JSON.stringify(t,null,2))}catch(i){return d.logger.debug(`submit-verdict: failed to write ${o}: ${i}`),{success:!1,message:`REJECTED: failed to write verdict file: ${i}`}}(0,e.setLastVerdictStatus)(s,t.status),(0,e.setLastVerdictHadIssues)(s,t.status==="pass"&&Array.isArray(t.issues)&&t.issues.length>0),(0,e.clearPendingFixes)(s),(0,e.isRecordingRequired)(s)&&(0,e.setRecordingRequired)(s,!1);const v=(0,e.getActiveActivityId)(s),h=(0,e.getActiveFixId)(s);if(h){const i=Date.now(),l={...(0,a.baseFields)(n),type:"fix_end",timestamp:i,fix_id:h,activity_id:v,duration:(0,a.findDurationSinceLastAction)(n,"fix_start",i)};await(0,a.appendAction)(n,l),(0,e.clearActiveFix)(s),(0,e.setPhase)(s,"coding"),d.logger.debug(`fix-end (verdict): ${h}`)}const p=(0,e.getActiveVerificationId)(s),A=(0,e.getActiveTraceId)(s);if(p){const i=Date.now(),l={...(0,a.baseFields)(n),type:"verification_end",timestamp:i,verification_id:p,activity_id:v,trace_id:A,duration:(0,a.findDurationSinceLastAction)(n,"verification_start",i),status:t.status};await(0,a.appendAction)(n,l),(0,e.clearActiveVerification)(s),d.logger.debug(`verification-end (auto): ${p} trace=${A}`)}const R=t,D={...(0,a.baseFields)(n),type:"verdict_write",timestamp:Date.now(),verification_id:p,activity_id:v,trace_id:A,verdict:R};if(await(0,a.appendAction)(n,D),await(0,V.trackVerdictWrite)(r,t.status,E),d.logger.debug(`submit-verdict: session=${r} status=${t.status}`),t.status==="pass"){const i=t.fixes?.length?` Fixes: ${t.fixes.join(", ")}`:"";return{success:!0,message:`VERDICT ACCEPTED: pass.${g.length>0?` (N/A cycles: ${g.join(", ")})`:""}${i}`}}return t.status==="not_applicable"?{success:!0,message:`VERDICT ACCEPTED: not_applicable. ${(t.reason??[]).join(", ")}`}:{success:!0,message:`VERDICT ACCEPTED: fail. Issues: ${(t.issues??[]).join(", ")}. Fix and re-verify.`}}_(L,"runSubmitVerdict");0&&(module.exports={runSubmitVerdict});
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var x=(n,t)=>v(n,"name",{value:t,configurable:!0});var A=(n,t)=>{for(var e in t)v(n,e,{get:t[e],enumerable:!0})},_=(n,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of y(t))!V.call(n,a)&&a!==e&&v(n,a,{get:()=>t[a],enumerable:!(s=p(t,a))||s.enumerable});return n};var F=n=>_(v({},"__esModule",{value:!0}),n);var D={};A(D,{endVerification:()=>w,openFixCycleIfFixing:()=>b,startVerification:()=>E});module.exports=F(D);var I=require("crypto"),f=require("../../lib/logger"),r=require("./actions"),i=require("./session-state");async function E(n){const{sessionDir:t,actionsFile:e}=n,s=(0,i.getActiveActivityId)(t),a=(0,i.getActiveFixId)(t);if(a){const g=Date.now(),u={...(0,r.baseFields)(e),type:"fix_end",timestamp:g,fix_id:a,activity_id:s,duration:(0,r.findDurationSinceLastAction)(e,"fix_start",g)};await(0,r.appendAction)(e,u),(0,i.clearActiveFix)(t),f.logger.debug(`fix-end: ${a} (starting new verification)`)}const c=(0,i.getActiveVerificationId)(t);if(c){const g=(0,i.getActiveTraceId)(t);f.logger.debug(`ending previous verification ${c} before starting new one`);const u=Date.now(),l={...(0,r.baseFields)(e),type:"verification_end",timestamp:u,verification_id:c,activity_id:s,trace_id:g,duration:(0,r.findDurationSinceLastAction)(e,"verification_start",u)};await(0,r.appendAction)(e,l),(0,i.clearActiveVerification)(t)}const o=(0,I.randomUUID)(),d=(0,i.generateTraceId)(),m={...(0,r.baseFields)(e),type:"verification_start",timestamp:Date.now(),verification_id:o,activity_id:s,trace_id:d};return await(0,r.appendAction)(e,m),(0,i.setActiveVerification)(t,o,d),n.recordingEnabled&&((0,i.setRecordingRequired)(t,!0),(0,i.setRecordingActive)(t,!1)),n.intent==="fix"?(0,i.setVerifyIntent)(t,"fix"):(0,i.clearVerifyIntent)(t),f.logger.debug(`verification-start: ${o} trace=${d} recording=${!!n.recordingEnabled} intent=${n.intent??"-"}`),{verificationId:o,traceId:d}}x(E,"startVerification");async function b(n){const{sessionDir:t,actionsFile:e}=n;if(!(0,i.isFailLikeVerdictStatus)((0,i.getLastVerdictStatus)(t)))return;const s=(0,i.getActiveFixId)(t);if(s)return s;const a=(0,i.getActiveActivityId)(t),c=(0,I.randomUUID)(),o={...(0,r.baseFields)(e),type:"fix_start",timestamp:Date.now(),fix_id:c,activity_id:a};return await(0,r.appendAction)(e,o),(0,i.setActiveFix)(t,c),(0,i.setPhase)(t,"fixing"),f.logger.debug(`fix-start (edit after fail): ${c}`),c}x(b,"openFixCycleIfFixing");async function w(n){const{sessionDir:t,actionsFile:e}=n,s=(0,i.getActiveVerificationId)(t);if(!s)return{success:!1,message:"No active verification to end."};const a=(0,i.getActiveTraceId)(t),c=(0,i.getActiveActivityId)(t),o=Date.now(),d={...(0,r.baseFields)(e),type:"verification_end",timestamp:o,verification_id:s,activity_id:c,trace_id:a,duration:(0,r.findDurationSinceLastAction)(e,"verification_start",o)};return await(0,r.appendAction)(e,d),(0,i.clearActiveVerification)(t),f.logger.debug(`verification-end: ${s} trace=${a}`),{success:!0,verificationId:s,traceId:a,message:`Verification ${s} ended.`}}x(w,"endVerification");0&&(module.exports={endVerification,openFixCycleIfFixing,startVerification});
1
+ "use strict";var v=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var x=(n,t)=>v(n,"name",{value:t,configurable:!0});var A=(n,t)=>{for(var e in t)v(n,e,{get:t[e],enumerable:!0})},_=(n,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of y(t))!V.call(n,a)&&a!==e&&v(n,a,{get:()=>t[a],enumerable:!(s=l(t,a))||s.enumerable});return n};var F=n=>_(v({},"__esModule",{value:!0}),n);var D={};A(D,{endVerification:()=>b,openFixCycleIfFixing:()=>w,startVerification:()=>E});module.exports=F(D);var I=require("crypto"),f=require("../../lib/logger"),r=require("./actions"),i=require("./session-state");async function E(n){const{sessionDir:t,actionsFile:e}=n,s=(0,i.getActiveActivityId)(t),a=(0,i.getActiveFixId)(t);if(a){const g=Date.now(),u={...(0,r.baseFields)(e),type:"fix_end",timestamp:g,fix_id:a,activity_id:s,duration:(0,r.findDurationSinceLastAction)(e,"fix_start",g)};await(0,r.appendAction)(e,u),(0,i.clearActiveFix)(t),f.logger.debug(`fix-end: ${a} (starting new verification)`)}const c=(0,i.getActiveVerificationId)(t);if(c){const g=(0,i.getActiveTraceId)(t);f.logger.debug(`ending previous verification ${c} before starting new one`);const u=Date.now(),p={...(0,r.baseFields)(e),type:"verification_end",timestamp:u,verification_id:c,activity_id:s,trace_id:g,duration:(0,r.findDurationSinceLastAction)(e,"verification_start",u)};await(0,r.appendAction)(e,p),(0,i.clearActiveVerification)(t)}const o=(0,I.randomUUID)(),d=(0,i.generateTraceId)(),m={...(0,r.baseFields)(e),type:"verification_start",timestamp:Date.now(),verification_id:o,activity_id:s,trace_id:d};return await(0,r.appendAction)(e,m),(0,i.setActiveVerification)(t,o,d),n.recordingEnabled&&((0,i.setRecordingRequired)(t,!0),(0,i.setRecordingActive)(t,!1)),n.intent==="fix"?(0,i.setVerifyIntent)(t,"fix"):(0,i.clearVerifyIntent)(t),f.logger.debug(`verification-start: ${o} trace=${d} recording=${!!n.recordingEnabled} intent=${n.intent??"-"}`),{verificationId:o,traceId:d}}x(E,"startVerification");async function w(n){const{sessionDir:t,actionsFile:e}=n;if(!(0,i.isFailLikeVerdictStatus)((0,i.getLastVerdictStatus)(t))&&!(0,i.getLastVerdictHadIssues)(t))return;const s=(0,i.getActiveFixId)(t);if(s)return s;const a=(0,i.getActiveActivityId)(t),c=(0,I.randomUUID)(),o={...(0,r.baseFields)(e),type:"fix_start",timestamp:Date.now(),fix_id:c,activity_id:a};return await(0,r.appendAction)(e,o),(0,i.setActiveFix)(t,c),(0,i.setPhase)(t,"fixing"),f.logger.debug(`fix-start (edit after fail / pass-with-issues): ${c}`),c}x(w,"openFixCycleIfFixing");async function b(n){const{sessionDir:t,actionsFile:e}=n,s=(0,i.getActiveVerificationId)(t);if(!s)return{success:!1,message:"No active verification to end."};const a=(0,i.getActiveTraceId)(t),c=(0,i.getActiveActivityId)(t),o=Date.now(),d={...(0,r.baseFields)(e),type:"verification_end",timestamp:o,verification_id:s,activity_id:c,trace_id:a,duration:(0,r.findDurationSinceLastAction)(e,"verification_start",o)};return await(0,r.appendAction)(e,d),(0,i.clearActiveVerification)(t),f.logger.debug(`verification-end: ${s} trace=${a}`),{success:!0,verificationId:s,traceId:a,message:`Verification ${s} ended.`}}x(b,"endVerification");0&&(module.exports={endVerification,openFixCycleIfFixing,startVerification});
@@ -1,9 +1,9 @@
1
- "use strict";var T=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var d=(e,t)=>T(e,"name",{value:t,configurable:!0});var K=(e,t)=>{for(var i in t)T(e,i,{get:t[i],enumerable:!0})},W=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Q(t))!z.call(e,s)&&s!==i&&T(e,s,{get:()=>t[s],enumerable:!(o=H(t,s))||o.enumerable});return e};var X=e=>W(T({},"__esModule",{value:!0}),e);var fe={};K(fe,{runVerifyGate:()=>ue});module.exports=X(fe);var v=require("fs"),u=require("../../lib/logger"),q=require("../../lib/telemetry"),h=require("./actions"),r=require("./session-state"),p=require("../../lib/config"),B=require("./required-tools");const Z=3,ee=1;function te(e){const t=p.CYCLE_TO_SERVER[e];if(t===void 0)throw new Error(`No MCP server registered for cycle '${e}'.`);return t}d(te,"mcpServerForCycle");function _(e){return JSON.stringify({session_id:e,status:"pass",checks:["form submits successfully","new item appears in list","no console errors"]})}d(_,"verdictExamplePass");function P(e){return JSON.stringify({session_id:e,status:"fail",checks:["form renders","submit button unresponsive"],issues:["button click handler not firing","TypeError in console"]})}d(P,"verdictExampleFail");function w(...e){for(const t of e)try{(0,v.existsSync)(t)&&(0,v.unlinkSync)(t)}catch(i){u.logger.debug(`failed to cleanup ${t}: ${i}`)}}d(w,"cleanup");function ie(e){if(!(0,v.existsSync)(e))return null;try{return JSON.parse((0,v.readFileSync)(e,"utf-8"))}catch{return null}}d(ie,"readVerdictQuietly");function oe(e,t){const i=(0,h.getFileChangesSinceLastVerification)(e),o=new Set;for(const f of i)for(const a of(0,p.getActiveCycles)(f.file_path,t))o.add(a);const s=[];o.has("browser")&&s.push("browser");for(const f of p.OPTIONAL_CYCLES)o.has(f)&&s.push(f);return s}d(oe,"computeActiveCycles");function re(e,t,i){const o=te(e),s=new Set(t.filter(a=>a.tool_type==="mcp"&&a.mcp_server===o).map(a=>a.tool_name)),f=(0,p.getRequiredToolsConfig)(i,e);return{cycle:e,result:(0,B.satisfyRequiredTools)(s,f),config:f,usedCount:s.size}}d(re,"checkCycleTools");function ne(e){return{cycle:"browser",valid:!0,passCriteriaMet:!0}}d(ne,"checkBrowserEvidence");function se(e){return{cycle:"node",valid:!0,passCriteriaMet:!0}}d(se,"checkNodeEvidence");function ae(e){return{cycle:"backend",valid:!0,passCriteriaMet:!0}}d(ae,"checkBackendEvidence");function ce(e){return{cycle:"android",valid:!0,passCriteriaMet:!0}}d(ce,"checkAndroidEvidence");function le(e,t){if(!Array.isArray(t.checks)||t.checks.length===0)return{cycle:e,valid:!1,reason:"missing checks"};if(e==="browser")return ne(t);if(e==="node")return se(t);if(e==="backend")return ae(t);if(e==="android")return ce(t);throw new Error(`No evidence checker registered for cycle '${e}'.`)}d(le,"checkCycleEvidence");function de(e){const t=e.cycle.charAt(0).toUpperCase()+e.cycle.slice(1);if(e.result.missing.length===0)return`${t} cycle: ok.`;const i=e.result.missing.map(o=>` - ${o}`).join(`
1
+ "use strict";var T=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var u=(e,t)=>T(e,"name",{value:t,configurable:!0});var W=(e,t)=>{for(var i in t)T(e,i,{get:t[i],enumerable:!0})},X=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!K.call(e,s)&&s!==i&&T(e,s,{get:()=>t[s],enumerable:!(o=Q(t,s))||o.enumerable});return e};var Z=e=>X(T({},"__esModule",{value:!0}),e);var ge={};W(ge,{runVerifyGate:()=>fe});module.exports=Z(ge);var b=require("fs"),d=require("../../lib/logger"),V=require("../../lib/telemetry"),h=require("./actions"),r=require("./session-state"),B=require("./activity-participants"),p=require("../../lib/config"),M=require("./required-tools");const ee=3,te=1;function ie(e){const t=p.CYCLE_TO_SERVER[e];if(t===void 0)throw new Error(`No MCP server registered for cycle '${e}'.`);return t}u(ie,"mcpServerForCycle");function _(e){return JSON.stringify({session_id:e,status:"pass",checks:["form submits successfully","new item appears in list","no console errors"]})}u(_,"verdictExamplePass");function q(e){return JSON.stringify({session_id:e,status:"fail",checks:["form renders","submit button unresponsive"],issues:["button click handler not firing","TypeError in console"]})}u(q,"verdictExampleFail");function k(...e){for(const t of e)try{(0,b.existsSync)(t)&&(0,b.unlinkSync)(t)}catch(i){d.logger.debug(`failed to cleanup ${t}: ${i}`)}}u(k,"cleanup");function oe(e){if(!(0,b.existsSync)(e))return null;try{return JSON.parse((0,b.readFileSync)(e,"utf-8"))}catch{return null}}u(oe,"readVerdictQuietly");function re(e,t){const i=(0,h.getFileChangesSinceLastVerification)(e),o=new Set;for(const f of i)for(const a of(0,p.getActiveCycles)(f.file_path,t))o.add(a);const s=[];o.has("browser")&&s.push("browser");for(const f of p.OPTIONAL_CYCLES)o.has(f)&&s.push(f);return s}u(re,"computeActiveCycles");function ne(e,t,i){const o=ie(e),s=new Set(t.filter(a=>a.tool_type==="mcp"&&a.mcp_server===o).map(a=>a.tool_name)),f=(0,p.getRequiredToolsConfig)(i,e);return{cycle:e,result:(0,M.satisfyRequiredTools)(s,f),config:f,usedCount:s.size}}u(ne,"checkCycleTools");function se(e){return{cycle:"browser",valid:!0,passCriteriaMet:!0}}u(se,"checkBrowserEvidence");function ae(e){return{cycle:"node",valid:!0,passCriteriaMet:!0}}u(ae,"checkNodeEvidence");function ce(e){return{cycle:"backend",valid:!0,passCriteriaMet:!0}}u(ce,"checkBackendEvidence");function le(e){return{cycle:"android",valid:!0,passCriteriaMet:!0}}u(le,"checkAndroidEvidence");function de(e,t){if(!Array.isArray(t.checks)||t.checks.length===0)return{cycle:e,valid:!1,reason:"missing checks"};if(e==="browser")return se(t);if(e==="node")return ae(t);if(e==="backend")return ce(t);if(e==="android")return le(t);throw new Error(`No evidence checker registered for cycle '${e}'.`)}u(de,"checkCycleEvidence");function ue(e){const t=e.cycle.charAt(0).toUpperCase()+e.cycle.slice(1);if(e.result.missing.length===0)return`${t} cycle: ok.`;const i=e.result.missing.map(o=>` - ${o}`).join(`
2
2
  `);return e.config.evidencePaths.length>0&&e.result.pathName!==void 0?`${t} cycle: incomplete (closest path "${e.result.pathName}", tried [${e.result.triedPaths.join(", ")}]):
3
3
  ${i}`:`${t} cycle: missing required tools:
4
- ${i}`}d(de,"describeMissingTools");async function ue(e){const{sessionId:t,sessionDir:i,actionsFile:o,verdictFile:s,maxRetries:f}=e,a=f??Z,k=e.config??(0,p.loadConfig)(e.projectDir);if(u.logger.debug(`verify-gate: session=${t} verdictExists=${(0,v.existsSync)(s)}`),!(0,h.hasFileChangesSinceLastVerification)(o)){if((0,r.getLastVerdictStatus)(i)==="fail"){if((0,r.getVerifyIntent)(i)!=="fix")return u.logger.debug("fail verdict with no code changes in window \u2014 status report, allowing"),(0,r.setLastVerdictStatus)(i,"fail_reported"),await c(o,i,t,"allow","fail_verdict_reported",[],e.projectDir),{action:"allow"};const n=(0,r.incrementRetries)(i);return n>=a?(u.logger.debug(`fix intent declared but retries exhausted (${n}/${a}) \u2014 releasing`),(0,r.resetRetries)(i),await(0,r.closeOpenCycles)(i,o,"max_retries_exceeded"),await c(o,i,t,"allow","max_retries_exceeded",[],e.projectDir),{action:"allow",message:`VERIFICATION FAILED ${a} TIMES. Allowing completion.
4
+ ${i}`}u(ue,"describeMissingTools");async function fe(e){const{sessionId:t,sessionDir:i,actionsFile:o,verdictFile:s,maxRetries:f}=e,a=f??ee,C=e.config??(0,p.loadConfig)(e.projectDir);if(d.logger.debug(`verify-gate: session=${t} verdictExists=${(0,b.existsSync)(s)}`),(0,B.anyNonMainParticipants)(i)&&((0,r.getActiveVerificationId)(i)!==void 0||!(0,b.existsSync)(s)))return d.logger.debug("verifier sub-agent still running \u2014 allowing the main Stop, deferring activity close to the verifier (silent): verifier_running"),{action:"allow",reason:"verifier_running",message:"Verification is still running (delegated to the ironbee-verifier sub-agent). It continues in the background; you'll be re-invoked with its verdict when it finishes \u2014 do NOT claim completion yet, and do NOT spawn another verifier. A PASS completes the work; a FAIL means fix the reported issues and re-verify."};if(!(0,h.hasFileChangesSinceLastVerification)(o)){if((0,r.getLastVerdictStatus)(i)==="fail"){if((0,r.getVerifyIntent)(i)!=="fix")return d.logger.debug("fail verdict with no code changes in window \u2014 status report, allowing"),(0,r.setLastVerdictStatus)(i,"fail_reported"),await l(o,i,t,"allow","fail_verdict_reported",[],e.projectDir),{action:"allow"};const n=(0,r.incrementRetries)(i);return n>=a?(d.logger.debug(`fix intent declared but retries exhausted (${n}/${a}) \u2014 releasing`),(0,r.resetRetries)(i),await(0,r.closeOpenCycles)(i,o,"max_retries_exceeded"),await l(o,i,t,"allow","max_retries_exceeded",[],e.projectDir),{action:"allow",message:`VERIFICATION FAILED ${a} TIMES. Allowing completion.
5
5
 
6
- The fail verdict was never resolved. Report the unresolved issues in your final response.`}):(u.logger.debug(`fix intent declared, fail verdict not addressed \u2014 blocking (unaddressed, attempt ${n}/${a})`),await c(o,i,t,"block","fail_verdict_unaddressed",[],e.projectDir),{action:"block",message:`VERIFICATION FAILED \u2014 unaddressed (attempt ${n}/${a}).
6
+ The fail verdict was never resolved. Report the unresolved issues in your final response.`}):(d.logger.debug(`fix intent declared, fail verdict not addressed \u2014 blocking (unaddressed, attempt ${n}/${a})`),await l(o,i,t,"block","fail_verdict_unaddressed",[],e.projectDir),{action:"block",message:`VERIFICATION FAILED \u2014 unaddressed (attempt ${n}/${a}).
7
7
 
8
8
  You submitted a fail verdict but did not address the reported issues. Either:
9
9
 
@@ -13,7 +13,7 @@ You submitted a fail verdict but did not address the reported issues. Either:
13
13
 
14
14
  2. Or \u2014 if the issues genuinely cannot be fixed \u2014 re-verify (keep the --intent fix flag)
15
15
  to confirm the failure: each blocked stop counts toward maxRetries; once exhausted,
16
- the gate will allow completion with the issues reported.`})}return u.logger.debug("no code changes detected, allowing completion"),await c(o,i,t,"allow","no_edits",[],e.projectDir),{action:"allow"}}const l=oe(o,k);if(l.length===0)return u.logger.debug("file changes match no cycle pattern, allowing completion"),await c(o,i,t,"allow","no_cycle_active",[],e.projectDir),{action:"allow"};const V=(0,p.getVerificationStrict)(k),M=(0,r.isFailLikeVerdictStatus)((0,r.getLastVerdictStatus)(i)),m=ie(s),x=!V&&!M&&m!==null&&Array.isArray(m.reason)&&m.reason.length>0;if(x&&m.status==="not_applicable")return u.logger.debug("global N/A verdict, allowing completion"),(0,r.resetRetries)(i),(0,r.setLastVerdictStatus)(i,"not_applicable"),await c(o,i,t,"allow","verdict_not_applicable",l,e.projectDir),{action:"allow"};let b=l;if(x&&Array.isArray(m.not_applicable_cycles)&&m.not_applicable_cycles.length>0){const n=new Set(m.not_applicable_cycles.filter(g=>l.includes(g)));if(b=l.filter(g=>!n.has(g)),b.length===0)return u.logger.debug("per-platform N/A exempted every active cycle \u2014 treating as global N/A"),(0,r.resetRetries)(i),(0,r.setLastVerdictStatus)(i,"not_applicable"),await c(o,i,t,"allow","verdict_not_applicable",l,e.projectDir),{action:"allow"};u.logger.debug(`per-platform N/A: exempt=[${[...n].join(",")}] enforced=[${b.join(",")}]`)}const U=(0,h.getToolCallsSinceLastFileChange)(o),S=b.map(n=>re(n,U,k)),D=S.filter(n=>!n.result.satisfied);if(D.length>0){const n=S.every(y=>y.usedCount===0),g=(0,r.incrementRetries)(i),$=!(0,h.hasVerifierEverEngaged)(o),J=$&&g>ee,G=g>=a;if(J||G){const y=$?"verifier_unavailable":"max_retries_exceeded";u.logger.debug(`tool-presence loop releasing (attempt ${g}/${a}, neverEngaged=${$}) \u2014 ${y}`),(0,r.resetRetries)(i),await(0,r.closeOpenCycles)(i,o,y),await c(o,i,t,"allow",y,l,e.projectDir);const A=l.join(", ");return $?{action:"allow",message:`VERIFICATION UNAVAILABLE \u2014 allowing completion.
16
+ the gate will allow completion with the issues reported.`})}return d.logger.debug("no code changes detected, allowing completion"),await l(o,i,t,"allow","no_edits",[],e.projectDir),{action:"allow"}}const c=re(o,C);if(c.length===0)return d.logger.debug("file changes match no cycle pattern, allowing completion"),await l(o,i,t,"allow","no_cycle_active",[],e.projectDir),{action:"allow"};const S=(0,p.getVerificationStrict)(C),U=(0,r.isFailLikeVerdictStatus)((0,r.getLastVerdictStatus)(i)),y=oe(s),x=!S&&!U&&y!==null&&Array.isArray(y.reason)&&y.reason.length>0;if(x&&y.status==="not_applicable")return d.logger.debug("global N/A verdict, allowing completion"),(0,r.resetRetries)(i),(0,r.setLastVerdictStatus)(i,"not_applicable"),await l(o,i,t,"allow","verdict_not_applicable",c,e.projectDir),{action:"allow"};let v=c;if(x&&Array.isArray(y.not_applicable_cycles)&&y.not_applicable_cycles.length>0){const n=new Set(y.not_applicable_cycles.filter(g=>c.includes(g)));if(v=c.filter(g=>!n.has(g)),v.length===0)return d.logger.debug("per-platform N/A exempted every active cycle \u2014 treating as global N/A"),(0,r.resetRetries)(i),(0,r.setLastVerdictStatus)(i,"not_applicable"),await l(o,i,t,"allow","verdict_not_applicable",c,e.projectDir),{action:"allow"};d.logger.debug(`per-platform N/A: exempt=[${[...n].join(",")}] enforced=[${v.join(",")}]`)}const J=(0,h.getToolCallsSinceLastFileChange)(o),N=v.map(n=>ne(n,J,C)),D=N.filter(n=>!n.result.satisfied);if(D.length>0){const n=N.every(m=>m.usedCount===0),g=(0,r.incrementRetries)(i),$=!(0,h.hasVerifierEverEngaged)(o),G=$&&g>te,Y=g>=a;if(G||Y){const m=$?"verifier_unavailable":"max_retries_exceeded";d.logger.debug(`tool-presence loop releasing (attempt ${g}/${a}, neverEngaged=${$}) \u2014 ${m}`),(0,r.resetRetries)(i),await(0,r.closeOpenCycles)(i,o,m),await l(o,i,t,"allow",m,c,e.projectDir);const A=c.join(", ");return $?{action:"allow",message:`VERIFICATION UNAVAILABLE \u2014 allowing completion.
17
17
 
18
18
  The ${A} verification cycle could not run this session: no verification was ever started and no verification tool was recorded across the whole session. This points to an environment/setup problem rather than a skipped step. Check:
19
19
  - the devtools MCP server is installed and loads (try \`npx -y @ironbee-ai/devtools\`);
@@ -22,11 +22,11 @@ The ${A} verification cycle could not run this session: no verification was ever
22
22
 
23
23
  Report this change as UNVERIFIED in your final response.`}:{action:"allow",message:`VERIFICATION NOT COMPLETED after ${a} attempts. Allowing completion.
24
24
 
25
- The ${A} verification cycle was attempted but its required tools were not all completed within ${a} attempts. If the change has no runtime surface to verify (e.g. a test-only or config change) or the verification tools are unavailable in this environment, say so in your final response; otherwise report the unresolved verification gap.`}}if(n){await c(o,i,t,"block","no_tools",l,e.projectDir);const y=` echo '${_(t)}' | ironbee hook submit-verdict`,A=` On fail: echo '${P(t)}' | ironbee hook submit-verdict`;return{action:"block",message:`VERIFICATION REQUIRED (attempt ${g}/${a}).
25
+ The ${A} verification cycle was attempted but its required tools were not all completed within ${a} attempts. If the change has no runtime surface to verify (e.g. a test-only or config change) or the verification tools are unavailable in this environment, say so in your final response; otherwise report the unresolved verification gap.`}}if(n){await l(o,i,t,"block","no_tools",c,e.projectDir);const m=` echo '${_(t)}' | ironbee hook submit-verdict`,A=` On fail: echo '${q(t)}' | ironbee hook submit-verdict`;return{action:"block",message:`VERIFICATION REQUIRED (attempt ${g}/${a}).
26
26
 
27
27
  You made code changes but did not verify them.
28
28
 
29
- ${b.includes("browser")?`Browser cycle (UI verification):
29
+ ${v.includes("browser")?`Browser cycle (UI verification):
30
30
  1. Build and start the application if not already running
31
31
  2. Navigate to the affected page(s)
32
32
  3. Functionally test your changes \u2014 click, type, submit, interact with the UI to confirm the code works
@@ -34,58 +34,58 @@ ${b.includes("browser")?`Browser cycle (UI verification):
34
34
  5. Take an accessibility snapshot to verify page structure
35
35
  6. Check console for errors
36
36
  7. Stop the dev server when done
37
- `:""}${b.includes("node")?`Node cycle (Node.js runtime debug):
37
+ `:""}${v.includes("node")?`Node cycle (Node.js runtime debug):
38
38
  1. Connect to the running Node process via ndt_debug_connect
39
39
  2. Set probes (tracepoint / logpoint / exceptionpoint) at the changed code paths
40
40
  3. Exercise the code path so probes fire
41
41
  4. Read snapshots via ndt_debug_get-probe-snapshots, OR inspect runtime errors via ndt_debug_get-logs
42
- `:""}${b.includes("backend")?`Backend cycle (runtime-agnostic service verification \u2014 pick ONE or more evidence paths):
42
+ `:""}${v.includes("backend")?`Backend cycle (runtime-agnostic service verification \u2014 pick ONE or more evidence paths):
43
43
  1. Identify the backend layer affected by your change (HTTP / gRPC / GraphQL / WebSocket endpoint, log output, or database state)
44
44
  2a. Protocol-call path: make a real call against the running service (bedt_request_http / bedt_request_grpc / bedt_request_graphql / bedt_request_websocket-open / bedt_request_replay), inspect status / body / traceId, chain follow-ups to verify side effects
45
45
  2b. Log-evidence path (for when something else drives the request): bedt_log_register-source (file / docker / kubernetes), then bedt_log_read / bedt_log_read-multi / bedt_log_follow
46
46
  2c. DB-evidence path (for schema / migration / seed / query-regression changes): bedt_db_connect (named, readonly by default), then bedt_db_query / bedt_db_describe-table / bedt_db_list-tables / bedt_db_snapshot / bedt_db_diff / bedt_db_get-changes
47
47
  3. (Optional) Pin a correlation trace id for the run via bedt_o11y_new-trace-id / bedt_o11y_set-trace-context \u2014 IronBee already injects an active verification traceId, so the o11y pin only matters when you want a fresh root for log searches.
48
- `:""}${b.includes("android")?`Android cycle (mobile device / emulator verification \u2014 pick ONE evidence path):
48
+ `:""}${v.includes("android")?`Android cycle (mobile device / emulator verification \u2014 pick ONE evidence path):
49
49
  1. Connect to a running device or emulator: adt_device_connect
50
50
  2a. Device-evidence path: drive the app UI (adt_device_launch-app / adt_interaction_tap / adt_interaction_input-text / adt_interaction_swipe), then capture BOTH a screenshot (adt_content_take-screenshot) AND a UI snapshot (adt_a11y_take-ui-snapshot) to confirm the visual + structural result
51
51
  2b. Log-evidence path: read Logcat output for the changed code path (adt_o11y_log-read / adt_o11y_log-follow) and confirm expected log lines / absence of errors
52
52
  `:""}
53
53
  Then submit your verdict (single verdict covers every active cycle):
54
- ${y}
54
+ ${m}
55
55
  ${A}
56
- If failed, fix the code and re-verify until it passes.`}}await c(o,i,t,"block","incomplete_tools",l,e.projectDir);const Y=D.map(y=>de(y)).join(`
56
+ If failed, fix the code and re-verify until it passes.`}}await l(o,i,t,"block","incomplete_tools",c,e.projectDir);const H=D.map(m=>ue(m)).join(`
57
57
  `);return{action:"block",message:`INCOMPLETE VERIFICATION (attempt ${g}/${a}).
58
58
 
59
59
  You used the IronBee verification tools but skipped required checks:
60
60
 
61
- ${Y}
61
+ ${H}
62
62
 
63
63
  Run the missing tools, functionally test your changes, then submit your verdict:
64
64
  Pass: echo '${_(t)}' | ironbee hook submit-verdict
65
- Fail: echo '${P(t)}' | ironbee hook submit-verdict`}}if(!(0,v.existsSync)(s))return await c(o,i,t,"block","no_verdict",l,e.projectDir),{action:"block",message:`VERDICT MISSING.
65
+ Fail: echo '${q(t)}' | ironbee hook submit-verdict`}}if(!(0,b.existsSync)(s))return await l(o,i,t,"block","no_verdict",c,e.projectDir),{action:"block",message:`VERDICT MISSING.
66
66
 
67
67
  You ran the verification tools but did not submit a verdict.${(0,r.isRecordingActive)(i)?`
68
68
  \u26A0 Recording is still active \u2014 call mcp__browser-devtools__bdt_content_stop-recording BEFORE submit-verdict (otherwise it will reject with "recording is still active").`:""}
69
69
 
70
70
  Submit your verdict via:
71
- echo '${_(t)}' | ironbee hook submit-verdict`};let C;try{C=JSON.parse((0,v.readFileSync)(s,"utf-8"))}catch(n){return u.logger.debug(`failed to parse verdict ${s}: ${n}`),w(s),await c(o,i,t,"block","invalid_verdict",l,e.projectDir),{action:"block",message:`INVALID VERDICT JSON. Re-submit valid JSON:
72
- echo '${_(t)}' | ironbee hook submit-verdict`}}if(C.status==="not_applicable")return w(s),await c(o,i,t,"block","not_applicable_rejected",b,e.projectDir),{action:"block",message:`VERDICT REJECTED: ${V?"N/A is not accepted in strict mode \u2014 verify the change with the required tools.":"N/A is not honored here \u2014 verify the change with the required tools, or report a fail."}
73
- echo '${_(t)}' | ironbee hook submit-verdict`};const N=b.map(n=>le(n,C)),F=N.filter(n=>!n.valid);if(F.length>0)return w(s),await c(o,i,t,"block","invalid_verdict",l,e.projectDir),{action:"block",message:`VERDICT REJECTED:
74
- ${F.map(g=>` - ${g.cycle} cycle: ${g.reason}`).join(`
71
+ echo '${_(t)}' | ironbee hook submit-verdict`};let w;try{w=JSON.parse((0,b.readFileSync)(s,"utf-8"))}catch(n){return d.logger.debug(`failed to parse verdict ${s}: ${n}`),k(s),await l(o,i,t,"block","invalid_verdict",c,e.projectDir),{action:"block",message:`INVALID VERDICT JSON. Re-submit valid JSON:
72
+ echo '${_(t)}' | ironbee hook submit-verdict`}}if(w.status==="not_applicable")return k(s),await l(o,i,t,"block","not_applicable_rejected",v,e.projectDir),{action:"block",message:`VERDICT REJECTED: ${S?"N/A is not accepted in strict mode \u2014 verify the change with the required tools.":"N/A is not honored here \u2014 verify the change with the required tools, or report a fail."}
73
+ echo '${_(t)}' | ironbee hook submit-verdict`};const F=v.map(n=>de(n,w)),j=F.filter(n=>!n.valid);if(j.length>0)return k(s),await l(o,i,t,"block","invalid_verdict",c,e.projectDir),{action:"block",message:`VERDICT REJECTED:
74
+ ${j.map(g=>` - ${g.cycle} cycle: ${g.reason}`).join(`
75
75
  `)}
76
76
 
77
77
  Re-submit:
78
- echo '${_(t)}' | ironbee hook submit-verdict`};const E=C.status;if(E!=="pass"&&E!=="fail")return w(s),await c(o,i,t,"block","invalid_verdict",l,e.projectDir),{action:"block",message:`INVALID VERDICT STATUS: "${E}". Status must be "pass" or "fail".
79
- echo '${_(t)}' | ironbee hook submit-verdict`};const R=N.filter(n=>n.passCriteriaMet===!1),j=E==="pass"&&R.length===0?"pass":"fail";if(E==="pass"&&j==="fail"&&u.logger.debug(`verify-gate: status=pass overridden to fail by cycle pass-criteria: ${R.map(n=>n.cycle).join(",")}`),j==="pass")return u.logger.debug("verdict passed, allowing completion"),(0,r.resetRetries)(i),await c(o,i,t,"allow","verdict_pass",l,e.projectDir),{action:"allow"};const L=(0,r.incrementRetries)(i),I=[];if(Array.isArray(C.issues))for(const n of C.issues)I.push(String(n));for(const n of R)I.push(`[${n.cycle}] ${n.passReason??"pass criteria not met"}`);I.length===0&&I.push("unknown");const O=I.join(`
80
- - `);return L>=a?(w(s),(0,r.resetRetries)(i),await(0,r.closeOpenCycles)(i,o,"max_retries_exceeded"),await c(o,i,t,"allow","max_retries_exceeded",l,e.projectDir),{action:"allow",message:`VERIFICATION FAILED ${a} TIMES. Allowing completion.
78
+ echo '${_(t)}' | ironbee hook submit-verdict`};const E=w.status;if(E!=="pass"&&E!=="fail")return k(s),await l(o,i,t,"block","invalid_verdict",c,e.projectDir),{action:"block",message:`INVALID VERDICT STATUS: "${E}". Status must be "pass" or "fail".
79
+ echo '${_(t)}' | ironbee hook submit-verdict`};const R=F.filter(n=>n.passCriteriaMet===!1),L=E==="pass"&&R.length===0?"pass":"fail";if(E==="pass"&&L==="fail"&&d.logger.debug(`verify-gate: status=pass overridden to fail by cycle pass-criteria: ${R.map(n=>n.cycle).join(",")}`),L==="pass")return d.logger.debug("verdict passed, allowing completion"),(0,r.resetRetries)(i),await l(o,i,t,"allow","verdict_pass",c,e.projectDir),{action:"allow"};const O=(0,r.incrementRetries)(i),I=[];if(Array.isArray(w.issues))for(const n of w.issues)I.push(String(n));for(const n of R)I.push(`[${n.cycle}] ${n.passReason??"pass criteria not met"}`);I.length===0&&I.push("unknown");const P=I.join(`
80
+ - `);return O>=a?(k(s),(0,r.resetRetries)(i),await(0,r.closeOpenCycles)(i,o,"max_retries_exceeded"),await l(o,i,t,"allow","max_retries_exceeded",c,e.projectDir),{action:"allow",message:`VERIFICATION FAILED ${a} TIMES. Allowing completion.
81
81
 
82
82
  Unresolved issues:
83
- - ${O}
83
+ - ${P}
84
84
 
85
- Report these issues in your final response.`}):(w(s),await c(o,i,t,"block","verdict_fail",l,e.projectDir),{action:"block",message:`VERIFICATION FAILED (attempt ${L}/${a}).
85
+ Report these issues in your final response.`}):(k(s),await l(o,i,t,"block","verdict_fail",c,e.projectDir),{action:"block",message:`VERIFICATION FAILED (attempt ${O}/${a}).
86
86
 
87
87
  Issues found:
88
- - ${O}
88
+ - ${P}
89
89
 
90
90
  Fix the issues, rebuild if needed, re-test functionally, and re-verify.
91
- Submit verdict: echo '<verdict-json>' | ironbee hook submit-verdict`})}d(ue,"runVerifyGate");async function c(e,t,i,o,s,f,a){o==="allow"&&(0,r.clearVerifyIntent)(t);const k={...(0,h.baseFields)(e),type:"verification_requested",timestamp:Date.now(),activity_id:(0,r.getActiveActivityId)(t),action:o,reason:s,modes:f.length>0?f:void 0};await(0,h.appendAction)(e,k),await(0,q.trackVerificationRequested)(i,o,s,a)}d(c,"recordMarker");0&&(module.exports={runVerifyGate});
91
+ Submit verdict: echo '<verdict-json>' | ironbee hook submit-verdict`})}u(fe,"runVerifyGate");async function l(e,t,i,o,s,f,a){o==="allow"&&(0,r.clearVerifyIntent)(t);const C=(0,r.getActiveActivityId)(t);if(!C){d.logger.debug(`verification_requested ${o}/${s} skipped \u2014 no active activity (would orphan)`),await(0,V.trackVerificationRequested)(i,o,s,a);return}const c={...(0,h.baseFields)(e),type:"verification_requested",timestamp:Date.now(),activity_id:C,action:o,reason:s,modes:f.length>0?f:void 0};await(0,h.appendAction)(e,c),await(0,V.trackVerificationRequested)(i,o,s,a)}u(l,"recordMarker");0&&(module.exports={runVerifyGate});