Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .planning/PROJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ An AI developer can run one safe, repeatable workflow and receive a complete, wo
- ✓ Doctor can emit human-readable and JSON readiness output — existing seed
- ✓ The seed can discover tools, repositories, and basic service health — existing seed
- ✓ Governance, schemas, Pester, static analysis, Windows CI, ADRs, and requirement traceability — validated in Phase 1
- ✓ Manifest, inventory, ownership, path safety, and ledger-only uninstall — validated in Phase 2
- ✓ Deterministic plan/apply, durable recovery, repair, and repository fail-closed behavior — validated in Phase 3

### Active

- [ ] Make manifest parsing, allowlisting, path handling, and destructive operations fail closed.
- [ ] Make setup and upgrade idempotent, observable, transactional, and recoverable after partial failure.
- [ ] Generate and merge profile-specific AI client, MCP, skill, workspace, and service configuration without overwriting unrelated user state.
- [ ] Provide actionable diagnostics, structured logs, state inventory, recovery, and redacted support bundles.
- [ ] Publish signed, reproducible releases with provenance and clean-machine end-to-end verification.
Expand Down Expand Up @@ -82,4 +82,4 @@ This document evolves at phase transitions and milestone boundaries.
4. Update context with evidence, users, feedback, and operational metrics.

---
*Last updated: 2026-06-11 after Phase 1 completion*
*Last updated: 2026-06-12 after Phase 3 completion*
28 changes: 14 additions & 14 deletions .planning/REQUIREMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

### Setup, Upgrade, and Recovery

- [ ] **OPS-01**: User can run one documented interactive or non-interactive setup command with equivalent outcomes.
- [ ] **OPS-02**: Setup and upgrade first produce a deterministic operation plan showing changes, skips, commands, sources, and risks.
- [ ] **OPS-03**: Re-running setup or upgrade on satisfied desired state performs no unintended mutations.
- [ ] **OPS-04**: Every external process and network-affecting operation emits observable, correlated, auditable events.
- [ ] **OPS-05**: Partial failure leaves a durable journal and actionable resume, retry, or rollback guidance.
- [ ] **OPS-06**: Repository synchronization detects dirty/diverged state and refuses destructive reconciliation by default.
- [ ] **OPS-07**: User can run a repair command that safely reconciles detected drift through the same plan/apply engine.
- [x] **OPS-01**: User can run one documented interactive or non-interactive setup command with equivalent outcomes.
- [x] **OPS-02**: Setup and upgrade first produce a deterministic operation plan showing changes, skips, commands, sources, and risks.
- [x] **OPS-03**: Re-running setup or upgrade on satisfied desired state performs no unintended mutations.
- [x] **OPS-04**: Every external process and network-affecting operation emits observable, correlated, auditable events.
- [x] **OPS-05**: Partial failure leaves a durable journal and actionable resume, retry, or rollback guidance.
- [x] **OPS-06**: Repository synchronization detects dirty/diverged state and refuses destructive reconciliation by default.
- [x] **OPS-07**: User can run a repair command that safely reconciles detected drift through the same plan/apply engine.

### Client and Workspace Integration

Expand Down Expand Up @@ -102,13 +102,13 @@
| SAFE-03 | Phase 2 | Complete |
| SAFE-04 | Phase 2 | Complete |
| SAFE-05 | Phase 2 | Complete |
| OPS-01 | Phase 3 | Pending |
| OPS-02 | Phase 3 | Pending |
| OPS-03 | Phase 3 | Pending |
| OPS-04 | Phase 3 | Pending |
| OPS-05 | Phase 3 | Pending |
| OPS-06 | Phase 3 | Pending |
| OPS-07 | Phase 3 | Pending |
| OPS-01 | Phase 3 | Complete |
| OPS-02 | Phase 3 | Complete |
| OPS-03 | Phase 3 | Complete |
| OPS-04 | Phase 3 | Complete |
| OPS-05 | Phase 3 | Complete |
| OPS-06 | Phase 3 | Complete |
| OPS-07 | Phase 3 | Complete |
| CFG-01 | Phase 4 | Pending |
| CFG-02 | Phase 4 | Pending |
| CFG-03 | Phase 4 | Pending |
Expand Down
2 changes: 1 addition & 1 deletion .planning/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CAS Workstation v1 progresses from a functional seed to a trustworthy desired-st
3. Canonical path and ownership policies reject forbidden, escaping, junction, and unrelated targets.
4. Uninstall preview and apply can affect only ledger-owned resources, with backup and atomic-write contracts verified.

### Phase 3: Transactional Plan and Apply Engine
### Phase 3: Transactional Plan and Apply Engine (Complete: 2026-06-12)

**Goal:** Setup, upgrade, and repair use one observable, idempotent, recoverable plan/apply engine.

Expand Down
26 changes: 13 additions & 13 deletions .planning/STATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
gsd_state_version: 1.0
milestone: v1.0
milestone_name: milestone
status: ready_to_plan
last_updated: "2026-06-11T19:11:00.000Z"
status: ready_to_discuss
last_updated: "2026-06-12T17:45:00.000Z"
progress:
total_phases: 7
completed_phases: 2
total_plans: 6
completed_plans: 6
percent: 29
completed_phases: 3
total_plans: 9
completed_plans: 9
percent: 43
---

# Project State
Expand All @@ -19,21 +19,21 @@ progress:
See: `.planning/PROJECT.md` (updated 2026-06-11)

**Core value:** An AI developer can run one safe, repeatable workflow and receive a complete, working workstation without manually discovering or reconciling prerequisites.
**Current focus:** Phase 3 - transactional plan and apply engine
**Current focus:** Phase 4 - client, skills, and workspace profiles

## Current Position

Phase: 3
Phase: 4
Plan: Not started

- Project initialization: complete
- Research: complete
- Requirements: 35 v1 requirements, all mapped
- Roadmap: 7 phases
- Completed phases: Phase 1 and Phase 2
- Active phase: Phase 3 - Transactional Plan and Apply Engine
- Phase 2 plans: 3/3 complete
- Implementation: Phase 2 verified
- Completed phases: Phase 1, Phase 2, and Phase 3
- Active phase: Phase 4 - Client, Skills, and Workspace Profiles
- Phase 3 plans: 3/3 complete
- Implementation: Phase 3 verified

## Workflow

Expand All @@ -47,7 +47,7 @@ Plan: Not started

## Next Action

Run `$gsd-discuss-phase 3` before planning Transactional Plan and Apply Engine.
Run `$gsd-discuss-phase 4` before planning client, skills, and workspace profiles.

## Decisions and Risks

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
phase: 03-transactional-plan-and-apply-engine
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
- scripts/Cas.Workstation.psm1
- schemas/operation-plan.schema.json
- tests/Plan.Tests.ps1
autonomous: true
requirements: [OPS-01, OPS-02, OPS-03]
---

<objective>
Build a deterministic, inspectable operation planner shared by all operation modes.
</objective>

<tasks>
<task type="auto">
<name>Implement deterministic planning contracts</name>
<files>scripts/Cas.Workstation.psm1, schemas/operation-plan.schema.json, tests/Plan.Tests.ps1</files>
<action>Create stable operations from desired state and inventory, stable plan IDs, explicit changes/skips/commands/sources/risks, and equivalent interactive/non-interactive behavior.</action>
<verify>Invoke-Pester tests/Plan.Tests.ps1</verify>
</task>
</tasks>

<success_criteria>Equivalent inputs produce byte-equivalent canonical plans and satisfied state produces skips.</success_criteria>
<output>Create `03-01-SUMMARY.md` after execution.</output>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
phase: 03-transactional-plan-and-apply-engine
plan: 01
requirements-completed: [OPS-01, OPS-02, OPS-03]
completed: 2026-06-12
---

# Phase 3 Plan 1 Summary

Added a deterministic operation planner with stable plan identity, explicit
commands, sources, risks, reasons, and idempotent skip outcomes.

## Verification

- Plan Pester tests: 3/3 passed.
- Operation-plan schema fixtures: passed.
- `git diff --check`: passed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
phase: 03-transactional-plan-and-apply-engine
plan: 02
type: execute
wave: 2
depends_on: ["03-01"]
files_modified:
- scripts/Cas.Workstation.psm1
- schemas/managed-state.schema.json
- schemas/event.schema.json
- tests/Apply.Tests.ps1
autonomous: true
requirements: [OPS-04, OPS-05]
---

<objective>
Build a durable correlated apply engine with bounded retry and recovery guidance.
</objective>

<tasks>
<task type="auto">
<name>Implement journaled apply and recovery</name>
<files>scripts/Cas.Workstation.psm1, schemas/managed-state.schema.json, schemas/event.schema.json, tests/Apply.Tests.ps1</files>
<action>Persist journal state before and after operations, emit correlated JSONL events, stop safely on failure, and support bounded retry/resume guidance through an injected operation handler.</action>
<verify>Invoke-Pester tests/Apply.Tests.ps1</verify>
</task>
</tasks>

<success_criteria>Partial failure is durable, observable, bounded, and actionable.</success_criteria>
<output>Create `03-02-SUMMARY.md` after execution.</output>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
phase: 03-transactional-plan-and-apply-engine
plan: 02
requirements-completed: [OPS-04, OPS-05]
completed: 2026-06-12
---

# Phase 3 Plan 2 Summary

Added atomic operation journals, correlated JSONL events, pre/post-operation
persistence, bounded retry, fail-stop behavior, and resumable execution.

## Verification

- Apply Pester tests: 3/3 passed.
- PSScriptAnalyzer: no findings.
- `git diff --check`: passed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
phase: 03-transactional-plan-and-apply-engine
plan: 03
type: execute
wave: 3
depends_on: ["03-01", "03-02"]
files_modified:
- scripts/Cas.Workstation.psm1
- setup.ps1
- upgrade.ps1
- repair.ps1
- tests/RepositorySafety.Tests.ps1
- tests/OperationWorkflow.Tests.ps1
- README.md
- docs/traceability.json
autonomous: true
requirements: [OPS-01, OPS-06, OPS-07]
---

<objective>
Route setup, upgrade, and repair through the engine and fail closed on risky repository state.
</objective>

<tasks>
<task type="auto">
<name>Integrate workflows and repository safety</name>
<files>scripts/Cas.Workstation.psm1, setup.ps1, upgrade.ps1, repair.ps1, tests/RepositorySafety.Tests.ps1, tests/OperationWorkflow.Tests.ps1</files>
<action>Add fail-closed Git synchronization checks and make all operational entry points preview-first wrappers over the shared planner/apply engine.</action>
<verify>Invoke-Pester tests/RepositorySafety.Tests.ps1,tests/OperationWorkflow.Tests.ps1</verify>
</task>
<task type="auto">
<name>Complete Phase 3 evidence</name>
<files>README.md, docs/traceability.json</files>
<action>Document plan/apply/recovery usage and map OPS-01 through OPS-07 to executable evidence.</action>
<verify>.\Invoke-Quality.ps1</verify>
</task>
</tasks>

<success_criteria>All operational modes share one safe engine and risky repositories fail closed.</success_criteria>
<output>Create `03-03-SUMMARY.md` after execution.</output>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
phase: 03-transactional-plan-and-apply-engine
plan: 03
requirements-completed: [OPS-01, OPS-06, OPS-07]
completed: 2026-06-12
---

# Phase 3 Plan 3 Summary

Routed setup, upgrade, and repair through one preview-first plan/apply engine,
added persisted CLI resume, enforced fail-closed repository synchronization,
and declared the four public CAS golden-path repositories in the full profile.

## Verification

- Phase 3 focused tests: 14/14 passed.
- Full quality gate: 46/46 tests passed with contracts, governance, and static analysis.
- `git diff --check`: passed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Phase 3 Context: Transactional Plan and Apply Engine

## Scope

Setup, upgrade, and repair must use one deterministic planner and one apply
engine. Preview is the default. Mutation requires explicit apply intent.

## Decisions

- Plans are derived from resolved desired state plus current inventory and use
stable operation IDs and ordering.
- Correlation IDs identify executions, while deterministic plan IDs identify
equivalent desired/current-state inputs.
- Every apply writes JSONL events and an atomic durable journal before and
after each operation.
- Resume and retry are bounded. Automatic rollback is not implied for external
package or Git operations; the journal must provide explicit guidance.
- Existing repositories that are dirty, detached, on an unexpected branch, or
diverged from the configured upstream fail closed.
- Setup, upgrade, and repair are modes over the same engine, not separate
mutation implementations.

## Safety Boundaries

- No external process runs during planning.
- Apply accepts only a plan generated by the engine and validates its digest.
- Satisfied resources become `skip` operations.
- Failed operations stop the run and leave later operations pending.
- Retry count is bounded and persisted.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Phase 3 Research: Transactional Plan and Apply Engine

## Recommended Design

Use a PowerShell orchestration core with serializable plan, journal, and event
contracts. Keep external execution behind an injected operation handler so
Pester can prove behavior without installing packages or contacting networks.

## Key Risks

- Random identifiers or timestamps in plan identity break deterministic preview.
- Treating command presence as desired-state satisfaction breaks idempotency.
- Git pull against dirty or diverged repositories can destroy user work.
- Writing journal state only after an operation loses recovery evidence.
- Unbounded retry can repeat unsafe external side effects.

## Verification Strategy

- Compare canonical plan JSON from equivalent interactive/non-interactive calls.
- Apply a synthetic plan twice and assert the second plan contains skips only.
- Inject operation failure and prove journal/event correlation and resume scope.
- Exercise dirty, detached, unexpected-branch, and diverged Git status parsing.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
status: passed
phase: 03-transactional-plan-and-apply-engine
verified: 2026-06-12
score: 7/7
---

# Phase 3 Verification

Phase 3 achieved its goal: setup, upgrade, and repair now use one observable,
idempotent, recoverable plan/apply engine.

## Requirement Evidence

| Requirement | Evidence | Result |
|-------------|----------|--------|
| OPS-01 | `tests/Plan.Tests.ps1`, `tests/OperationWorkflow.Tests.ps1` | Passed |
| OPS-02 | `tests/Plan.Tests.ps1` | Passed |
| OPS-03 | `tests/Plan.Tests.ps1` | Passed |
| OPS-04 | `tests/Apply.Tests.ps1` | Passed |
| OPS-05 | `tests/Apply.Tests.ps1`, `tests/OperationWorkflow.Tests.ps1` | Passed |
| OPS-06 | `tests/RepositorySafety.Tests.ps1` | Passed |
| OPS-07 | `tests/OperationWorkflow.Tests.ps1` | Passed |

## Quality Evidence

- Full quality gate: passed.
- Pester: 46/46 passed.
- PSScriptAnalyzer: passed.
- Contract fixtures: passed.
- Governance validation: 35 requirements mapped, 21 verified.
- `git diff --check`: passed after planning document normalization.
Loading
Loading