@probelabs/visor 0.1.113 → 0.1.122

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 (120) hide show
  1. package/defaults/workflow-builder.tests.yaml +363 -0
  2. package/defaults/workflow-builder.yaml +720 -0
  3. package/dist/ai-review-service.d.ts.map +1 -1
  4. package/dist/cli-main.d.ts.map +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/defaults/workflow-builder.tests.yaml +363 -0
  7. package/dist/defaults/workflow-builder.yaml +720 -0
  8. package/dist/docs/workflow-creation-guide.md +1274 -0
  9. package/dist/frontends/slack-frontend.d.ts +3 -0
  10. package/dist/frontends/slack-frontend.d.ts.map +1 -1
  11. package/dist/generated/config-schema.d.ts +14 -6
  12. package/dist/generated/config-schema.d.ts.map +1 -1
  13. package/dist/generated/config-schema.json +14 -6
  14. package/dist/index.js +36879 -13895
  15. package/dist/logger.d.ts +9 -0
  16. package/dist/logger.d.ts.map +1 -1
  17. package/dist/mcp-server.d.ts +4 -4
  18. package/dist/output/traces/{run-2026-01-21T12-31-10-108Z.ndjson → run-2026-01-28T13-56-32-263Z.ndjson} +84 -84
  19. package/dist/output/traces/run-2026-01-28T13-57-13-140Z.ndjson +1357 -0
  20. package/dist/providers/ai-check-provider.d.ts.map +1 -1
  21. package/dist/providers/check-provider.interface.d.ts +15 -1
  22. package/dist/providers/check-provider.interface.d.ts.map +1 -1
  23. package/dist/providers/command-check-provider.d.ts.map +1 -1
  24. package/dist/providers/git-checkout-provider.d.ts.map +1 -1
  25. package/dist/sdk/{check-provider-registry-534KL5HT.mjs → check-provider-registry-JMNLGIMJ.mjs} +11 -11
  26. package/dist/sdk/{chunk-AIVFBIS4.mjs → chunk-35NT3725.mjs} +30 -10
  27. package/dist/sdk/chunk-35NT3725.mjs.map +1 -0
  28. package/dist/sdk/{chunk-AGIZJ4UZ.mjs → chunk-3NMLT3YS.mjs} +42 -8
  29. package/dist/sdk/chunk-3NMLT3YS.mjs.map +1 -0
  30. package/dist/sdk/{chunk-AK6BVWIT.mjs → chunk-7GUAFV6L.mjs} +2 -2
  31. package/dist/sdk/{chunk-QY2XYPEV.mjs → chunk-CUNPH6TR.mjs} +18 -10
  32. package/dist/sdk/chunk-CUNPH6TR.mjs.map +1 -0
  33. package/dist/sdk/{chunk-HTOKWMPO.mjs → chunk-HQL734ZI.mjs} +2 -2
  34. package/dist/sdk/{chunk-7UK3NIIT.mjs → chunk-IHZOSIF4.mjs} +2 -2
  35. package/dist/sdk/{chunk-AUT26LHW.mjs → chunk-J2QWVDXK.mjs} +2 -2
  36. package/dist/sdk/{chunk-QR7MOMJH.mjs → chunk-J6EVEXC2.mjs} +2 -2
  37. package/dist/sdk/{chunk-SIWNBRTK.mjs → chunk-SWEEZ5D5.mjs} +3 -3
  38. package/dist/sdk/{chunk-23L3QRYX.mjs → chunk-VPEQOQ7G.mjs} +279 -70
  39. package/dist/sdk/chunk-VPEQOQ7G.mjs.map +1 -0
  40. package/dist/sdk/{command-executor-TYUV6HUS.mjs → command-executor-Q7MHJKZJ.mjs} +3 -3
  41. package/dist/sdk/{config-YNC2EOOT.mjs → config-MK4XTU45.mjs} +3 -3
  42. package/dist/sdk/{failure-condition-evaluator-YGTF2GHG.mjs → failure-condition-evaluator-HB35XRLZ.mjs} +4 -4
  43. package/dist/sdk/{github-frontend-SIAEOCON.mjs → github-frontend-6Q4BISZX.mjs} +4 -4
  44. package/dist/sdk/{host-DXUYTNMU.mjs → host-P5NQICP7.mjs} +3 -3
  45. package/dist/sdk/{liquid-extensions-PKWCKK7E.mjs → liquid-extensions-DFDEBMUI.mjs} +4 -4
  46. package/dist/sdk/{memory-store-XGBB7LX7.mjs → memory-store-RW5N2NGJ.mjs} +3 -3
  47. package/dist/sdk/{prompt-state-YRJY6QAL.mjs → prompt-state-EZYOUG75.mjs} +3 -3
  48. package/dist/sdk/{renderer-schema-LPKN5UJS.mjs → renderer-schema-CKFB5NDB.mjs} +2 -2
  49. package/dist/sdk/{routing-6N45MJ4F.mjs → routing-KZ345OFG.mjs} +5 -5
  50. package/dist/sdk/sdk.d.mts +19 -1
  51. package/dist/sdk/sdk.d.ts +19 -1
  52. package/dist/sdk/sdk.js +421 -75
  53. package/dist/sdk/sdk.js.map +1 -1
  54. package/dist/sdk/sdk.mjs +35 -18
  55. package/dist/sdk/sdk.mjs.map +1 -1
  56. package/dist/sdk/{slack-frontend-BVKW3GD5.mjs → slack-frontend-J442FJWZ.mjs} +61 -3
  57. package/dist/sdk/slack-frontend-J442FJWZ.mjs.map +1 -0
  58. package/dist/sdk/{workflow-registry-R6KSACFR.mjs → workflow-registry-6LZKCWHP.mjs} +3 -3
  59. package/dist/state-machine/context/build-engine-context.d.ts.map +1 -1
  60. package/dist/state-machine/dispatch/history-snapshot.d.ts.map +1 -1
  61. package/dist/state-machine/runner.d.ts.map +1 -1
  62. package/dist/state-machine/states/level-dispatch.d.ts.map +1 -1
  63. package/dist/state-machine/states/routing.d.ts.map +1 -1
  64. package/dist/state-machine/states/wave-planning.d.ts.map +1 -1
  65. package/dist/ter-u14b.json +17826 -0
  66. package/dist/ter-u14n.json +17826 -0
  67. package/dist/test-runner/index.d.ts.map +1 -1
  68. package/dist/traces/{run-2026-01-21T12-31-10-108Z.ndjson → run-2026-01-28T13-56-32-263Z.ndjson} +84 -84
  69. package/dist/traces/run-2026-01-28T13-57-13-140Z.ndjson +1357 -0
  70. package/dist/tui.d.ts +51 -0
  71. package/dist/tui.d.ts.map +1 -0
  72. package/dist/types/cli.d.ts +10 -0
  73. package/dist/types/cli.d.ts.map +1 -1
  74. package/dist/types/config.d.ts +4 -0
  75. package/dist/types/config.d.ts.map +1 -1
  76. package/dist/types/engine.d.ts +3 -0
  77. package/dist/types/engine.d.ts.map +1 -1
  78. package/dist/usr/fonts/AUTHORS +1 -0
  79. package/dist/usr/fonts/LICENSE +94 -0
  80. package/dist/usr/fonts/README +340 -0
  81. package/dist/usr/fonts/ter-u14b.json +17826 -0
  82. package/dist/usr/fonts/ter-u14n.json +17826 -0
  83. package/dist/usr/linux +0 -0
  84. package/dist/usr/windows-ansi +0 -0
  85. package/dist/usr/xterm +0 -0
  86. package/dist/usr/xterm-256color +0 -0
  87. package/dist/usr/xterm.termcap +243 -0
  88. package/dist/usr/xterm.terminfo +1977 -0
  89. package/dist/utils/workspace-manager.d.ts +2 -0
  90. package/dist/utils/workspace-manager.d.ts.map +1 -1
  91. package/dist/utils/worktree-manager.d.ts +5 -0
  92. package/dist/utils/worktree-manager.d.ts.map +1 -1
  93. package/dist/xterm +0 -0
  94. package/dist/xterm.termcap +243 -0
  95. package/package.json +9 -7
  96. package/dist/output/traces/run-2026-01-21T12-32-04-510Z.ndjson +0 -1067
  97. package/dist/sdk/chunk-23L3QRYX.mjs.map +0 -1
  98. package/dist/sdk/chunk-AGIZJ4UZ.mjs.map +0 -1
  99. package/dist/sdk/chunk-AIVFBIS4.mjs.map +0 -1
  100. package/dist/sdk/chunk-QY2XYPEV.mjs.map +0 -1
  101. package/dist/sdk/slack-frontend-BVKW3GD5.mjs.map +0 -1
  102. package/dist/traces/run-2026-01-21T12-32-04-510Z.ndjson +0 -1067
  103. /package/dist/sdk/{check-provider-registry-534KL5HT.mjs.map → check-provider-registry-JMNLGIMJ.mjs.map} +0 -0
  104. /package/dist/sdk/{chunk-AK6BVWIT.mjs.map → chunk-7GUAFV6L.mjs.map} +0 -0
  105. /package/dist/sdk/{chunk-HTOKWMPO.mjs.map → chunk-HQL734ZI.mjs.map} +0 -0
  106. /package/dist/sdk/{chunk-7UK3NIIT.mjs.map → chunk-IHZOSIF4.mjs.map} +0 -0
  107. /package/dist/sdk/{chunk-AUT26LHW.mjs.map → chunk-J2QWVDXK.mjs.map} +0 -0
  108. /package/dist/sdk/{chunk-QR7MOMJH.mjs.map → chunk-J6EVEXC2.mjs.map} +0 -0
  109. /package/dist/sdk/{chunk-SIWNBRTK.mjs.map → chunk-SWEEZ5D5.mjs.map} +0 -0
  110. /package/dist/sdk/{command-executor-TYUV6HUS.mjs.map → command-executor-Q7MHJKZJ.mjs.map} +0 -0
  111. /package/dist/sdk/{config-YNC2EOOT.mjs.map → config-MK4XTU45.mjs.map} +0 -0
  112. /package/dist/sdk/{failure-condition-evaluator-YGTF2GHG.mjs.map → failure-condition-evaluator-HB35XRLZ.mjs.map} +0 -0
  113. /package/dist/sdk/{github-frontend-SIAEOCON.mjs.map → github-frontend-6Q4BISZX.mjs.map} +0 -0
  114. /package/dist/sdk/{host-DXUYTNMU.mjs.map → host-P5NQICP7.mjs.map} +0 -0
  115. /package/dist/sdk/{liquid-extensions-PKWCKK7E.mjs.map → liquid-extensions-DFDEBMUI.mjs.map} +0 -0
  116. /package/dist/sdk/{memory-store-XGBB7LX7.mjs.map → memory-store-RW5N2NGJ.mjs.map} +0 -0
  117. /package/dist/sdk/{prompt-state-YRJY6QAL.mjs.map → prompt-state-EZYOUG75.mjs.map} +0 -0
  118. /package/dist/sdk/{renderer-schema-LPKN5UJS.mjs.map → renderer-schema-CKFB5NDB.mjs.map} +0 -0
  119. /package/dist/sdk/{routing-6N45MJ4F.mjs.map → routing-KZ345OFG.mjs.map} +0 -0
  120. /package/dist/sdk/{workflow-registry-R6KSACFR.mjs.map → workflow-registry-6LZKCWHP.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ai-check-provider.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/providers/ai-check-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAkB5C;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,YAAY,CAA0C;;IAQ9D,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIxB,8DAA8D;IAC9D,OAAO,CAAC,QAAQ;IAWhB,uFAAuF;IACvF,OAAO,CAAC,sBAAsB;IAgCxB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAkDvD;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAqB1B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;OAEG;YACW,aAAa;IA8B3B;;OAEG;YACW,UAAU;IAsExB;;OAEG;YACW,kBAAkB;IA0ChC;;OAEG;YACW,oBAAoB;IAmQ5B,OAAO,CACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,EAC3B,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAC/C,WAAW,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GACjE,OAAO,CAAC,aAAa,CAAC;YAiBX,iBAAiB;IA2nB/B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAiCvB,sBAAsB,IAAI,MAAM,EAAE;IAiC5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAYrC,eAAe,IAAI,MAAM,EAAE;CAQ5B"}
1
+ {"version":3,"file":"ai-check-provider.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/providers/ai-check-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAkB5C;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,YAAY,CAA0C;;IAQ9D,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIxB,8DAA8D;IAC9D,OAAO,CAAC,QAAQ;IAWhB,uFAAuF;IACvF,OAAO,CAAC,sBAAsB;IAgCxB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAkDvD;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAqB1B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;OAEG;YACW,aAAa;IA8B3B;;OAEG;YACW,UAAU;IAsExB;;OAEG;YACW,kBAAkB;IA0ChC;;OAEG;YACW,oBAAoB;IAmQ5B,OAAO,CACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,EAC3B,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAC/C,WAAW,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GACjE,OAAO,CAAC,aAAa,CAAC;YAiBX,iBAAiB;IAsnB/B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAiCvB,sBAAsB,IAAI,MAAM,EAAE;IAiC5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAYrC,eAAe,IAAI,MAAM,EAAE;CAQ5B"}
@@ -56,7 +56,7 @@ export interface ExecutionContext {
56
56
  workflowInputs?: Record<string, unknown>;
57
57
  /** Custom arguments passed from on_init 'with' directive */
58
58
  args?: Record<string, unknown>;
59
- /** SDK hooks for human input */
59
+ /** SDK hooks for human input and check completion */
60
60
  hooks?: {
61
61
  onHumanInput?: (request: HumanInputRequest) => Promise<string>;
62
62
  onPromptCaptured?: (info: {
@@ -65,6 +65,20 @@ export interface ExecutionContext {
65
65
  prompt: string;
66
66
  }) => void;
67
67
  mockForStep?: (step: string) => unknown | undefined;
68
+ /** Called when a check completes - useful for streaming TUI updates */
69
+ onCheckComplete?: (info: {
70
+ checkId: string;
71
+ result: {
72
+ output?: unknown;
73
+ content?: string;
74
+ };
75
+ checkConfig?: {
76
+ type?: string;
77
+ group?: string;
78
+ criticality?: string;
79
+ schema?: unknown;
80
+ };
81
+ }) => void;
68
82
  };
69
83
  /**
70
84
  * Optional execution mode hints. The core engine does not read environment
@@ -1 +1 @@
1
- {"version":3,"file":"check-provider.interface.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/providers/check-provider.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1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M,EAAE;IAEpC;;;;OAIG;IACH,iBAAiB,CAAC,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAC/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"command-check-provider.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/providers/command-check-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAe,MAAM,aAAa,CAAC;AAqBzD;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAC,CAAU;;IAY1B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIlB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAejD,OAAO,CACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,EAC3B,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAC9C,OAAO,CAAC,EAAE,OAAO,4BAA4B,EAAE,gBAAgB,GAC9D,OAAO,CAAC,aAAa,CAAC;IAukCzB,OAAO,CAAC,kBAAkB;IAgC1B;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAgFrB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,mBAAmB;IAiD3B,OAAO,CAAC,iBAAiB;IAmBzB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,2BAA2B;IAiBnC,sBAAsB,IAAI,MAAM,EAAE;IAgB5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAKrC,eAAe,IAAI,MAAM,EAAE;IAQ3B,OAAO,CAAC,uBAAuB;IAoF/B,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,cAAc;IAuFtB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,QAAQ;YAWF,qBAAqB;IAwCnC,OAAO,CAAC,uBAAuB;CAqChC"}
1
+ {"version":3,"file":"command-check-provider.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/providers/command-check-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAe,MAAM,aAAa,CAAC;AAqBzD;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAC,CAAU;;IAY1B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIlB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAejD,OAAO,CACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,EAC3B,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAC9C,OAAO,CAAC,EAAE,OAAO,4BAA4B,EAAE,gBAAgB,GAC9D,OAAO,CAAC,aAAa,CAAC;IA+lCzB,OAAO,CAAC,kBAAkB;IAgC1B;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAgFrB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,mBAAmB;IAiD3B,OAAO,CAAC,iBAAiB;IAmBzB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,2BAA2B;IAiBnC,sBAAsB,IAAI,MAAM,EAAE;IAgB5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAKrC,eAAe,IAAI,MAAM,EAAE;IAQ3B,OAAO,CAAC,uBAAuB;IAoF/B,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,cAAc;IAuFtB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,QAAQ;YAWF,qBAAqB;IAwCnC,OAAO,CAAC,uBAAuB;CAqChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"git-checkout-provider.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/providers/git-checkout-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAK3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGxF,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,OAAO,CAAC,MAAM,CAA0B;IAExC,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIlB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAwDjD,OAAO,CACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,EAC3B,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAC9C,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,aAAa,CAAC;IA+HzB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA+C5B,sBAAsB,IAAI,MAAM,EAAE;IA2B5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAWrC,eAAe,IAAI,MAAM,EAAE;CAG5B"}
1
+ {"version":3,"file":"git-checkout-provider.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/providers/git-checkout-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAK3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGxF,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,OAAO,CAAC,MAAM,CAA0B;IAExC,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIlB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAwDjD,OAAO,CACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,EAC3B,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAC9C,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,aAAa,CAAC;IAmLzB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA+C5B,sBAAsB,IAAI,MAAM,EAAE;IA2B5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAWrC,eAAe,IAAI,MAAM,EAAE;CAG5B"}
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  CheckProviderRegistry,
3
3
  init_check_provider_registry
4
- } from "./chunk-23L3QRYX.mjs";
4
+ } from "./chunk-VPEQOQ7G.mjs";
5
5
  import "./chunk-NAW3DB3I.mjs";
6
- import "./chunk-AUT26LHW.mjs";
7
- import "./chunk-HTOKWMPO.mjs";
8
- import "./chunk-QR7MOMJH.mjs";
9
- import "./chunk-QY2XYPEV.mjs";
6
+ import "./chunk-J2QWVDXK.mjs";
7
+ import "./chunk-HQL734ZI.mjs";
8
+ import "./chunk-J6EVEXC2.mjs";
9
+ import "./chunk-CUNPH6TR.mjs";
10
10
  import "./chunk-O5EZDNYL.mjs";
11
- import "./chunk-AIVFBIS4.mjs";
12
- import "./chunk-SIWNBRTK.mjs";
11
+ import "./chunk-35NT3725.mjs";
12
+ import "./chunk-SWEEZ5D5.mjs";
13
13
  import "./chunk-BOVFH3LI.mjs";
14
14
  import "./chunk-ZYAUYXSW.mjs";
15
15
  import "./chunk-S2RUE2RG.mjs";
16
- import "./chunk-AK6BVWIT.mjs";
16
+ import "./chunk-7GUAFV6L.mjs";
17
17
  import "./chunk-CNX7V5JK.mjs";
18
- import "./chunk-7UK3NIIT.mjs";
19
- import "./chunk-AGIZJ4UZ.mjs";
18
+ import "./chunk-IHZOSIF4.mjs";
19
+ import "./chunk-3NMLT3YS.mjs";
20
20
  import "./chunk-YSN4G6CI.mjs";
21
21
  import "./chunk-3OMWVM6J.mjs";
22
22
  import "./chunk-WMJKH4XE.mjs";
@@ -24,4 +24,4 @@ init_check_provider_registry();
24
24
  export {
25
25
  CheckProviderRegistry
26
26
  };
27
- //# sourceMappingURL=check-provider-registry-534KL5HT.mjs.map
27
+ //# sourceMappingURL=check-provider-registry-JMNLGIMJ.mjs.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FailureConditionEvaluator,
3
3
  init_failure_condition_evaluator
4
- } from "./chunk-SIWNBRTK.mjs";
4
+ } from "./chunk-SWEEZ5D5.mjs";
5
5
  import {
6
6
  compileAndRun,
7
7
  createSecureSandbox,
@@ -14,11 +14,11 @@ import {
14
14
  import {
15
15
  MemoryStore,
16
16
  init_memory_store
17
- } from "./chunk-7UK3NIIT.mjs";
17
+ } from "./chunk-IHZOSIF4.mjs";
18
18
  import {
19
19
  init_logger,
20
20
  logger
21
- } from "./chunk-AGIZJ4UZ.mjs";
21
+ } from "./chunk-3NMLT3YS.mjs";
22
22
  import {
23
23
  __esm,
24
24
  __export,
@@ -210,6 +210,12 @@ function createMemoryHelpers() {
210
210
  }
211
211
  };
212
212
  }
213
+ function getHistoryLimit() {
214
+ const raw = process.env.VISOR_TEST_HISTORY_LIMIT || process.env.VISOR_OUTPUT_HISTORY_LIMIT;
215
+ if (!raw) return void 0;
216
+ const n = parseInt(raw, 10);
217
+ return Number.isFinite(n) && n > 0 ? n : void 0;
218
+ }
213
219
  function formatScopeLabel(scope) {
214
220
  if (!scope || scope.length === 0) return "";
215
221
  return scope.map((item) => `${item.check}:${item.index}`).join("|");
@@ -810,7 +816,9 @@ async function processOnFail(checkId, scope, result, checkConfig, context, state
810
816
  type: "ForwardRunRequested",
811
817
  target: targetCheck,
812
818
  scope: itemScope,
813
- origin: "run"
819
+ origin: "run",
820
+ sourceCheck: checkId
821
+ // The failed check that triggered on_fail.run
814
822
  });
815
823
  }
816
824
  } else {
@@ -827,7 +835,9 @@ async function processOnFail(checkId, scope, result, checkConfig, context, state
827
835
  type: "ForwardRunRequested",
828
836
  target: targetCheck,
829
837
  scope,
830
- origin: "run"
838
+ origin: "run",
839
+ sourceCheck: checkId
840
+ // The failed check that triggered on_fail.run
831
841
  });
832
842
  }
833
843
  }
@@ -870,7 +880,9 @@ async function processOnFail(checkId, scope, result, checkConfig, context, state
870
880
  type: "ForwardRunRequested",
871
881
  target: targetCheck,
872
882
  scope,
873
- origin: "run_js"
883
+ origin: "run_js",
884
+ sourceCheck: checkId
885
+ // The failed check that triggered on_fail.run_js
874
886
  });
875
887
  }
876
888
  }
@@ -1017,6 +1029,7 @@ async function processOnFail(checkId, scope, result, checkConfig, context, state
1017
1029
  async function evaluateRunJs(runJs, checkId, checkConfig, result, context, _state) {
1018
1030
  try {
1019
1031
  const sandbox = createSecureSandbox();
1032
+ const historyLimit = getHistoryLimit();
1020
1033
  const snapshotId = context.journal.beginSnapshot();
1021
1034
  const contextView = new (init_snapshot_store(), __toCommonJS(snapshot_store_exports)).ContextView(
1022
1035
  context.journal,
@@ -1041,7 +1054,8 @@ async function evaluateRunJs(runJs, checkId, checkConfig, result, context, _stat
1041
1054
  try {
1042
1055
  const history = contextView.getHistory(checkIdFromJournal);
1043
1056
  if (history && history.length > 0) {
1044
- outputsHistory[checkIdFromJournal] = history.map(
1057
+ const trimmed = historyLimit && history.length > historyLimit ? history.slice(history.length - historyLimit) : history;
1058
+ outputsHistory[checkIdFromJournal] = trimmed.map(
1045
1059
  (r) => r.output !== void 0 ? r.output : r
1046
1060
  );
1047
1061
  }
@@ -1123,6 +1137,7 @@ async function evaluateGoto(gotoJs, gotoStatic, checkId, checkConfig, result, co
1123
1137
  if (gotoJs) {
1124
1138
  try {
1125
1139
  const sandbox = createSecureSandbox();
1140
+ const historyLimit = getHistoryLimit();
1126
1141
  const snapshotId = context.journal.beginSnapshot();
1127
1142
  const contextView = new (init_snapshot_store(), __toCommonJS(snapshot_store_exports)).ContextView(
1128
1143
  context.journal,
@@ -1147,7 +1162,8 @@ async function evaluateGoto(gotoJs, gotoStatic, checkId, checkConfig, result, co
1147
1162
  try {
1148
1163
  const history = contextView.getHistory(checkIdFromJournal);
1149
1164
  if (history && history.length > 0) {
1150
- outputsHistory[checkIdFromJournal] = history.map(
1165
+ const trimmed = historyLimit && history.length > historyLimit ? history.slice(history.length - historyLimit) : history;
1166
+ outputsHistory[checkIdFromJournal] = trimmed.map(
1151
1167
  (r) => r.output !== void 0 ? r.output : r
1152
1168
  );
1153
1169
  }
@@ -1250,6 +1266,7 @@ async function evaluateTransitions(transitions, checkId, checkConfig, result, co
1250
1266
  if (!transitions || transitions.length === 0) return void 0;
1251
1267
  try {
1252
1268
  const sandbox = createSecureSandbox();
1269
+ const historyLimit = getHistoryLimit();
1253
1270
  const snapshotId = context.journal.beginSnapshot();
1254
1271
  const ContextView2 = (init_snapshot_store(), __toCommonJS(snapshot_store_exports)).ContextView;
1255
1272
  const view = new ContextView2(context.journal, context.sessionId, snapshotId, [], void 0);
@@ -1266,7 +1283,10 @@ async function evaluateTransitions(transitions, checkId, checkConfig, result, co
1266
1283
  try {
1267
1284
  const hist = view.getHistory(cid);
1268
1285
  if (hist && hist.length > 0) {
1269
- outputsHistory[cid] = hist.map((r) => r.output !== void 0 ? r.output : r);
1286
+ const trimmed = historyLimit && hist.length > historyLimit ? hist.slice(hist.length - historyLimit) : hist;
1287
+ outputsHistory[cid] = trimmed.map(
1288
+ (r) => r.output !== void 0 ? r.output : r
1289
+ );
1270
1290
  }
1271
1291
  } catch {
1272
1292
  }
@@ -1368,4 +1388,4 @@ export {
1368
1388
  evaluateTransitions,
1369
1389
  init_routing
1370
1390
  };
1371
- //# sourceMappingURL=chunk-AIVFBIS4.mjs.map
1391
+ //# sourceMappingURL=chunk-35NT3725.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/snapshot-store.ts","../../src/state-machine/states/routing.ts"],"sourcesContent":["/*\n * Internal snapshot store for incremental adoption of snapshot+scope execution.\n * Phase 0: journal only — no behavior change, used for future visibility work.\n */\n\nimport type { ReviewSummary } from './reviewer';\nimport type { EventTrigger } from './types/config';\n\nexport type ScopePath = Array<{ check: string; index: number }>;\n\nexport interface JournalEntry {\n commitId: number;\n sessionId: string;\n scope: ScopePath;\n checkId: string;\n event: EventTrigger | undefined;\n result: ReviewSummary & { output?: unknown; content?: string };\n}\n\nexport class ExecutionJournal {\n private commit = 0;\n private entries: JournalEntry[] = [];\n\n beginSnapshot(): number {\n return this.commit;\n }\n\n commitEntry(entry: {\n sessionId: string;\n scope: ScopePath;\n checkId: string;\n result: ReviewSummary & { output?: unknown; content?: string };\n event?: EventTrigger;\n }): JournalEntry {\n const committed: JournalEntry = {\n sessionId: entry.sessionId,\n scope: entry.scope,\n checkId: entry.checkId,\n result: entry.result,\n event: entry.event,\n commitId: ++this.commit,\n };\n this.entries.push(committed);\n return committed;\n }\n\n readVisible(sessionId: string, commitMax: number, event?: EventTrigger): JournalEntry[] {\n return this.entries.filter(\n e =>\n e.sessionId === sessionId && e.commitId <= commitMax && (event ? e.event === event : true)\n );\n }\n\n // Lightweight helpers for debugging/metrics\n size(): number {\n return this.entries.length;\n }\n}\n\nexport class ContextView {\n constructor(\n private journal: ExecutionJournal,\n private sessionId: string,\n private snapshotId: number,\n private scope: ScopePath,\n private event?: EventTrigger\n ) {}\n\n /** Return the nearest result for a check in this scope (exact item → ancestor → latest). */\n get(checkId: string): (ReviewSummary & { output?: unknown; content?: string }) | undefined {\n const visible = this.journal\n .readVisible(this.sessionId, this.snapshotId, this.event)\n .filter(e => e.checkId === checkId);\n if (visible.length === 0) return undefined;\n\n // exact scope match: prefer the most recent commit for this scope\n const exactMatches = visible.filter(e => this.sameScope(e.scope, this.scope));\n if (exactMatches.length > 0) {\n return exactMatches[exactMatches.length - 1].result;\n }\n\n // nearest ancestor (shortest distance)\n let best: { entry: JournalEntry; dist: number } | undefined;\n for (const e of visible) {\n const dist = this.ancestorDistance(e.scope, this.scope);\n if (dist >= 0 && (best === undefined || dist < best.dist)) {\n best = { entry: e, dist };\n }\n }\n if (best) return best.entry.result;\n\n // fallback to latest committed result\n return visible[visible.length - 1]?.result;\n }\n\n /** Return an aggregate (raw) result – the shallowest scope for this check. */\n getRaw(checkId: string): (ReviewSummary & { output?: unknown; content?: string }) | undefined {\n const visible = this.journal\n .readVisible(this.sessionId, this.snapshotId, this.event)\n .filter(e => e.checkId === checkId);\n if (visible.length === 0) return undefined;\n let shallow = visible[0];\n for (const e of visible) {\n if (e.scope.length < shallow.scope.length) shallow = e;\n }\n return shallow.result;\n }\n\n /** All results for a check up to this snapshot. */\n getHistory(checkId: string): Array<ReviewSummary & { output?: unknown; content?: string }> {\n return this.journal\n .readVisible(this.sessionId, this.snapshotId, this.event)\n .filter(e => e.checkId === checkId)\n .map(e => e.result);\n }\n\n private sameScope(a: ScopePath, b: ScopePath): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i].check !== b[i].check || a[i].index !== b[i].index) return false;\n }\n return true;\n }\n\n // distance from ancestor to current; -1 if not ancestor\n private ancestorDistance(ancestor: ScopePath, current: ScopePath): number {\n if (ancestor.length > current.length) return -1;\n // Treat root scope ([]) as non-ancestor for unrelated branches\n if (ancestor.length === 0 && current.length > 0) return -1;\n for (let i = 0; i < ancestor.length; i++) {\n if (ancestor[i].check !== current[i].check || ancestor[i].index !== current[i].index)\n return -1;\n }\n return current.length - ancestor.length;\n }\n}\n","/**\n * Routing State Handler\n *\n * Responsibilities:\n * - Evaluate fail_if conditions after check execution\n * - Process on_success, on_fail, on_finish triggers\n * - Enqueue ForwardRunRequested events for goto\n * - Enqueue WaveRetry events for routing loops\n * - Transition back to WavePlanning or Completed\n *\n * M2: Core routing logic implementation\n */\n\nimport type { EngineContext, RunState, EngineState, EngineEvent } from '../../types/engine';\nimport type { ReviewSummary, ReviewIssue } from '../../reviewer';\nimport type { CheckConfig, OnFailConfig, TransitionRule } from '../../types/config';\nimport { logger } from '../../logger';\nimport { addEvent } from '../../telemetry/trace-helpers';\nimport { FailureConditionEvaluator } from '../../failure-condition-evaluator';\nimport { createSecureSandbox, compileAndRun } from '../../utils/sandbox';\nimport { MemoryStore } from '../../memory-store';\n\n/**\n * Check if any configured check depends (directly or via OR dependency) on the\n * given `checkId`. Used to decide whether a forEach parent has downstream\n * dependents, in which case its on_finish should defer to the LevelDispatch\n * post-children hook.\n */\n// hasDependents helper removed (unused)\n\n/**\n * Check if any dependent of `checkId` would execute with map fanout.\n * Used to decide whether a forEach parent's on_finish should be deferred to\n * the LevelDispatch post-children hook (only necessary when map-fanout children\n * will run per item).\n */\nfunction hasMapFanoutDependents(context: EngineContext, checkId: string): boolean {\n const checks = context.config.checks || {};\n const reduceProviders = new Set(['log', 'memory', 'script', 'workflow', 'noop']);\n\n for (const [cid, cfg] of Object.entries(checks)) {\n if (cid === checkId) continue;\n const rawDeps = (cfg as any).depends_on || [];\n const depList = Array.isArray(rawDeps) ? rawDeps : [rawDeps];\n // Does this check depend on our target?\n let depends = false;\n for (const dep of depList) {\n if (typeof dep !== 'string') continue;\n if (dep.includes('|')) {\n const opts = dep\n .split('|')\n .map(s => s.trim())\n .filter(Boolean);\n if (opts.includes(checkId)) {\n depends = true;\n break;\n }\n } else if (dep === checkId) {\n depends = true;\n break;\n }\n }\n if (!depends) continue;\n\n // Determine this dependent's fanout mode\n const explicit = (cfg as any).fanout as 'map' | 'reduce' | undefined;\n if (explicit === 'map') return true;\n if (explicit === 'reduce') continue;\n\n // Infer default based on provider type\n const providerType = context.checks[cid]?.providerType || (checks as any)[cid]?.type || '';\n const inferred: 'map' | 'reduce' = reduceProviders.has(providerType) ? 'reduce' : 'map';\n if (inferred === 'map') return true;\n }\n return false;\n}\n\n/** Classify failure type to inform retry policy mapping */\nfunction classifyFailure(result: ReviewSummary): 'none' | 'logical' | 'execution' {\n const issues = result?.issues || [];\n if (!issues || issues.length === 0) return 'none';\n // Heuristics:\n // - logical: fail_if, contract/guarantee_failed, explicit ruleIds ending with _fail_if\n // - execution: provider/command errors, forEach/execution_error, sandbox_runner_error\n let hasLogical = false;\n let hasExecution = false;\n for (const iss of issues) {\n const id = String((iss as any).ruleId || '');\n const msg = String((iss as any).message || '');\n if (\n id.endsWith('_fail_if') ||\n id.includes('contract/guarantee_failed') ||\n id.includes('contract/schema_validation_failed')\n )\n hasLogical = true;\n if (id.includes('/execution_error') || msg.includes('Command execution failed'))\n hasExecution = true;\n if (id.includes('forEach/execution_error') || msg.includes('sandbox_runner_error'))\n hasExecution = true;\n }\n if (hasLogical && !hasExecution) return 'logical';\n if (hasExecution && !hasLogical) return 'execution';\n // Mixed or unknown: treat as execution to avoid suppressing retries unexpectedly\n return hasExecution ? 'execution' : 'logical';\n}\n\nfunction getCriticality(context: EngineContext, checkId: string): CheckConfig['criticality'] {\n const cfg = context.config.checks?.[checkId];\n return (cfg && (cfg as any).criticality) || 'policy';\n}\n\n/**\n * Context for a check that just completed and needs routing evaluation\n */\ninterface RoutingContext {\n checkId: string;\n scope: Array<{ check: string; index: number }>;\n result: ReviewSummary;\n checkConfig: CheckConfig;\n success: boolean; // true if no fatal issues\n}\n\n/**\n * Create memory helpers for sandbox context\n */\nfunction createMemoryHelpers() {\n const memoryStore = MemoryStore.getInstance();\n return {\n get: (key: string, ns?: string) => memoryStore.get(key, ns),\n has: (key: string, ns?: string) => memoryStore.has(key, ns),\n getAll: (ns?: string) => memoryStore.getAll(ns),\n set: (key: string, value: unknown, ns?: string) => {\n const nsName = ns || memoryStore.getDefaultNamespace();\n const data: Map<string, Map<string, unknown>> = (memoryStore as any)['data'];\n if (!data.has(nsName)) data.set(nsName, new Map());\n data.get(nsName)!.set(key, value);\n },\n clear: (ns?: string) => {\n const data: Map<string, Map<string, unknown>> = (memoryStore as any)['data'];\n if (ns) data.delete(ns);\n else data.clear();\n },\n increment: (key: string, amount = 1, ns?: string) => {\n const nsName = ns || memoryStore.getDefaultNamespace();\n const data: Map<string, Map<string, unknown>> = (memoryStore as any)['data'];\n if (!data.has(nsName)) data.set(nsName, new Map());\n const nsMap = data.get(nsName)!;\n const current = nsMap.get(key);\n const numCurrent = typeof current === 'number' ? current : 0;\n const newValue = numCurrent + amount;\n nsMap.set(key, newValue);\n return newValue;\n },\n };\n}\n\nfunction getHistoryLimit(): number | undefined {\n const raw = process.env.VISOR_TEST_HISTORY_LIMIT || process.env.VISOR_OUTPUT_HISTORY_LIMIT;\n if (!raw) return undefined;\n const n = parseInt(raw, 10);\n return Number.isFinite(n) && n > 0 ? n : undefined;\n}\n\ntype RoutingTrigger = 'on_success' | 'on_fail' | 'on_finish';\ntype RoutingAction = 'run' | 'goto' | 'retry';\ntype RoutingSource = 'run' | 'run_js' | 'goto' | 'goto_js' | 'transitions' | 'retry';\n\nfunction formatScopeLabel(scope: Array<{ check: string; index: number }> | undefined): string {\n if (!scope || scope.length === 0) return '';\n return scope.map(item => `${item.check}:${item.index}`).join('|');\n}\n\nfunction recordRoutingEvent(args: {\n checkId: string;\n trigger: RoutingTrigger;\n action: RoutingAction;\n target?: string;\n source?: RoutingSource;\n scope?: Array<{ check: string; index: number }>;\n gotoEvent?: string;\n}): void {\n const attrs: Record<string, unknown> = {\n check_id: args.checkId,\n trigger: args.trigger,\n action: args.action,\n };\n if (args.target) attrs.target = args.target;\n if (args.source) attrs.source = args.source;\n const scopeLabel = formatScopeLabel(args.scope);\n if (scopeLabel) attrs.scope = scopeLabel;\n if (args.gotoEvent) attrs.goto_event = args.gotoEvent;\n addEvent('visor.routing', attrs);\n}\n\n/**\n * Handle routing state - evaluate conditions and decide next actions\n */\nexport async function handleRouting(\n context: EngineContext,\n state: RunState,\n transition: (newState: EngineState) => void,\n emitEvent: (event: EngineEvent) => void,\n routingContext: RoutingContext\n): Promise<void> {\n const { checkId, scope, result, checkConfig, success } = routingContext;\n\n // Always log routing entry for debugging E2E expectations\n logger.info(`[Routing] Evaluating routing for check: ${checkId}, success: ${success}`);\n\n // Step 1: Evaluate fail_if conditions\n const failIfTriggered = await evaluateFailIf(checkId, result, checkConfig, context, state);\n\n if (failIfTriggered) {\n if (context.debug) {\n logger.info(`[Routing] fail_if triggered for ${checkId}`);\n }\n\n // Treat as failure for routing purposes\n await processOnFail(checkId, scope, result, checkConfig, context, state, emitEvent);\n } else if (success) {\n // Step 2: Process on_success routing\n await processOnSuccess(checkId, scope, result, checkConfig, context, state, emitEvent);\n } else {\n // Step 3: Process on_fail routing\n await processOnFail(checkId, scope, result, checkConfig, context, state, emitEvent);\n }\n\n // Step 4: on_finish\n // Process on_finish here for:\n // - non-forEach checks\n // - forEach parents that do NOT have map-fanout dependents\n // (reduce-only dependents don't need the post-children barrier)\n const shouldProcessOnFinishHere =\n !!checkConfig.on_finish &&\n (checkConfig.forEach !== true || !hasMapFanoutDependents(context, checkId));\n if (checkConfig.on_finish) {\n logger.info(\n `[Routing] on_finish decision for ${checkId}: forEach=${!!checkConfig.forEach}, processHere=${shouldProcessOnFinishHere}`\n );\n }\n if (shouldProcessOnFinishHere) {\n await processOnFinish(checkId, scope, result, checkConfig, context, state, emitEvent);\n }\n\n // Transition back to WavePlanning to process queued events\n transition('WavePlanning');\n}\n\n/**\n * Process on_finish routing\n */\nasync function processOnFinish(\n checkId: string,\n scope: Array<{ check: string; index: number }>,\n result: ReviewSummary,\n checkConfig: CheckConfig,\n context: EngineContext,\n state: RunState,\n emitEvent: (event: EngineEvent) => void\n): Promise<void> {\n const onFinish = checkConfig.on_finish;\n\n if (!onFinish) {\n return; // No on_finish configuration\n }\n\n // Log at info level so it's visible in test output\n logger.info(`Processing on_finish for ${checkId}`);\n let queuedForward = false;\n // Process on_finish.run\n if (onFinish.run && onFinish.run.length > 0) {\n // Check if current check is a forEach parent with items\n const currentCheckIsForEach = checkConfig.forEach === true;\n const forEachItems = currentCheckIsForEach ? (result as any).forEachItems : undefined;\n const hasForEachItems = Array.isArray(forEachItems) && forEachItems.length > 0;\n\n for (const targetCheck of onFinish.run) {\n // Check loop budget before scheduling\n if (checkLoopBudget(context, state, 'on_finish', 'run')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? DEFAULT_MAX_LOOPS}) during on_finish run`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n\n // Handle fanout: check if target has fanout configuration\n const targetConfig = context.config.checks?.[targetCheck];\n const fanoutMode = targetConfig?.fanout || 'reduce'; // default to reduce\n\n if (context.debug) {\n logger.info(\n `[Routing] on_finish.run: scheduling ${targetCheck} with fanout=${fanoutMode}, hasForEachItems=${hasForEachItems}`\n );\n }\n\n // If current check has forEach items and target is map fanout, emit one event per item\n if (fanoutMode === 'map' && hasForEachItems) {\n // Map fanout: emit one ForwardRunRequested per forEach item\n for (let itemIndex = 0; itemIndex < forEachItems!.length; itemIndex++) {\n // Increment loop count for each item\n state.routingLoopCount++;\n\n const itemScope: Array<{ check: string; index: number }> = [\n { check: checkId, index: itemIndex },\n ];\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_finish',\n action: 'run',\n target: targetCheck,\n source: 'run',\n scope: itemScope,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: targetCheck,\n scope: itemScope,\n origin: 'run',\n });\n queuedForward = true;\n }\n } else {\n // Reduce fanout (or no forEach context): emit with empty scope once\n // Increment loop count\n state.routingLoopCount++;\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_finish',\n action: 'run',\n target: targetCheck,\n source: 'run',\n scope: [],\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: targetCheck,\n scope: [],\n origin: 'run',\n });\n queuedForward = true;\n }\n }\n }\n\n // Process on_finish.run_js\n if (onFinish.run_js) {\n const dynamicTargets = await evaluateRunJs(\n onFinish.run_js,\n checkId,\n checkConfig,\n result,\n context,\n state\n );\n\n for (const targetCheck of dynamicTargets) {\n // Check loop budget before scheduling\n if (checkLoopBudget(context, state, 'on_finish', 'run')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? DEFAULT_MAX_LOOPS}) during on_finish run`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n\n if (context.debug) {\n logger.info(`[Routing] on_finish.run_js: scheduling ${targetCheck}`);\n }\n\n // Increment loop count\n state.routingLoopCount++;\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_finish',\n action: 'run',\n target: targetCheck,\n source: 'run_js',\n scope,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: targetCheck,\n scope,\n origin: 'run_js',\n });\n queuedForward = true;\n }\n }\n\n // Declarative transitions (override goto/goto_js when present)\n const finishTransTarget = await evaluateTransitions(\n onFinish.transitions,\n checkId,\n checkConfig,\n result,\n context,\n state\n );\n if (finishTransTarget !== undefined) {\n if (finishTransTarget) {\n if (checkLoopBudget(context, state, 'on_finish', 'goto')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? DEFAULT_MAX_LOOPS}) during on_finish goto`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n state.routingLoopCount++;\n recordRoutingEvent({\n checkId,\n trigger: 'on_finish',\n action: 'goto',\n target: finishTransTarget.to,\n source: 'transitions',\n scope,\n gotoEvent: finishTransTarget.goto_event,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: finishTransTarget.to,\n scope,\n origin: 'goto_js',\n gotoEvent: finishTransTarget.goto_event,\n });\n }\n return; // transitions override goto/goto_js\n }\n\n // Process on_finish.goto / goto_js\n const gotoTarget = await evaluateGoto(\n onFinish.goto_js,\n onFinish.goto,\n checkId,\n checkConfig,\n result,\n context,\n state\n );\n\n if (gotoTarget) {\n // Check loop budget before scheduling goto\n if (checkLoopBudget(context, state, 'on_finish', 'goto')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? DEFAULT_MAX_LOOPS}) during on_finish goto`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n\n if (context.debug) {\n logger.info(`[Routing] on_finish.goto: ${gotoTarget}`);\n }\n\n // Increment loop count\n state.routingLoopCount++;\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_finish',\n action: 'goto',\n target: gotoTarget,\n source: onFinish.goto_js ? 'goto_js' : 'goto',\n scope,\n });\n // Enqueue forward run event\n emitEvent({\n type: 'ForwardRunRequested',\n target: gotoTarget,\n scope,\n origin: 'goto_js',\n });\n\n // Mark that we've seen a forward run\n state.flags.forwardRunRequested = true;\n }\n\n // If we scheduled any forward-run targets via on_finish, request a wave retry so\n // dependent checks (with if conditions) can re-evaluate after the forward-run completes.\n // Guard: only enqueue once per originating check per wave to avoid loops.\n if (queuedForward) {\n const guardKey = `waveRetry:on_finish:${checkId}:wave:${state.wave}`;\n if (!(state as any).forwardRunGuards?.has(guardKey)) {\n (state as any).forwardRunGuards?.add(guardKey);\n emitEvent({ type: 'WaveRetry', reason: 'on_finish' });\n }\n }\n}\n\n/**\n * Evaluate fail_if conditions for a check\n */\n// Returns true only when a check-level fail_if is triggered.\n// Global fail_if records an issue for summary/reporting but MUST NOT gate routing.\nasync function evaluateFailIf(\n checkId: string,\n result: ReviewSummary,\n checkConfig: CheckConfig,\n context: EngineContext,\n state: RunState\n): Promise<boolean> {\n const config = context.config;\n\n // Check for fail_if at global or check level\n const globalFailIf = config.fail_if;\n const checkFailIf = checkConfig.fail_if;\n\n if (!globalFailIf && !checkFailIf) {\n return false; // No fail_if conditions\n }\n\n const evaluator = new FailureConditionEvaluator();\n\n // Build outputs record from state\n const outputsRecord: Record<string, ReviewSummary> = {};\n for (const [key] of state.stats.entries()) {\n // Try to get the actual result from context.journal if available\n try {\n const snapshotId = context.journal.beginSnapshot();\n const contextView = new (require('../../snapshot-store').ContextView)(\n context.journal,\n context.sessionId,\n snapshotId,\n [],\n context.event\n );\n const journalResult = contextView.get(key);\n if (journalResult) {\n outputsRecord[key] = journalResult as ReviewSummary;\n }\n } catch {\n // Fallback to empty result\n outputsRecord[key] = { issues: [] };\n }\n }\n\n const checkSchema = typeof checkConfig.schema === 'object' ? 'custom' : checkConfig.schema || '';\n const checkGroup = checkConfig.group || '';\n\n // Evaluate global fail_if (non-gating)\n if (globalFailIf) {\n try {\n const failed = await evaluator.evaluateSimpleCondition(\n checkId,\n checkSchema,\n checkGroup,\n result,\n globalFailIf,\n outputsRecord\n );\n\n if (failed) {\n logger.warn(`[Routing] Global fail_if triggered for ${checkId}: ${globalFailIf}`);\n\n // Add fail_if issue to result\n const failIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: 'global_fail_if',\n message: `Global failure condition met: ${globalFailIf}`,\n severity: 'error',\n category: 'logic',\n };\n\n result.issues = [...(result.issues || []), failIssue];\n // IMPORTANT: do not gate routing on global fail_if\n // This condition contributes to overall run status but should not\n // block dependents from executing when the producing check succeeded.\n // Continue evaluating check-level fail_if below.\n }\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n logger.error(`[Routing] Error evaluating global fail_if: ${msg}`);\n }\n }\n\n // Evaluate check-specific fail_if\n if (checkFailIf) {\n try {\n const failed = await evaluator.evaluateSimpleCondition(\n checkId,\n checkSchema,\n checkGroup,\n result,\n checkFailIf,\n outputsRecord\n );\n\n if (failed) {\n logger.warn(`[Routing] Check fail_if triggered for ${checkId}: ${checkFailIf}`);\n\n // Add fail_if issue to result\n const failIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}_fail_if`,\n message: `Check failure condition met: ${checkFailIf}`,\n severity: 'error',\n category: 'logic',\n };\n\n result.issues = [...(result.issues || []), failIssue];\n return true;\n }\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n logger.error(`[Routing] Error evaluating check fail_if: ${msg}`);\n }\n }\n\n return false;\n}\n\n/**\n * Check if routing loop budget is exceeded\n */\nexport function checkLoopBudget(\n context: EngineContext,\n state: RunState,\n origin: 'on_success' | 'on_fail' | 'on_finish',\n action: 'run' | 'goto'\n): boolean {\n const maxLoops = context.config.routing?.max_loops ?? DEFAULT_MAX_LOOPS;\n\n if (state.routingLoopCount >= maxLoops) {\n const msg = `Routing loop budget exceeded (max_loops=${maxLoops}) during ${origin} ${action}`;\n logger.error(`[Routing] ${msg}`);\n return true; // Budget exceeded\n }\n\n return false; // Budget OK\n}\n\n/**\n * Process on_success routing\n */\nasync function processOnSuccess(\n checkId: string,\n scope: Array<{ check: string; index: number }>,\n result: ReviewSummary,\n checkConfig: CheckConfig,\n context: EngineContext,\n state: RunState,\n emitEvent: (event: EngineEvent) => void\n): Promise<void> {\n const onSuccess = checkConfig.on_success;\n\n if (!onSuccess) {\n return; // No on_success configuration\n }\n\n if (context.debug) {\n logger.info(`[Routing] Processing on_success for ${checkId}`);\n }\n\n // Process on_success.run\n if (onSuccess.run && onSuccess.run.length > 0) {\n // Detect forEach context based on the actual result (aggregated map execution)\n const resForEachItems: any[] | undefined =\n (result && (result as any).forEachItems) || undefined;\n const hasForEachItems = Array.isArray(resForEachItems) && resForEachItems.length > 0;\n\n for (const targetCheck of onSuccess.run) {\n // Check loop budget before scheduling\n if (checkLoopBudget(context, state, 'on_success', 'run')) {\n // Add error issue to result\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? DEFAULT_MAX_LOOPS}) during on_success run`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return; // Stop processing\n }\n\n // Handle fanout: check if target has fanout configuration\n const targetConfig = context.config.checks?.[targetCheck];\n const fanoutMode = targetConfig?.fanout || 'reduce'; // default to reduce\n\n if (context.debug) {\n logger.info(\n `[Routing] on_success.run: scheduling ${targetCheck} with fanout=${fanoutMode}, hasForEachItems=${hasForEachItems}`\n );\n }\n\n // If current check has forEach items and target is map fanout, emit one event per item\n if (fanoutMode === 'map' && hasForEachItems) {\n // Map fanout: emit one ForwardRunRequested per forEach item\n for (let itemIndex = 0; itemIndex < resForEachItems!.length; itemIndex++) {\n // Increment loop count for each item\n state.routingLoopCount++;\n\n const itemScope: Array<{ check: string; index: number }> = [\n { check: checkId, index: itemIndex },\n ];\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_success',\n action: 'run',\n target: targetCheck,\n source: 'run',\n scope: itemScope,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: targetCheck,\n scope: itemScope,\n origin: 'run',\n });\n }\n } else {\n // Reduce fanout (or no forEach context): emit with empty scope once\n // Increment loop count\n state.routingLoopCount++;\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_success',\n action: 'run',\n target: targetCheck,\n source: 'run',\n scope,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: targetCheck,\n scope,\n origin: 'run',\n });\n }\n }\n }\n\n // Process on_success.run_js\n if (onSuccess.run_js) {\n const dynamicTargets = await evaluateRunJs(\n onSuccess.run_js,\n checkId,\n checkConfig,\n result,\n context,\n state\n );\n\n for (const targetCheck of dynamicTargets) {\n // Check loop budget before scheduling\n if (checkLoopBudget(context, state, 'on_success', 'run')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? 10}) during on_success run`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n\n if (context.debug) {\n logger.info(`[Routing] on_success.run_js: scheduling ${targetCheck}`);\n }\n\n // Increment loop count\n state.routingLoopCount++;\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_success',\n action: 'run',\n target: targetCheck,\n source: 'run_js',\n scope,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: targetCheck,\n scope,\n origin: 'run_js',\n });\n }\n }\n\n // Declarative transitions for on_success (override goto/goto_js when present)\n const successTransTarget = await evaluateTransitions(\n onSuccess.transitions,\n checkId,\n checkConfig,\n result,\n context,\n state\n );\n if (successTransTarget !== undefined) {\n if (successTransTarget) {\n if (checkLoopBudget(context, state, 'on_success', 'goto')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? DEFAULT_MAX_LOOPS}) during on_success goto`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n state.routingLoopCount++;\n recordRoutingEvent({\n checkId,\n trigger: 'on_success',\n action: 'goto',\n target: successTransTarget.to,\n source: 'transitions',\n scope,\n gotoEvent: successTransTarget.goto_event,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: successTransTarget.to,\n scope,\n origin: 'goto_js',\n gotoEvent: successTransTarget.goto_event,\n });\n state.flags.forwardRunRequested = true;\n }\n return;\n }\n\n // Process on_success.goto / goto_js\n const gotoTarget = await evaluateGoto(\n onSuccess.goto_js,\n onSuccess.goto,\n checkId,\n checkConfig,\n result,\n context,\n state\n );\n\n if (gotoTarget) {\n // Check loop budget before scheduling goto\n if (checkLoopBudget(context, state, 'on_success', 'goto')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? 10}) during on_success goto`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n\n if (context.debug) {\n logger.info(`[Routing] on_success.goto: ${gotoTarget}`);\n }\n\n // Increment loop count\n state.routingLoopCount++;\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_success',\n action: 'goto',\n target: gotoTarget,\n source: onSuccess.goto_js ? 'goto_js' : 'goto',\n scope,\n gotoEvent: onSuccess.goto_event,\n });\n // Enqueue forward run event with optional event override\n emitEvent({\n type: 'ForwardRunRequested',\n target: gotoTarget,\n gotoEvent: onSuccess.goto_event,\n scope,\n origin: 'goto_js',\n });\n\n // Mark that we've seen a forward run\n state.flags.forwardRunRequested = true;\n }\n}\n\n/**\n * Process on_fail routing\n */\nasync function processOnFail(\n checkId: string,\n scope: Array<{ check: string; index: number }>,\n result: ReviewSummary,\n checkConfig: CheckConfig,\n context: EngineContext,\n state: RunState,\n emitEvent: (event: EngineEvent) => void\n): Promise<void> {\n // Merge defaults with check-specific on_fail\n const defaults = context.config.routing?.defaults?.on_fail || {};\n const onFail: OnFailConfig | undefined = checkConfig.on_fail\n ? { ...defaults, ...checkConfig.on_fail }\n : undefined;\n\n if (!onFail) {\n return; // No on_fail configuration\n }\n\n if (context.debug) {\n logger.info(`[Routing] Processing on_fail for ${checkId}`);\n }\n\n // Process on_fail.run\n if (onFail.run && onFail.run.length > 0) {\n // Detect forEach context based on the actual aggregated result\n const resForEachItems: any[] | undefined =\n (result && (result as any).forEachItems) || undefined;\n const hasForEachItems = Array.isArray(resForEachItems) && resForEachItems.length > 0;\n\n for (const targetCheck of onFail.run) {\n // Check loop budget before scheduling\n if (checkLoopBudget(context, state, 'on_fail', 'run')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? 10}) during on_fail run`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n\n // Handle fanout: check if target has fanout configuration\n const targetConfig = context.config.checks?.[targetCheck];\n const fanoutMode = targetConfig?.fanout || 'reduce'; // default to reduce\n\n if (context.debug) {\n logger.info(\n `[Routing] on_fail.run: scheduling ${targetCheck} with fanout=${fanoutMode}, hasForEachItems=${hasForEachItems}`\n );\n }\n\n // If current check ran in forEach context, schedule remediation per item\n if (hasForEachItems) {\n for (let itemIndex = 0; itemIndex < resForEachItems!.length; itemIndex++) {\n const itemOut = resForEachItems![itemIndex] as any;\n // Only remediate failed iterations if __failed is present; otherwise run for all\n if (\n itemOut &&\n typeof itemOut === 'object' &&\n itemOut.__failed !== true &&\n fanoutMode !== 'map'\n ) {\n // For reduce targets, skip successful iterations to avoid redundant runs\n continue;\n }\n\n state.routingLoopCount++;\n const itemScope: Array<{ check: string; index: number }> = [\n { check: checkId, index: itemIndex },\n ];\n recordRoutingEvent({\n checkId,\n trigger: 'on_fail',\n action: 'run',\n target: targetCheck,\n source: 'run',\n scope: itemScope,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: targetCheck,\n scope: itemScope,\n origin: 'run',\n sourceCheck: checkId, // The failed check that triggered on_fail.run\n });\n }\n } else {\n // No forEach context: preserve current scope (if any)\n state.routingLoopCount++;\n recordRoutingEvent({\n checkId,\n trigger: 'on_fail',\n action: 'run',\n target: targetCheck,\n source: 'run',\n scope,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: targetCheck,\n scope,\n origin: 'run',\n sourceCheck: checkId, // The failed check that triggered on_fail.run\n });\n }\n }\n }\n\n // Process on_fail.run_js\n if (onFail.run_js) {\n const dynamicTargets = await evaluateRunJs(\n onFail.run_js,\n checkId,\n checkConfig,\n result,\n context,\n state\n );\n\n for (const targetCheck of dynamicTargets) {\n // Check loop budget before scheduling\n if (checkLoopBudget(context, state, 'on_fail', 'run')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? 10}) during on_fail run`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n\n if (context.debug) {\n logger.info(`[Routing] on_fail.run_js: scheduling ${targetCheck}`);\n }\n\n // Increment loop count\n state.routingLoopCount++;\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_fail',\n action: 'run',\n target: targetCheck,\n source: 'run_js',\n scope,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: targetCheck,\n scope,\n origin: 'run_js',\n sourceCheck: checkId, // The failed check that triggered on_fail.run_js\n });\n }\n }\n\n // Process on_fail.retry (schedule retry of the current check)\n if (onFail.retry && typeof onFail.retry.max === 'number' && onFail.retry.max > 0) {\n // Criticality mapping: for 'external' and 'internal', avoid automatic\n // retries for logical failures (fail_if/guarantee violations).\n const crit = getCriticality(context, checkId);\n const failureKind = classifyFailure(result);\n if ((crit === 'external' || crit === 'internal') && failureKind === 'logical') {\n if (context.debug) {\n logger.info(\n `[Routing] on_fail.retry suppressed for ${checkId} (criticality=${crit}, failure=logical)`\n );\n }\n // Skip retry scheduling\n } else {\n const max = Math.max(0, onFail.retry.max || 0);\n // Initialize retry attempt map on state\n if (!(state as any).retryAttempts) (state as any).retryAttempts = new Map<string, number>();\n const attemptsMap: Map<string, number> = (state as any).retryAttempts;\n\n const makeKey = (sc: Array<{ check: string; index: number }> | undefined) => {\n const keyScope = sc && sc.length > 0 ? JSON.stringify(sc) : 'root';\n return `${checkId}::${keyScope}`;\n };\n\n const scheduleRetryForScope = (sc: Array<{ check: string; index: number }> | undefined) => {\n const key = makeKey(sc);\n const used = attemptsMap.get(key) || 0;\n if (used >= max) return; // budget exhausted\n attemptsMap.set(key, used + 1);\n\n // Increment loop count and schedule forward run for the same check\n state.routingLoopCount++;\n recordRoutingEvent({\n checkId,\n trigger: 'on_fail',\n action: 'retry',\n source: 'retry',\n scope: sc || [],\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: checkId,\n scope: sc || [],\n origin: 'run',\n });\n };\n\n const resForEachItems: any[] | undefined =\n (result && (result as any).forEachItems) || undefined;\n const hasForEachItems = Array.isArray(resForEachItems) && resForEachItems.length > 0;\n\n if (hasForEachItems) {\n for (let i = 0; i < resForEachItems!.length; i++) {\n const itemOut = resForEachItems![i] as any;\n // Only retry failed iterations (marked by __failed)\n if (itemOut && typeof itemOut === 'object' && itemOut.__failed === true) {\n const sc: Array<{ check: string; index: number }> = [{ check: checkId, index: i }];\n scheduleRetryForScope(sc);\n }\n }\n } else {\n scheduleRetryForScope(scope);\n }\n\n // Note: backoff.delay_ms and mode are intentionally not awaited here; the\n // state-machine processes retries as subsequent waves. If needed later, we\n // can insert a timed wait in the orchestrator layer.\n }\n }\n\n // Declarative transitions for on_fail (override goto/goto_js when present)\n const failTransTarget = await evaluateTransitions(\n onFail.transitions,\n checkId,\n checkConfig,\n result,\n context,\n state\n );\n if (failTransTarget !== undefined) {\n if (failTransTarget) {\n if (checkLoopBudget(context, state, 'on_fail', 'goto')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? DEFAULT_MAX_LOOPS}) during on_fail goto`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n state.routingLoopCount++;\n recordRoutingEvent({\n checkId,\n trigger: 'on_fail',\n action: 'goto',\n target: failTransTarget.to,\n source: 'transitions',\n scope,\n gotoEvent: failTransTarget.goto_event,\n });\n emitEvent({\n type: 'ForwardRunRequested',\n target: failTransTarget.to,\n scope,\n origin: 'goto_js',\n gotoEvent: failTransTarget.goto_event,\n });\n state.flags.forwardRunRequested = true;\n }\n return;\n }\n\n // Process on_fail.goto / goto_js\n const gotoTarget = await evaluateGoto(\n onFail.goto_js,\n onFail.goto,\n checkId,\n checkConfig,\n result,\n context,\n state\n );\n\n if (gotoTarget) {\n // Check loop budget before scheduling goto\n if (checkLoopBudget(context, state, 'on_fail', 'goto')) {\n const errorIssue: ReviewIssue = {\n file: 'system',\n line: 0,\n ruleId: `${checkId}/routing/loop_budget_exceeded`,\n message: `Routing loop budget exceeded (max_loops=${context.config.routing?.max_loops ?? 10}) during on_fail goto`,\n severity: 'error',\n category: 'logic',\n };\n result.issues = [...(result.issues || []), errorIssue];\n return;\n }\n\n if (context.debug) {\n logger.info(`[Routing] on_fail.goto: ${gotoTarget}`);\n }\n\n // Increment loop count\n state.routingLoopCount++;\n\n recordRoutingEvent({\n checkId,\n trigger: 'on_fail',\n action: 'goto',\n target: gotoTarget,\n source: onFail.goto_js ? 'goto_js' : 'goto',\n scope,\n gotoEvent: onFail.goto_event,\n });\n // Enqueue forward run event with optional event override\n emitEvent({\n type: 'ForwardRunRequested',\n target: gotoTarget,\n gotoEvent: onFail.goto_event,\n scope,\n origin: 'goto_js',\n });\n\n // Mark that we've seen a forward run\n state.flags.forwardRunRequested = true;\n }\n}\n\n/**\n * Evaluate run_js expression to get dynamic check targets\n */\nasync function evaluateRunJs(\n runJs: string,\n checkId: string,\n checkConfig: CheckConfig,\n result: ReviewSummary,\n context: EngineContext,\n _state: RunState\n): Promise<string[]> {\n try {\n const sandbox = createSecureSandbox();\n const historyLimit = getHistoryLimit();\n\n // Build outputs record and outputs_history\n const snapshotId = context.journal.beginSnapshot();\n const contextView = new (require('../../snapshot-store').ContextView)(\n context.journal,\n context.sessionId,\n snapshotId,\n [],\n context.event\n );\n\n const outputsRecord: Record<string, any> = {};\n const outputsHistory: Record<string, any[]> = {};\n\n // Get all visible journal entries to build complete history\n const allEntries = context.journal.readVisible(context.sessionId, snapshotId, context.event);\n const uniqueCheckIds = new Set(allEntries.map(e => e.checkId));\n\n for (const checkIdFromJournal of uniqueCheckIds) {\n try {\n // Get current output for this check\n const journalResult = contextView.get(checkIdFromJournal);\n if (journalResult) {\n // Prefer the output field if present, otherwise use the full result\n outputsRecord[checkIdFromJournal] =\n journalResult.output !== undefined ? journalResult.output : journalResult;\n }\n } catch {\n outputsRecord[checkIdFromJournal] = { issues: [] };\n }\n\n // Build history for this check\n try {\n const history = contextView.getHistory(checkIdFromJournal);\n if (history && history.length > 0) {\n const trimmed =\n historyLimit && history.length > historyLimit\n ? history.slice(history.length - historyLimit)\n : history;\n // Extract outputs from history (prefer output field if available)\n outputsHistory[checkIdFromJournal] = trimmed.map((r: any) =>\n r.output !== undefined ? r.output : r\n );\n }\n } catch {\n // Ignore history errors\n }\n }\n\n // Add history as a property on outputs object for convenient access\n outputsRecord.history = outputsHistory;\n\n // Compute minimal forEach metadata for run_js parity\n let forEachMeta: any = undefined;\n try {\n const hist = outputsHistory[checkId] || [];\n const lastArr = (hist as any[])\n .slice()\n .reverse()\n .find((x: any) => Array.isArray(x));\n if (checkConfig.forEach === true && Array.isArray(lastArr)) {\n forEachMeta = {\n is_parent: true,\n last_wave_size: lastArr.length,\n last_items: lastArr,\n };\n }\n } catch {}\n\n const scopeObj: any = {\n step: {\n id: checkId,\n tags: checkConfig.tags || [],\n group: checkConfig.group,\n },\n outputs: outputsRecord,\n outputs_history: outputsHistory,\n output: (result as any)?.output,\n memory: createMemoryHelpers(),\n event: {\n name: context.event || 'manual',\n },\n forEach: forEachMeta,\n };\n\n const code = `\n const step = scope.step;\n const outputs = scope.outputs;\n const outputs_history = scope.outputs_history;\n const output = scope.output;\n const memory = scope.memory;\n const event = scope.event;\n const forEach = scope.forEach;\n const log = (...args) => console.log('🔍 Debug:', ...args);\n const __fn = () => {\n ${runJs}\n };\n const __res = __fn();\n return Array.isArray(__res) ? __res.filter(x => typeof x === 'string' && x) : [];\n `;\n\n try {\n const evalResult = compileAndRun<string[]>(\n sandbox,\n code,\n { scope: scopeObj },\n { injectLog: false, wrapFunction: false }\n );\n return Array.isArray(evalResult) ? evalResult.filter(Boolean) : [];\n } catch (_e) {\n // Fallback to VM for modern syntax used inside run_js\n try {\n const vm = require('node:vm');\n const context = vm.createContext({ scope: scopeObj, console: { log: () => {} } });\n const src = `(() => { ${runJs}\\n })()`;\n const val = new vm.Script(src).runInContext(context, { timeout: 100 });\n return Array.isArray(val) ? val.filter((x: any) => typeof x === 'string' && x) : [];\n } catch (_vmErr) {\n return [];\n }\n }\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n logger.error(`[Routing] Error evaluating run_js: ${msg}`);\n return [];\n }\n}\n\n/**\n * Evaluate goto_js or return static goto target\n */\nexport async function evaluateGoto(\n gotoJs: string | undefined,\n gotoStatic: string | undefined,\n checkId: string,\n checkConfig: CheckConfig,\n result: ReviewSummary,\n context: EngineContext,\n _state: RunState\n): Promise<string | null> {\n // Evaluate goto_js first\n if (gotoJs) {\n try {\n const sandbox = createSecureSandbox();\n const historyLimit = getHistoryLimit();\n\n // Build outputs record and outputs_history from the full session snapshot.\n // Do not filter by event here — on_finish (especially forEach post-children) may\n // need to see results committed under different event triggers within the same run.\n const snapshotId = context.journal.beginSnapshot();\n const contextView = new (require('../../snapshot-store').ContextView)(\n context.journal,\n context.sessionId,\n snapshotId,\n [],\n undefined\n );\n\n const outputsRecord: Record<string, any> = {};\n const outputsHistory: Record<string, any[]> = {};\n\n // Get all visible journal entries to build complete history\n const allEntries = context.journal.readVisible(context.sessionId, snapshotId, undefined);\n const uniqueCheckIds = new Set(allEntries.map(e => e.checkId));\n\n for (const checkIdFromJournal of uniqueCheckIds) {\n try {\n // Get current output for this check\n const journalResult = contextView.get(checkIdFromJournal);\n if (journalResult) {\n // Prefer the output field if present, otherwise use the full result\n outputsRecord[checkIdFromJournal] =\n journalResult.output !== undefined ? journalResult.output : journalResult;\n }\n } catch {\n outputsRecord[checkIdFromJournal] = { issues: [] };\n }\n\n // Build history for this check\n try {\n const history = contextView.getHistory(checkIdFromJournal);\n if (history && history.length > 0) {\n const trimmed =\n historyLimit && history.length > historyLimit\n ? history.slice(history.length - historyLimit)\n : history;\n // Extract outputs from history (prefer output field if available)\n outputsHistory[checkIdFromJournal] = trimmed.map((r: any) =>\n r.output !== undefined ? r.output : r\n );\n }\n } catch {\n // Ignore history errors\n }\n }\n\n // Add history as a property on outputs object for convenient access\n outputsRecord.history = outputsHistory;\n\n // Compute minimal forEach metadata for convenience in goto_js\n // - last_wave_size: number of items in the latest root-scope array output\n // - last_items: the latest array output itself (if available)\n let forEachMeta: any = undefined;\n try {\n const hist = outputsHistory[checkId] || [];\n const lastArr = (hist as any[])\n .slice()\n .reverse()\n .find((x: any) => Array.isArray(x));\n if (checkConfig.forEach === true && Array.isArray(lastArr)) {\n forEachMeta = {\n is_parent: true,\n last_wave_size: lastArr.length,\n last_items: lastArr,\n };\n }\n } catch {}\n\n const scopeObj: any = {\n step: {\n id: checkId,\n tags: checkConfig.tags || [],\n group: checkConfig.group,\n },\n outputs: outputsRecord,\n outputs_history: outputsHistory,\n output: (result as any)?.output,\n memory: createMemoryHelpers(),\n event: {\n name: context.event || 'manual',\n },\n forEach: forEachMeta,\n };\n\n // Debug: Log outputs_history\n if (context.debug) {\n logger.info(\n `[Routing] evaluateGoto: checkId=${checkId}, outputs_history keys=${Object.keys(outputsHistory).join(',')}`\n );\n for (const [key, values] of Object.entries(outputsHistory)) {\n logger.info(`[Routing] ${key}: ${values.length} items`);\n }\n }\n\n const code = `\n const step = scope.step;\n const outputs = scope.outputs;\n const outputs_history = scope.outputs_history;\n const output = scope.output;\n const memory = scope.memory;\n const event = scope.event;\n const forEach = scope.forEach;\n const log = (...args) => console.log('🔍 Debug:', ...args);\n ${gotoJs}\n `;\n\n try {\n const evalResult = compileAndRun<string | null>(\n sandbox,\n code,\n { scope: scopeObj },\n { injectLog: false, wrapFunction: true }\n );\n\n if (context.debug) {\n logger.info(`[Routing] evaluateGoto result: ${evalResult}`);\n }\n\n if (typeof evalResult === 'string' && evalResult) {\n return evalResult;\n }\n } catch (_e) {\n // Fallback to VM for modern syntax in goto_js\n try {\n const vm = require('node:vm');\n const contextObj = {\n step: scopeObj.step,\n outputs: scopeObj.outputs,\n outputs_history: scopeObj.outputs_history,\n output: scopeObj.output,\n memory: scopeObj.memory,\n event: scopeObj.event,\n forEach: (scopeObj as any).forEach,\n };\n const vmctx = vm.createContext(contextObj);\n const src = `(() => { ${gotoJs}\\n })()`;\n const res = new vm.Script(src).runInContext(vmctx, { timeout: 100 });\n if (typeof res === 'string' && res) return res;\n } catch (_vmErr) {\n // ignore; fall through to static goto\n }\n }\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n logger.error(`[Routing] Error evaluating goto_js: ${msg}`);\n\n // Fall back to static goto if available\n if (gotoStatic) {\n logger.info(`[Routing] Falling back to static goto: ${gotoStatic}`);\n return gotoStatic;\n }\n }\n }\n\n // Return static goto\n return gotoStatic || null;\n}\n// Default values (used only when config is absent)\nconst DEFAULT_MAX_LOOPS = 10;\n\n/**\n * Evaluate declarative transitions. Returns:\n * - { to, goto_event } when a rule matches,\n * - null (explicit) when a rule matches with to=null,\n * - undefined when no rule matched or transitions is empty.\n */\nexport async function evaluateTransitions(\n transitions: TransitionRule[] | undefined,\n checkId: string,\n checkConfig: CheckConfig,\n result: ReviewSummary,\n context: EngineContext,\n _state: RunState\n): Promise<\n { to: string; goto_event?: import('../../types/config').EventTrigger } | null | undefined\n> {\n if (!transitions || transitions.length === 0) return undefined;\n try {\n const sandbox = createSecureSandbox();\n const historyLimit = getHistoryLimit();\n\n // Build outputs record and outputs_history from the full session snapshot\n const snapshotId = context.journal.beginSnapshot();\n const ContextView = (require('../../snapshot-store') as any).ContextView;\n const view = new ContextView(context.journal, context.sessionId, snapshotId, [], undefined);\n\n const outputsRecord: Record<string, any> = {};\n const outputsHistory: Record<string, any[]> = {};\n const allEntries = context.journal.readVisible(context.sessionId, snapshotId, undefined);\n const uniqueCheckIds = new Set(allEntries.map((e: any) => e.checkId));\n for (const cid of uniqueCheckIds) {\n try {\n const jr = view.get(cid);\n if (jr) outputsRecord[cid] = jr.output !== undefined ? jr.output : jr;\n } catch {}\n try {\n const hist = view.getHistory(cid);\n if (hist && hist.length > 0) {\n const trimmed =\n historyLimit && hist.length > historyLimit\n ? hist.slice(hist.length - historyLimit)\n : hist;\n outputsHistory[cid] = trimmed.map((r: any) =>\n r.output !== undefined ? r.output : r\n );\n }\n } catch {}\n }\n outputsRecord.history = outputsHistory;\n\n const scopeObj: any = {\n step: { id: checkId, tags: checkConfig.tags || [], group: checkConfig.group },\n outputs: outputsRecord,\n outputs_history: outputsHistory,\n output: (result as any)?.output,\n memory: createMemoryHelpers(),\n event: { name: context.event || 'manual' },\n };\n\n for (const rule of transitions) {\n const helpers = `\n const any = (arr, pred) => Array.isArray(arr) && arr.some(x => pred(x));\n const all = (arr, pred) => Array.isArray(arr) && arr.every(x => pred(x));\n const none = (arr, pred) => Array.isArray(arr) && !arr.some(x => pred(x));\n const count = (arr, pred) => Array.isArray(arr) ? arr.filter(x => pred(x)).length : 0;\n `;\n // Mirror the variable exposure pattern used in goto_js/run_js so that\n // `when:` expressions can reference `outputs`, `outputs_history`, `event`, etc.\n const code = `\n ${helpers}\n const step = scope.step;\n const outputs = scope.outputs;\n const outputs_history = scope.outputs_history;\n const output = scope.output;\n const memory = scope.memory;\n const event = scope.event;\n const __eval = () => { return (${rule.when}); };\n return __eval();\n `;\n let matched: boolean | undefined;\n try {\n matched = compileAndRun<boolean>(\n sandbox,\n code,\n { scope: scopeObj },\n { injectLog: false, wrapFunction: false }\n );\n } catch (_e) {\n // Fallback: Node VM for modern syntax like optional chaining and ??\n try {\n const vm = require('node:vm');\n const helpersFns = {\n any: (arr: any[], pred: (x: any) => boolean) => Array.isArray(arr) && arr.some(pred),\n all: (arr: any[], pred: (x: any) => boolean) => Array.isArray(arr) && arr.every(pred),\n none: (arr: any[], pred: (x: any) => boolean) => Array.isArray(arr) && !arr.some(pred),\n count: (arr: any[], pred: (x: any) => boolean) =>\n Array.isArray(arr) ? arr.filter(pred).length : 0,\n };\n const context = vm.createContext({\n step: scopeObj.step,\n outputs: scopeObj.outputs,\n outputs_history: scopeObj.outputs_history,\n output: scopeObj.output,\n memory: scopeObj.memory,\n event: scopeObj.event,\n ...helpersFns,\n });\n const res = new vm.Script(`(${rule.when})`).runInContext(context, { timeout: 50 });\n matched = !!res;\n } catch (_vmErr) {\n matched = false;\n }\n }\n if (matched) {\n if (rule.to === null) return null;\n if (typeof rule.to === 'string' && rule.to.length > 0) {\n return { to: rule.to, goto_event: (rule as any).goto_event };\n }\n return null;\n }\n }\n return undefined;\n } catch (err) {\n logger.error(\n `[Routing] Error evaluating transitions: ${err instanceof Error ? err.message : String(err)}`\n );\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmBa,kBAwCA;AA3Db;AAAA;AAAA;AAmBO,IAAM,mBAAN,MAAuB;AAAA,MACpB,SAAS;AAAA,MACT,UAA0B,CAAC;AAAA,MAEnC,gBAAwB;AACtB,eAAO,KAAK;AAAA,MACd;AAAA,MAEA,YAAY,OAMK;AACf,cAAM,YAA0B;AAAA,UAC9B,WAAW,MAAM;AAAA,UACjB,OAAO,MAAM;AAAA,UACb,SAAS,MAAM;AAAA,UACf,QAAQ,MAAM;AAAA,UACd,OAAO,MAAM;AAAA,UACb,UAAU,EAAE,KAAK;AAAA,QACnB;AACA,aAAK,QAAQ,KAAK,SAAS;AAC3B,eAAO;AAAA,MACT;AAAA,MAEA,YAAY,WAAmB,WAAmB,OAAsC;AACtF,eAAO,KAAK,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,UACnD;AACA,gBAAMD,WAAU,GAAG,cAAc;AAAA,YAC/B,MAAM,SAAS;AAAA,YACf,SAAS,SAAS;AAAA,YAClB,iBAAiB,SAAS;AAAA,YAC1B,QAAQ,SAAS;AAAA,YACjB,QAAQ,SAAS;AAAA,YACjB,OAAO,SAAS;AAAA,YAChB,GAAG;AAAA,UACL,CAAC;AACD,gBAAM,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK,IAAI,GAAG,EAAE,aAAaA,UAAS,EAAE,SAAS,GAAG,CAAC;AACjF,oBAAU,CAAC,CAAC;AAAA,QACd,SAAS,QAAQ;AACf,oBAAU;AAAA,QACZ;AAAA,MACF;AACA,UAAI,SAAS;AACX,YAAI,KAAK,OAAO,KAAM,QAAO;AAC7B,YAAI,OAAO,KAAK,OAAO,YAAY,KAAK,GAAG,SAAS,GAAG;AACrD,iBAAO,EAAE,IAAI,KAAK,IAAI,YAAa,KAAa,WAAW;AAAA,QAC7D;AACA,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,WAAO;AAAA,MACL,2CAA2C,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,IAC7F;AACA,WAAO;AAAA,EACT;AACF;AApqDA,IAkiDM;AAliDN;AAAA;AAgBA;AACA;AACA;AACA;AACA;AA8gDA,IAAM,oBAAoB;AAAA;AAAA;","names":["context","ContextView"]}
@@ -56,6 +56,10 @@ var init_logger = __esm({
56
56
  isTTY = typeof process !== "undefined" ? !!process.stderr.isTTY : false;
57
57
  showTimestamps = true;
58
58
  // default: always show timestamps
59
+ sink;
60
+ sinkPassthrough = true;
61
+ sinkErrorMode = "throw";
62
+ sinkErrorHandler;
59
63
  configure(opts = {}) {
60
64
  let lvl = "info";
61
65
  if (opts.debug || process.env.VISOR_DEBUG === "true") {
@@ -76,6 +80,12 @@ var init_logger = __esm({
76
80
  const output = opts.outputFormat || process.env.VISOR_OUTPUT_FORMAT || "table";
77
81
  this.isJsonLike = output === "json" || output === "sarif";
78
82
  }
83
+ setSink(sink, opts = {}) {
84
+ this.sink = sink;
85
+ this.sinkPassthrough = opts.passthrough !== void 0 ? opts.passthrough : true;
86
+ this.sinkErrorMode = opts.errorMode || "throw";
87
+ this.sinkErrorHandler = opts.onError;
88
+ }
79
89
  shouldLog(level) {
80
90
  const desired = levelToNumber(level);
81
91
  const current = levelToNumber(this.level);
@@ -98,14 +108,38 @@ var init_logger = __esm({
98
108
  }
99
109
  }
100
110
  write(msg, level) {
111
+ const suffix = this.getTraceSuffix(msg);
112
+ const decoratedMsg = suffix ? `${msg}${suffix}` : msg;
113
+ const lvl = level || "info";
114
+ if (this.sink) {
115
+ try {
116
+ this.sink(decoratedMsg, lvl);
117
+ } catch (error) {
118
+ if (this.sinkErrorMode === "warn") {
119
+ try {
120
+ if (this.sinkErrorHandler) {
121
+ this.sinkErrorHandler(error);
122
+ } else {
123
+ const errMsg = error instanceof Error ? error.message : String(error);
124
+ process.stderr.write(`[logger] sink failed: ${errMsg}
125
+ `);
126
+ }
127
+ } catch {
128
+ }
129
+ }
130
+ if (this.sinkErrorMode === "throw") {
131
+ throw error;
132
+ }
133
+ return;
134
+ }
135
+ if (!this.sinkPassthrough) return;
136
+ }
101
137
  try {
102
- const suffix = this.getTraceSuffix(msg);
103
- const decoratedMsg = suffix ? `${msg}${suffix}` : msg;
104
138
  if (this.showTimestamps) {
105
139
  const ts = (/* @__PURE__ */ new Date()).toISOString();
106
- const lvl = level ? level : void 0;
140
+ const lvl2 = level ? level : void 0;
107
141
  let tsToken = `[${ts}]`;
108
- let lvlToken = lvl ? `[${lvl}]` : "";
142
+ let lvlToken = lvl2 ? `[${lvl2}]` : "";
109
143
  if (this.isTTY && !this.isJsonLike) {
110
144
  const reset = "\x1B[0m";
111
145
  const dim = "\x1B[2m";
@@ -123,14 +157,14 @@ var init_logger = __esm({
123
157
  // bright black / gray
124
158
  };
125
159
  tsToken = `${dim}${tsToken}${reset}`;
126
- if (lvl) {
127
- const colour = colours[lvl] || "";
160
+ if (lvl2) {
161
+ const colour = colours[lvl2] || "";
128
162
  if (colour) {
129
163
  lvlToken = `${colour}${lvlToken}${reset}`;
130
164
  }
131
165
  }
132
166
  }
133
- const prefix = lvl ? `${tsToken} ${lvlToken}` : tsToken;
167
+ const prefix = lvl2 ? `${tsToken} ${lvlToken}` : tsToken;
134
168
  process.stderr.write(`${prefix} ${decoratedMsg}
135
169
  `);
136
170
  } else {
@@ -170,4 +204,4 @@ export {
170
204
  logger_exports,
171
205
  init_logger
172
206
  };
173
- //# sourceMappingURL=chunk-AGIZJ4UZ.mjs.map
207
+ //# sourceMappingURL=chunk-3NMLT3YS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/logger.ts"],"sourcesContent":["/*\n * Centralized logger for Visor CLI and Action modes.\n * - Respects output format (suppresses info in JSON/SARIF unless debug)\n * - Supports levels: silent < error < warn < info < verbose < debug\n * - Routes logs to stderr to keep stdout clean for machine-readable output\n */\nimport { context as otContext, trace } from './telemetry/lazy-otel';\n\nexport type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'verbose' | 'debug';\n\nfunction levelToNumber(level: LogLevel): number {\n switch (level) {\n case 'silent':\n return 0;\n case 'error':\n return 10;\n case 'warn':\n return 20;\n case 'info':\n return 30;\n case 'verbose':\n return 40;\n case 'debug':\n return 50;\n }\n}\n\nclass Logger {\n private level: LogLevel = 'info';\n private isJsonLike: boolean = false;\n private isTTY: boolean = typeof process !== 'undefined' ? !!process.stderr.isTTY : false;\n private showTimestamps: boolean = true; // default: always show timestamps\n private sink?: (msg: string, level: LogLevel) => void;\n private sinkPassthrough: boolean = true;\n private sinkErrorMode: 'throw' | 'warn' | 'silent' = 'throw';\n private sinkErrorHandler?: (error: unknown) => void;\n\n configure(\n opts: {\n outputFormat?: string;\n level?: LogLevel;\n debug?: boolean;\n verbose?: boolean;\n quiet?: boolean;\n } = {}\n ): void {\n // Determine base level\n let lvl: LogLevel = 'info';\n\n if (opts.debug || process.env.VISOR_DEBUG === 'true') {\n lvl = 'debug';\n } else if (opts.verbose || process.env.VISOR_LOG_LEVEL === 'verbose') {\n lvl = 'verbose';\n } else if (opts.quiet || process.env.VISOR_LOG_LEVEL === 'quiet') {\n lvl = 'warn';\n } else if (opts.level) {\n lvl = opts.level;\n } else if (process.env.VISOR_LOG_LEVEL) {\n const envLvl = process.env.VISOR_LOG_LEVEL as LogLevel;\n if (['silent', 'error', 'warn', 'info', 'verbose', 'debug'].includes(envLvl)) {\n lvl = envLvl as LogLevel;\n }\n }\n\n this.level = lvl;\n const output = opts.outputFormat || process.env.VISOR_OUTPUT_FORMAT || 'table';\n // In JSON/SARIF we suppress non-error logs unless explicitly verbose/debug\n this.isJsonLike = output === 'json' || output === 'sarif';\n }\n\n setSink(\n sink?: (msg: string, level: LogLevel) => void,\n opts: {\n passthrough?: boolean;\n errorMode?: 'throw' | 'warn' | 'silent';\n onError?: (error: unknown) => void;\n } = {}\n ): void {\n this.sink = sink;\n this.sinkPassthrough = opts.passthrough !== undefined ? opts.passthrough : true;\n this.sinkErrorMode = opts.errorMode || 'throw';\n this.sinkErrorHandler = opts.onError;\n }\n\n private shouldLog(level: LogLevel): boolean {\n const desired = levelToNumber(level);\n const current = levelToNumber(this.level);\n if (desired > current) return false;\n if (\n this.isJsonLike &&\n desired < levelToNumber('error') &&\n this.level !== 'debug' &&\n this.level !== 'verbose'\n ) {\n // In JSON/SARIF, hide info/warn unless explicitly verbose/debug\n return false;\n }\n return true;\n }\n\n private getTraceSuffix(msg: string): string {\n if (!msg) return '';\n if (msg.includes('trace_id=') || msg.includes('trace_id:')) return '';\n try {\n const span = trace.getSpan(otContext.active()) || trace.getActiveSpan();\n const ctx = span?.spanContext?.();\n if (!ctx?.traceId) return '';\n return ` [trace_id=${ctx.traceId} span_id=${ctx.spanId}]`;\n } catch {\n return '';\n }\n }\n\n private write(msg: string, level?: LogLevel): void {\n // Always route to stderr to keep stdout clean for results\n const suffix = this.getTraceSuffix(msg);\n const decoratedMsg = suffix ? `${msg}${suffix}` : msg;\n const lvl = level || 'info';\n\n if (this.sink) {\n try {\n this.sink(decoratedMsg, lvl);\n } catch (error) {\n if (this.sinkErrorMode === 'warn') {\n try {\n if (this.sinkErrorHandler) {\n this.sinkErrorHandler(error);\n } else {\n const errMsg = error instanceof Error ? error.message : String(error);\n process.stderr.write(`[logger] sink failed: ${errMsg}\\n`);\n }\n } catch {\n // ignore secondary failures\n }\n }\n if (this.sinkErrorMode === 'throw') {\n throw error;\n }\n return;\n }\n if (!this.sinkPassthrough) return;\n }\n\n try {\n if (this.showTimestamps) {\n const ts = new Date().toISOString();\n const lvl = level ? level : undefined;\n\n let tsToken = `[${ts}]`;\n let lvlToken = lvl ? `[${lvl}]` : '';\n\n // Add simple ANSI colour when running in a TTY and not emitting\n // JSON/SARIF. Colours are intentionally minimal and only applied\n // to the prefix markers, not the full line.\n if (this.isTTY && !this.isJsonLike) {\n const reset = '\\x1b[0m';\n const dim = '\\x1b[2m';\n const colours: Record<LogLevel, string> = {\n silent: '',\n error: '\\x1b[31m', // red\n warn: '\\x1b[33m', // yellow\n info: '\\x1b[36m', // cyan\n verbose: '\\x1b[35m', // magenta\n debug: '\\x1b[90m', // bright black / gray\n };\n\n tsToken = `${dim}${tsToken}${reset}`;\n\n if (lvl) {\n const colour = colours[lvl] || '';\n if (colour) {\n lvlToken = `${colour}${lvlToken}${reset}`;\n }\n }\n }\n\n const prefix = lvl ? `${tsToken} ${lvlToken}` : tsToken;\n process.stderr.write(`${prefix} ${decoratedMsg}\\n`);\n } else {\n process.stderr.write(decoratedMsg + '\\n');\n }\n } catch {\n // Ignore write errors\n }\n }\n\n info(msg: string): void {\n if (this.shouldLog('info')) this.write(msg, 'info');\n }\n\n warn(msg: string): void {\n if (this.shouldLog('warn')) this.write(msg, 'warn');\n }\n\n error(msg: string): void {\n if (this.shouldLog('error')) this.write(msg, 'error');\n }\n\n verbose(msg: string): void {\n if (this.shouldLog('verbose')) this.write(msg, 'verbose');\n }\n\n debug(msg: string): void {\n if (this.shouldLog('debug')) this.write(msg, 'debug');\n }\n\n step(msg: string): void {\n // High-level phase indicator\n if (this.shouldLog('info')) this.write(`▶ ${msg}`, 'info');\n }\n\n success(msg: string): void {\n if (this.shouldLog('info')) this.write(`✔ ${msg}`, 'info');\n }\n}\n\n// Singleton instance\nexport const logger = new Logger();\n\n// Helper to configure from CLI options in a single place\nexport function configureLoggerFromCli(options: {\n output?: string;\n debug?: boolean;\n verbose?: boolean;\n quiet?: boolean;\n}): void {\n logger.configure({\n outputFormat: options.output,\n debug: options.debug,\n verbose: options.verbose,\n quiet: options.quiet,\n });\n\n // Expose output format and debug to process env for modules that need to gate\n // stdout emissions without plumbing the value through every call site.\n try {\n if (options.output) process.env.VISOR_OUTPUT_FORMAT = String(options.output);\n if (typeof options.debug === 'boolean') {\n process.env.VISOR_DEBUG = options.debug ? 'true' : 'false';\n }\n } catch {\n // ignore\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,SAAS,cAAc,OAAyB;AAC9C,UAAQ,OAAO;AAAA,IACb,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAmMO,SAAS,uBAAuB,SAK9B;AACP,SAAO,UAAU;AAAA,IACf,cAAc,QAAQ;AAAA,IACtB,OAAO,QAAQ;AAAA,IACf,SAAS,QAAQ;AAAA,IACjB,OAAO,QAAQ;AAAA,EACjB,CAAC;AAID,MAAI;AACF,QAAI,QAAQ,OAAQ,SAAQ,IAAI,sBAAsB,OAAO,QAAQ,MAAM;AAC3E,QAAI,OAAO,QAAQ,UAAU,WAAW;AACtC,cAAQ,IAAI,cAAc,QAAQ,QAAQ,SAAS;AAAA,IACrD;AAAA,EACF,QAAQ;AAA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AAK,MAAM,KAAK,OAAO;AAAA,MACtD;AAAA,MAEA,KAAK,KAAmB;AAEtB,YAAI,KAAK,UAAU,MAAM,EAAG,MAAK,MAAM,UAAK,GAAG,IAAI,MAAM;AAAA,MAC3D;AAAA,MAEA,QAAQ,KAAmB;AACzB,YAAI,KAAK,UAAU,MAAM,EAAG,MAAK,MAAM,UAAK,GAAG,IAAI,MAAM;AAAA,MAC3D;AAAA,IACF;AAGO,IAAM,SAAS,IAAI,OAAO;AAAA;AAAA;","names":["lvl"]}
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  MemoryStore,
13
13
  init_memory_store
14
- } from "./chunk-7UK3NIIT.mjs";
14
+ } from "./chunk-IHZOSIF4.mjs";
15
15
  import {
16
16
  __esm
17
17
  } from "./chunk-WMJKH4XE.mjs";
@@ -423,4 +423,4 @@ export {
423
423
  createExtendedLiquid,
424
424
  init_liquid_extensions
425
425
  };
426
- //# sourceMappingURL=chunk-AK6BVWIT.mjs.map
426
+ //# sourceMappingURL=chunk-7GUAFV6L.mjs.map