dev-loops 0.1.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 (156) hide show
  1. package/.pi/dev-loop/defaults.yaml +477 -0
  2. package/AGENTS.md +25 -0
  3. package/CHANGELOG.md +18 -0
  4. package/LICENSE +21 -0
  5. package/README.md +178 -0
  6. package/agents/dev-loop.agent.md +82 -0
  7. package/agents/developer.agent.md +37 -0
  8. package/agents/docs.agent.md +33 -0
  9. package/agents/fixer.agent.md +53 -0
  10. package/agents/quality.agent.md +28 -0
  11. package/agents/refiner.agent.md +87 -0
  12. package/agents/review.agent.md +64 -0
  13. package/cli/index.mjs +424 -0
  14. package/extension/README.md +233 -0
  15. package/extension/checks.ts +94 -0
  16. package/extension/index.ts +131 -0
  17. package/extension/post-merge-update.ts +512 -0
  18. package/extension/presentation.ts +107 -0
  19. package/lib/dev-loops-core.mjs +284 -0
  20. package/package.json +103 -0
  21. package/scripts/README.md +1007 -0
  22. package/scripts/_cli-primitives.mjs +10 -0
  23. package/scripts/_core-helpers.mjs +30 -0
  24. package/scripts/docs/validate-links.mjs +567 -0
  25. package/scripts/docs/validate-no-duplicate-rules.mjs +250 -0
  26. package/scripts/github/_review-thread-mutations.mjs +214 -0
  27. package/scripts/github/capture-review-threads.mjs +180 -0
  28. package/scripts/github/create-draft-pr.mjs +108 -0
  29. package/scripts/github/detect-checkpoint-evidence.mjs +393 -0
  30. package/scripts/github/detect-linked-issue-pr.mjs +331 -0
  31. package/scripts/github/manage-sub-issues.mjs +394 -0
  32. package/scripts/github/probe-copilot-review.mjs +323 -0
  33. package/scripts/github/ready-for-review.mjs +93 -0
  34. package/scripts/github/reconcile-draft-gate.mjs +328 -0
  35. package/scripts/github/reply-resolve-review-thread.mjs +42 -0
  36. package/scripts/github/reply-resolve-review-threads.mjs +329 -0
  37. package/scripts/github/request-copilot-review.mjs +551 -0
  38. package/scripts/github/resolve-tracker-local-spec.mjs +205 -0
  39. package/scripts/github/stage-reviewer-draft.mjs +191 -0
  40. package/scripts/github/upsert-checkpoint-verdict.mjs +694 -0
  41. package/scripts/github/verify-fresh-review-context.mjs +125 -0
  42. package/scripts/github/write-gate-findings-log.mjs +212 -0
  43. package/scripts/loop/_checkpoint-io.mjs +55 -0
  44. package/scripts/loop/_checkpoint-paths.mjs +28 -0
  45. package/scripts/loop/_handoff-contract.mjs +230 -0
  46. package/scripts/loop/_inspect-run-viewer-adapter.mjs +345 -0
  47. package/scripts/loop/_loop-evidence.mjs +32 -0
  48. package/scripts/loop/_pr-runner-coordination.mjs +611 -0
  49. package/scripts/loop/_stale-runner-detection.mjs +145 -0
  50. package/scripts/loop/_steering-state-file.mjs +134 -0
  51. package/scripts/loop/build-handoff-envelope.mjs +181 -0
  52. package/scripts/loop/checkpoint-contract.mjs +49 -0
  53. package/scripts/loop/conductor-monitor.mjs +1850 -0
  54. package/scripts/loop/conductor.mjs +214 -0
  55. package/scripts/loop/copilot-pr-handoff.mjs +493 -0
  56. package/scripts/loop/debt-remediate.mjs +304 -0
  57. package/scripts/loop/detect-change-scope.mjs +102 -0
  58. package/scripts/loop/detect-copilot-loop-state.mjs +454 -0
  59. package/scripts/loop/detect-copilot-session-activity.mjs +186 -0
  60. package/scripts/loop/detect-initial-copilot-pr-state.mjs +318 -0
  61. package/scripts/loop/detect-internal-only-pr.mjs +270 -0
  62. package/scripts/loop/detect-issue-refinement-artifact.mjs +163 -0
  63. package/scripts/loop/detect-pr-gate-coordination-state.mjs +509 -0
  64. package/scripts/loop/detect-reviewer-loop-state.mjs +231 -0
  65. package/scripts/loop/detect-stale-runner.mjs +250 -0
  66. package/scripts/loop/detect-tracker-first-loop-state.mjs +76 -0
  67. package/scripts/loop/detect-tracker-pr-state.mjs +102 -0
  68. package/scripts/loop/info.mjs +267 -0
  69. package/scripts/loop/inspect-run-viewer/cli.mjs +117 -0
  70. package/scripts/loop/inspect-run-viewer/constants.mjs +80 -0
  71. package/scripts/loop/inspect-run-viewer/graph.mjs +757 -0
  72. package/scripts/loop/inspect-run-viewer/handoff-envelope-renderer.mjs +398 -0
  73. package/scripts/loop/inspect-run-viewer/inbox.mjs +308 -0
  74. package/scripts/loop/inspect-run-viewer/managed-instance.mjs +750 -0
  75. package/scripts/loop/inspect-run-viewer/rendering.mjs +411 -0
  76. package/scripts/loop/inspect-run-viewer/server.mjs +638 -0
  77. package/scripts/loop/inspect-run-viewer/shared.mjs +103 -0
  78. package/scripts/loop/inspect-run-viewer/status.mjs +715 -0
  79. package/scripts/loop/inspect-run-viewer-ci-changes.mjs +77 -0
  80. package/scripts/loop/inspect-run-viewer.mjs +82 -0
  81. package/scripts/loop/inspect-run.mjs +382 -0
  82. package/scripts/loop/outer-loop.mjs +419 -0
  83. package/scripts/loop/pr-runner-coordination.mjs +143 -0
  84. package/scripts/loop/pre-commit-branch-guard.mjs +68 -0
  85. package/scripts/loop/pre-flight-gate.mjs +236 -0
  86. package/scripts/loop/pre-pr-ready-gate.mjs +183 -0
  87. package/scripts/loop/pre-push-main-guard.mjs +103 -0
  88. package/scripts/loop/pre-write-remote-freshness-guard.mjs +32 -0
  89. package/scripts/loop/print-gates.mjs +42 -0
  90. package/scripts/loop/resolve-dev-loop-startup.mjs +533 -0
  91. package/scripts/loop/run-conductor-cycle.mjs +322 -0
  92. package/scripts/loop/run-queue.mjs +124 -0
  93. package/scripts/loop/run-refinement-audit.mjs +513 -0
  94. package/scripts/loop/run-watch-cycle.mjs +358 -0
  95. package/scripts/loop/steer-loop.mjs +841 -0
  96. package/scripts/loop/ui-designer-review-contract.mjs +76 -0
  97. package/scripts/loop/watch-initial-copilot-pr.mjs +253 -0
  98. package/scripts/projects/add-queue-item.mjs +528 -0
  99. package/scripts/projects/ensure-queue-board.mjs +837 -0
  100. package/scripts/projects/list-queue-items.mjs +489 -0
  101. package/scripts/projects/move-queue-item.mjs +549 -0
  102. package/scripts/projects/reorder-queue-item.mjs +518 -0
  103. package/scripts/refine/_refine-helpers.mjs +258 -0
  104. package/scripts/refine/prose-linkage-detector.mjs +92 -0
  105. package/scripts/refine/refinement-completeness-checker.mjs +88 -0
  106. package/scripts/refine/scope-boundary-cross-checker.mjs +163 -0
  107. package/scripts/refine/tree-integrity-validator.mjs +211 -0
  108. package/scripts/refine/verify.mjs +178 -0
  109. package/scripts/repo-wiki-local.mjs +156 -0
  110. package/scripts/repo-wiki.mjs +119 -0
  111. package/skills/copilot-pr-followup/SKILL.md +380 -0
  112. package/skills/dev-loop/SKILL.md +141 -0
  113. package/skills/dev-loop/scripts/dev-mode-context.mjs +152 -0
  114. package/skills/dev-loop/scripts/dev-mode-context.test.mjs +80 -0
  115. package/skills/dev-loop/scripts/init-phase.mjs +71 -0
  116. package/skills/dev-loop/scripts/log-bash-exit-1.mjs +25 -0
  117. package/skills/dev-loop/scripts/phase-files.mjs +29 -0
  118. package/skills/dev-loop/scripts/post-gate-verdict-fallback.mjs +480 -0
  119. package/skills/dev-loop/scripts/post-gate-verdict-fallback.test.mjs +732 -0
  120. package/skills/dev-loop/scripts/render-template.mjs +82 -0
  121. package/skills/dev-loop/scripts/render-template.test.mjs +63 -0
  122. package/skills/dev-loop/templates/bootstrap-agents.md +26 -0
  123. package/skills/dev-loop/templates/bootstrap-implementation-state.md +31 -0
  124. package/skills/dev-loop/templates/bootstrap-implementation-workflow.md +17 -0
  125. package/skills/dev-loop/templates/dev-mode-retrospective.md +15 -0
  126. package/skills/dev-loop/templates/dev-mode-review.md +17 -0
  127. package/skills/dev-loop/templates/dev-mode-skill-changes.md +11 -0
  128. package/skills/dev-loop/templates/merged-phase-plan.md +19 -0
  129. package/skills/dev-loop/templates/phase-doc.md +27 -0
  130. package/skills/dev-loop/templates/phase-summary.md +13 -0
  131. package/skills/dev-loop/templates/phase-variant.md +15 -0
  132. package/skills/dev-loop/templates/retrospective.md +11 -0
  133. package/skills/dev-loop/templates/review.md +32 -0
  134. package/skills/dev-loop/templates/ui-vision-review.md +55 -0
  135. package/skills/docs/acceptance-criteria-verification.md +21 -0
  136. package/skills/docs/anti-patterns.md +21 -0
  137. package/skills/docs/artifact-authority-contract.md +119 -0
  138. package/skills/docs/confirmation-rules.md +28 -0
  139. package/skills/docs/copilot-ci-status-contract.md +52 -0
  140. package/skills/docs/copilot-loop-operations.md +233 -0
  141. package/skills/docs/debt-remediation-contract.md +107 -0
  142. package/skills/docs/entrypoint-strategies.md +115 -0
  143. package/skills/docs/epic-tree-refinement-procedure.md +234 -0
  144. package/skills/docs/issue-intake-procedure.md +235 -0
  145. package/skills/docs/main-agent-contract.md +72 -0
  146. package/skills/docs/merge-preconditions.md +29 -0
  147. package/skills/docs/pr-lifecycle-contract.md +209 -0
  148. package/skills/docs/public-dev-loop-contract.md +497 -0
  149. package/skills/docs/retrospective-checkpoint-contract.md +159 -0
  150. package/skills/docs/stop-conditions.md +29 -0
  151. package/skills/docs/structural-quality.md +42 -0
  152. package/skills/docs/tracker-first-loop-state.md +281 -0
  153. package/skills/docs/validation-policy.md +27 -0
  154. package/skills/docs/workflow-handoff-contract.md +135 -0
  155. package/skills/final-approval/SKILL.md +19 -0
  156. package/skills/local-implementation/SKILL.md +640 -0
@@ -0,0 +1,209 @@
1
+ # PR lifecycle contract
2
+
3
+ This document defines the deterministic **family-local PR lifecycle contract** for the GitHub/Copilot workflow family in `dev-loops`.
4
+
5
+ The canonical contract lives in the shipped `skills/docs/` surface because installed skill/runtime consumers reliably own the skills subtree.
6
+
7
+ It consolidates the lifecycle boundary currently split across:
8
+ - [Copilot Loop State Graph](../../docs/copilot-loop-state-graph.md)
9
+ - [Reviewer Loop State Graph](../../docs/reviewer-loop-state-graph.md)
10
+ - [Gate Review Comment Contract](../../docs/gate-review-comment-contract.md)
11
+
12
+ ## Purpose
13
+
14
+ This contract freezes the end-to-end lifecycle semantics for one PR as it moves through:
15
+
16
+ ```text
17
+ draft-stage local gate -> draft remediation -> ready-for-review
18
+ -> explicit Copilot request/wait -> Copilot remediation / reply-resolve / re-review
19
+ -> final local pre-approval gate -> human approval / merge waits
20
+ ```
21
+
22
+ This document owns the **family-local lifecycle semantics** only.
23
+ It does not redefine helper transport mechanics, reviewer-loop internals, conductor routing, or merge policy.
24
+
25
+ ## Relationship to adjacent contracts
26
+
27
+ | Surface | Relationship |
28
+ |---|---|
29
+ | [Copilot Loop State Graph](../../docs/copilot-loop-state-graph.md) | Copilot-family inner-loop state machine consumed by this lifecycle |
30
+ | [Reviewer Loop State Graph](../../docs/reviewer-loop-state-graph.md) | Reviewer-side review production / submission boundary consumed by this lifecycle |
31
+ | [Gate Review Comment Contract](../../docs/gate-review-comment-contract.md) | Visible evidence contract for `draft_gate` and `pre_approval_gate` |
32
+ | [Conductor Routing Contract](../../docs/conductor-routing-contract.md) | Downstream consumer of family-local lifecycle outcomes |
33
+ | issue #29 | Reviewer-loop boundary semantics |
34
+ | issue #34 | Copilot request / re-request / watch helper mechanics |
35
+ | issue #43 | Review-angle policy for the final local pre-approval gate (now config-driven via `gates.preApproval.angles` and `resolveGateAngles`) |
36
+ | issue #61 | Conductor routing and loop-family handoff above this family-local lifecycle |
37
+ | issue #32 | Ownership/idempotency truth for active runs |
38
+
39
+ ## Core rules
40
+
41
+ - Exactly **one current lifecycle state** must apply at a time.
42
+ - The lifecycle must fail closed when required evidence is missing, stale, ambiguous, or unparsable.
43
+ - Every gate-crossing decision is for the **current PR head SHA**.
44
+ - Draft existence alone is **not** draft-gate readiness.
45
+ - A PR must clear the draft-stage gate for the current head before Copilot review may be requested.
46
+ - Ready -> draft resets the lifecycle back into draft-stage gating.
47
+ - Human approval / merge are explicit external waits, not hidden remediation states.
48
+
49
+ ## Two required local gates
50
+
51
+ Each gate runs an independent review chain with its own disposition ledger, review angles,
52
+ and exit conditions. The chains are not interchangeable; see [Checkpoint Review Chain Contract](../../docs/gate-review-sub-loop-contract.md).
53
+
54
+ ### 1. `draft_gate`
55
+
56
+ Applies while the PR is draft.
57
+
58
+ Purpose:
59
+ - decide whether the current draft head is materially reviewable
60
+ - decide whether the PR stays draft for more remediation or may leave draft
61
+ - when `gates.draft.requireCi=true` (default), require green current-head CI before the draft gate may be entered; when `false`, this draft-only CI prerequisite may be skipped
62
+
63
+ Boundary note:
64
+ - `draft_gate` governs only the draft -> ready-for-review boundary for the reviewed head
65
+ - a clean verdict requires no findings at any severity in the gate's `blockCleanOnFindingSeverities` (resolved from config via `resolveGateConfig(config, "draft").blockCleanOnFindingSeverities`)
66
+ - every gate pass writes a durable disposition ledger via `write-gate-findings-log.mjs` under `tmp/gate-findings/`
67
+ - visible comment schema/evidence rules stay in [Gate Review Comment Contract](../../docs/gate-review-comment-contract.md)
68
+ - `gates.draft.requireCi=false` does **not** relax `pre_approval_gate`; final approval and merge readiness still require green current-head CI
69
+
70
+ ### 2. `pre_approval_gate`
71
+
72
+ Applies after Copilot convergence and before final approval / merge claims.
73
+
74
+ This gate uses review angles resolved from config (`resolveGateAngles(config, "preApproval")`). Originally defined by #43; now config-driven.
75
+
76
+ Boundary note:
77
+ - `pre_approval_gate` governs only final approval readiness for the reviewed head
78
+ - a clean verdict requires no findings at any severity in the gate's `blockCleanOnFindingSeverities` (resolved from config via `resolveGateConfig(config, "preApproval").blockCleanOnFindingSeverities`)
79
+ - every gate pass writes a durable disposition ledger via `write-gate-findings-log.mjs` under `tmp/gate-findings/`
80
+ - non-draft PRs do not need visible `draft_gate` evidence to enter the post-draft review / `pre_approval_gate` lifecycle; only the draft -> ready transition depends on `draft_gate`
81
+ - visible comment schema/evidence rules stay in [Gate Review Comment Contract](../../docs/gate-review-comment-contract.md)
82
+
83
+ ## Lifecycle states
84
+
85
+ The family-local lifecycle should be modeled in this vocabulary. These state identifiers are part of the stable contract surface for this lifecycle, even if adjacent helper implementations evolve around them:
86
+
87
+ | State | Meaning |
88
+ |---|---|
89
+ | `draft_local_review_gate` | draft PR is at the local draft-stage gate boundary |
90
+ | `draft_local_remediation` | draft-stage findings require more local remediation while the PR remains draft |
91
+ | `ready_state_needs_copilot_request` | draft gate is clear for the current head; Copilot request is the next legal step |
92
+ | `waiting_for_copilot_review` | Copilot request/re-review is observably in progress for the current head |
93
+ | `copilot_feedback_remediation` | unresolved Copilot feedback exists; fixes are the next active step |
94
+ | `copilot_reply_resolve_pending` | fixes were applied, but GitHub thread reply/resolve work still remains |
95
+ | `merge_conflict_resolution` | current PR head conflicts with base or local reconcile is in progress; resolve conflicts before any further gate progression |
96
+ | `final_local_preapproval_gate` | current-head post-Copilot convergence is ready for the final local gate |
97
+ | `final_gate_remediation` | Pre-approval gate findings require more remediation after the final gate |
98
+ | `waiting_for_human_pr_approval` | local gates are satisfied; waiting for explicit human approval |
99
+ | `waiting_for_merge` | approval exists; waiting for merge / merge-triggering external action |
100
+ | `terminal_slice_complete` | merged/closed and no further owned step remains |
101
+ | `stopped_needs_user_decision` | blocked/ambiguous state requiring explicit human decision |
102
+
103
+ ## Required transitions
104
+
105
+ At minimum, the lifecycle must enforce these transitions:
106
+
107
+ - `draft_local_review_gate` -> `draft_local_remediation`
108
+ - blocking `draft_gate` findings
109
+ - `draft_local_review_gate` -> `ready_state_needs_copilot_request`
110
+ - clean current-head `draft_gate` evidence exists
111
+ - `draft_local_review_gate` -> `stopped_needs_user_decision`
112
+ - human decision required
113
+ - `draft_local_remediation` -> `draft_local_review_gate`
114
+ - fixes pushed on the draft head
115
+ - `ready_state_needs_copilot_request` -> `waiting_for_copilot_review`
116
+ - explicit request/confirm succeeded
117
+ - `ready_state_needs_copilot_request` -> `stopped_needs_user_decision`
118
+ - request unavailable or blocked
119
+ - `waiting_for_copilot_review` -> `copilot_feedback_remediation`
120
+ - unresolved Copilot feedback exists
121
+ - `copilot_feedback_remediation` -> `copilot_reply_resolve_pending`
122
+ - fixes applied but reply/resolve still remains
123
+ - `copilot_reply_resolve_pending` -> `ready_state_needs_copilot_request`
124
+ - reply/resolve complete and another Copilot pass is required
125
+ - any open non-terminal lifecycle slice -> `merge_conflict_resolution`
126
+ - current-head merge state is conflicted (`DIRTY` / `CONFLICTING`) or local conflict reconciliation is already in progress
127
+ - `merge_conflict_resolution` -> normal lifecycle re-entry state
128
+ - only after local conflict resolution produces a new head, validation is rerun for the touched conflict slice, and gate state is re-detected for that new head
129
+ - `waiting_for_copilot_review` -> `final_local_preapproval_gate`
130
+ - the current-head request/re-review cycle has settled cleanly with no unresolved feedback and no further Copilot pass is needed
131
+ - `final_local_preapproval_gate` -> `final_gate_remediation`
132
+ - pre-approval gate findings require changes
133
+ - `final_local_preapproval_gate` -> `waiting_for_human_pr_approval`
134
+ - clean current-head `pre_approval_gate` evidence exists
135
+ - `waiting_for_human_pr_approval` -> `waiting_for_merge`
136
+ - approval arrives
137
+ - `waiting_for_human_pr_approval` -> `draft_local_review_gate`
138
+ - PR reset to draft
139
+ - `waiting_for_merge` -> `terminal_slice_complete`
140
+ - merged/closed and the PR lifecycle is complete
141
+
142
+ ### Required negative boundaries
143
+
144
+ - no Copilot request before clean current-head `draft_gate` evidence
145
+ - no direct skip from fix-applied to Copilot re-request while reply/resolve remains incomplete
146
+ - no reuse of ready-side or gate evidence after ready -> draft
147
+ - a conflicted PR must not be treated as `waiting_for_human_pr_approval`, `waiting_for_merge`, or merge-ready, even if older gate comments and CI were previously green
148
+ - no implicit fallthrough from approval/merge waits into remediation without a triggering event
149
+
150
+ ## Remediation ownership boundary
151
+
152
+ The lifecycle must keep the next action class explicit:
153
+ - draft-stage local findings route to `draft_local_remediation`
154
+ - unresolved Copilot feedback routes to `copilot_feedback_remediation`
155
+ - fixes applied but unresolved GitHub reply/resolve work remains route to `copilot_reply_resolve_pending`
156
+ - pre-approval gate findings route to `final_gate_remediation`
157
+ - merge conflicts route to `merge_conflict_resolution` and must be reconciled locally on the PR branch before lifecycle re-entry
158
+ - human approval / merge remain explicit external waits
159
+
160
+ Reviewer-loop reminder:
161
+ - reviewer-loop semantics end at a review result / submission boundary
162
+ - this lifecycle defines what happens after that boundary without absorbing reviewer-loop planning/submission behavior
163
+
164
+ ## Required evidence classes
165
+
166
+ The lifecycle distinguishes two evidence classes:
167
+
168
+ 1. **observable GitHub state**
169
+ - PR draft/non-draft/merged/closed state
170
+ - current head SHA
171
+ - reviews, review threads, requested reviewers
172
+ - any current-head validation/check freshness only where an adjacent gate/helper already makes a boundary CI-dependent
173
+
174
+ 2. **visible gate evidence on the PR**
175
+ - current-head `draft_gate` evidence when draft-gate clearance is required
176
+ - current-head `pre_approval_gate` evidence when final approval readiness is required
177
+
178
+ 3. **durable disposition ledger**
179
+ - every gate pass logs findings and dispositions under `tmp/gate-findings/<repo-slug>/pr-<N>/`
180
+ - the ledger is the durable record of what each gate found and what was decided
181
+ - the visible PR comment is a summary; the disposition ledger is the complete record
182
+
183
+ ### Precedence rules
184
+
185
+ - current observable PR/head state beats stale local memory
186
+ - required visible gate evidence beats local-only gate records for crossing a gate boundary
187
+ - incomplete or conflicting evidence yields fail-closed blocked/reconcile behavior, not optimistic progression
188
+
189
+ ## Fail-closed rules
190
+
191
+ The lifecycle must stop or reconcile rather than advance when:
192
+ - current head SHA cannot be determined
193
+ - required current-head `draft_gate` evidence is missing
194
+ - required current-head `pre_approval_gate` evidence is missing
195
+ - gate evidence exists but gate name, verdict, or reviewed SHA is missing or unparsable
196
+ - evidence exists only for an older head SHA
197
+ - review-thread capture failed or is incomplete, so unresolved feedback cannot safely be treated as zero
198
+ - Copilot request status is failed, unavailable without in-progress evidence, or otherwise ambiguous for the current head
199
+ - a required current-head wait cannot be confirmed settled
200
+ - the current head reports conflicted merge state (`DIRTY` / `CONFLICTING`) or local git conflict markers are present; enter `merge_conflict_resolution` instead of progressing
201
+ - a boundary that is already CI/validation-dependent cannot confirm current-head freshness because the relevant status is pending, none, unknown, or stale
202
+ - a required visible gate comment could not be confirmed posted
203
+
204
+ In those cases the workflow must not:
205
+ - leave draft
206
+ - request or re-request Copilot review
207
+ - declare final approval readiness
208
+ - silently fall through to a more permissive state
209
+