@exaudeus/workrail 3.10.0 → 3.11.1

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 (64) hide show
  1. package/dist/application/services/validation-engine.js +134 -0
  2. package/dist/application/services/workflow-compiler.js +54 -0
  3. package/dist/manifest.json +138 -74
  4. package/dist/mcp/handlers/v2-advance-core/assessment-consequences.d.ts +14 -0
  5. package/dist/mcp/handlers/v2-advance-core/assessment-consequences.js +27 -0
  6. package/dist/mcp/handlers/v2-advance-core/assessment-validation.d.ts +16 -0
  7. package/dist/mcp/handlers/v2-advance-core/assessment-validation.js +213 -0
  8. package/dist/mcp/handlers/v2-advance-core/event-builders.d.ts +1 -0
  9. package/dist/mcp/handlers/v2-advance-core/event-builders.js +3 -2
  10. package/dist/mcp/handlers/v2-advance-core/index.js +23 -8
  11. package/dist/mcp/handlers/v2-advance-core/input-validation.d.ts +9 -1
  12. package/dist/mcp/handlers/v2-advance-core/input-validation.js +22 -2
  13. package/dist/mcp/handlers/v2-advance-core/outcome-blocked.d.ts +2 -0
  14. package/dist/mcp/handlers/v2-advance-core/outcome-blocked.js +69 -19
  15. package/dist/mcp/handlers/v2-advance-core/outcome-success.js +22 -0
  16. package/dist/mcp/handlers/v2-execution/replay.js +7 -0
  17. package/dist/mcp/output-schemas.d.ts +156 -42
  18. package/dist/mcp/output-schemas.js +15 -0
  19. package/dist/mcp/v2-response-formatter.js +7 -1
  20. package/dist/types/workflow-definition.d.ts +26 -0
  21. package/dist/types/workflow-definition.js +16 -1
  22. package/dist/v2/durable-core/constants.d.ts +2 -0
  23. package/dist/v2/durable-core/constants.js +2 -0
  24. package/dist/v2/durable-core/domain/assessment-consequence-event-builder.d.ts +23 -0
  25. package/dist/v2/durable-core/domain/assessment-consequence-event-builder.js +36 -0
  26. package/dist/v2/durable-core/domain/assessment-record.d.ts +12 -0
  27. package/dist/v2/durable-core/domain/assessment-record.js +2 -0
  28. package/dist/v2/durable-core/domain/assessment-recorded-event-builder.d.ts +22 -0
  29. package/dist/v2/durable-core/domain/assessment-recorded-event-builder.js +38 -0
  30. package/dist/v2/durable-core/domain/blocked-node-builder.d.ts +1 -1
  31. package/dist/v2/durable-core/domain/blocked-node-builder.js +8 -0
  32. package/dist/v2/durable-core/domain/blocking-decision.d.ts +6 -0
  33. package/dist/v2/durable-core/domain/blocking-decision.js +15 -0
  34. package/dist/v2/durable-core/domain/prompt-renderer.js +25 -1
  35. package/dist/v2/durable-core/domain/reason-model.d.ts +12 -2
  36. package/dist/v2/durable-core/domain/reason-model.js +27 -2
  37. package/dist/v2/durable-core/domain/risk-policy-guardrails.js +1 -0
  38. package/dist/v2/durable-core/domain/validation-criteria-validator.d.ts +1 -0
  39. package/dist/v2/durable-core/domain/validation-criteria-validator.js +11 -0
  40. package/dist/v2/durable-core/schemas/artifacts/assessment.d.ts +55 -0
  41. package/dist/v2/durable-core/schemas/artifacts/assessment.js +29 -0
  42. package/dist/v2/durable-core/schemas/artifacts/index.d.ts +2 -1
  43. package/dist/v2/durable-core/schemas/artifacts/index.js +8 -1
  44. package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +24 -24
  45. package/dist/v2/durable-core/schemas/execution-snapshot/blocked-snapshot.d.ts +141 -21
  46. package/dist/v2/durable-core/schemas/execution-snapshot/blocked-snapshot.js +10 -1
  47. package/dist/v2/durable-core/schemas/execution-snapshot/execution-snapshot.v1.d.ts +729 -171
  48. package/dist/v2/durable-core/schemas/export-bundle/index.d.ts +1442 -202
  49. package/dist/v2/durable-core/schemas/session/events.d.ts +231 -8
  50. package/dist/v2/durable-core/schemas/session/events.js +36 -0
  51. package/dist/v2/durable-core/schemas/session/gaps.d.ts +2 -2
  52. package/dist/v2/projections/assessment-consequences.d.ts +19 -0
  53. package/dist/v2/projections/assessment-consequences.js +33 -0
  54. package/dist/v2/projections/assessments.d.ts +21 -0
  55. package/dist/v2/projections/assessments.js +35 -0
  56. package/package.json +1 -1
  57. package/spec/authoring-spec.json +38 -4
  58. package/spec/production-readiness-audit-rubric.md +43 -0
  59. package/spec/workflow.schema.json +110 -0
  60. package/workflows/bug-investigation.agentic.v2.json +28 -2
  61. package/workflows/production-readiness-audit.json +354 -0
  62. package/workflows/test-artifact-loop-control.json +28 -2
  63. package/workflows/workflow-for-workflows.v2.json +395 -58
  64. package/workflows/wr.discovery.json +33 -69
@@ -135,6 +135,14 @@
135
135
  },
136
136
  "uniqueItems": true
137
137
  },
138
+ "assessments": {
139
+ "type": "array",
140
+ "description": "Workflow-declared assessment definitions. Steps reference these by ID via assessmentRefs instead of embedding assessment structure inline repeatedly.",
141
+ "items": {
142
+ "$ref": "#/$defs/assessmentDefinition"
143
+ },
144
+ "uniqueItems": true
145
+ },
138
146
  "extensionPoints": {
139
147
  "type": "array",
140
148
  "description": "Bounded cognitive slots that users can customize via .workrail/bindings.json. Each slot is referenced in step prompts via {{wr.bindings.slotId}} and resolved at compile time. Use extension points for bounded cognitive units, not for core orchestration or final synthesis ownership.",
@@ -293,6 +301,21 @@
293
301
  "runCondition": { "$ref": "#/$defs/condition" },
294
302
  "validationCriteria": { "oneOf": [ { "type": "array", "items": { "$ref": "#/$defs/validationRule" } }, { "$ref": "#/$defs/validationComposition" } ] },
295
303
  "outputContract": { "$ref": "#/$defs/outputContract" },
304
+ "assessmentRefs": {
305
+ "type": "array",
306
+ "description": "References to workflow-level assessment definitions expected for this step. V1 supports exactly one assessmentRef per step.",
307
+ "items": { "type": "string", "minLength": 1, "maxLength": 64 },
308
+ "minItems": 1,
309
+ "maxItems": 1,
310
+ "uniqueItems": true
311
+ },
312
+ "assessmentConsequences": {
313
+ "type": "array",
314
+ "description": "Step-local assessment consequence declarations. V1 supports at most one exact-match follow-up consequence.",
315
+ "items": { "$ref": "#/$defs/assessmentConsequence" },
316
+ "minItems": 1,
317
+ "maxItems": 1
318
+ },
296
319
  "notesOptional": { "type": "boolean", "description": "When true, output.notesMarkdown is not required for this step. Steps with outputContract are automatically exempt. Use sparingly for mechanical steps with no substantive work to document." },
297
320
  "functionDefinitions": { "type": "array", "items": { "$ref": "#/$defs/functionDefinition" } },
298
321
  "functionCalls": { "type": "array", "items": { "$ref": "#/$defs/functionCall" } },
@@ -727,6 +750,93 @@
727
750
  "required": ["contractRef"],
728
751
  "additionalProperties": false
729
752
  },
753
+ "assessmentDimension": {
754
+ "type": "object",
755
+ "description": "A bounded dimension within a workflow-declared assessment definition.",
756
+ "properties": {
757
+ "id": {
758
+ "type": "string",
759
+ "minLength": 1,
760
+ "maxLength": 64
761
+ },
762
+ "purpose": {
763
+ "type": "string",
764
+ "minLength": 1,
765
+ "maxLength": 256
766
+ },
767
+ "levels": {
768
+ "type": "array",
769
+ "items": {
770
+ "type": "string",
771
+ "minLength": 1,
772
+ "maxLength": 64
773
+ },
774
+ "minItems": 2,
775
+ "uniqueItems": true
776
+ },
777
+ "required": {
778
+ "type": "boolean",
779
+ "default": true
780
+ }
781
+ },
782
+ "required": ["id", "purpose", "levels"],
783
+ "additionalProperties": false
784
+ },
785
+ "assessmentDefinition": {
786
+ "type": "object",
787
+ "description": "Workflow-declared assessment definition referenced by steps.",
788
+ "properties": {
789
+ "id": {
790
+ "type": "string",
791
+ "minLength": 1,
792
+ "maxLength": 64
793
+ },
794
+ "purpose": {
795
+ "type": "string",
796
+ "minLength": 1,
797
+ "maxLength": 256
798
+ },
799
+ "dimensions": {
800
+ "type": "array",
801
+ "items": {
802
+ "$ref": "#/$defs/assessmentDimension"
803
+ },
804
+ "minItems": 1
805
+ }
806
+ },
807
+ "required": ["id", "purpose", "dimensions"],
808
+ "additionalProperties": false
809
+ },
810
+ "assessmentConsequenceTrigger": {
811
+ "type": "object",
812
+ "description": "Exact-match trigger on one declared assessment dimension and one declared canonical level.",
813
+ "properties": {
814
+ "dimensionId": { "type": "string", "minLength": 1, "maxLength": 64 },
815
+ "equalsLevel": { "type": "string", "minLength": 1, "maxLength": 64 }
816
+ },
817
+ "required": ["dimensionId", "equalsLevel"],
818
+ "additionalProperties": false
819
+ },
820
+ "assessmentConsequenceEffect": {
821
+ "type": "object",
822
+ "description": "V1 assessment consequence effect. Keeps the same step pending and requires follow-up before retry.",
823
+ "properties": {
824
+ "kind": { "const": "require_followup" },
825
+ "guidance": { "type": "string", "minLength": 1, "maxLength": 512 }
826
+ },
827
+ "required": ["kind", "guidance"],
828
+ "additionalProperties": false
829
+ },
830
+ "assessmentConsequence": {
831
+ "type": "object",
832
+ "description": "Step-local assessment consequence declaration. V1 supports one exact-match follow-up consequence only.",
833
+ "properties": {
834
+ "when": { "$ref": "#/$defs/assessmentConsequenceTrigger" },
835
+ "effect": { "$ref": "#/$defs/assessmentConsequenceEffect" }
836
+ },
837
+ "required": ["when", "effect"],
838
+ "additionalProperties": false
839
+ },
730
840
  "functionCall": {
731
841
  "type": "object",
732
842
  "properties": {
@@ -31,6 +31,19 @@
31
31
  "TRIGGERS: WorkRail can only react to explicit outputs. Use structural fields like `contextUnknownCount`, `hypothesesConsideredCount`, `hasStrongAlternative`, `contradictionCount`, `unresolvedEvidenceGapCount`, and `diagnosisConfidenceBand`.",
32
32
  "BOUNDARY: this workflow investigates and proves root cause. It may describe high-level fix direction and likely files, but must not create implementation plans, patch sequencing, PR plans, or code-writing momentum."
33
33
  ],
34
+ "assessments": [
35
+ {
36
+ "id": "diagnosis_readiness_gate",
37
+ "purpose": "Assess whether the diagnosis is ready to hand off after validation.",
38
+ "dimensions": [
39
+ {
40
+ "id": "confidence",
41
+ "purpose": "How confident the agent is that the diagnosis is ready for final handoff.",
42
+ "levels": ["low", "high"]
43
+ }
44
+ ]
45
+ }
46
+ ],
34
47
  "steps": [
35
48
  {
36
49
  "id": "phase-0-triage-and-intake",
@@ -116,7 +129,20 @@
116
129
  {
117
130
  "id": "phase-5-diagnosis-validation",
118
131
  "title": "Phase 5: Diagnosis Validation Bundle",
119
- "prompt": "Stress-test the current diagnosis before handoff.\n\nSet `diagnosisConfidenceBand` using these rules:\n- High = all symptoms explained, no material contradictions, no unresolved evidence gaps\n- Medium = likely diagnosis, but one bounded uncertainty remains\n- Low = multiple viable explanations remain or contradictions are unresolved\n\nMode-adaptive validation:\n- QUICK: self-challenge; if `diagnosisConfidenceBand != High` or contradictions remain, optionally spawn ONE WorkRail Executor running `routine-hypothesis-challenge`\n- STANDARD: if delegation is available, spawn TWO WorkRail Executors SIMULTANEOUSLY running `routine-hypothesis-challenge` and `routine-execution-simulation`\n- THOROUGH: if delegation is available, spawn THREE WorkRail Executors SIMULTANEOUSLY running `routine-hypothesis-challenge`, `routine-execution-simulation`, and an additional `routine-hypothesis-challenge` pass focused on breaking the current diagnosis from a different angle\n\nParallel-output synthesis rules:\n- if 2+ validators raise serious concerns, reopen evidence or shortlist work\n- if exactly one validator raises a concern, investigate it before escalating\n- if no validator can materially break the diagnosis and `contradictionCount = 0`, proceed to handoff\n\nSet context variables:\n- `diagnosisConfidenceBand`\n- `validationFindingsCountBySeverity`\n- `validationSummary`\n\nBoundary rule:\n- allowed: high-level fix direction, likely files involved, verification recommendations\n- not allowed: implementation plan, patch sequencing, PR plan, or code-writing momentum",
132
+ "prompt": "Stress-test the current diagnosis before handoff.\n\nSet `diagnosisConfidenceBand` using these rules:\n- High = all symptoms explained, no material contradictions, no unresolved evidence gaps\n- Medium = likely diagnosis, but one bounded uncertainty remains\n- Low = multiple viable explanations remain or contradictions are unresolved\n\nMode-adaptive validation:\n- QUICK: self-challenge; if `diagnosisConfidenceBand != High` or contradictions remain, optionally spawn ONE WorkRail Executor running `routine-hypothesis-challenge`\n- STANDARD: if delegation is available, spawn TWO WorkRail Executors SIMULTANEOUSLY running `routine-hypothesis-challenge` and `routine-execution-simulation`\n- THOROUGH: if delegation is available, spawn THREE WorkRail Executors SIMULTANEOUSLY running `routine-hypothesis-challenge`, `routine-execution-simulation`, and an additional `routine-hypothesis-challenge` pass focused on breaking the current diagnosis from a different angle\n\nParallel-output synthesis rules:\n- if 2+ validators raise serious concerns, reopen evidence or shortlist work\n- if exactly one validator raises a concern, investigate it before escalating\n- if no validator can materially break the diagnosis and `contradictionCount = 0`, proceed to handoff\n\nAfter synthesizing the validation result, assess whether the diagnosis is ready for final handoff.\n\nSet context variables:\n- `diagnosisConfidenceBand`\n- `validationFindingsCountBySeverity`\n- `validationSummary`\n\nBoundary rule:\n- allowed: high-level fix direction, likely files involved, verification recommendations\n- not allowed: implementation plan, patch sequencing, PR plan, or code-writing momentum",
133
+ "assessmentRefs": ["diagnosis_readiness_gate"],
134
+ "assessmentConsequences": [
135
+ {
136
+ "when": {
137
+ "dimensionId": "confidence",
138
+ "equalsLevel": "low"
139
+ },
140
+ "effect": {
141
+ "kind": "require_followup",
142
+ "guidance": "Resolve the remaining diagnosis uncertainty, tighten the evidence summary, and retry this validation step before handing off."
143
+ }
144
+ }
145
+ ],
120
146
  "requireConfirmation": {
121
147
  "or": [
122
148
  { "var": "diagnosisConfidenceBand", "equals": "Low" },
@@ -131,4 +157,4 @@
131
157
  "requireConfirmation": true
132
158
  }
133
159
  ]
134
- }
160
+ }
@@ -0,0 +1,354 @@
1
+ {
2
+ "id": "production-readiness-audit",
3
+ "name": "Production Readiness Audit (v2 • Evidence-Driven Readiness Review)",
4
+ "version": "0.1.0",
5
+ "description": "Audit a bounded codebase scope for debugging risk, runtime readiness, stale or misleading implementation surfaces, technical debt, and anything else that would keep it from being honestly production-ready.",
6
+ "recommendedPreferences": {
7
+ "recommendedAutonomy": "guided",
8
+ "recommendedRiskPolicy": "conservative"
9
+ },
10
+ "features": [
11
+ "wr.features.subagent_guidance"
12
+ ],
13
+ "references": [
14
+ {
15
+ "id": "audit-rubric",
16
+ "title": "Production Readiness Audit Rubric",
17
+ "source": "./spec/production-readiness-audit-rubric.md",
18
+ "purpose": "Canonical coverage, evidence, confidence, and verdict rubric for this workflow.",
19
+ "authoritative": true,
20
+ "resolveFrom": "package"
21
+ }
22
+ ],
23
+ "preconditions": [
24
+ "The user provides a target scope or the agent can infer a bounded scope from the request.",
25
+ "The agent can inspect the code, surrounding context, and deterministic evidence needed to assess readiness honestly.",
26
+ "A human will consume the final verdict, findings, or remediation order."
27
+ ],
28
+ "metaGuidance": [
29
+ "DEFAULT BEHAVIOR: self-execute with tools. Ask only for true scope decisions, missing external artifacts, or permissions you cannot resolve yourself.",
30
+ "V2 DURABILITY: keep workflow truth in output.notesMarkdown and explicit context fields. Human-facing markdown artifacts are optional companions only.",
31
+ "OWNERSHIP: the main agent owns the fact packet, synthesis, severity calibration, verdict, and remediation order. Delegated work is evidence, not authority.",
32
+ "SUBAGENT DISCIPLINE: use a few explicit fan-out and fan-in checkpoints rather than scattered optional subagent calls.",
33
+ "READINESS MODEL: first understand and bound the scope, then state a readiness hypothesis, then freeze a neutral readiness fact packet, then let reviewer families challenge it in parallel, then reconcile contradictions explicitly.",
34
+ "COVERAGE LEDGER: track audit domains as `checked`, `uncertain`, `not_applicable`, `contradicted`, or `needs_followup`. Do not finalize with unresolved material gaps unless you name them clearly.",
35
+ "VERDICTS: allow `ready`, `ready_with_conditions`, `not_ready`, and `inconclusive`. Do not force a cleaner answer than the evidence supports.",
36
+ "BOUNDARY: this workflow audits and prioritizes. It must not drift into implementation planning or patch sequencing unless the user explicitly asks."
37
+ ],
38
+ "steps": [
39
+ {
40
+ "id": "phase-0-understand-and-classify",
41
+ "title": "Phase 0: Understand and Classify",
42
+ "promptBlocks": {
43
+ "goal": "Build the minimum complete understanding needed to audit readiness honestly.",
44
+ "constraints": [
45
+ [
46
+ { "kind": "ref", "refId": "wr.refs.notes_first_durability" }
47
+ ],
48
+ "Use tools first. Ask only for true scope or permission gaps you cannot resolve yourself.",
49
+ "Separate in-scope code from adjacent noise before you classify rigor or risk."
50
+ ],
51
+ "procedure": [
52
+ "Locate the real target surface, likely entry points, critical paths, public contracts, invariants, data or runtime surfaces, and affected consumers that matter.",
53
+ "Find the repo patterns and philosophy sources that should shape the audit, and state what production-ready should mean for this scope instead of assuming a generic bar.",
54
+ "Classify `scopeShape`, `riskLevel`, `rigorMode`, `criticalSurfaceTouched`, and `needsSimulation` after exploration, not before.",
55
+ "Run a context-clarity check with concrete scores for boundary clarity, production-bar clarity, philosophy clarity, and verification clarity.",
56
+ "If rigor and uncertainty justify it, spawn TWO WorkRail Executors in parallel running `routine-context-gathering` with complementary completeness/depth focus, then synthesize what changed."
57
+ ],
58
+ "outputRequired": {
59
+ "notesMarkdown": "Audit scope, production bar, classification, clarity scores, and what is still unknown.",
60
+ "context": "Capture scopeShape, riskLevel, rigorMode, contextSummary, candidateFiles, criticalPaths, productionBar, contextUnknownCount, criticalSurfaceTouched, needsSimulation, and openQuestions."
61
+ },
62
+ "verify": [
63
+ "The classification is driven by evidence, not vibes.",
64
+ "Open questions are real human-decision gaps only.",
65
+ "If scope is whole-codebase or risk is High, treat confirmation as a real review barrier."
66
+ ]
67
+ },
68
+ "requireConfirmation": {
69
+ "or": [
70
+ { "var": "scopeShape", "equals": "whole_codebase" },
71
+ { "var": "riskLevel", "equals": "High" }
72
+ ]
73
+ }
74
+ },
75
+ {
76
+ "id": "phase-1-state-readiness-hypothesis",
77
+ "title": "Phase 1: State Readiness Hypothesis",
78
+ "promptBlocks": {
79
+ "goal": "State your current readiness hypothesis before the reviewer families challenge it.",
80
+ "constraints": [
81
+ "Keep this short and falsifiable.",
82
+ "This is a reference point, not a position to defend."
83
+ ],
84
+ "procedure": [
85
+ "Write your current best guess about the likely readiness verdict direction.",
86
+ "Name the issue category or failure mode you are most worried about right now.",
87
+ "Say what would most likely make your current view wrong."
88
+ ],
89
+ "outputRequired": {
90
+ "notesMarkdown": "Current readiness hypothesis and the strongest reason it might be wrong.",
91
+ "context": "Capture readinessHypothesis."
92
+ },
93
+ "verify": [
94
+ "The hypothesis is concrete enough that later synthesis can say what changed your mind."
95
+ ]
96
+ },
97
+ "requireConfirmation": false
98
+ },
99
+ {
100
+ "id": "phase-2-freeze-fact-packet-and-select-reviewers",
101
+ "title": "Phase 2: Freeze Fact Packet and Select Reviewer Families",
102
+ "promptBlocks": {
103
+ "goal": "Freeze a neutral readiness fact packet and decide how much reviewer-family parallelism is warranted.",
104
+ "constraints": [
105
+ [
106
+ { "kind": "ref", "refId": "wr.refs.notes_first_durability" }
107
+ ],
108
+ "The fact packet is the primary truth for downstream reviewer families.",
109
+ "Keep `readinessHypothesis` as a hypothesis to challenge, not a frame to defend.",
110
+ "Keep any live audit artifact optional. Workflow truth lives in notes and context."
111
+ ],
112
+ "procedure": [
113
+ "Create a neutral `readinessFactPacket` containing: scope purpose and expected behavior, key entry points and runtime surfaces, critical invariants and failure costs, data and deployment assumptions, changed or risky seams, test/observability posture, repo patterns and philosophy constraints, and explicit open unknowns.",
114
+ "Include realism signals directly in the fact packet: likely dead code paths, fixture or fake-data dependence, placeholder behavior, stale comments or docs, and any seams that look misleadingly complete.",
115
+ "Initialize `coverageLedger` for these domains: `debugging_correctness`, `runtime_operability`, `artifact_realism`, `maintainability_debt`, `tests_observability`, `philosophy_patterns`, `security_performance`.",
116
+ "Perform a preliminary self-audit from the fact packet before choosing reviewer families.",
117
+ "Reviewer family options: `correctness_debugging`, `runtime_operability`, `artifact_realism`, `maintainability_debt`, `tests_observability`, `philosophy_patterns`, `security_performance`, `false_positive_skeptic`, `missed_issue_hunter`.",
118
+ "Selection guidance: QUICK = no bundle by default unless ambiguity still feels material; STANDARD = 4 or 5 families by default; THOROUGH = 6 or 7 families by default.",
119
+ "Always include `correctness_debugging`, `runtime_operability`, and `artifact_realism` unless clearly not applicable. Include `security_performance` when the scope touches auth, permissions, input trust boundaries, secrets, network surfaces, data exposure, resource intensity, latency-sensitive flows, or unbounded work. Include `tests_observability` in STANDARD and THOROUGH unless clearly not applicable. Include `philosophy_patterns` when the repo or user philosophy is strong enough to judge honestly. Include `missed_issue_hunter` in THOROUGH. Include `false_positive_skeptic` when blocker or major-grade findings already look plausible or severity inflation risk is non-trivial.",
120
+ "Set `needsReviewerBundle` explicitly. Set `coverageUncertainCount` as the number of coverage domains not yet safely closed: `uncertain` + `contradicted` + `needs_followup`. Initialize `contradictionCount`, `blindSpotCount`, and `falsePositiveRiskCount` to `0` if no reviewer-family bundle will run."
121
+ ],
122
+ "outputRequired": {
123
+ "notesMarkdown": "Neutral readiness fact packet, preliminary self-audit, selected reviewer families, and why the bundle is sized the way it is.",
124
+ "context": "Capture readinessFactPacket, coverageLedger, selectedReviewerFamilies, needsReviewerBundle, coverageUncertainCount, contradictionCount, blindSpotCount, falsePositiveRiskCount, needsSimulation."
125
+ },
126
+ "verify": [
127
+ "The fact packet is concrete enough that downstream reviewer families can use it without regathering broad context.",
128
+ "The workflow has a clear reason for whether `needsReviewerBundle` is true or false."
129
+ ]
130
+ },
131
+ "promptFragments": [
132
+ {
133
+ "id": "phase-2-quick",
134
+ "when": { "var": "rigorMode", "equals": "QUICK" },
135
+ "text": "Keep the fact packet compact. QUICK should not manufacture a giant ceremony layer."
136
+ },
137
+ {
138
+ "id": "phase-2-thorough",
139
+ "when": { "var": "rigorMode", "equals": "THOROUGH" },
140
+ "text": "For THOROUGH rigor, make the hidden-risk surfaces explicit: blind spots, fake confidence vectors, and production assumptions that would hurt if wrong."
141
+ }
142
+ ],
143
+ "requireConfirmation": false
144
+ },
145
+ {
146
+ "id": "phase-3-reviewer-family-bundle",
147
+ "title": "Phase 3: Parallel Reviewer Family Bundle",
148
+ "runCondition": {
149
+ "var": "needsReviewerBundle",
150
+ "equals": true
151
+ },
152
+ "promptBlocks": {
153
+ "goal": "Run the selected reviewer families in parallel from the same readiness fact packet, then synthesize their output as evidence rather than conclusions.",
154
+ "constraints": [
155
+ [
156
+ { "kind": "ref", "refId": "wr.refs.notes_first_durability" }
157
+ ],
158
+ [
159
+ { "kind": "ref", "refId": "wr.refs.synthesis_under_disagreement" }
160
+ ],
161
+ "Each reviewer family must use `readinessFactPacket` as primary truth.",
162
+ "Use `readinessHypothesis` only as comparison context.",
163
+ "Reviewer-family outputs are raw evidence, not canonical audit state."
164
+ ],
165
+ "procedure": [
166
+ "Before delegating, restate the current `readinessHypothesis` and say which reviewer family is most likely to challenge it.",
167
+ "Each reviewer family must return: top findings, strongest evidence, biggest uncertainty, likely false-confidence vector, and what would most likely falsify its current conclusion.",
168
+ "Family missions: `correctness_debugging` = logic defects, contradictory state, failure paths, unsafe assumptions, and strongest debugging leads; `runtime_operability` = production behavior, concurrency/state flow, deployment assumptions, resilience, rollback pain, and observability under failure; `artifact_realism` = stale code, dead seams, placeholder behavior, misleading comments/docs, fake-data dependence, and surfaces that look complete but are not; `maintainability_debt` = complexity, duplication, brittle seams, drift, and future-change cost; `tests_observability` = test adequacy, verification blind spots, logging/monitoring gaps, hidden failure modes, and rollout confidence; `philosophy_patterns` = architectural consistency, repo-pattern drift, and principle tension; `security_performance` = trust boundaries, auth/permission mistakes, secrets handling, unsafe inputs, data exposure, expensive paths, unbounded work, and performance cliffs likely to matter in production; `false_positive_skeptic` = challenge overreach, weak evidence, or severity inflation; `missed_issue_hunter` = search for an important issue family the others may miss.",
169
+ "Mode-adaptive parallelism: STANDARD = spawn FOUR WorkRail Executors simultaneously for the selected families; THOROUGH = spawn SIX WorkRail Executors simultaneously for the selected families.",
170
+ "After receiving outputs, explicitly synthesize: what reviewer families confirmed, what was genuinely new, what appeared weak or overreached, and what changed your mind or did not.",
171
+ "Build a compact `familyEvidenceLedger` for each selected family covering its strongest concern, strongest evidence, biggest uncertainty, and what could make it wrong."
172
+ ],
173
+ "outputRequired": {
174
+ "notesMarkdown": "Reviewer-family synthesis, contradictions, blind spots, false-positive challenges, and the family evidence ledger.",
175
+ "context": "Capture familyEvidenceLedger, familyFindingsSummary, contradictionCount, blindSpotCount, falsePositiveRiskCount, coverageUncertainCount, and needsSimulation."
176
+ },
177
+ "verify": [
178
+ "The same fact packet was used as primary truth across reviewer families.",
179
+ "Reviewer-family output is not treated as self-finalizing.",
180
+ "Contradictions, blind spots, and false-positive risks are reflected structurally in context."
181
+ ]
182
+ },
183
+ "requireConfirmation": false
184
+ },
185
+ {
186
+ "id": "phase-4-evidence-and-contradiction-loop",
187
+ "type": "loop",
188
+ "title": "Phase 4: Evidence and Contradiction Loop",
189
+ "loop": {
190
+ "type": "while",
191
+ "conditionSource": {
192
+ "kind": "artifact_contract",
193
+ "contractRef": "wr.contracts.loop_control",
194
+ "loopId": "readiness_synthesis_loop"
195
+ },
196
+ "maxIterations": 4
197
+ },
198
+ "body": [
199
+ {
200
+ "id": "phase-4a-targeted-follow-up",
201
+ "title": "Targeted Follow-Up Bundle",
202
+ "promptBlocks": {
203
+ "goal": "If contradictions, blind spots, or important coverage gaps remain, run only the smallest targeted follow-up needed.",
204
+ "constraints": [
205
+ [
206
+ { "kind": "ref", "refId": "wr.refs.parallelize_cognition_serialize_synthesis" }
207
+ ],
208
+ "Prefer one compact targeted bundle over repeated broad delegation moments.",
209
+ "Do not regather broad context unless a contradiction proves the original fact packet is insufficient.",
210
+ "Targeted follow-up output is evidence only and must still be synthesized by the main agent."
211
+ ],
212
+ "procedure": [
213
+ "Before delegating, state the current likely readiness verdict, the strongest unresolved concern, and what result would change your mind.",
214
+ "If `contradictionCount > 0`, run targeted challenge or validation aimed at the specific disagreement.",
215
+ "If `coverageUncertainCount > 0` or `blindSpotCount > 0`, run the smallest reviewer-family or context follow-up needed to close the gap.",
216
+ "If `needsSimulation = true`, include `routine-execution-simulation`.",
217
+ "If `falsePositiveRiskCount > 0`, include `routine-hypothesis-challenge`.",
218
+ "If philosophy tension is materially affecting severity or verdict quality, include `routine-philosophy-alignment`.",
219
+ "If no trigger fires, do not delegate this step."
220
+ ],
221
+ "outputRequired": {
222
+ "notesMarkdown": "What targeted follow-up ran, why it was needed, and what it resolved or failed to resolve."
223
+ },
224
+ "verify": [
225
+ "Only the smallest targeted bundle needed was run.",
226
+ "No broad context regather happened without an explicit contradiction-driven reason."
227
+ ]
228
+ },
229
+ "requireConfirmation": false
230
+ },
231
+ {
232
+ "id": "phase-4b-canonical-synthesis",
233
+ "title": "Canonical Synthesis and Coverage Update",
234
+ "promptBlocks": {
235
+ "goal": "Turn reviewer-family evidence and follow-up work into one canonical readiness state.",
236
+ "constraints": [
237
+ "If a blocker-grade or major-grade finding is still only plausible, say so plainly instead of silently upgrading it.",
238
+ "If a domain remains uncertain, carry that uncertainty into the final verdict."
239
+ ],
240
+ "procedure": [
241
+ "Revisit `readinessHypothesis`: say what the evidence confirmed, what it challenged, what changed your mind, what held firm, and what you explicitly reject.",
242
+ "Apply this decision table: if multiple reviewer families independently surface the same serious issue with compatible evidence, treat it as strongly supported; if severities disagree, default upward only when the lower-severity position lacks concrete counter-evidence; if one family says false positive and another says valid issue, explicitly adjudicate the disagreement in notes before finalization; if simulation reveals a new operational risk, add a new finding and re-evaluate verdict confidence.",
243
+ "Update the findings ledger and classify each material finding as Confirmed, Plausible, or Rejected.",
244
+ "Update the coverage ledger honestly: move a domain to `checked` only when evidence is materially adequate; keep it `uncertain` if disagreement or missing evidence still affects verdict quality; use `not_applicable` only when the scope truly does not engage that area; clear `contradicted` only when the contradiction is explicitly resolved.",
245
+ "Cap `finalConfidenceBand` downward when unresolved blind spots still cover materially risky space, and prefer `inconclusive` later if those blind spots remain decision-relevant without a cheap next check."
246
+ ],
247
+ "outputRequired": {
248
+ "notesMarkdown": "Canonical findings ledger update, readiness-hypothesis comparison, coverage update, and confidence update.",
249
+ "context": "Capture findingsLedger, confirmedFindingsCount, plausibleFindingsCount, rejectedFindingsCount, blockerCount, majorGapCount, coverageLedger, coverageUncertainCount, contradictionCount, blindSpotCount, falsePositiveRiskCount, finalConfidenceBand, needsEvidenceRefinement."
250
+ },
251
+ "verify": [
252
+ "Decision-driving findings are explicitly classified.",
253
+ "Coverage status matches the actual evidence quality."
254
+ ]
255
+ },
256
+ "requireConfirmation": false
257
+ },
258
+ {
259
+ "id": "phase-4c-loop-decision",
260
+ "title": "Synthesis Loop Decision",
261
+ "promptBlocks": {
262
+ "goal": "Decide whether the evidence-and-contradiction loop should continue.",
263
+ "constraints": [
264
+ "Use the trigger rules, not vibes."
265
+ ],
266
+ "procedure": [
267
+ "Continue if `contradictionCount > 0`.",
268
+ "Otherwise continue if `coverageUncertainCount > 0` and the uncertainty materially affects the verdict.",
269
+ "Otherwise continue if `falsePositiveRiskCount > 0` for a serious finding, or if `blindSpotCount > 0` for uncovered materially risky space.",
270
+ "Otherwise continue if `needsEvidenceRefinement = true`.",
271
+ "Otherwise stop."
272
+ ],
273
+ "outputRequired": {
274
+ "artifact": "Emit a `wr.loop_control` artifact for `readiness_synthesis_loop` with `decision` set to `continue` or `stop`."
275
+ },
276
+ "verify": [
277
+ "The output preserves the loop-control contract without forcing one decision in the example."
278
+ ]
279
+ },
280
+ "outputContract": {
281
+ "contractRef": "wr.contracts.loop_control"
282
+ },
283
+ "requireConfirmation": false
284
+ }
285
+ ]
286
+ },
287
+ {
288
+ "id": "phase-5-final-validation",
289
+ "title": "Phase 5: Final Validation",
290
+ "promptBlocks": {
291
+ "goal": "Stress-test the current readiness verdict before final handoff.",
292
+ "constraints": [
293
+ [
294
+ { "kind": "ref", "refId": "wr.refs.adversarial_challenge_rules" }
295
+ ],
296
+ [
297
+ { "kind": "ref", "refId": "wr.refs.synthesis_under_disagreement" }
298
+ ],
299
+ "Validation output is evidence to synthesize, not automatic authority."
300
+ ],
301
+ "procedure": [
302
+ "Run final validation if any of these are true: `criticalSurfaceTouched = true`, `needsSimulation = true`, `falsePositiveRiskCount > 0`, `blindSpotCount > 0`, `coverageUncertainCount > 0`, or `finalConfidenceBand != High`.",
303
+ "Before delegating, state: what is your current verdict, where are you least confident, and what finding would most likely change your mind now.",
304
+ "Set the current readiness verdict first: `ready`, `ready_with_conditions`, `not_ready`, or `inconclusive`.",
305
+ "Use `inconclusive` deliberately when material coverage uncertainty or unresolved blind spots remain and there is no bounded next check that would resolve them cheaply.",
306
+ "Mode-adaptive validation: QUICK = self-validate and optionally spawn ONE WorkRail Executor running `routine-hypothesis-challenge` if a serious uncertainty remains; STANDARD = if validation is required and delegation is available, spawn TWO WorkRail Executors simultaneously running `routine-hypothesis-challenge` and either `routine-execution-simulation` or `routine-final-verification`; THOROUGH = if validation is required and delegation is available, spawn THREE WorkRail Executors simultaneously running `routine-hypothesis-challenge`, `routine-execution-simulation` when needed, and `routine-final-verification`.",
307
+ "After receiving validator output, explicitly synthesize what was confirmed, what was new, what appears weak, and whether your verdict changed.",
308
+ "State explicitly whether the verdict is being limited by unresolved contradictions, unresolved false-positive risk, blind spots, or coverage uncertainty."
309
+ ],
310
+ "outputRequired": {
311
+ "notesMarkdown": "Validation synthesis, verdict stress test, and any conditions the verdict still depends on.",
312
+ "context": "Capture finalVerdict, finalConfidenceBand, validationSummary, followUpCount, and verdictConditions."
313
+ },
314
+ "verify": [
315
+ "If multiple validators still raise serious concerns, confidence is downgraded and synthesis is reopened.",
316
+ "If exactly one validator raises a concern, it is adjudicated before finalization.",
317
+ "If no validator can materially break the current verdict and the evidence is internally consistent, proceed to handoff."
318
+ ]
319
+ },
320
+ "requireConfirmation": {
321
+ "or": [
322
+ { "var": "finalConfidenceBand", "equals": "Low" },
323
+ { "var": "finalVerdict", "equals": "inconclusive" }
324
+ ]
325
+ }
326
+ },
327
+ {
328
+ "id": "phase-6-final-handoff",
329
+ "title": "Phase 6: Final Handoff",
330
+ "promptBlocks": {
331
+ "goal": "Deliver the final production-readiness handoff for a human decision-maker.",
332
+ "constraints": [
333
+ "This workflow informs a decision. It does not approve a release or make code changes by itself.",
334
+ "Do not drift into implementation planning, patch sequencing, or PR execution unless the user explicitly asks."
335
+ ],
336
+ "procedure": [
337
+ "Summarize the target scope, audit intent, final verdict, and confidence band.",
338
+ "List blocker-grade findings, major gaps, strongest remaining uncertainties, top confirmed findings, and plausible but unresolved findings that still matter.",
339
+ "Call out the strongest debugging leads, runtime or operational risks, artifact-realism concerns such as stale code or fake completeness, and the most important technical-debt themes.",
340
+ "Summarize the coverage ledger, especially any domains still uncertain or needing follow-up.",
341
+ "Give a remediation order and verification or monitoring follow-ups. Mention human-facing companion artifacts only if you actually created them."
342
+ ],
343
+ "outputRequired": {
344
+ "notesMarkdown": "Decision-ready final handoff covering verdict, confidence, findings, coverage gaps, and recommended remediation order."
345
+ },
346
+ "verify": [
347
+ "The handoff is verdict-first and evidence-aware.",
348
+ "Open uncertainty is disclosed rather than hidden."
349
+ ]
350
+ },
351
+ "requireConfirmation": false
352
+ }
353
+ ]
354
+ }
@@ -53,8 +53,34 @@
53
53
  {
54
54
  "id": "complete",
55
55
  "title": "Complete",
56
- "prompt": "The iteration loop has completed. Summarize what was accomplished.",
57
- "requireConfirmation": false
56
+ "prompt": "The iteration loop has completed. Assess whether the loop result is ready to publish.\n\nProvide an assessment artifact for readiness.",
57
+ "requireConfirmation": false,
58
+ "assessmentRefs": ["readiness_gate"],
59
+ "assessmentConsequences": [
60
+ {
61
+ "when": {
62
+ "dimensionId": "confidence",
63
+ "equalsLevel": "low"
64
+ },
65
+ "effect": {
66
+ "kind": "require_followup",
67
+ "guidance": "Review the loop result one more time and confirm the outcome before completing this step."
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ ],
73
+ "assessments": [
74
+ {
75
+ "id": "readiness_gate",
76
+ "purpose": "Assess whether the loop result is ready to publish.",
77
+ "dimensions": [
78
+ {
79
+ "id": "confidence",
80
+ "purpose": "How confident the agent is that the loop result is complete and correct.",
81
+ "levels": ["low", "high"]
82
+ }
83
+ ]
58
84
  }
59
85
  ]
60
86
  }