@namewta/speculo 0.7.2 → 0.7.4

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 (55) hide show
  1. package/dist/src/migrations.js +755 -23
  2. package/dist/src/migrations.js.map +1 -1
  3. package/package.json +1 -1
  4. package/template/canonical/canonical-specdev-engineering-cognitive-mentor.md +200 -448
  5. package/template/canonical/canonical-specdev-goal-plan.md +744 -1108
  6. package/template/canonical/canonical-specdev-grill-with-docs.md +201 -449
  7. package/template/canonical/canonical-specdev-spec.md +232 -486
  8. package/template/canonical/canonical-specdev-tickets.md +411 -590
  9. package/template/canonical/canonical-specdev-wayfinder.md +199 -447
  10. package/template/skills/migrate-runtime-state/SKILL.md +6 -6
  11. package/template/skills/migrate-runtime-state/references/migration-contract.md +9 -3
  12. package/template/skills/migrate-runtime-state/scripts/migrate-runtime-state.mjs +404 -33
  13. package/template/workflows/specdev/I-implement/I-implement.md +98 -143
  14. package/template/workflows/specdev/I-implement/evidence-template.md +66 -48
  15. package/template/workflows/specdev/I-implement/execution-preflight.md +31 -21
  16. package/template/workflows/specdev/I-implement/merge-conflict-protocol.md +12 -12
  17. package/template/workflows/specdev/I-init-setup/I-init-setup.md +4 -5
  18. package/template/workflows/specdev/I-init-setup/change-status-template.json +14 -1
  19. package/template/workflows/specdev/I-init-setup/config-template.json +7 -6
  20. package/template/workflows/specdev/I-init-setup/status-template.json +1 -1
  21. package/template/workflows/specdev/INDEX.md +11 -8
  22. package/template/workflows/specdev/P-goal-plan/P-goal-plan.md +76 -102
  23. package/template/workflows/specdev/P-goal-plan/completion-control.md +26 -44
  24. package/template/workflows/specdev/P-goal-plan/goal-plan-template.md +46 -37
  25. package/template/workflows/specdev/P-goal-plan/lead-orchestration.md +34 -0
  26. package/template/workflows/specdev/P-goal-plan/orchestration-protocol.md +31 -46
  27. package/template/workflows/specdev/P-goal-plan/planning-modes.md +67 -89
  28. package/template/workflows/specdev/P-prototype/ui-prototype.md +1 -1
  29. package/template/workflows/specdev/T-tickets/T-tickets.md +6 -3
  30. package/template/workflows/specdev/T-tickets/ticket-readiness.md +5 -3
  31. package/template/workflows/specdev/T-tickets/ticket-template.md +8 -1
  32. package/template/workflows/specdev/T-tickets/tickets-map-template.md +5 -4
  33. package/template/workflows/specdev/_state/status.json +1 -1
  34. package/template/workflows/specdev/common/README.md +2 -2
  35. package/template/workflows/specdev/common/rules/change-completion.md +17 -20
  36. package/template/workflows/specdev/common/rules/deviation-control.md +1 -1
  37. package/template/workflows/specdev/common/rules/evidence-and-verification.md +31 -37
  38. package/template/workflows/specdev/common/rules/path-ownership.md +21 -23
  39. package/template/workflows/specdev/common/rules/readiness-and-depth.md +1 -1
  40. package/template/workflows/specdev/common/schemas/change-status.schema.json +153 -363
  41. package/template/workflows/specdev/common/schemas/config.schema.json +17 -13
  42. package/template/workflows/specdev/common/schemas/goal-plan.schema.json +33 -16
  43. package/template/workflows/specdev/common/schemas/status.schema.json +7 -63
  44. package/template/workflows/specdev/common/skills/dev-worktree/SKILL.md +42 -21
  45. package/template/workflows/specdev/common/skills/dev-worktree/references/create.md +36 -21
  46. package/template/workflows/specdev/common/skills/dev-worktree/references/finalize.md +46 -18
  47. package/template/workflows/specdev/common/skills/subagent-delivery/SKILL.md +34 -31
  48. package/template/workflows/specdev/common/skills/subagent-delivery/references/external-web-subagent.md +10 -23
  49. package/template/workflows/specdev/common/skills/subagent-delivery/references/native-subagent.md +15 -25
  50. package/template/workflows/specdev/common/tools/README.md +2 -1
  51. package/template/workflows/specdev/common/tools/validate-specdev.mjs +591 -219
  52. package/template/workflows/specdev/I-implement/delegated-evidence-template.md +0 -12
  53. package/template/workflows/specdev/P-goal-plan/delegated-execution-template.md +0 -35
  54. package/template/workflows/specdev/P-goal-plan/delegated-execution.md +0 -59
  55. package/template/workflows/specdev/P-goal-plan/workspace-execution-template.md +0 -24
@@ -442,7 +442,7 @@ Change CONTEXT/ADR 是 active change 内的执行权威,不是 workflow 级永
442
442
 
443
443
  ### Deep
444
444
 
445
- 任一条件触发:公共 API、schema、wire format、数据迁移、认证授权、隐私、资金、不可逆操作、expand-contract、共享核心路径、多 Agent 复杂协作、多个实质架构方案或高事故半径。
445
+ 任一条件触发:公共 API、schema、wire format、数据迁移、认证授权、隐私、资金、不可逆操作、expand-contract、共享核心路径、多个 implementation owner 的跨 Ticket 写入协调、多个实质架构方案或高事故半径。
446
446
 
447
447
  额外要求:数据流或状态转换、兼容窗口、迁移顺序、可观测性、回滚、风险缓解、收缩条件和人工批准点。
448
448
 
@@ -482,61 +482,55 @@ Ticket 只有同时满足以下适用条件才可设置 `ready: true`:
482
482
 
483
483
  # 证据与验证规范
484
484
 
485
- 验证回答“怎样证明行为已经正确发生”,Evidence 回答“实际运行了什么、结果是什么、仍有什么风险”。
485
+ 验证回答“怎样证明”,Evidence 记录“实际运行了什么、在哪个状态运行、结果和残余风险是什么”。
486
486
 
487
487
  ## 1. 验证矩阵
488
488
 
489
- 每一行绑定一个行为、合同或风险:
489
+ 每行绑定行为、合同或风险,并标记环境:
490
490
 
491
- | 行为或风险 | 验证接缝 | 方法或命令 | 预期结果 | Evidence |
492
- |---|---|---|---|---|
493
- | 正常路径 | 公共接口 | 项目定向测试 | 指定外部行为成立 | `specdev/changes/{change}/evidence/T-NN.md` |
494
- | 无效输入 | schema 或公共接口 | 定向失败测试 | 稳定错误行为成立 | `specdev/changes/{change}/evidence/T-NN.md` |
495
- | 回归 | 现有测试套件 | 项目回归命令 | 相关既有行为保持 | `specdev/changes/{change}/evidence/T-NN.md` |
491
+ | 行为或风险 | 接缝 | 命令/方法 | 环境 | 预期 | Evidence |
492
+ |---|---|---|---|---|---|
493
+ | 正常/失败路径 | 公共接口或稳定接缝 | 定向测试 | current-workspace source-worktree | 合同成立 | Ticket Evidence |
494
+ | 跨模块回归 | 集成接缝 | 回归命令 | current-workspace 或 parent-candidate | 组合状态成立 | Ticket Evidence |
495
+ | E2E required | 真实端到端边界 | 场景步骤 | current-workspace parent-candidate | 外部行为成立 | Ticket Evidence |
496
+
497
+ ## 2. 两层验证
498
+
499
+ ### Current workspace
500
+
501
+ current 模式的 implementation owner 在当前父分支和当前 workspace 工作。Ticket 必须严格串行,workspace clean 后形成非空 implementation commit;Lead 在同一 workspace 执行适用集成/回归和 E2E,并在父 HEAD 未漂移时将 Ticket commit 记录为 result SHA。
502
+
503
+ ### Source-worktree
496
504
 
497
- 命令引用项目脚本时,项目文件路径使用项目根相对路径,例如 `package.json` `Makefile`。
505
+ implementation owner 运行最接近目标行为的单元/组件测试、静态分析、类型、lint/build 等适用非 E2E 检查。来源实现必须在 clean worktree 形成 commit。任何 source-worktree E2E pass 声明无效。
498
506
 
499
- ## 2. 最小充分验证
507
+ ### Parent-candidate
500
508
 
501
- 选择最接近目标行为的稳定接缝:
509
+ required 模式下,Lead 在最新父分支与 source commit 的 candidate 状态运行受影响集成/回归、项目父状态检查和适用 E2E。E2E 由实际跨边界风险决定,不限于 UI;not-required 必须写理由。required E2E 未运行或失败时不得推进父分支。
502
510
 
503
- 1. 公共接口或契约集成测试;
504
- 2. 稳定接缝上的单元测试;
505
- 3. 类型检查、静态分析、lint 和构建;
506
- 4. 可重复手动步骤、截图或查询结果;
507
- 5. 代码阅读推断。
511
+ ### Direct Spec
508
512
 
509
- E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由当前实现或集成 owner 运行;委派执行中 Worker 只记录场景、预期结果和待执行状态,由 Lead 在集成阶段运行。APICLI、后端、库或数据变更默认使用其稳定接缝,不追加 E2E
513
+ 获批 Direct Spec 不创建 Ticket worktree 或 candidate。Lead 在 current workspace 记录实施前基线,运行轻量合同要求的定向检查、适用回归与 E2E,并记录最终 checkpointdirty 状态、运行环境、命令、退出状态和未运行原因。E2E 仍只由 Lead 执行;不得为套用两层验证而伪造 Ticket、source/candidate/result 或父分支推进证据。
510
514
 
511
- 低层证据不能替代明确要求的用户行为证据。高风险迁移还需要 dry-run、调用点扫描、数据核对、监控信号或回滚演练。
515
+ 低层证据不能替代明确要求的外部行为证据。高风险迁移还需要 dry-run、调用点扫描、数据核对、监控或恢复演练。
512
516
 
513
- ## 3. 失败分类
517
+ ## 3. Agent 声明
514
518
 
515
- 每个失败必须分类为:
519
+ subagent 只返回候选命令与结果,不写 Evidence。Lead 重读 workspace/Git、必要时复跑或核对输出后落盘;外部 provider 自报、截图、模拟和推断在此之前标记 `unverified`。review/research/test-observation agent 不拥有 E2E Gate。
516
520
 
517
- - Ticket 引入的新失败;
518
- - 基线已存在的失败;
519
- - 环境、权限或基础设施失败;
520
- - 验证本身无效或无法观察目标行为。
521
+ ## 4. 失败分类与完整性
521
522
 
522
- 不得通过跳过测试、放宽断言、吞错、删除用例或把命令移出验证矩阵来制造绿色。
523
+ 失败分类为本 Ticket 新失败、基线既有失败、环境/权限/基础设施失败、无效验证或 candidate stale。不得通过跳过、放宽断言、吞错、删除用例或迁移验证位置制造绿色。
523
524
 
524
- ## 4. Evidence 最低内容
525
+ 受控反向验证只用于可能静默通过的关键门禁:证明检查能在目标风险出现时失败,再恢复并重跑。普通测试不为形式执行破坏性操作。
525
526
 
526
- 每个完成 Ticket `specdev/changes/{change}/evidence/T-NN.md` 记录:
527
+ ## 5. Evidence 最低内容
527
528
 
528
- - 基线、分支或 worktree;
529
- - 实际修改的项目路径;
530
- - 每条命令、退出状态和结果摘要;
531
- - 每条验收合同的证据映射;
532
- - 未运行项与原因;
533
- - 新失败、既有失败和环境失败;
534
- - 偏差及批准;
535
- - 残余风险;
536
- - worktree、提交或 PR 引用;
537
- - 最终结论。
529
+ 每个 Ticket Evidence 至少包含:Lead、Dispatch/返回(若有)、workspace 策略、base/source/result SHA、candidate 字段(required 模式适用,current 模式明确不适用)、实际路径、每条命令/环境/退出状态、合同映射、双轴审查、E2E disposition、未运行项、失败分类、偏差、残余风险和父分支重读结果。
538
530
 
539
- 无法运行关键验证、存在未批准偏差或 Evidence 不完整时,Ticket 不得标为 `done`。
531
+ required Ticket Done 必须有 source commit、通过 candidate、父分支 result 与 Lead Evidence;current Ticket Done 必须有 implementation commit、通过 direct-parent 验证、父分支 result 与 Lead Evidence。无法运行 required 验证、存在未批准偏差、父分支未包含 Ticket commit 或 Evidence 不完整时不得 Done。
532
+
533
+ Direct Spec Evidence 至少包含:用户批准与轻量合同、Lead、实施前/最终 checkpoint、实际路径、定向/回归/E2E 命令及环境、验收映射、未运行项、偏差、残余风险和提交授权状态。
540
534
 
541
535
  </evidence-and-verification>
542
536
 
@@ -584,7 +578,7 @@ E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由
584
578
 
585
579
  - 未批准的 ticket、spec、architecture 或 release 偏差不得继续实现。
586
580
  - 不得通过扩大 `writable_paths`、删除测试、降低断言或把风险改写成“已知限制”来绕过停止。
587
- - 偏差影响普通并行执行时,当前集成 owner 必须暂停受影响 Wave,重新计算路径所有权、依赖和 Gate;委派执行由 Lead 承担同一责任。
581
+ - 偏差影响并行执行、source checkpoint 或 candidate 集成时,Lead 必须暂停受影响 Wave,重新计算路径所有权、依赖、Gate 与父分支顺序;任何 subagent 都不能自行改写上层合同。
588
582
 
589
583
  </deviation-control>
590
584
 
@@ -647,16 +641,15 @@ E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由
647
641
 
648
642
  ```json
649
643
  {
650
- "schema_version": 3,
644
+ "schema_version": 5,
651
645
  "interaction_language": "zh-CN",
652
646
  "artifact_language": "zh-CN",
653
647
  "git": {
654
- "auto_commit": false,
655
- "default_branch": null,
656
- "worktree_for_parallel": true
648
+ "default_branch": null
657
649
  },
658
650
  "execution": {
659
- "max_parallel": 3,
651
+ "max_implementation_agents": 3,
652
+ "max_integration_attempts": 3,
660
653
  "deep_ticket_human_approval": true,
661
654
  "shared_path_owner": "explicit"
662
655
  },
@@ -669,7 +662,9 @@ E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由
669
662
  "planning": {
670
663
  "default_depth": "standard",
671
664
  "require_ready_gate": true,
672
- "require_evidence": true
665
+ "require_evidence": true,
666
+ "ui_prototype_default_variants": 3,
667
+ "ui_prototype_max_variants": 5
673
668
  }
674
669
  }
675
670
  ```
@@ -681,33 +676,32 @@ E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由
681
676
  ```json
682
677
  {
683
678
  "$schema": "https://json-schema.org/draft/2020-12/schema",
684
- "$id": "urn:speculo:specdev:config:v3",
679
+ "$id": "urn:speculo:specdev:config:v5",
685
680
  "title": "SpecDev Configuration",
686
681
  "type": "object",
687
682
  "required": ["schema_version", "interaction_language", "artifact_language", "git", "execution", "verification", "planning"],
688
683
  "properties": {
689
- "schema_version": {"const": 3},
684
+ "schema_version": {"const": 5},
690
685
  "interaction_language": {"type": "string", "minLength": 1},
691
686
  "artifact_language": {"type": "string", "minLength": 1},
692
687
  "git": {
693
688
  "type": "object",
694
- "required": ["auto_commit", "default_branch", "worktree_for_parallel"],
689
+ "required": ["default_branch"],
695
690
  "properties": {
696
- "auto_commit": {"type": "boolean"},
697
- "default_branch": {"type": ["string", "null"]},
698
- "worktree_for_parallel": {"type": "boolean"}
691
+ "default_branch": {"type": ["string", "null"]}
699
692
  },
700
- "additionalProperties": true
693
+ "additionalProperties": false
701
694
  },
702
695
  "execution": {
703
696
  "type": "object",
704
- "required": ["max_parallel", "deep_ticket_human_approval", "shared_path_owner"],
697
+ "required": ["max_implementation_agents", "max_integration_attempts", "deep_ticket_human_approval", "shared_path_owner"],
705
698
  "properties": {
706
- "max_parallel": {"type": "integer", "minimum": 1},
699
+ "max_implementation_agents": {"type": "integer", "minimum": 1},
700
+ "max_integration_attempts": {"type": "integer", "minimum": 1},
707
701
  "deep_ticket_human_approval": {"type": "boolean"},
708
702
  "shared_path_owner": {"type": "string", "minLength": 1}
709
703
  },
710
- "additionalProperties": true
704
+ "additionalProperties": false
711
705
  },
712
706
  "verification": {
713
707
  "type": "object",
@@ -722,16 +716,21 @@ E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由
722
716
  },
723
717
  "planning": {
724
718
  "type": "object",
725
- "required": ["default_depth", "require_ready_gate", "require_evidence"],
719
+ "required": ["default_depth", "require_ready_gate", "require_evidence", "ui_prototype_default_variants", "ui_prototype_max_variants"],
726
720
  "properties": {
727
721
  "default_depth": {"enum": ["lite", "standard", "deep"]},
728
722
  "require_ready_gate": {"type": "boolean"},
729
- "require_evidence": {"type": "boolean"}
723
+ "require_evidence": {"type": "boolean"},
724
+ "ui_prototype_default_variants": {"type": "integer", "minimum": 1},
725
+ "ui_prototype_max_variants": {"type": "integer", "minimum": 1}
730
726
  },
731
727
  "additionalProperties": true
732
728
  }
733
729
  },
734
- "additionalProperties": true
730
+ "allOf": [{
731
+ "$comment": "ui_prototype_default_variants <= ui_prototype_max_variants is enforced by validate-specdev.mjs because JSON Schema cannot compare sibling numeric values."
732
+ }],
733
+ "additionalProperties": false
735
734
  }
736
735
  ```
737
736
 
@@ -741,7 +740,7 @@ E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由
741
740
 
742
741
  ```json
743
742
  {
744
- "schema_version": 4,
743
+ "schema_version": 5,
745
744
  "workflow": "specdev",
746
745
  "active": [],
747
746
  "archived": []
@@ -755,83 +754,27 @@ E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由
755
754
  ```json
756
755
  {
757
756
  "$schema": "https://json-schema.org/draft/2020-12/schema",
758
- "$id": "urn:speculo:specdev:status:v4",
757
+ "$id": "urn:speculo:specdev:status:v5",
759
758
  "title": "SpecDev Global Status",
760
759
  "type": "object",
761
- "required": [
762
- "schema_version",
763
- "workflow",
764
- "active",
765
- "archived"
766
- ],
760
+ "required": ["schema_version", "workflow", "active", "archived"],
767
761
  "properties": {
768
- "schema_version": {
769
- "const": 4
770
- },
771
- "workflow": {
772
- "const": "specdev"
773
- },
762
+ "schema_version": {"const": 5},
763
+ "workflow": {"const": "specdev"},
774
764
  "active": {
775
765
  "type": "array",
776
766
  "items": {
777
767
  "type": "object",
778
- "required": [
779
- "change",
780
- "current_work",
781
- "works_run"
782
- ],
768
+ "required": ["change"],
783
769
  "properties": {
784
770
  "change": {
785
771
  "type": "string",
786
772
  "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}-[a-z0-9]+(?:-[a-z0-9]+)*$"
787
- },
788
- "current_work": {
789
- "type": [
790
- "string",
791
- "null"
792
- ],
793
- "pattern": "^specdev/"
794
- },
795
- "works_run": {
796
- "type": "array",
797
- "items": {
798
- "type": "string",
799
- "pattern": "^specdev/"
800
- },
801
- "uniqueItems": true
802
- },
803
- "claimed_investigations": {
804
- "type": "array",
805
- "items": {
806
- "type": "object",
807
- "required": [
808
- "id",
809
- "owner",
810
- "claimed_at"
811
- ],
812
- "properties": {
813
- "id": {
814
- "type": "string"
815
- },
816
- "owner": {
817
- "type": "string"
818
- },
819
- "session": {
820
- "type": [
821
- "string",
822
- "null"
823
- ]
824
- },
825
- "claimed_at": {
826
- "type": "string"
827
- }
828
- },
829
- "additionalProperties": false
830
- }
831
773
  }
832
774
  },
833
775
  "additionalProperties": false
834
- }
776
+ },
777
+ "uniqueItems": true
835
778
  },
836
779
  "archived": {
837
780
  "type": "array",
@@ -852,11 +795,24 @@ E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由
852
795
 
853
796
  ```json
854
797
  {
855
- "schema_version": 3,
798
+ "schema_version": 6,
856
799
  "artifact": "change-status",
857
800
  "change": "<YYYY-MM-DD-topic>",
858
801
  "change_status": "active",
859
802
  "current_work": null,
803
+ "works_run": [],
804
+ "claimed_investigations": [],
805
+ "execution_authorization": {
806
+ "implementation_commit": {"status": "not-authorized", "source": null, "granted_at": null, "scope": "Ticket implementation commits"},
807
+ "local_candidate_integration": {"status": "not-authorized", "source": null, "granted_at": null, "scope": "Lead-owned local direct-parent or candidate integration and parent update"},
808
+ "source_cleanup": {"status": "not-authorized", "source": null, "granted_at": null, "scope": "Source worktree and branch cleanup"}
809
+ },
810
+ "leadership": {
811
+ "current": "<owner-or-session-locator>",
812
+ "epoch": 1,
813
+ "assigned_at": "<ISO-8601>",
814
+ "history": []
815
+ },
860
816
  "created_at": "<ISO-8601>",
861
817
  "updated_at": "<ISO-8601>",
862
818
  "completed_at": null,
@@ -875,394 +831,184 @@ E2E 仅在变更影响用户界面交互时加入验证矩阵。普通执行由
875
831
  ```json
876
832
  {
877
833
  "$schema": "https://json-schema.org/draft/2020-12/schema",
878
- "$id": "urn:speculo:specdev:change-status:v3",
834
+ "$id": "urn:speculo:specdev:change-status:v6",
879
835
  "title": "SpecDev Change Status",
880
836
  "type": "object",
881
837
  "required": [
882
- "schema_version",
883
- "artifact",
884
- "change",
885
- "change_status",
886
- "current_work",
887
- "created_at",
888
- "updated_at",
889
- "completed_at",
890
- "archived",
891
- "archive_path",
892
- "blockers",
893
- "deviations"
838
+ "schema_version", "artifact", "change", "change_status", "current_work", "works_run",
839
+ "claimed_investigations", "execution_authorization", "leadership", "created_at", "updated_at",
840
+ "completed_at", "archived", "archive_path", "blockers", "deviations", "worktrees"
894
841
  ],
895
842
  "properties": {
896
- "schema_version": {
897
- "const": 3
898
- },
899
- "artifact": {
900
- "const": "change-status"
901
- },
902
- "change": {
903
- "type": "string",
904
- "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}-[a-z0-9]+(?:-[a-z0-9]+)*$"
905
- },
906
- "change_status": {
907
- "enum": [
908
- "active",
909
- "blocked",
910
- "completed",
911
- "archived"
912
- ]
843
+ "schema_version": {"const": 6},
844
+ "artifact": {"const": "change-status"},
845
+ "change": {"type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}-[a-z0-9]+(?:-[a-z0-9]+)*$"},
846
+ "change_status": {"enum": ["active", "blocked", "completed", "archived"]},
847
+ "current_work": {"type": ["string", "null"], "pattern": "^specdev/"},
848
+ "works_run": {"type": "array", "items": {"type": "string", "pattern": "^specdev/"}, "uniqueItems": true},
849
+ "claimed_investigations": {"type": "array", "items": {"$ref": "#/$defs/claim"}},
850
+ "execution_authorization": {"$ref": "#/$defs/authorization"},
851
+ "leadership": {"$ref": "#/$defs/leadership"},
852
+ "created_at": {"type": "string", "minLength": 1},
853
+ "updated_at": {"type": "string", "minLength": 1},
854
+ "completed_at": {"type": ["string", "null"]},
855
+ "archived": {"type": "boolean"},
856
+ "archive_path": {"anyOf": [{"type": "null"}, {"type": "string", "pattern": "^specdev/archive/[0-9]{4}-[0-9]{2}/.+/$"}]},
857
+ "blockers": {"type": "array", "items": {"type": "string"}},
858
+ "deviations": {"type": "array", "items": {"type": "string"}},
859
+ "worktrees": {"type": "array", "items": {"$ref": "#/$defs/worktree"}}
860
+ },
861
+ "$defs": {
862
+ "claim": {
863
+ "type": "object",
864
+ "required": ["id", "owner", "session", "claimed_at"],
865
+ "properties": {
866
+ "id": {"type": "string", "minLength": 1},
867
+ "owner": {"type": "string", "minLength": 1},
868
+ "session": {"type": ["string", "null"]},
869
+ "claimed_at": {"type": "string", "minLength": 1}
870
+ },
871
+ "additionalProperties": false
913
872
  },
914
- "current_work": {
915
- "type": [
916
- "string",
917
- "null"
918
- ]
873
+ "authorization-entry": {
874
+ "type": "object",
875
+ "required": ["status", "source", "granted_at", "scope"],
876
+ "properties": {
877
+ "status": {"enum": ["authorized", "not-authorized", "revoked"]},
878
+ "source": {"type": ["string", "null"]},
879
+ "granted_at": {"type": ["string", "null"]},
880
+ "scope": {"type": "string", "minLength": 1}
881
+ },
882
+ "allOf": [{
883
+ "if": {"properties": {"status": {"const": "authorized"}}, "required": ["status"]},
884
+ "then": {"properties": {"source": {"type": "string", "minLength": 1}, "granted_at": {"type": "string", "minLength": 1}}}
885
+ }],
886
+ "additionalProperties": false
919
887
  },
920
- "created_at": {
921
- "type": "string",
922
- "minLength": 1
888
+ "authorization": {
889
+ "type": "object",
890
+ "required": ["implementation_commit", "local_candidate_integration", "source_cleanup"],
891
+ "properties": {
892
+ "implementation_commit": {"$ref": "#/$defs/authorization-entry"},
893
+ "local_candidate_integration": {"$ref": "#/$defs/authorization-entry"},
894
+ "source_cleanup": {"$ref": "#/$defs/authorization-entry"}
895
+ },
896
+ "additionalProperties": false
923
897
  },
924
- "updated_at": {
925
- "type": "string",
926
- "minLength": 1
898
+ "leadership-history": {
899
+ "type": "object",
900
+ "required": ["owner", "epoch", "assigned_at", "ended_at"],
901
+ "properties": {
902
+ "owner": {"type": "string", "minLength": 1},
903
+ "epoch": {"type": "integer", "minimum": 1},
904
+ "assigned_at": {"type": "string", "minLength": 1},
905
+ "ended_at": {"type": "string", "minLength": 1}
906
+ },
907
+ "additionalProperties": false
927
908
  },
928
- "completed_at": {
929
- "type": [
930
- "string",
931
- "null"
932
- ]
909
+ "leadership": {
910
+ "type": "object",
911
+ "required": ["current", "epoch", "assigned_at", "history"],
912
+ "properties": {
913
+ "current": {"type": "string", "minLength": 1},
914
+ "epoch": {"type": "integer", "minimum": 1},
915
+ "assigned_at": {"type": "string", "minLength": 1},
916
+ "history": {"type": "array", "items": {"$ref": "#/$defs/leadership-history"}}
917
+ },
918
+ "additionalProperties": false
933
919
  },
934
- "archived": {
935
- "type": "boolean"
920
+ "full-suite": {
921
+ "type": "object",
922
+ "required": ["required", "status", "reason", "evidence"],
923
+ "properties": {
924
+ "required": {"type": "boolean"},
925
+ "status": {"enum": ["not-required", "pending", "passed", "failed"]},
926
+ "reason": {"type": ["string", "null"]},
927
+ "evidence": {"type": ["string", "null"]}
928
+ },
929
+ "allOf": [{
930
+ "if": {"properties": {"required": {"const": false}}, "required": ["required"]},
931
+ "then": {"properties": {"status": {"const": "not-required"}, "reason": {"type": "string", "minLength": 1}}}
932
+ }],
933
+ "additionalProperties": false
936
934
  },
937
- "archive_path": {
938
- "anyOf": [
939
- {
940
- "type": "null"
941
- },
935
+ "worktree": {
936
+ "type": "object",
937
+ "required": ["ticket_id", "owner", "implementation_owner", "integration_owner", "provider", "base_sha", "parent_branch", "branch", "workspace_ref", "source_checkpoint", "integration", "status", "updated_at"],
938
+ "properties": {
939
+ "ticket_id": {"type": "string", "pattern": "^T-[0-9]{2,}$"},
940
+ "owner": {"type": "string", "minLength": 1},
941
+ "implementation_owner": {"type": "string", "minLength": 1},
942
+ "integration_owner": {"type": "string", "minLength": 1},
943
+ "provider": {"const": "git"},
944
+ "base_sha": {"type": "string", "minLength": 1},
945
+ "parent_branch": {"type": "string", "minLength": 1},
946
+ "branch": {"type": "string", "minLength": 1},
947
+ "workspace_ref": {"type": "string", "pattern": "^(?:current|specdev-worktree/[0-9]{4}-[0-9]{2}-[0-9]{2}-[a-z0-9]+(?:-[a-z0-9]+)*/T-[0-9]{2,})$"},
948
+ "source_checkpoint": {"type": ["string", "null"]},
949
+ "integration": {"$ref": "#/$defs/integration"},
950
+ "status": {"enum": ["planned", "active", "review", "integrating", "integrated", "removed", "blocked"]},
951
+ "updated_at": {"type": "string", "minLength": 1}
952
+ },
953
+ "allOf": [
942
954
  {
943
- "type": "string",
944
- "pattern": "^specdev/archive/[0-9]{4}-[0-9]{2}/.+/$"
945
- }
946
- ]
947
- },
948
- "blockers": {
949
- "type": "array",
950
- "items": {
951
- "type": "string"
952
- }
953
- },
954
- "deviations": {
955
- "type": "array",
956
- "items": {
957
- "type": "string"
958
- }
959
- },
960
- "worktrees": {
961
- "type": "array",
962
- "items": {
963
- "type": "object",
964
- "required": [
965
- "ticket_id",
966
- "owner",
967
- "provider",
968
- "base_sha",
969
- "branch",
970
- "workspace_ref",
971
- "status",
972
- "updated_at"
973
- ],
974
- "properties": {
975
- "ticket_id": {
976
- "type": "string",
977
- "pattern": "^T-[0-9]{2,}$"
978
- },
979
- "owner": {
980
- "type": "string",
981
- "minLength": 1
982
- },
983
- "integration_owner": {
984
- "type": "string",
985
- "minLength": 1
986
- },
987
- "provider": {
988
- "enum": [
989
- "native",
990
- "git",
991
- "external"
992
- ]
993
- },
994
- "base_sha": {
995
- "type": "string",
996
- "minLength": 1
997
- },
998
- "parent_branch": {
999
- "type": "string",
1000
- "minLength": 1
1001
- },
1002
- "branch": {
1003
- "type": "string",
1004
- "minLength": 1
1005
- },
1006
- "workspace_ref": {
1007
- "type": "string",
1008
- "minLength": 1,
1009
- "pattern": "^(?!/)(?![A-Za-z]:[\\\\/]).+"
1010
- },
1011
- "terminal_action": {
1012
- "enum": [
1013
- "integrate",
1014
- "retain"
1015
- ]
1016
- },
1017
- "source_checkpoint": {
1018
- "type": [
1019
- "string",
1020
- "null"
1021
- ]
1022
- },
1023
- "integration": {
1024
- "type": "object",
1025
- "required": [
1026
- "status",
1027
- "parent_before_sha",
1028
- "source_sha",
1029
- "result_sha",
1030
- "method",
1031
- "conflict_paths",
1032
- "verification",
1033
- "evidence",
1034
- "attempts"
1035
- ],
955
+ "if": {"properties": {"workspace_ref": {"const": "current"}}, "required": ["workspace_ref"]},
956
+ "then": {
1036
957
  "properties": {
1037
- "status": {
1038
- "enum": [
1039
- "pending",
1040
- "running",
1041
- "passed",
1042
- "blocked"
1043
- ]
1044
- },
1045
- "parent_before_sha": {
1046
- "type": ["string", "null"]
1047
- },
1048
- "source_sha": {
1049
- "type": ["string", "null"]
1050
- },
1051
- "result_sha": {
1052
- "type": ["string", "null"]
1053
- },
1054
- "method": {
1055
- "enum": [null, "fast-forward", "merge-commit"]
1056
- },
1057
- "conflict_paths": {
1058
- "type": "array",
1059
- "items": {"type": "string"}
1060
- },
1061
- "verification": {
1062
- "enum": ["pending", "passed", "failed"]
1063
- },
1064
- "evidence": {
1065
- "type": "string",
1066
- "pattern": "^\\{roots\\.state\\}/specdev/changes/[^<]+/evidence/T-[0-9]{2,}\\.md$"
1067
- },
1068
- "attempts": {
1069
- "type": "integer",
1070
- "minimum": 0
1071
- }
1072
- },
1073
- "additionalProperties": true
1074
- },
1075
- "status": {
1076
- "enum": [
1077
- "planned",
1078
- "active",
1079
- "review",
1080
- "integrating",
1081
- "integrated",
1082
- "removed",
1083
- "blocked"
1084
- ]
1085
- },
1086
- "updated_at": {
1087
- "type": "string",
1088
- "minLength": 1
1089
- }
1090
- },
1091
- "dependentRequired": {
1092
- "terminal_action": [
1093
- "integration_owner",
1094
- "parent_branch",
1095
- "source_checkpoint",
1096
- "integration"
1097
- ]
1098
- },
1099
- "allOf": [
1100
- {
1101
- "if": {
1102
- "properties": {
1103
- "status": {"const": "integrating"}
1104
- },
1105
- "required": ["status"]
1106
- },
1107
- "then": {
1108
- "required": [
1109
- "terminal_action",
1110
- "integration_owner",
1111
- "parent_branch",
1112
- "source_checkpoint",
1113
- "integration"
1114
- ],
1115
- "properties": {
1116
- "terminal_action": {"const": "integrate"}
1117
- }
1118
- }
1119
- },
1120
- {
1121
- "if": {
1122
- "properties": {
1123
- "status": {"enum": ["integrating", "integrated"]},
1124
- "terminal_action": {"const": "integrate"}
1125
- },
1126
- "required": ["status", "terminal_action"]
1127
- },
1128
- "then": {
1129
- "properties": {
1130
- "source_checkpoint": {"type": "string", "minLength": 1},
1131
- "integration": {
1132
- "properties": {
1133
- "parent_before_sha": {"type": "string", "minLength": 1},
1134
- "source_sha": {"type": "string", "minLength": 1},
1135
- "attempts": {"type": "integer", "minimum": 1}
1136
- }
1137
- }
1138
- }
1139
- }
1140
- },
1141
- {
1142
- "if": {
1143
- "properties": {
1144
- "status": {"const": "integrating"},
1145
- "terminal_action": {"const": "integrate"}
1146
- },
1147
- "required": ["status", "terminal_action"]
1148
- },
1149
- "then": {
1150
- "properties": {
1151
- "integration": {
1152
- "properties": {
1153
- "status": {"const": "running"}
1154
- }
1155
- }
1156
- }
1157
- }
1158
- },
1159
- {
1160
- "if": {
1161
- "properties": {
1162
- "status": {"const": "integrated"},
1163
- "terminal_action": {"const": "integrate"}
1164
- },
1165
- "required": ["status", "terminal_action"]
1166
- },
1167
- "then": {
1168
- "properties": {
1169
- "integration": {
958
+ "integration": {
959
+ "allOf": [{
1170
960
  "properties": {
1171
- "status": {"const": "passed"},
1172
- "result_sha": {"type": "string", "minLength": 1},
1173
- "method": {"enum": ["fast-forward", "merge-commit"]},
1174
- "verification": {"const": "passed"}
961
+ "candidate_sha": {"const": null},
962
+ "candidate_tree_sha": {"const": null},
963
+ "candidate_branch": {"const": null},
964
+ "candidate_workspace_ref": {"const": null},
965
+ "method": {"enum": [null, "direct-parent"]}
1175
966
  }
1176
- }
967
+ }]
1177
968
  }
1178
969
  }
1179
970
  },
1180
- {
1181
- "if": {
1182
- "properties": {
1183
- "terminal_action": {"const": "retain"}
1184
- },
1185
- "required": ["terminal_action"]
1186
- },
1187
- "then": {
1188
- "properties": {
1189
- "status": {
1190
- "not": {"enum": ["integrating", "integrated"]}
1191
- }
1192
- }
1193
- }
1194
- }
1195
- ],
1196
- "additionalProperties": true
1197
- }
1198
- }
1199
- },
1200
- "allOf": [
1201
- {
1202
- "if": {
1203
- "properties": {
1204
- "worktrees": {
1205
- "contains": {
1206
- "properties": {
1207
- "provider": {
1208
- "const": "git"
1209
- }
1210
- },
1211
- "required": [
1212
- "provider"
1213
- ]
1214
- }
1215
- }
1216
- }
1217
- },
1218
- "then": {
1219
- "properties": {
1220
- "worktrees": {
1221
- "items": {
1222
- "if": {
1223
- "properties": {
1224
- "provider": {
1225
- "const": "git"
1226
- }
1227
- },
1228
- "required": [
1229
- "provider"
1230
- ]
1231
- },
1232
- "then": {
1233
- "properties": {
1234
- "workspace_ref": {
1235
- "pattern": "^specdev-worktree/T-[0-9]{2,}$"
1236
- }
1237
- }
971
+ "else": {
972
+ "properties": {
973
+ "integration": {
974
+ "allOf": [{"properties": {"method": {"enum": [null, "fast-forward", "merge-commit"]}}}]
1238
975
  }
1239
976
  }
1240
977
  }
1241
978
  }
1242
- }
979
+ ],
980
+ "additionalProperties": false
1243
981
  },
1244
- {
1245
- "if": {
1246
- "properties": {
1247
- "change_status": {
1248
- "const": "archived"
1249
- }
1250
- }
982
+ "integration": {
983
+ "type": "object",
984
+ "required": ["status", "parent_ref", "parent_before_sha", "source_sha", "candidate_sha", "candidate_tree_sha", "candidate_branch", "candidate_workspace_ref", "result_sha", "method", "conflict_paths", "verification", "full_suite", "e2e", "evidence", "attempts", "promotion_status"],
985
+ "properties": {
986
+ "status": {"enum": ["pending", "candidate", "passed", "failed", "stale"]},
987
+ "parent_ref": {"type": ["string", "null"]},
988
+ "parent_before_sha": {"type": ["string", "null"]},
989
+ "source_sha": {"type": ["string", "null"]},
990
+ "candidate_sha": {"type": ["string", "null"]},
991
+ "candidate_tree_sha": {"type": ["string", "null"]},
992
+ "candidate_branch": {"type": ["string", "null"]},
993
+ "candidate_workspace_ref": {"anyOf": [{"type": "null"}, {"type": "string", "pattern": "^specdev-worktree/\\.integration/[0-9]{4}-[0-9]{2}-[0-9]{2}-[a-z0-9]+(?:-[a-z0-9]+)*/T-[0-9]{2,}$"}]},
994
+ "result_sha": {"type": ["string", "null"]},
995
+ "method": {"enum": [null, "direct-parent", "fast-forward", "merge-commit"]},
996
+ "conflict_paths": {"type": "array", "items": {"type": "string"}},
997
+ "verification": {"enum": ["pending", "passed", "failed"]},
998
+ "full_suite": {"$ref": "#/$defs/full-suite"},
999
+ "e2e": {"$ref": "#/$defs/full-suite"},
1000
+ "evidence": {"type": "string", "pattern": "^\\{roots\\.state\\}/specdev/changes/[^<]+/evidence/T-[0-9]{2,}\\.md$"},
1001
+ "attempts": {"type": "integer", "minimum": 0},
1002
+ "promotion_status": {"enum": ["pending", "applying", "applied", "failed", "stale"]}
1251
1003
  },
1252
- "then": {
1253
- "properties": {
1254
- "archived": {
1255
- "const": true
1256
- },
1257
- "archive_path": {
1258
- "type": "string",
1259
- "pattern": "^specdev/archive/[0-9]{4}-[0-9]{2}/.+/$"
1260
- }
1261
- }
1262
- }
1004
+ "additionalProperties": false
1263
1005
  }
1264
- ],
1265
- "additionalProperties": true
1006
+ },
1007
+ "allOf": [{
1008
+ "if": {"properties": {"change_status": {"const": "archived"}}, "required": ["change_status"]},
1009
+ "then": {"properties": {"archived": {"const": true}, "archive_path": {"type": "string", "pattern": "^specdev/archive/[0-9]{4}-[0-9]{2}/.+/$"}}}
1010
+ }],
1011
+ "additionalProperties": false
1266
1012
  }
1267
1013
  ```
1268
1014