@deksden-com/dd-flow-cli 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +666 -0
  2. package/README.md +7 -2
  3. package/dist/build-info.json +5 -5
  4. package/dist/cli/help.js +88 -10
  5. package/dist/cli/run-cli.js +523 -28
  6. package/dist/domain/stage-catalog.js +22 -0
  7. package/dist/domain/validation.js +1 -1
  8. package/dist/schemas/code-review-decision.schema.json +26 -0
  9. package/dist/schemas/code-review-result.schema.json +14 -0
  10. package/dist/schemas/code-verification.schema.json +14 -0
  11. package/dist/schemas/code-work-batch.schema.json +24 -0
  12. package/dist/schemas/code-work-result.schema.json +16 -0
  13. package/dist/schemas/compatibility.schema.json +32 -0
  14. package/dist/schemas/flow-contract.schema.json +9 -5
  15. package/dist/schemas/flow-run.schema.json +16 -123
  16. package/dist/schemas/plan-aspect-map.schema.json +22 -0
  17. package/dist/schemas/plan-review-decision.schema.json +14 -0
  18. package/dist/schemas/plan-review-result.schema.json +42 -0
  19. package/dist/schemas/protocol-plan.schema.json +15 -182
  20. package/dist/schemas/stage-finish-input.schema.json +16 -2
  21. package/dist/schemas/stage-report.schema.json +8 -7
  22. package/dist/schemas/stage-start-response.schema.json +4 -2
  23. package/dist/schemas/status-report.schema.json +76 -0
  24. package/dist/schemas/vnext-protocol-plan.schema.json +37 -0
  25. package/dist/schemas/vnext-protocolize-result.schema.json +29 -0
  26. package/dist/schemas/vnext-specify.schema.json +45 -0
  27. package/dist/services/branch-context.js +1 -1
  28. package/dist/services/cleanup.js +8 -8
  29. package/dist/services/cli-operation-classifier.js +10 -2
  30. package/dist/services/code-checks.js +244 -0
  31. package/dist/services/config.js +7 -1
  32. package/dist/services/dashboard.js +12 -12
  33. package/dist/services/engines.js +1 -1
  34. package/dist/services/eval-snapshots.js +404 -0
  35. package/dist/services/hooks.js +774 -18
  36. package/dist/services/ids.js +16 -6
  37. package/dist/services/lanes.js +1 -1
  38. package/dist/services/merge-queue.js +5 -5
  39. package/dist/services/merge-worker.js +2 -2
  40. package/dist/services/migrations.js +2 -2
  41. package/dist/services/plan-runtime.js +1 -1
  42. package/dist/services/projects.js +4 -4
  43. package/dist/services/prompts.js +17 -11
  44. package/dist/services/protocols.js +8 -8
  45. package/dist/services/run-projection.js +49 -13
  46. package/dist/services/runs.js +504 -51
  47. package/dist/services/schema-validation.js +21 -3
  48. package/dist/services/sessions.js +51 -12
  49. package/dist/services/stage-blocker.js +57 -0
  50. package/dist/services/stage-context.js +90 -0
  51. package/dist/services/stage-lifecycle.js +198 -75
  52. package/dist/services/stage-pause.js +175 -0
  53. package/dist/services/stage-report-renderer.js +65 -0
  54. package/dist/services/usage.js +526 -18
  55. package/dist/services/vnext-code-review.js +305 -0
  56. package/dist/services/vnext-code.js +686 -0
  57. package/dist/services/vnext-contracts.js +1 -0
  58. package/dist/services/vnext-execution-profile.js +27 -0
  59. package/dist/services/vnext-fanout.js +79 -0
  60. package/dist/services/vnext-plan-review.js +499 -0
  61. package/dist/services/vnext-plan.js +552 -0
  62. package/dist/services/vnext-protocolize.js +542 -0
  63. package/dist/services/vnext-specify.js +595 -0
  64. package/dist/services/vnext-workspace-policy.js +87 -0
  65. package/dist/services/work-registry.js +522 -0
  66. package/dist/services/worktrees.js +58 -37
  67. package/dist/storage/database.js +263 -34
  68. package/dist/storage/paths.js +47 -1
  69. package/package.json +12 -12
@@ -0,0 +1,22 @@
1
+ import { AppError } from "../shared/errors.js";
2
+ export const vnextStages = [
3
+ { id: "specify", directory: "01-specify", result: "specify.json", schema: "dd-flow/vnext-specify-result@4", next: ["protocolize"] },
4
+ { id: "protocolize", directory: "02-protocolize", result: "protocolize-result.json", schema: "dd-flow/vnext-protocolize-result@3", next: ["plan"] },
5
+ { id: "plan", directory: "03-plan", result: "stage-report.json", schema: "dd-flow/stage-report@2", next: ["plan-review", "code"] },
6
+ { id: "plan-review", directory: "04-plan-review", result: "decision.json", schema: "dd-flow/plan-review-decision@3", next: ["code"] },
7
+ { id: "code", directory: "05-code", result: "code-verification.json", schema: "dd-flow/code-verification@2", next: ["code-review", "merge"] },
8
+ { id: "code-review", directory: "06-code-review", result: "decision.json", schema: "dd-flow/code-review-decision@2", next: ["merge"] },
9
+ { id: "merge", directory: "07-merge", result: "merge-result.json", schema: "dd-flow/merge-result@1", next: [] }
10
+ ];
11
+ export function vnextStage(id) {
12
+ const stage = vnextStages.find((candidate) => candidate.id === id);
13
+ if (!stage)
14
+ throw new AppError("validation", `Unknown vNext stage: ${id}`, 2, { stage: id });
15
+ return stage;
16
+ }
17
+ export function vnextStageDirectory(id) {
18
+ return vnextStage(id).directory;
19
+ }
20
+ export function isLegalVnextTransition(from, to) {
21
+ return vnextStage(from).next.includes(to);
22
+ }
@@ -113,7 +113,7 @@ function validateExecutionContext(input, itemId) {
113
113
  prompt_profile: requireString(context.prompt_profile, `Plan item ${itemId} execution_context.prompt_profile`),
114
114
  required_read: requireStringArray(context.required_read, `Plan item ${itemId} execution_context.required_read`),
115
115
  discovery_boundary: requireStringArray(context.discovery_boundary, `Plan item ${itemId} execution_context.discovery_boundary`),
116
- write_scope: requireStringArray(context.write_scope, `Plan item ${itemId} execution_context.write_scope`),
116
+ planned_write_areas: requireStringArray(context.planned_write_areas, `Plan item ${itemId} execution_context.planned_write_areas`),
117
117
  checks: requireStringArray(context.checks, `Plan item ${itemId} execution_context.checks`)
118
118
  };
119
119
  }
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "dd-flow/code-review-decision@2",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["schema_id", "summary", "findings"],
7
+ "properties": {
8
+ "schema_id": {"const": "dd-flow/code-review-decision@2"},
9
+ "summary": {"type": "string", "minLength": 1},
10
+ "findings": {
11
+ "type": "array",
12
+ "items": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["finding_ref", "disposition", "reason"],
16
+ "properties": {
17
+ "finding_ref": {"type": "string", "pattern": "^WRK-[^/]+/FIND-[0-9]{3}$"},
18
+ "disposition": {"enum": ["fix", "defer", "reject", "duplicate"]},
19
+ "reason": {"type": "string", "minLength": 1},
20
+ "def_id": {"type": "string", "minLength": 1},
21
+ "duplicate_of": {"type": "string", "minLength": 1}
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "dd-flow/code-review-result@1",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["schema_id", "verdict", "summary", "aspects", "findings"],
7
+ "properties": {
8
+ "schema_id": {"const": "dd-flow/code-review-result@1"},
9
+ "verdict": {"enum": ["pass", "findings", "blocked"]},
10
+ "summary": {"type": "string", "minLength": 1},
11
+ "aspects": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["aspect_id", "verdict", "summary", "evidence_refs"], "properties": {"aspect_id": {"type": "string", "minLength": 1}, "verdict": {"enum": ["pass", "findings", "blocked"]}, "summary": {"type": "string", "minLength": 1}, "evidence_refs": {"type": "array", "items": {"type": "string"}}}}},
12
+ "findings": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["finding_id", "aspect_id", "priority", "problem", "impact", "evidence_refs", "obligation_refs"], "properties": {"finding_id": {"type": "string", "pattern": "^FIND-[0-9]{3}$"}, "aspect_id": {"type": "string", "minLength": 1}, "priority": {"enum": ["p0", "p1", "p2", "p3"]}, "problem": {"type": "string", "minLength": 1}, "impact": {"type": "string", "minLength": 1}, "evidence_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}, "obligation_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}}}}
13
+ }
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "dd-flow/code-verification@2",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["schema_id", "verdict", "summary", "unresolved", "deviations"],
7
+ "properties": {
8
+ "schema_id": {"const": "dd-flow/code-verification@2"},
9
+ "verdict": {"enum": ["passed", "needs_repair", "blocked"]},
10
+ "summary": {"type": "string", "minLength": 1},
11
+ "unresolved": {"type": "array", "items": {"type": "string", "minLength": 1}},
12
+ "deviations": {"type": "array", "items": {"type": "string", "minLength": 1}}
13
+ }
14
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "dd-flow/code-work-batch@5",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["schema_id", "sources", "works"],
7
+ "properties": {
8
+ "schema_id": {"const": "dd-flow/code-work-batch@5"},
9
+ "sources": {"type": "array", "minItems": 1, "items": {"type": "object", "additionalProperties": false, "required": ["plan_id", "protocol_id", "revision", "sha256"], "properties": {"plan_id": {"type": "string", "minLength": 1}, "protocol_id": {"type": "string", "minLength": 1}, "revision": {"type": "integer", "minimum": 1}, "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}}}},
10
+ "works": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/work"}}
11
+ },
12
+ "$defs": {
13
+ "strings": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
14
+ "stringList": {"type": "array", "items": {"type": "string", "minLength": 1}},
15
+ "source": {"type": "object", "additionalProperties": false, "required": ["plan_id", "protocol_id", "plan_item_id", "revision", "sha256"], "properties": {"plan_id": {"type": "string", "minLength": 1}, "protocol_id": {"type": "string", "minLength": 1}, "plan_item_id": {"type": "string", "minLength": 1}, "revision": {"type": "integer", "minimum": 1}, "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}}},
16
+ "spine": {"type": "object", "additionalProperties": false, "required": ["user_outcome", "component_responsibility", "must_preserve", "non_goals", "acceptance_contribution"], "properties": {"user_outcome": {"type": "string", "minLength": 1}, "component_responsibility": {"type": "string", "minLength": 1}, "must_preserve": {"$ref": "#/$defs/strings"}, "non_goals": {"$ref": "#/$defs/stringList"}, "acceptance_contribution": {"type": "string", "minLength": 1}}},
17
+ "obligation": {"type": "object", "additionalProperties": false, "required": ["id", "statement"], "properties": {"id": {"type": "string", "minLength": 1}, "statement": {"type": "string", "minLength": 1}}},
18
+ "acceptance": {"type": "object", "additionalProperties": false, "required": ["criterion_id", "path", "environment", "fixtures", "cleanup", "check_refs", "expected_evidence", "proof_limits", "gate"], "properties": {"criterion_id": {"type": "string", "pattern": "^AC-[0-9]+$"}, "path": {"type": "string", "minLength": 1}, "environment": {"type": "string", "minLength": 1}, "fixtures": {"$ref": "#/$defs/stringList"}, "cleanup": {"type": "string", "minLength": 1}, "check_refs": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}, "expected_evidence": {"$ref": "#/$defs/strings"}, "proof_limits": {"$ref": "#/$defs/strings"}, "gate": {"type": "string", "minLength": 1}}},
19
+ "check": {"type": "object", "additionalProperties": false, "required": ["id", "command", "purpose", "run_at", "availability"], "properties": {"id": {"type": "string", "pattern": "^CHK-[A-Za-z0-9-]+$"}, "command": {"type": "string", "minLength": 1}, "purpose": {"type": "string", "minLength": 1}, "run_at": {"enum": ["work", "code", "readiness", "merge", "release", "external"]}, "availability": {"enum": ["available", "planned"]}, "provided_by": {"type": "string", "minLength": 1}, "definition": {"type": "string", "minLength": 1}, "required_artifacts": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}}, "allOf": [{"if": {"properties": {"availability": {"const": "planned"}}, "required": ["availability"]}, "then": {"required": ["provided_by", "definition"], "properties": {"command": {"pattern": "^@check/"}}}}]},
20
+ "documentUpdate": {"type": "object", "additionalProperties": false, "required": ["path", "action", "owner", "reason", "baseline_sha256"], "properties": {"path": {"type": "string", "minLength": 1}, "action": {"enum": ["create", "update"]}, "owner": {"type": "string", "minLength": 1}, "reason": {"type": "string", "minLength": 1}, "baseline_sha256": {"type": ["string", "null"], "pattern": "^[a-f0-9]{64}$"}}},
21
+ "repair": {"type": "object", "additionalProperties": false, "required": ["origin_work_ids"], "anyOf": [{"required": ["check_receipt_id", "failure_receipt_path"]}, {"required": ["review_finding_ids", "review_evidence_refs"]}], "properties": {"origin_work_ids": {"$ref": "#/$defs/strings"}, "check_receipt_id": {"type": "string", "minLength": 1}, "failure_receipt_path": {"type": "string", "minLength": 1}, "review_finding_ids": {"$ref": "#/$defs/strings"}, "review_evidence_refs": {"$ref": "#/$defs/strings"}}},
22
+ "work": {"type": "object", "additionalProperties": false, "required": ["schema_id", "key", "launch_policy", "source", "task", "semantic_spine", "requirements", "acceptance", "document_updates", "required_read", "discovery_boundary", "planned_write_areas", "checks", "provides_checks", "stop_conditions", "depends_on", "result_schema"], "properties": {"schema_id": {"const": "dd-flow/code-work-packet@5"}, "key": {"type": "string", "minLength": 1}, "launch_policy": {"const": "fresh_agent_required"}, "source": {"$ref": "#/$defs/source"}, "repair": {"$ref": "#/$defs/repair"}, "task": {"type": "string", "minLength": 1}, "semantic_spine": {"$ref": "#/$defs/spine"}, "requirements": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/obligation"}}, "acceptance": {"type": "array", "items": {"$ref": "#/$defs/acceptance"}}, "document_updates": {"type": "array", "items": {"$ref": "#/$defs/documentUpdate"}}, "required_read": {"$ref": "#/$defs/strings", "description": "Mandatory starting sources, not a read allowlist."}, "discovery_boundary": {"$ref": "#/$defs/strings", "description": "Likely discovery areas; additional project-local reads are allowed."}, "planned_write_areas": {"type": "array", "items": {"type": "string", "minLength": 1}, "description": "Soft coordination hints only. A worker may change any necessary project file inside the RUN workspace."}, "checks": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/check"}}, "provides_checks": {"type": "array", "items": {"$ref": "#/$defs/check"}}, "stop_conditions": {"$ref": "#/$defs/strings", "description": "Hard semantic or external stop conditions; path prediction drift is not a stop condition."}, "depends_on": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}, "result_schema": {"const": "dd-flow/code-work-result@2"}}}
23
+ }
24
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "dd-flow/code-work-result@2",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["schema_id", "summary", "changed_paths", "evidence", "deviations", "blockers"],
7
+ "properties": {
8
+ "schema_id": {"const": "dd-flow/code-work-result@2"},
9
+ "summary": {"type": "string", "minLength": 1},
10
+ "changed_paths": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}},
11
+ "evidence": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["criterion_id", "refs"], "properties": {"criterion_id": {"type": "string", "minLength": 1}, "refs": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}}}},
12
+ "deviations": {"type": "array", "items": {"type": "string", "minLength": 1}},
13
+ "blockers": {"type": "array", "items": {"type": "string", "minLength": 1}},
14
+ "resolved_finding_refs": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}
15
+ }
16
+ }
@@ -51,6 +51,38 @@
51
51
  "status": { "type": "string", "minLength": 1 }
52
52
  }
53
53
  },
54
+ "upgrade_contract": {
55
+ "type": "object",
56
+ "additionalProperties": false,
57
+ "required": ["model", "authorization", "storage_mutation", "run_creation", "post_sync_routing", "contexts", "order"],
58
+ "properties": {
59
+ "model": { "const": "dual_context_target_routing" },
60
+ "authorization": { "const": "command_allowlist" },
61
+ "storage_mutation": { "const": "explicit_migration_apply_only" },
62
+ "run_creation": { "const": "after_storage_readiness" },
63
+ "post_sync_routing": { "const": "marker_free_project_current" },
64
+ "contexts": {
65
+ "type": "array",
66
+ "const": ["project_current", "upgrade_target", "effective_execution"]
67
+ },
68
+ "order": {
69
+ "type": "array",
70
+ "const": [
71
+ "pin_target_canon",
72
+ "verify_target_router",
73
+ "resolve_contexts",
74
+ "read_only_diagnostics",
75
+ "check_shared_home_activity",
76
+ "verify_backup",
77
+ "plan_adjacent_migration",
78
+ "apply_migration_explicitly",
79
+ "create_upgrade_run",
80
+ "sync_canonical_layer",
81
+ "verify_marker_free_normal_route"
82
+ ]
83
+ }
84
+ }
85
+ },
54
86
  "contracts": {
55
87
  "type": "object",
56
88
  "additionalProperties": false,
@@ -34,12 +34,13 @@
34
34
  "specifications": {
35
35
  "type": "array",
36
36
  "minItems": 3,
37
+ "uniqueItems": true,
37
38
  "items": {
38
39
  "type": "object",
39
40
  "additionalProperties": false,
40
41
  "required": ["id", "version", "sha256"],
41
42
  "properties": {
42
- "id": {"enum": ["SPC-004", "SPC-005", "SPC-006"]},
43
+ "id": {"enum": ["SPC-004", "SPC-005", "SPC-006", "SPC-009", "SPC-010", "SPC-011"]},
43
44
  "version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"},
44
45
  "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}
45
46
  }
@@ -80,7 +81,7 @@
80
81
  },
81
82
  "start_command": {"const": "dd-flow stage start <RUN> --stage <stage> --json"},
82
83
  "bootstrap_command": {"const": "dd-flow stage start --bootstrap --stage specify --project-root <root> --subject <label> --intake-file <path> --json"},
83
- "finish_command": {"const": "dd-flow stage finish <RUN> --stage <stage> --outcome <outcome> --json"},
84
+ "finish_command": {"const": "dd-flow stage finish <RUN> --stage <stage> --json"},
84
85
  "prompt_sections": {
85
86
  "const": [
86
87
  "stage_identity",
@@ -114,7 +115,7 @@
114
115
  "required": ["finish_outputs", "model_input", "mechanical_facts"],
115
116
  "properties": {
116
117
  "finish_outputs": {"const": ["stage-report.json", "stage-report.md", "stage-report.html", "summary.md"]},
117
- "model_input": {"const": "semantic-only; outcome flag"},
118
+ "model_input": {"const": "semantic-only; status in stage-input.json; mechanical facts are CLI-owned"},
118
119
  "mechanical_facts": {"const": "cli-owned"}
119
120
  }
120
121
  },
@@ -131,11 +132,14 @@
131
132
  "workspaceContract": {
132
133
  "type": "object",
133
134
  "additionalProperties": false,
134
- "required": ["manager", "command", "project_hooks", "fallbacks"],
135
+ "required": ["manager", "command", "project_hooks", "feature_route_stage", "service_checkout_root", "feature_branch_template", "fallbacks"],
135
136
  "properties": {
136
137
  "manager": {"const": "official-worktrunk"},
137
138
  "command": {"const": "wt switch --create <branch> --base <base> --format json"},
138
139
  "project_hooks": {"const": [".worktreeinclude", ".config/wt.toml"]},
140
+ "feature_route_stage": {"const": "protocolize_start"},
141
+ "service_checkout_root": {"const": "$DD_FLOW_HOME/projects/<PRJ-ID>/checkouts/worktrees/<RUN>/<repo>"},
142
+ "feature_branch_template": {"const": "feature/run-<RUN>-<slug>"},
139
143
  "fallbacks": {"const": "forbidden"}
140
144
  }
141
145
  },
@@ -177,7 +181,7 @@
177
181
  "source_of_truth": {"const": "canonical prompts and schemas"},
178
182
  "runtime_owner": {"const": "dd-flow-cli"},
179
183
  "lint_owner": {"const": "mb-lint"},
180
- "integrated_gate": {"const": "compatible releases plus clean specify-to-plan eval"}
184
+ "integrated_gate": {"type": "string", "minLength": 1}
181
185
  }
182
186
  }
183
187
  }
@@ -1,143 +1,36 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "dd-flow/flow-run@2",
4
- "title": "dd-flow canonical RUN state",
5
- "description": "The sole current machine-readable state for one RUN. Event history belongs to timeline.jsonl.",
3
+ "$id": "dd-flow/flow-run@3",
4
+ "title": "dd-flow portable RUN projection",
5
+ "description": "Compact current projection. SQLite owns runtime state and timeline.jsonl owns history.",
6
6
  "type": "object",
7
7
  "additionalProperties": true,
8
- "required": ["schema_id", "run_id", "project", "subject", "status", "started_at", "workspace", "current_stage", "attempts", "session_coverage", "usage_coverage", "artifacts"],
8
+ "required": ["schema_id", "run_id", "project", "subject", "status", "started_at", "workspace"],
9
9
  "properties": {
10
- "schema_id": {"const": "dd-flow/flow-run@2"},
10
+ "schema_id": {"const": "dd-flow/flow-run@3"},
11
11
  "run_id": {"type": "string", "pattern": "^RUN-[0-9]+-[a-z0-9][a-z0-9-]*$"},
12
12
  "project": {"$ref": "#/definitions/identity"},
13
13
  "subject": {"$ref": "#/definitions/identity"},
14
- "protocol_id": {"type": "string"},
15
14
  "flow_kind": {"type": "string", "minLength": 1},
16
- "status": {"enum": ["created", "running", "done", "failed", "blocked", "discarded"]},
15
+ "status": {"enum": ["created", "running", "paused", "waiting_for_user", "done", "failed", "blocked", "cancelled", "discarded"]},
17
16
  "verdict": {"type": ["string", "null"]},
18
17
  "started_at": {"type": "string", "format": "date-time"},
19
18
  "finished_at": {"type": ["string", "null"], "format": "date-time"},
20
19
  "wall_clock_ms": {"type": ["integer", "null"], "minimum": 0},
21
20
  "timing_status": {"enum": ["measured", "partial", "unavailable"]},
22
21
  "workspace": {"$ref": "#/definitions/workspace"},
23
- "current_stage": {"type": ["string", "null"]},
24
- "plan_ref": {"$ref": "#/definitions/planRef"},
25
- "plan_progress": {"$ref": "#/definitions/planProgress"},
26
- "workers": {"$ref": "#/definitions/workers"},
27
- "attempts": {"type": "array", "items": {"$ref": "#/definitions/attempt"}},
28
- "session_coverage": {"$ref": "#/definitions/coverage"},
29
- "usage_coverage": {"$ref": "#/definitions/coverage"},
30
- "artifacts": {"$ref": "#/definitions/artifacts"},
22
+ "root_work_id": {"type": ["string", "null"]},
23
+ "active_stages": {"type": "array", "items": {"type": "string", "minLength": 1}, "uniqueItems": true},
24
+ "next_actions": {"type": "array", "items": {"type": "string", "minLength": 1}, "uniqueItems": true},
25
+ "works": {"type": "array", "items": {"$ref": "#/definitions/work"}},
26
+ "sessions": {"type": "array", "items": {"$ref": "#/definitions/session"}},
27
+ "variables": {"type": "object"},
31
28
  "timeline_path": {"const": "timeline.jsonl"}
32
29
  },
33
30
  "definitions": {
34
- "planRef": {
35
- "type": "object",
36
- "additionalProperties": false,
37
- "required": ["path", "plan_id", "revision", "sha256"],
38
- "properties": {
39
- "path": {"type": "string", "pattern": "^\\.memory-bank/protocol/[^/]+/plan\\.json$"},
40
- "plan_id": {"type": "string", "minLength": 1},
41
- "revision": {"type": "integer", "minimum": 1},
42
- "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}
43
- }
44
- },
45
- "planProgress": {
46
- "type": "object",
47
- "additionalProperties": false,
48
- "patternProperties": {
49
- "^P[0-9]+$": {"$ref": "#/definitions/progressItem"}
50
- }
51
- },
52
- "progressItem": {
53
- "type": "object",
54
- "additionalProperties": false,
55
- "required": ["status"],
56
- "properties": {
57
- "status": {"enum": ["pending", "in_progress", "done", "blocked", "skipped"]},
58
- "started_at": {"type": "string", "format": "date-time"},
59
- "completed_at": {"type": "string", "format": "date-time"},
60
- "summary": {"type": "string", "minLength": 1},
61
- "evidence": {"type": "array", "items": {"type": "string", "minLength": 1}}
62
- }
63
- },
64
- "workers": {
65
- "type": "object",
66
- "additionalProperties": false,
67
- "patternProperties": {
68
- "^JOB-[A-Za-z0-9._-]+$": {"$ref": "#/definitions/worker"}
69
- }
70
- },
71
- "worker": {
72
- "type": "object",
73
- "additionalProperties": false,
74
- "required": ["units", "status"],
75
- "properties": {
76
- "units": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
77
- "session_id": {"type": "string", "minLength": 1},
78
- "status": {"enum": ["registered", "running", "completed", "failed", "blocked"]},
79
- "task_ref": {"type": "string", "minLength": 1},
80
- "prompt_ref": {"type": "string", "minLength": 1},
81
- "report_ref": {"type": "string", "minLength": 1}
82
- }
83
- },
84
- "identity": {
85
- "type": "object",
86
- "additionalProperties": false,
87
- "required": ["id", "title"],
88
- "properties": {"id": {"type": "string", "minLength": 1}, "title": {"type": "string", "minLength": 1}}
89
- },
90
- "workspace": {
91
- "type": "object",
92
- "additionalProperties": false,
93
- "required": ["project_root", "workspace_path", "branch", "base"],
94
- "properties": {
95
- "project_root": {"type": "string", "minLength": 1},
96
- "workspace_path": {"type": "string", "minLength": 1},
97
- "branch": {"type": "string", "minLength": 1},
98
- "base": {"type": "string", "minLength": 1},
99
- "manager": {"const": "official-worktrunk"},
100
- "bootstrap_status": {"type": "string", "minLength": 1}
101
- }
102
- },
103
- "attempt": {
104
- "type": "object",
105
- "additionalProperties": false,
106
- "required": ["stage", "attempt_number", "root", "status"],
107
- "properties": {
108
- "stage": {"type": "string", "minLength": 1},
109
- "attempt_number": {"type": "integer", "minimum": 1},
110
- "root": {"type": "string", "minLength": 1},
111
- "archive": {"type": ["string", "null"]},
112
- "status": {"type": "string", "minLength": 1},
113
- "started_at": {"type": "string", "format": "date-time"},
114
- "finished_at": {"type": ["string", "null"], "format": "date-time"}
115
- }
116
- },
117
- "coverage": {
118
- "type": "object",
119
- "additionalProperties": false,
120
- "required": ["status", "expected", "observed", "missing"],
121
- "properties": {
122
- "status": {"enum": ["complete", "partial", "unavailable"]},
123
- "expected": {"type": "array", "items": {"type": "string"}},
124
- "observed": {"type": "array", "items": {"type": "string"}},
125
- "missing": {"type": "array", "items": {"type": "string"}},
126
- "diagnostics": {"type": "array", "items": {"type": "string"}},
127
- "reason": {"type": "string"}
128
- }
129
- },
130
- "artifacts": {
131
- "type": "object",
132
- "additionalProperties": false,
133
- "required": ["stage_prompt", "stage_report_json", "stage_report_md", "stage_report_html", "summary"],
134
- "properties": {
135
- "stage_prompt": {"type": "string", "minLength": 1},
136
- "stage_report_json": {"type": "string", "minLength": 1},
137
- "stage_report_md": {"type": "string", "minLength": 1},
138
- "stage_report_html": {"type": "string", "minLength": 1},
139
- "summary": {"type": "string", "minLength": 1}
140
- }
141
- }
31
+ "identity": {"type": "object", "additionalProperties": false, "required": ["id", "title"], "properties": {"id": {"type": "string", "minLength": 1}, "title": {"type": "string", "minLength": 1}}},
32
+ "workspace": {"type": "object", "additionalProperties": true, "required": ["project_root", "workspace_path", "branch", "base"], "properties": {"project_root": {"type": "string", "minLength": 1}, "workspace_path": {"type": "string", "minLength": 1}, "branch": {"type": "string", "minLength": 1}, "base": {"type": "string", "minLength": 1}}},
33
+ "work": {"type": "object", "additionalProperties": false, "required": ["work_id", "status", "depends_on"], "properties": {"work_id": {"type": "string"}, "parent_work_id": {"type": ["string", "null"]}, "status": {"enum": ["created", "running", "completed", "failed", "cancelled"]}, "depends_on": {"type": "array", "items": {"type": "string"}}, "launch_policy": {"enum": ["reuse_allowed", "fresh_agent_required"]}, "started_at": {"type": ["string", "null"]}, "completed_at": {"type": ["string", "null"]}}},
34
+ "session": {"type": "object", "additionalProperties": true, "required": ["session_id", "status"], "properties": {"session_id": {"type": "string", "minLength": 1}, "parent_session_id": {"type": ["string", "null"]}, "work_id": {"type": "string"}, "agent_id": {"type": ["string", "null"]}, "status": {"type": "string"}}}
142
35
  }
143
36
  }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "dd-flow/plan-aspect-map@3",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["$schema", "schema_id", "protocol_id", "plan_id", "plan_revision", "catalog_ref", "routing", "review_groups", "aspects"],
7
+ "properties": {
8
+ "$schema": {"type": "string", "minLength": 1},
9
+ "schema_id": {"const": "dd-flow/plan-aspect-map@3"},
10
+ "protocol_id": {"type": "string", "pattern": "^PRT-"},
11
+ "plan_id": {"type": "string", "minLength": 1},
12
+ "plan_revision": {"type": "integer", "minimum": 1},
13
+ "catalog_ref": {"type": "object", "additionalProperties": false, "required": ["path"], "properties": {"path": {"type": "string", "minLength": 1}, "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}}},
14
+ "routing": {"type": "object", "additionalProperties": false, "required": ["initial_state", "selected_route", "reason", "groups"], "properties": {"initial_state": {"const": "orchestrator_local"}, "selected_route": {"enum": ["local_compact", "single_wave_grouped", "multi_wave_grouped", "external_handoff"]}, "reason": {"type": "string", "minLength": 1}, "groups": {"type": "array", "items": {"$ref": "#/$defs/group"}}}},
15
+ "review_groups": {"type": "array", "description": "Every applicable aspect exactly once. Prefer one semantically safe wave within measured capacity.", "items": {"$ref": "#/$defs/group"}},
16
+ "review_tail_reason": {"type": "string", "minLength": 1},
17
+ "aspects": {"type": "array", "minItems": 1, "items": {"type": "object", "additionalProperties": false, "required": ["aspect_id", "applicability", "reason", "planned_artifact_refs"], "properties": {"aspect_id": {"type": "string", "minLength": 1}, "applicability": {"enum": ["applicable", "not_applicable"]}, "reason": {"type": "string", "minLength": 1}, "planned_artifact_refs": {"type": "array", "items": {"type": "string", "minLength": 1}}}}}
18
+ },
19
+ "$defs": {
20
+ "group": {"type": "object", "additionalProperties": false, "required": ["id", "aspect_ids"], "properties": {"id": {"type": "string", "minLength": 1}, "aspect_ids": {"type": "array", "minItems": 1, "maxItems": 3, "uniqueItems": true, "items": {"type": "string", "minLength": 1}}}}
21
+ }
22
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "dd-flow/plan-review-decision@3",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["schema_id", "outcome", "summary", "finding_decisions", "correction"],
7
+ "properties": {
8
+ "schema_id": {"const": "dd-flow/plan-review-decision@3"},
9
+ "outcome": {"enum": ["accepted", "blocked", "failed", "cancelled"]},
10
+ "summary": {"type": "string", "minLength": 1},
11
+ "finding_decisions": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["finding_ref", "decision", "reason"], "properties": {"finding_ref": {"type": "string", "pattern": "^WRK-[^/]+/FIND-[0-9]{3}$"}, "decision": {"enum": ["accepted_fix", "rejected", "deferred_as_DEF", "requires_user", "duplicate"]}, "reason": {"type": "string", "minLength": 1}}}},
12
+ "correction": {"type": "object", "additionalProperties": false, "required": ["status", "previous_plan_revision", "changed_paths", "summary"], "properties": {"status": {"enum": ["applied", "not_required"]}, "previous_plan_revision": {"type": "integer", "minimum": 1}, "changed_paths": {"type": "array", "items": {"type": "string", "minLength": 1}}, "summary": {"type": "string", "minLength": 1}}}
13
+ }
14
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "dd-flow/plan-review-result@1",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["schema_id", "plan_revision", "overall_verdict", "summary", "aspects"],
7
+ "properties": {
8
+ "schema_id": {"const": "dd-flow/plan-review-result@1"},
9
+ "plan_revision": {"type": "integer", "minimum": 1},
10
+ "overall_verdict": {"enum": ["pass", "watch", "needs_changes", "blocked"]},
11
+ "summary": {"type": "string", "minLength": 1},
12
+ "aspects": {
13
+ "type": "array",
14
+ "minItems": 1,
15
+ "items": {
16
+ "type": "object",
17
+ "additionalProperties": false,
18
+ "required": ["aspect_id", "verdict", "summary", "evidence_refs", "findings"],
19
+ "properties": {
20
+ "aspect_id": {"type": "string", "minLength": 1},
21
+ "verdict": {"enum": ["pass", "watch", "needs_changes", "blocked"]},
22
+ "summary": {"type": "string", "minLength": 1},
23
+ "evidence_refs": {"type": "array", "items": {"type": "string", "minLength": 1}},
24
+ "findings": {
25
+ "type": "array",
26
+ "items": {
27
+ "type": "object",
28
+ "additionalProperties": false,
29
+ "required": ["finding_id", "severity", "summary", "evidence_refs"],
30
+ "properties": {
31
+ "finding_id": {"type": "string", "pattern": "^FIND-[0-9]{3}$"},
32
+ "severity": {"enum": ["blocker", "high", "medium", "low", "info"]},
33
+ "summary": {"type": "string", "minLength": 1},
34
+ "evidence_refs": {"type": "array", "items": {"type": "string", "minLength": 1}}
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }