devflow-toolkit 0.3.1__tar.gz → 0.3.2__tar.gz
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.
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/CHANGELOG.md +23 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/PKG-INFO +51 -7
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/README.md +50 -6
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/pyproject.toml +1 -1
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/cli.py +5 -1
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/commands/approve.py +1 -1
- devflow_toolkit-0.3.2/src/devflow/commands/doctor.py +133 -0
- devflow_toolkit-0.3.2/src/devflow/commands/recover.py +78 -0
- devflow_toolkit-0.3.2/src/devflow/core/recovery.py +259 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/state/manager.py +3 -1
- devflow_toolkit-0.3.2/tests/test_recovery.py +153 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/.gitignore +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/LICENSE +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/__init__.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/__init__.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/agents.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/base.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/claude_code.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/codex.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/detector.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/instructions.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/kiro.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/opencode.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/adapters/registry.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/commands/__init__.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/commands/harness.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/commands/init.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/commands/spec.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/commands/status.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/__init__.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/architecture.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/artifacts/__init__.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/artifacts/errors.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/artifacts/models.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/artifacts/store.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/clock.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/config.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/constitution.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/discovery.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/ports.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/profile_manager.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/project.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/spec_workflow.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/specification.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/state/__init__.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/state/errors.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/state/events.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/state/locator.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/state/lock.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/state/models.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/core/state/transitions.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/models/__init__.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/models/profile.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/models/project.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/ai-rag/constitution/ai-rag-standards.md +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/ai-rag/profile.yaml +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/base/constitution/architecture.md +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/base/constitution/code-standards.md +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/base/constitution/constitution.md +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/base/profile.yaml +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/django-backend/constitution/django-standards.md +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/django-backend/profile.yaml +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/fastapi-backend/constitution/fastapi-standards.md +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/fastapi-backend/profile.yaml +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/prompts/__init__.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/prompts/discovery.md +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/prompts/spec.greenfield.md +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/prompts/spec.md +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/tests/test_cli.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/tests/test_discovery.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/tests/test_event_log.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/tests/test_greenfield.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/tests/test_hardening.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/tests/test_harness_adapters.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/tests/test_spec_workflow.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/tests/test_state.py +0 -0
- {devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/tests/test_state_replay.py +0 -0
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to DevFlow Toolkit are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.3.2 - 2026-11-03
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `devflow doctor <id>` to diagnose a change without modifying it. It
|
|
10
|
+
reports whether `workflow.yaml`, `events.jsonl`, Discovery and the
|
|
11
|
+
specification are present and current, lists orphan artifacts, and
|
|
12
|
+
exits non-zero when the change is unhealthy.
|
|
13
|
+
- `devflow recover <id>` to register an existing complete Discovery and
|
|
14
|
+
a structurally valid `spec.md` when the workflow state is missing. It
|
|
15
|
+
preserves the artifact bytes and digests, uses `source: existing`, and
|
|
16
|
+
does not approve the change.
|
|
17
|
+
- Idempotent recovery: running `devflow recover` again once the workflow
|
|
18
|
+
exists reports the current state and changes nothing.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Package version is `0.3.2`.
|
|
23
|
+
- The missing-workflow error now suggests `devflow doctor <id>` when
|
|
24
|
+
`context.md`, `discovery.yaml` and `spec.md` may already exist.
|
|
25
|
+
- `recover` refuses to register an incomplete Discovery or an invalid
|
|
26
|
+
specification and names how to resolve the problem.
|
|
27
|
+
|
|
5
28
|
## 0.3.1 - 2026-11-03
|
|
6
29
|
|
|
7
30
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: devflow-toolkit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Specification workflow toolkit for AI-assisted software changes
|
|
5
5
|
Author: DevFlow contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -42,7 +42,7 @@ anyone starts implementing it. DevFlow owns the workflow state; the
|
|
|
42
42
|
selected agent harness is only the execution backend that drafts the
|
|
43
43
|
specification.
|
|
44
44
|
|
|
45
|
-
This is the `0.3.
|
|
45
|
+
This is the `0.3.2` MVP. It implements the **discovery and
|
|
46
46
|
specification stages only**. It supports two specification contexts:
|
|
47
47
|
**Existing Project** (the default) and **Greenfield**. It is not a
|
|
48
48
|
complete SDD platform and does not include planning, implementation or
|
|
@@ -114,7 +114,7 @@ pip install devflow-toolkit
|
|
|
114
114
|
To install a specific built artifact instead:
|
|
115
115
|
|
|
116
116
|
```bash
|
|
117
|
-
pip install devflow_toolkit-0.3.
|
|
117
|
+
pip install devflow_toolkit-0.3.2-py3-none-any.whl
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
Verify the installation:
|
|
@@ -278,7 +278,7 @@ as an architectural constraint when it is present.
|
|
|
278
278
|
|
|
279
279
|
### Harnesses
|
|
280
280
|
|
|
281
|
-
| Harness | Status in 0.3.
|
|
281
|
+
| Harness | Status in 0.3.2 |
|
|
282
282
|
| --- | --- |
|
|
283
283
|
| OpenCode | Verified end-to-end in non-interactive mode |
|
|
284
284
|
| Codex | Integration files are generated, but not verified for this release |
|
|
@@ -409,8 +409,10 @@ require Discovery.
|
|
|
409
409
|
5. Review `spec.md` and resolve any remaining non-blocking questions.
|
|
410
410
|
6. Record the approval.
|
|
411
411
|
7. Inspect the state, artifacts and approval digests.
|
|
412
|
+
8. If artifacts exist without workflow state, diagnose with
|
|
413
|
+
`devflow doctor <id>` and repair with `devflow recover <id>`.
|
|
412
414
|
|
|
413
|
-
Available commands in `0.3.
|
|
415
|
+
Available commands in `0.3.2`:
|
|
414
416
|
|
|
415
417
|
| Command | Status |
|
|
416
418
|
| --- | --- |
|
|
@@ -418,6 +420,8 @@ Available commands in `0.3.1`:
|
|
|
418
420
|
| `devflow spec` | Implemented: Discovery, specification, and `--continue` |
|
|
419
421
|
| `devflow approve <id> --stage spec` | Implemented |
|
|
420
422
|
| `devflow status <id>` | Implemented |
|
|
423
|
+
| `devflow doctor <id>` | Implemented: read-only diagnostics |
|
|
424
|
+
| `devflow recover <id>` | Implemented: register existing artifacts |
|
|
421
425
|
| `devflow version` | Implemented |
|
|
422
426
|
| `devflow plan` | Not implemented |
|
|
423
427
|
| `devflow approve <id> --stage plan` | Rejected |
|
|
@@ -504,6 +508,45 @@ devflow status 001-add-a-get-patients-endpoint
|
|
|
504
508
|
approvals, stale artifacts and orphan files. It reconciles
|
|
505
509
|
`workflow.yaml` from `events.jsonl` before reporting.
|
|
506
510
|
|
|
511
|
+
### Diagnose and recover a change
|
|
512
|
+
|
|
513
|
+
If `context.md`, `discovery.yaml` or `spec.md` were written outside
|
|
514
|
+
`devflow spec`, the change can exist on disk without `workflow.yaml`,
|
|
515
|
+
`events.jsonl` or `runs/`. In that case `status` reports that no workflow
|
|
516
|
+
state was found.
|
|
517
|
+
|
|
518
|
+
Diagnose the change without changing anything:
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
devflow doctor 001
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
`doctor` checks the workflow, Discovery and specification, reports
|
|
525
|
+
orphan artifacts, and exits non-zero when the change is unhealthy.
|
|
526
|
+
|
|
527
|
+
If `discovery.yaml` is complete and `spec.md` is structurally valid,
|
|
528
|
+
register the existing artifacts without regenerating them:
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
devflow recover 001
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
`recover` creates the missing workflow state and registers Discovery and
|
|
535
|
+
the specification with `source: existing`. It preserves the artifact
|
|
536
|
+
bytes and their digests, does not modify `spec.md`, and does not approve
|
|
537
|
+
the change. Running it again after recovery is a no-op.
|
|
538
|
+
|
|
539
|
+
Recovery does not bypass review. After recovering, inspect
|
|
540
|
+
`devflow status 001`, then approve explicitly:
|
|
541
|
+
|
|
542
|
+
```bash
|
|
543
|
+
devflow approve 001 --stage spec
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
If Discovery is incomplete or `spec.md` is invalid, `recover` refuses to
|
|
547
|
+
register the artifacts and names the problem. Resolve it with
|
|
548
|
+
`devflow spec --continue 001` first.
|
|
549
|
+
|
|
507
550
|
### Approve the specification
|
|
508
551
|
|
|
509
552
|
```bash
|
|
@@ -511,7 +554,7 @@ devflow approve 001 --stage spec
|
|
|
511
554
|
```
|
|
512
555
|
|
|
513
556
|
Approval is explicit and binds the decision to the current artifact
|
|
514
|
-
digests. For a `0.3.
|
|
557
|
+
digests. For a `0.3.2` change it binds `spec.md`, `discovery.yaml` and,
|
|
515
558
|
when a manifest applies, the architecture manifest digest. Repeating the
|
|
516
559
|
same approval is a no-op. If an artifact changes after validation,
|
|
517
560
|
DevFlow marks it stale and refuses approval until it is regenerated and
|
|
@@ -521,7 +564,7 @@ Discovery must be complete before approval. If it is not, approval fails
|
|
|
521
564
|
and names the pending questions and assumptions. Legacy `0.2.0` changes
|
|
522
565
|
without `discovery.yaml` remain approvable with a warning.
|
|
523
566
|
|
|
524
|
-
Only the `spec` stage is available in `0.3.
|
|
567
|
+
Only the `spec` stage is available in `0.3.2`. `--stage plan` and
|
|
525
568
|
`--stage review` are rejected. There are no `plan`, `implement` or
|
|
526
569
|
`review` commands in this release.
|
|
527
570
|
|
|
@@ -545,6 +588,7 @@ my-project/
|
|
|
545
588
|
│ ├── spec.md # only when Discovery is complete
|
|
546
589
|
│ ├── workflow.yaml # projection of events.jsonl
|
|
547
590
|
│ ├── events.jsonl # append-only source of truth
|
|
591
|
+
│ ├── runs/ # agent run metadata
|
|
548
592
|
│ └── .lock # per-change advisory lock
|
|
549
593
|
├── AGENTS.md
|
|
550
594
|
├── opencode.json # when OpenCode is selected
|
|
@@ -10,7 +10,7 @@ anyone starts implementing it. DevFlow owns the workflow state; the
|
|
|
10
10
|
selected agent harness is only the execution backend that drafts the
|
|
11
11
|
specification.
|
|
12
12
|
|
|
13
|
-
This is the `0.3.
|
|
13
|
+
This is the `0.3.2` MVP. It implements the **discovery and
|
|
14
14
|
specification stages only**. It supports two specification contexts:
|
|
15
15
|
**Existing Project** (the default) and **Greenfield**. It is not a
|
|
16
16
|
complete SDD platform and does not include planning, implementation or
|
|
@@ -82,7 +82,7 @@ pip install devflow-toolkit
|
|
|
82
82
|
To install a specific built artifact instead:
|
|
83
83
|
|
|
84
84
|
```bash
|
|
85
|
-
pip install devflow_toolkit-0.3.
|
|
85
|
+
pip install devflow_toolkit-0.3.2-py3-none-any.whl
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
Verify the installation:
|
|
@@ -246,7 +246,7 @@ as an architectural constraint when it is present.
|
|
|
246
246
|
|
|
247
247
|
### Harnesses
|
|
248
248
|
|
|
249
|
-
| Harness | Status in 0.3.
|
|
249
|
+
| Harness | Status in 0.3.2 |
|
|
250
250
|
| --- | --- |
|
|
251
251
|
| OpenCode | Verified end-to-end in non-interactive mode |
|
|
252
252
|
| Codex | Integration files are generated, but not verified for this release |
|
|
@@ -377,8 +377,10 @@ require Discovery.
|
|
|
377
377
|
5. Review `spec.md` and resolve any remaining non-blocking questions.
|
|
378
378
|
6. Record the approval.
|
|
379
379
|
7. Inspect the state, artifacts and approval digests.
|
|
380
|
+
8. If artifacts exist without workflow state, diagnose with
|
|
381
|
+
`devflow doctor <id>` and repair with `devflow recover <id>`.
|
|
380
382
|
|
|
381
|
-
Available commands in `0.3.
|
|
383
|
+
Available commands in `0.3.2`:
|
|
382
384
|
|
|
383
385
|
| Command | Status |
|
|
384
386
|
| --- | --- |
|
|
@@ -386,6 +388,8 @@ Available commands in `0.3.1`:
|
|
|
386
388
|
| `devflow spec` | Implemented: Discovery, specification, and `--continue` |
|
|
387
389
|
| `devflow approve <id> --stage spec` | Implemented |
|
|
388
390
|
| `devflow status <id>` | Implemented |
|
|
391
|
+
| `devflow doctor <id>` | Implemented: read-only diagnostics |
|
|
392
|
+
| `devflow recover <id>` | Implemented: register existing artifacts |
|
|
389
393
|
| `devflow version` | Implemented |
|
|
390
394
|
| `devflow plan` | Not implemented |
|
|
391
395
|
| `devflow approve <id> --stage plan` | Rejected |
|
|
@@ -472,6 +476,45 @@ devflow status 001-add-a-get-patients-endpoint
|
|
|
472
476
|
approvals, stale artifacts and orphan files. It reconciles
|
|
473
477
|
`workflow.yaml` from `events.jsonl` before reporting.
|
|
474
478
|
|
|
479
|
+
### Diagnose and recover a change
|
|
480
|
+
|
|
481
|
+
If `context.md`, `discovery.yaml` or `spec.md` were written outside
|
|
482
|
+
`devflow spec`, the change can exist on disk without `workflow.yaml`,
|
|
483
|
+
`events.jsonl` or `runs/`. In that case `status` reports that no workflow
|
|
484
|
+
state was found.
|
|
485
|
+
|
|
486
|
+
Diagnose the change without changing anything:
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
devflow doctor 001
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
`doctor` checks the workflow, Discovery and specification, reports
|
|
493
|
+
orphan artifacts, and exits non-zero when the change is unhealthy.
|
|
494
|
+
|
|
495
|
+
If `discovery.yaml` is complete and `spec.md` is structurally valid,
|
|
496
|
+
register the existing artifacts without regenerating them:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
devflow recover 001
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
`recover` creates the missing workflow state and registers Discovery and
|
|
503
|
+
the specification with `source: existing`. It preserves the artifact
|
|
504
|
+
bytes and their digests, does not modify `spec.md`, and does not approve
|
|
505
|
+
the change. Running it again after recovery is a no-op.
|
|
506
|
+
|
|
507
|
+
Recovery does not bypass review. After recovering, inspect
|
|
508
|
+
`devflow status 001`, then approve explicitly:
|
|
509
|
+
|
|
510
|
+
```bash
|
|
511
|
+
devflow approve 001 --stage spec
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
If Discovery is incomplete or `spec.md` is invalid, `recover` refuses to
|
|
515
|
+
register the artifacts and names the problem. Resolve it with
|
|
516
|
+
`devflow spec --continue 001` first.
|
|
517
|
+
|
|
475
518
|
### Approve the specification
|
|
476
519
|
|
|
477
520
|
```bash
|
|
@@ -479,7 +522,7 @@ devflow approve 001 --stage spec
|
|
|
479
522
|
```
|
|
480
523
|
|
|
481
524
|
Approval is explicit and binds the decision to the current artifact
|
|
482
|
-
digests. For a `0.3.
|
|
525
|
+
digests. For a `0.3.2` change it binds `spec.md`, `discovery.yaml` and,
|
|
483
526
|
when a manifest applies, the architecture manifest digest. Repeating the
|
|
484
527
|
same approval is a no-op. If an artifact changes after validation,
|
|
485
528
|
DevFlow marks it stale and refuses approval until it is regenerated and
|
|
@@ -489,7 +532,7 @@ Discovery must be complete before approval. If it is not, approval fails
|
|
|
489
532
|
and names the pending questions and assumptions. Legacy `0.2.0` changes
|
|
490
533
|
without `discovery.yaml` remain approvable with a warning.
|
|
491
534
|
|
|
492
|
-
Only the `spec` stage is available in `0.3.
|
|
535
|
+
Only the `spec` stage is available in `0.3.2`. `--stage plan` and
|
|
493
536
|
`--stage review` are rejected. There are no `plan`, `implement` or
|
|
494
537
|
`review` commands in this release.
|
|
495
538
|
|
|
@@ -513,6 +556,7 @@ my-project/
|
|
|
513
556
|
│ ├── spec.md # only when Discovery is complete
|
|
514
557
|
│ ├── workflow.yaml # projection of events.jsonl
|
|
515
558
|
│ ├── events.jsonl # append-only source of truth
|
|
559
|
+
│ ├── runs/ # agent run metadata
|
|
516
560
|
│ └── .lock # per-change advisory lock
|
|
517
561
|
├── AGENTS.md
|
|
518
562
|
├── opencode.json # when OpenCode is selected
|
|
@@ -6,7 +6,9 @@ import typer
|
|
|
6
6
|
from rich.console import Console
|
|
7
7
|
|
|
8
8
|
from devflow.commands.approve import approve as approve_command
|
|
9
|
+
from devflow.commands.doctor import doctor as doctor_command
|
|
9
10
|
from devflow.commands.init import init as init_command
|
|
11
|
+
from devflow.commands.recover import recover as recover_command
|
|
10
12
|
from devflow.commands.spec import spec as spec_command
|
|
11
13
|
from devflow.commands.status import status as status_command
|
|
12
14
|
|
|
@@ -23,6 +25,8 @@ app.command("init")(init_command)
|
|
|
23
25
|
app.command("spec")(spec_command)
|
|
24
26
|
app.command("approve")(approve_command)
|
|
25
27
|
app.command("status")(status_command)
|
|
28
|
+
app.command("doctor")(doctor_command)
|
|
29
|
+
app.command("recover")(recover_command)
|
|
26
30
|
|
|
27
31
|
|
|
28
32
|
@app.command()
|
|
@@ -31,7 +35,7 @@ def version() -> None:
|
|
|
31
35
|
try:
|
|
32
36
|
current_version = package_version("devflow-toolkit")
|
|
33
37
|
except PackageNotFoundError:
|
|
34
|
-
current_version = "0.3.
|
|
38
|
+
current_version = "0.3.2"
|
|
35
39
|
console.print(f"DevFlow v{current_version}")
|
|
36
40
|
|
|
37
41
|
|
|
@@ -57,7 +57,7 @@ def _approve(spec_id: str, path: Path, stage: str) -> None:
|
|
|
57
57
|
normalized = stage.strip().lower()
|
|
58
58
|
if normalized != "spec":
|
|
59
59
|
msg = (
|
|
60
|
-
f"Stage '{stage}' is not available in DevFlow 0.3.
|
|
60
|
+
f"Stage '{stage}' is not available in DevFlow 0.3.2. "
|
|
61
61
|
"Only the 'spec' stage can be approved."
|
|
62
62
|
)
|
|
63
63
|
raise UnsupportedStageError(msg)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Implementation of the devflow doctor command."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
|
|
10
|
+
from devflow.core.artifacts.errors import ArtifactError
|
|
11
|
+
from devflow.core.config import ConfigError, ConfigManager
|
|
12
|
+
from devflow.core.discovery import DiscoveryError
|
|
13
|
+
from devflow.core.project import ProjectDetector
|
|
14
|
+
from devflow.core.recovery import ChangeInspection, inspect_change
|
|
15
|
+
from devflow.core.state import StateError, WorkflowLocator
|
|
16
|
+
|
|
17
|
+
console = Console()
|
|
18
|
+
error_console = Console(stderr=True)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def doctor(
|
|
22
|
+
spec_id: str = typer.Argument(
|
|
23
|
+
...,
|
|
24
|
+
help="Change id (001) or change directory (001-add-health).",
|
|
25
|
+
),
|
|
26
|
+
path: Path = typer.Argument(
|
|
27
|
+
Path("."),
|
|
28
|
+
help="Project root or a path inside it.",
|
|
29
|
+
),
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Diagnose a change, including artifacts written without state."""
|
|
32
|
+
try:
|
|
33
|
+
healthy = _doctor(spec_id, path)
|
|
34
|
+
except (
|
|
35
|
+
ArtifactError,
|
|
36
|
+
ConfigError,
|
|
37
|
+
DiscoveryError,
|
|
38
|
+
StateError,
|
|
39
|
+
FileNotFoundError,
|
|
40
|
+
NotADirectoryError,
|
|
41
|
+
OSError,
|
|
42
|
+
) as error:
|
|
43
|
+
error_console.print(f"[red]Error:[/red] {error}")
|
|
44
|
+
raise typer.Exit(code=1) from error
|
|
45
|
+
if not healthy:
|
|
46
|
+
raise typer.Exit(code=1)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _doctor(spec_id: str, path: Path) -> bool:
|
|
50
|
+
root = ProjectDetector().find_root(path)
|
|
51
|
+
config = ConfigManager(root).load()
|
|
52
|
+
location = WorkflowLocator(config.specifications_path).find(spec_id)
|
|
53
|
+
inspection = inspect_change(config, location)
|
|
54
|
+
|
|
55
|
+
console.print(f"[bold]Change:[/bold] {location.change}")
|
|
56
|
+
console.print(f"[bold]Directory:[/bold] {location.directory}")
|
|
57
|
+
console.print(
|
|
58
|
+
"[bold]Workflow:[/bold] "
|
|
59
|
+
+ (
|
|
60
|
+
f"present ({inspection.workflow_status})"
|
|
61
|
+
if inspection.workflow_present
|
|
62
|
+
else "[yellow]missing[/yellow]"
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
console.print(
|
|
66
|
+
"[bold]Events:[/bold] "
|
|
67
|
+
+ ("present" if inspection.events_present else "[yellow]missing[/yellow]")
|
|
68
|
+
)
|
|
69
|
+
_print_discovery(inspection)
|
|
70
|
+
_print_spec(inspection)
|
|
71
|
+
|
|
72
|
+
if inspection.warnings:
|
|
73
|
+
console.print("\n[bold]Warnings[/bold]")
|
|
74
|
+
for warning in inspection.warnings:
|
|
75
|
+
console.print(f"[yellow]- {warning}[/yellow]")
|
|
76
|
+
if inspection.orphans:
|
|
77
|
+
console.print("\n[bold]Orphan artifacts[/bold]")
|
|
78
|
+
for orphan in inspection.orphans:
|
|
79
|
+
console.print(f"[yellow]- {orphan} is not registered[/yellow]")
|
|
80
|
+
|
|
81
|
+
if inspection.healthy:
|
|
82
|
+
console.print("\n[bold green]Diagnosis: healthy.[/bold green]")
|
|
83
|
+
return True
|
|
84
|
+
|
|
85
|
+
if inspection.can_recover:
|
|
86
|
+
console.print(
|
|
87
|
+
"\n[bold yellow]Diagnosis: recoverable without regenerating the "
|
|
88
|
+
"artifacts.[/bold yellow]"
|
|
89
|
+
)
|
|
90
|
+
console.print(
|
|
91
|
+
"[bold]Next:[/bold] "
|
|
92
|
+
f"devflow recover {location.spec_id} {root}"
|
|
93
|
+
)
|
|
94
|
+
else:
|
|
95
|
+
console.print(
|
|
96
|
+
"\n[bold yellow]Diagnosis: needs attention.[/bold yellow]"
|
|
97
|
+
)
|
|
98
|
+
console.print(
|
|
99
|
+
"[dim]Resolve the issues above before approving or continuing "
|
|
100
|
+
"this change.[/dim]"
|
|
101
|
+
)
|
|
102
|
+
return False
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _print_discovery(inspection: ChangeInspection) -> None:
|
|
106
|
+
console.print("\n[bold]Discovery[/bold]")
|
|
107
|
+
if not inspection.discovery_present:
|
|
108
|
+
console.print(" [yellow]missing discovery.yaml[/yellow]")
|
|
109
|
+
return
|
|
110
|
+
if inspection.discovery_error:
|
|
111
|
+
console.print(
|
|
112
|
+
f" [yellow]invalid: {inspection.discovery_error}[/yellow]"
|
|
113
|
+
)
|
|
114
|
+
return
|
|
115
|
+
console.print(
|
|
116
|
+
f" status: {inspection.discovery_status} · "
|
|
117
|
+
f"digest: {inspection.discovery_digest}"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _print_spec(inspection: ChangeInspection) -> None:
|
|
122
|
+
console.print("\n[bold]Specification[/bold]")
|
|
123
|
+
if not inspection.spec_present:
|
|
124
|
+
console.print(" [yellow]missing spec.md[/yellow]")
|
|
125
|
+
return
|
|
126
|
+
if inspection.spec_valid:
|
|
127
|
+
console.print(
|
|
128
|
+
f" valid · digest: {inspection.spec_digest}"
|
|
129
|
+
)
|
|
130
|
+
else:
|
|
131
|
+
console.print(
|
|
132
|
+
f" [yellow]invalid: {inspection.spec_error}[/yellow]"
|
|
133
|
+
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Implementation of the devflow recover command."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
|
|
10
|
+
from devflow.core.artifacts.errors import ArtifactError
|
|
11
|
+
from devflow.core.config import ConfigError, ConfigManager
|
|
12
|
+
from devflow.core.discovery import DiscoveryError
|
|
13
|
+
from devflow.core.project import ProjectDetector
|
|
14
|
+
from devflow.core.recovery import recover_change
|
|
15
|
+
from devflow.core.state import StateError, WorkflowLocator
|
|
16
|
+
|
|
17
|
+
console = Console()
|
|
18
|
+
error_console = Console(stderr=True)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def recover(
|
|
22
|
+
spec_id: str = typer.Argument(
|
|
23
|
+
...,
|
|
24
|
+
help="Change id (001) or change directory (001-add-health).",
|
|
25
|
+
),
|
|
26
|
+
path: Path = typer.Argument(
|
|
27
|
+
Path("."),
|
|
28
|
+
help="Project root or a path inside it.",
|
|
29
|
+
),
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Register existing valid artifacts in a missing workflow state."""
|
|
32
|
+
try:
|
|
33
|
+
_recover(spec_id, path)
|
|
34
|
+
except (
|
|
35
|
+
ArtifactError,
|
|
36
|
+
ConfigError,
|
|
37
|
+
DiscoveryError,
|
|
38
|
+
StateError,
|
|
39
|
+
FileNotFoundError,
|
|
40
|
+
NotADirectoryError,
|
|
41
|
+
OSError,
|
|
42
|
+
) as error:
|
|
43
|
+
error_console.print(f"[red]Error:[/red] {error}")
|
|
44
|
+
raise typer.Exit(code=1) from error
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _recover(spec_id: str, path: Path) -> None:
|
|
48
|
+
root = ProjectDetector().find_root(path)
|
|
49
|
+
config = ConfigManager(root).load()
|
|
50
|
+
location = WorkflowLocator(config.specifications_path).find(spec_id)
|
|
51
|
+
result = recover_change(config, location)
|
|
52
|
+
|
|
53
|
+
if not result.recovered:
|
|
54
|
+
console.print(
|
|
55
|
+
f"[bold]{location.change}[/bold] already has workflow state "
|
|
56
|
+
f"([bold]{result.state.status}[/bold]). Nothing to recover."
|
|
57
|
+
)
|
|
58
|
+
console.print(
|
|
59
|
+
f"[dim]Run 'devflow status {location.spec_id}' to inspect it.[/dim]"
|
|
60
|
+
)
|
|
61
|
+
return
|
|
62
|
+
|
|
63
|
+
console.print(
|
|
64
|
+
f"[bold green]Recovered[/bold green] {location.change} without "
|
|
65
|
+
"regenerating its artifacts."
|
|
66
|
+
)
|
|
67
|
+
console.print(f"Workflow status: {result.state.status}")
|
|
68
|
+
console.print(
|
|
69
|
+
"Registered: discovery "
|
|
70
|
+
f"{result.inspection.discovery_digest}"
|
|
71
|
+
)
|
|
72
|
+
console.print(
|
|
73
|
+
f"Registered: spec {result.inspection.spec_digest}"
|
|
74
|
+
)
|
|
75
|
+
console.print(
|
|
76
|
+
"\n[bold]Next:[/bold] review the specification, then run "
|
|
77
|
+
f"'devflow approve {location.spec_id}'."
|
|
78
|
+
)
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"""Inspect and recover changes written without workflow state."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from devflow.core.architecture import (
|
|
8
|
+
ArchitectureError,
|
|
9
|
+
ArchitectureManifest,
|
|
10
|
+
ArchitectureManifestLoader,
|
|
11
|
+
)
|
|
12
|
+
from devflow.core.artifacts.errors import ArtifactError
|
|
13
|
+
from devflow.core.artifacts.store import ArtifactStore
|
|
14
|
+
from devflow.core.config import DevFlowConfig
|
|
15
|
+
from devflow.core.discovery import DiscoveryError, DiscoveryManager
|
|
16
|
+
from devflow.core.specification import SpecificationManager
|
|
17
|
+
from devflow.core.state import (
|
|
18
|
+
ChangeLocation,
|
|
19
|
+
StateError,
|
|
20
|
+
WorkflowLocator,
|
|
21
|
+
WorkflowStateManager,
|
|
22
|
+
)
|
|
23
|
+
from devflow.core.state.models import WorkflowState
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class ChangeInspection:
|
|
28
|
+
"""Read-only diagnostic view of one change directory."""
|
|
29
|
+
|
|
30
|
+
location: ChangeLocation
|
|
31
|
+
events_present: bool
|
|
32
|
+
workflow_present: bool
|
|
33
|
+
workflow_status: str
|
|
34
|
+
discovery_present: bool
|
|
35
|
+
discovery_complete: bool
|
|
36
|
+
discovery_status: str
|
|
37
|
+
discovery_digest: str
|
|
38
|
+
discovery_error: str
|
|
39
|
+
spec_present: bool
|
|
40
|
+
spec_valid: bool
|
|
41
|
+
spec_digest: str
|
|
42
|
+
spec_error: str
|
|
43
|
+
architecture_digest: str
|
|
44
|
+
warnings: tuple[str, ...] = ()
|
|
45
|
+
orphans: tuple[str, ...] = ()
|
|
46
|
+
can_recover: bool = False
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def healthy(self) -> bool:
|
|
50
|
+
"""Return whether the change has a complete, current workflow."""
|
|
51
|
+
return (
|
|
52
|
+
self.events_present
|
|
53
|
+
and self.workflow_present
|
|
54
|
+
and not self.warnings
|
|
55
|
+
and not self.orphans
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass(frozen=True)
|
|
60
|
+
class RecoveryResult:
|
|
61
|
+
"""Outcome of registering orphaned artifacts."""
|
|
62
|
+
|
|
63
|
+
inspection: ChangeInspection
|
|
64
|
+
state: WorkflowState
|
|
65
|
+
recovered: bool = True
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def inspect_change(
|
|
69
|
+
config: DevFlowConfig,
|
|
70
|
+
location: ChangeLocation,
|
|
71
|
+
) -> ChangeInspection:
|
|
72
|
+
"""Inspect workflow, Discovery and specification without repairing."""
|
|
73
|
+
store = ArtifactStore(config.root)
|
|
74
|
+
manager = WorkflowStateManager(
|
|
75
|
+
config.specifications_path,
|
|
76
|
+
project_root=config.root,
|
|
77
|
+
)
|
|
78
|
+
events_present = location.events_path.is_file()
|
|
79
|
+
workflow_present = location.workflow_path.is_file()
|
|
80
|
+
warnings: list[str] = []
|
|
81
|
+
orphans: tuple[str, ...] = ()
|
|
82
|
+
workflow_status = ""
|
|
83
|
+
|
|
84
|
+
if events_present:
|
|
85
|
+
try:
|
|
86
|
+
current = manager.status(location)
|
|
87
|
+
except StateError as error:
|
|
88
|
+
warnings.append(str(error))
|
|
89
|
+
else:
|
|
90
|
+
workflow_status = current.state.status
|
|
91
|
+
warnings.extend(current.warnings)
|
|
92
|
+
orphans = current.orphans
|
|
93
|
+
elif workflow_present:
|
|
94
|
+
warnings.append(
|
|
95
|
+
"workflow.yaml exists without events.jsonl; the projection cannot "
|
|
96
|
+
"be trusted. Restore the event log or remove the orphan projection."
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
discovery_path = location.directory / "discovery.yaml"
|
|
100
|
+
discovery_present = discovery_path.is_file()
|
|
101
|
+
discovery_complete = False
|
|
102
|
+
discovery_status = ""
|
|
103
|
+
discovery_digest = ""
|
|
104
|
+
discovery_error = ""
|
|
105
|
+
if discovery_present:
|
|
106
|
+
try:
|
|
107
|
+
discovery = DiscoveryManager(config.root).load(
|
|
108
|
+
location.directory,
|
|
109
|
+
required=True,
|
|
110
|
+
)
|
|
111
|
+
except DiscoveryError as error:
|
|
112
|
+
discovery_error = str(error)
|
|
113
|
+
else:
|
|
114
|
+
if discovery is not None:
|
|
115
|
+
discovery_complete = discovery.is_complete
|
|
116
|
+
discovery_status = discovery.status
|
|
117
|
+
if not discovery_error:
|
|
118
|
+
try:
|
|
119
|
+
discovery_digest = store.digest_file(discovery_path)
|
|
120
|
+
except ArtifactError as error:
|
|
121
|
+
discovery_error = str(error)
|
|
122
|
+
|
|
123
|
+
architecture: ArchitectureManifest | None = None
|
|
124
|
+
architecture_digest = ""
|
|
125
|
+
try:
|
|
126
|
+
architecture = ArchitectureManifestLoader().load(
|
|
127
|
+
config.root,
|
|
128
|
+
required=config.project_mode == "greenfield",
|
|
129
|
+
)
|
|
130
|
+
except ArchitectureError as error:
|
|
131
|
+
warnings.append(f"Architecture manifest: {error}")
|
|
132
|
+
else:
|
|
133
|
+
if architecture is not None:
|
|
134
|
+
architecture_digest = architecture.digest
|
|
135
|
+
|
|
136
|
+
spec_path = location.directory / "spec.md"
|
|
137
|
+
spec_present = spec_path.is_file()
|
|
138
|
+
spec_valid = False
|
|
139
|
+
spec_digest = ""
|
|
140
|
+
spec_error = ""
|
|
141
|
+
if spec_present:
|
|
142
|
+
try:
|
|
143
|
+
spec_digest = store.digest_file(spec_path)
|
|
144
|
+
spec_text = spec_path.read_text(encoding="utf-8")
|
|
145
|
+
spec_valid, spec_error = SpecificationManager().validate(
|
|
146
|
+
spec_text,
|
|
147
|
+
project_mode=config.project_mode,
|
|
148
|
+
architecture=architecture,
|
|
149
|
+
discovery_digest=discovery_digest or None,
|
|
150
|
+
)
|
|
151
|
+
except (ArtifactError, OSError) as error:
|
|
152
|
+
spec_error = str(error)
|
|
153
|
+
else:
|
|
154
|
+
spec_error = "spec.md is missing"
|
|
155
|
+
|
|
156
|
+
can_recover = (
|
|
157
|
+
not events_present
|
|
158
|
+
and not workflow_present
|
|
159
|
+
and discovery_complete
|
|
160
|
+
and spec_valid
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
return ChangeInspection(
|
|
164
|
+
location=location,
|
|
165
|
+
events_present=events_present,
|
|
166
|
+
workflow_present=workflow_present,
|
|
167
|
+
workflow_status=workflow_status,
|
|
168
|
+
discovery_present=discovery_present,
|
|
169
|
+
discovery_complete=discovery_complete,
|
|
170
|
+
discovery_status=discovery_status,
|
|
171
|
+
discovery_digest=discovery_digest,
|
|
172
|
+
discovery_error=discovery_error,
|
|
173
|
+
spec_present=spec_present,
|
|
174
|
+
spec_valid=spec_valid,
|
|
175
|
+
spec_digest=spec_digest,
|
|
176
|
+
spec_error=spec_error,
|
|
177
|
+
architecture_digest=architecture_digest,
|
|
178
|
+
warnings=tuple(warnings),
|
|
179
|
+
orphans=orphans,
|
|
180
|
+
can_recover=can_recover,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def recover_change(
|
|
185
|
+
config: DevFlowConfig,
|
|
186
|
+
location: ChangeLocation,
|
|
187
|
+
) -> RecoveryResult:
|
|
188
|
+
"""Register existing valid artifacts in a missing workflow state.
|
|
189
|
+
|
|
190
|
+
Running this function again once a workflow exists is safe: it returns
|
|
191
|
+
the current state without changing it.
|
|
192
|
+
"""
|
|
193
|
+
inspection = inspect_change(config, location)
|
|
194
|
+
manager = WorkflowStateManager(
|
|
195
|
+
config.specifications_path,
|
|
196
|
+
project_root=config.root,
|
|
197
|
+
)
|
|
198
|
+
if inspection.events_present:
|
|
199
|
+
return RecoveryResult(
|
|
200
|
+
inspection=inspection,
|
|
201
|
+
state=manager.status(location).state,
|
|
202
|
+
recovered=False,
|
|
203
|
+
)
|
|
204
|
+
if inspection.workflow_present:
|
|
205
|
+
raise StateError(
|
|
206
|
+
f"Cannot recover {location.change}: workflow.yaml exists without "
|
|
207
|
+
"events.jsonl. Restore the event log or remove the orphan "
|
|
208
|
+
"projection, then run 'devflow doctor' again."
|
|
209
|
+
)
|
|
210
|
+
if not inspection.discovery_present:
|
|
211
|
+
raise StateError(
|
|
212
|
+
f"Cannot recover {location.change}: discovery.yaml is missing. "
|
|
213
|
+
"Run 'devflow spec' first."
|
|
214
|
+
)
|
|
215
|
+
if not inspection.discovery_complete:
|
|
216
|
+
detail = inspection.discovery_error or (
|
|
217
|
+
f"Discovery status is '{inspection.discovery_status}'."
|
|
218
|
+
)
|
|
219
|
+
raise StateError(
|
|
220
|
+
f"Cannot recover {location.change}: Discovery is not complete. "
|
|
221
|
+
f"{detail} Resolve it with 'devflow spec --continue "
|
|
222
|
+
f"{location.spec_id}'."
|
|
223
|
+
)
|
|
224
|
+
if not inspection.spec_present:
|
|
225
|
+
raise StateError(
|
|
226
|
+
f"Cannot recover {location.change}: spec.md is missing. "
|
|
227
|
+
f"Run 'devflow spec --continue {location.spec_id}' first."
|
|
228
|
+
)
|
|
229
|
+
if not inspection.spec_valid:
|
|
230
|
+
raise StateError(
|
|
231
|
+
f"Cannot recover {location.change}: spec.md is invalid. "
|
|
232
|
+
f"{inspection.spec_error}"
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
manager.initialize_change(location.directory)
|
|
236
|
+
location = WorkflowLocator(config.specifications_path).from_directory(
|
|
237
|
+
location.directory
|
|
238
|
+
)
|
|
239
|
+
manager.record_artifact(
|
|
240
|
+
location,
|
|
241
|
+
stage="discovery",
|
|
242
|
+
path=location.directory / "discovery.yaml",
|
|
243
|
+
validated=True,
|
|
244
|
+
source="existing",
|
|
245
|
+
)
|
|
246
|
+
metadata: dict[str, str] = {
|
|
247
|
+
"discovery_digest": inspection.discovery_digest,
|
|
248
|
+
}
|
|
249
|
+
if inspection.architecture_digest:
|
|
250
|
+
metadata["architecture_digest"] = inspection.architecture_digest
|
|
251
|
+
state = manager.record_artifact(
|
|
252
|
+
location,
|
|
253
|
+
stage="spec",
|
|
254
|
+
path=location.directory / "spec.md",
|
|
255
|
+
validated=True,
|
|
256
|
+
source="existing",
|
|
257
|
+
metadata=metadata,
|
|
258
|
+
)
|
|
259
|
+
return RecoveryResult(inspection=inspection, state=state)
|
|
@@ -842,7 +842,9 @@ class WorkflowStateManager:
|
|
|
842
842
|
raise InvalidStateError(msg)
|
|
843
843
|
msg = (
|
|
844
844
|
f"No workflow state found for {location.change}. "
|
|
845
|
-
"Run 'devflow spec' first
|
|
845
|
+
"Run 'devflow spec' first, or run 'devflow doctor "
|
|
846
|
+
f"{location.spec_id}' if the change already has context.md, "
|
|
847
|
+
"discovery.yaml and spec.md."
|
|
846
848
|
)
|
|
847
849
|
raise ChangeNotFoundError(msg)
|
|
848
850
|
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""Tests for workflow diagnostics and recovery."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import shutil
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from typer.testing import CliRunner
|
|
9
|
+
|
|
10
|
+
from devflow.cli import app
|
|
11
|
+
|
|
12
|
+
runner = CliRunner()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _write(path: Path, content: str) -> None:
|
|
16
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
17
|
+
path.write_text(content, encoding="utf-8")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _project(root: Path) -> None:
|
|
21
|
+
_write(
|
|
22
|
+
root / "pyproject.toml",
|
|
23
|
+
"""
|
|
24
|
+
[project]
|
|
25
|
+
name = "demo"
|
|
26
|
+
version = "0.1.0"
|
|
27
|
+
requires-python = ">=3.11"
|
|
28
|
+
""".lstrip(),
|
|
29
|
+
)
|
|
30
|
+
result = runner.invoke(
|
|
31
|
+
app,
|
|
32
|
+
["init", str(root), "--yes", "--harness", "none"],
|
|
33
|
+
)
|
|
34
|
+
assert result.exit_code == 0, result.output
|
|
35
|
+
result = runner.invoke(
|
|
36
|
+
app,
|
|
37
|
+
["spec", "Add a health endpoint", str(root), "--no-agent"],
|
|
38
|
+
)
|
|
39
|
+
assert result.exit_code == 0, result.output
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _change(root: Path) -> Path:
|
|
43
|
+
return next((root / ".devflow" / "specs").glob("001-*"))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _orphan(root: Path) -> Path:
|
|
47
|
+
"""Keep the artifacts and remove the workflow state."""
|
|
48
|
+
change = _change(root)
|
|
49
|
+
for name in ("workflow.yaml", "events.jsonl"):
|
|
50
|
+
(change / name).unlink()
|
|
51
|
+
shutil.rmtree(change / "runs")
|
|
52
|
+
return change
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_doctor_reports_healthy_change(tmp_path: Path) -> None:
|
|
56
|
+
_project(tmp_path)
|
|
57
|
+
change = _change(tmp_path)
|
|
58
|
+
|
|
59
|
+
result = runner.invoke(
|
|
60
|
+
app,
|
|
61
|
+
["doctor", change.name, str(tmp_path)],
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
assert result.exit_code == 0, result.output
|
|
65
|
+
assert "Diagnosis: healthy." in result.output
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_doctor_detects_orphaned_artifacts(tmp_path: Path) -> None:
|
|
69
|
+
_project(tmp_path)
|
|
70
|
+
change = _orphan(tmp_path)
|
|
71
|
+
|
|
72
|
+
result = runner.invoke(
|
|
73
|
+
app,
|
|
74
|
+
["doctor", change.name, str(tmp_path)],
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
assert result.exit_code == 1
|
|
78
|
+
assert "Workflow:" in result.output
|
|
79
|
+
assert "missing" in result.output
|
|
80
|
+
assert "recoverable without regenerating" in result.output
|
|
81
|
+
assert "devflow recover 001" in result.output
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_recover_registers_existing_artifacts(tmp_path: Path) -> None:
|
|
85
|
+
_project(tmp_path)
|
|
86
|
+
change = _orphan(tmp_path)
|
|
87
|
+
spec_before = (change / "spec.md").read_text(encoding="utf-8")
|
|
88
|
+
|
|
89
|
+
result = runner.invoke(
|
|
90
|
+
app,
|
|
91
|
+
["recover", change.name, str(tmp_path)],
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
assert result.exit_code == 0, result.output
|
|
95
|
+
assert "Recovered" in result.output
|
|
96
|
+
assert (change / "workflow.yaml").is_file()
|
|
97
|
+
assert (change / "events.jsonl").is_file()
|
|
98
|
+
assert (change / "runs").is_dir()
|
|
99
|
+
assert (change / "spec.md").read_text(encoding="utf-8") == spec_before
|
|
100
|
+
|
|
101
|
+
status_result = runner.invoke(
|
|
102
|
+
app,
|
|
103
|
+
["status", change.name, str(tmp_path)],
|
|
104
|
+
)
|
|
105
|
+
assert status_result.exit_code == 0, status_result.output
|
|
106
|
+
assert "Status: draft" in status_result.output
|
|
107
|
+
assert "discovery: validated" in status_result.output
|
|
108
|
+
assert "spec: validated" in status_result.output
|
|
109
|
+
|
|
110
|
+
approve_result = runner.invoke(
|
|
111
|
+
app,
|
|
112
|
+
["approve", change.name, str(tmp_path)],
|
|
113
|
+
)
|
|
114
|
+
assert approve_result.exit_code == 0, approve_result.output
|
|
115
|
+
assert "Workflow status: spec_approved" in approve_result.output
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def test_recover_is_idempotent(tmp_path: Path) -> None:
|
|
119
|
+
_project(tmp_path)
|
|
120
|
+
change = _orphan(tmp_path)
|
|
121
|
+
|
|
122
|
+
first = runner.invoke(
|
|
123
|
+
app,
|
|
124
|
+
["recover", change.name, str(tmp_path)],
|
|
125
|
+
)
|
|
126
|
+
assert first.exit_code == 0, first.output
|
|
127
|
+
|
|
128
|
+
second = runner.invoke(
|
|
129
|
+
app,
|
|
130
|
+
["recover", change.name, str(tmp_path)],
|
|
131
|
+
)
|
|
132
|
+
assert second.exit_code == 0, second.output
|
|
133
|
+
assert "already has workflow state" in second.output
|
|
134
|
+
assert "Run 'devflow status 001'" in second.output
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def test_recover_refuses_invalid_spec(tmp_path: Path) -> None:
|
|
138
|
+
_project(tmp_path)
|
|
139
|
+
change = _orphan(tmp_path)
|
|
140
|
+
_write(
|
|
141
|
+
change / "spec.md",
|
|
142
|
+
"# Not a specification\n\nNo required sections.\n",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
result = runner.invoke(
|
|
146
|
+
app,
|
|
147
|
+
["recover", change.name, str(tmp_path)],
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
assert result.exit_code == 1
|
|
151
|
+
assert "spec.md is invalid" in result.output
|
|
152
|
+
assert not (change / "workflow.yaml").exists()
|
|
153
|
+
assert not (change / "events.jsonl").exists()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/django-backend/profile.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{devflow_toolkit-0.3.1 → devflow_toolkit-0.3.2}/src/devflow/profiles/fastapi-backend/profile.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|