From 55afe77e67c1893bd0a2bc8e364783c65870bf30 Mon Sep 17 00:00:00 2001 From: Russell Jones Date: Mon, 11 May 2026 16:59:38 -0400 Subject: [PATCH 01/45] Add spec for feature extract-template-startup-scripts-01KRCDD7 --- kitty-specs/extract-template-startup-scripts-01KRCDD7/spec.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 kitty-specs/extract-template-startup-scripts-01KRCDD7/spec.md diff --git a/kitty-specs/extract-template-startup-scripts-01KRCDD7/spec.md b/kitty-specs/extract-template-startup-scripts-01KRCDD7/spec.md new file mode 100644 index 0000000..e69de29 From 2d9f64302e43913ab7c9b461b95f691d906ec4ab Mon Sep 17 00:00:00 2001 From: Russell Jones Date: Mon, 11 May 2026 16:59:39 -0400 Subject: [PATCH 02/45] Add meta for feature extract-template-startup-scripts-01KRCDD7 --- .../meta.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 kitty-specs/extract-template-startup-scripts-01KRCDD7/meta.json diff --git a/kitty-specs/extract-template-startup-scripts-01KRCDD7/meta.json b/kitty-specs/extract-template-startup-scripts-01KRCDD7/meta.json new file mode 100644 index 0000000..ce3c959 --- /dev/null +++ b/kitty-specs/extract-template-startup-scripts-01KRCDD7/meta.json @@ -0,0 +1,10 @@ +{ + "created_at": "2026-05-11T20:59:39.092220+00:00", + "friendly_name": "extract template startup scripts", + "mission_id": "01KRCDD730HK8SWWHAADCM8KQH", + "mission_number": null, + "mission_slug": "extract-template-startup-scripts-01KRCDD7", + "mission_type": "software-dev", + "slug": "extract-template-startup-scripts-01KRCDD7", + "target_branch": "extract-template-startup-scripts" +} From d9f53873cdebbeef7243be4a550d482fe5f4b35f Mon Sep 17 00:00:00 2001 From: Russell Jones Date: Mon, 11 May 2026 17:02:58 -0400 Subject: [PATCH 03/45] spec: extract-template-startup-scripts mission (issue #76) Add Spec Kitty mission spec for extracting inline bash from each template's coder_agent.main.startup_script heredoc into versioned .sh files under scripts/templates// + scripts/shared/, loaded from template.tf via file() or templatefile(). Behavior-preserving refactor; gated by the #71 test surface (closed 2026-05-10). Mission ID: 01KRCDD730HK8SWWHAADCM8KQH Source: ddev/coder-ddev#76 Co-Authored-By: Claude Opus 4.7 (1M context) --- .../checklists/requirements.md | 41 +++++ .../meta.json | 6 +- .../spec.md | 168 ++++++++++++++++++ .../status.events.jsonl | 0 .../tasks/.gitkeep | 0 .../tasks/README.md | 64 +++++++ 6 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 kitty-specs/extract-template-startup-scripts-01KRCDD7/checklists/requirements.md create mode 100644 kitty-specs/extract-template-startup-scripts-01KRCDD7/status.events.jsonl create mode 100644 kitty-specs/extract-template-startup-scripts-01KRCDD7/tasks/.gitkeep create mode 100644 kitty-specs/extract-template-startup-scripts-01KRCDD7/tasks/README.md diff --git a/kitty-specs/extract-template-startup-scripts-01KRCDD7/checklists/requirements.md b/kitty-specs/extract-template-startup-scripts-01KRCDD7/checklists/requirements.md new file mode 100644 index 0000000..d76cd5f --- /dev/null +++ b/kitty-specs/extract-template-startup-scripts-01KRCDD7/checklists/requirements.md @@ -0,0 +1,41 @@ +# Specification Quality Checklist: Extract Template Startup Scripts + +**Purpose**: Validate specification completeness and quality before proceeding to planning +**Created**: 2026-05-11 +**Feature**: [spec.md](../spec.md) +**Source**: ddev/coder-ddev#76 + +## Content Quality + +- [x] No implementation details (languages, frameworks, APIs) — *spec names Terraform/`file()`/`templatefile()` and bash because those are the inherent technologies of the codebase being refactored, not new implementation choices* +- [x] Focused on user value and business needs — reviewer/contributor ergonomics, no end-user-visible change +- [x] Written for stakeholders (maintainers + contributors) +- [x] All mandatory sections completed + +## Requirement Completeness + +- [x] No [NEEDS CLARIFICATION] markers remain +- [x] Requirements are testable and unambiguous +- [x] Requirement types are separated (Functional / Non-Functional / Constraints) +- [x] IDs are unique across FR-###, NFR-###, and C-### entries +- [x] All requirement rows include a non-empty Status value +- [x] Non-functional requirements include measurable thresholds (NFR-001 within 10% baseline, NFR-003 ≤ 20 lines, etc.) +- [x] Success criteria are measurable +- [x] Success criteria are technology-agnostic where possible — Success Criterion #1 references `template.tf` because that file's existence is the problem being solved; #3 references `terraform test` because that is the actual #71 test surface +- [x] All acceptance scenarios are defined (A–D) +- [x] Edge cases are identified (`$${}` escaping, embedded heredocs, ordering) +- [x] Scope is clearly bounded (in/out scope sections + bulk-edit classification) +- [x] Dependencies and assumptions identified + +## Feature Readiness + +- [x] All functional requirements have clear acceptance criteria (mapped through Scenarios A–D and Success Criteria) +- [x] User scenarios cover primary flows (boot identical, reviewer experience, shared-helper reuse, variable flow) +- [x] Feature meets measurable outcomes defined in Success Criteria (6 criteria, all measurable) +- [x] No implementation details leak into specification beyond what the existing codebase already mandates + +## Notes + +- This is a refactor with high constraint density. The spec deliberately calls out specific line ranges (`template.tf` heredoc bounds) because those are the artifacts being modified — they aren't implementation details, they're the subject. +- One reasonable judgement call was loading mechanism (`file()` vs `templatefile()`) — the spec keeps both available rather than forcing one, with FR-005 / FR-006 governing correctness either way. +- Plan phase should produce: (a) per-template interpolation manifest, (b) duplication side-by-side, (c) WP breakdown likely sequenced one-template-at-a-time so each WP is independently reviewable, with shared helpers extracted in a final consolidation WP or in-flight as duplication emerges. diff --git a/kitty-specs/extract-template-startup-scripts-01KRCDD7/meta.json b/kitty-specs/extract-template-startup-scripts-01KRCDD7/meta.json index ce3c959..8f5d103 100644 --- a/kitty-specs/extract-template-startup-scripts-01KRCDD7/meta.json +++ b/kitty-specs/extract-template-startup-scripts-01KRCDD7/meta.json @@ -1,10 +1,12 @@ { "created_at": "2026-05-11T20:59:39.092220+00:00", - "friendly_name": "extract template startup scripts", + "friendly_name": "Extract Template Startup Scripts", "mission_id": "01KRCDD730HK8SWWHAADCM8KQH", "mission_number": null, "mission_slug": "extract-template-startup-scripts-01KRCDD7", "mission_type": "software-dev", "slug": "extract-template-startup-scripts-01KRCDD7", - "target_branch": "extract-template-startup-scripts" + "source_description": "GitHub issue ddev/coder-ddev#76 — refactor inline bash in terraform templates into reusable scripts. Prerequisite #71 (automated tests) closed 2026-05-10.", + "target_branch": "extract-template-startup-scripts", + "vcs": "git" } diff --git a/kitty-specs/extract-template-startup-scripts-01KRCDD7/spec.md b/kitty-specs/extract-template-startup-scripts-01KRCDD7/spec.md index e69de29..37418e5 100644 --- a/kitty-specs/extract-template-startup-scripts-01KRCDD7/spec.md +++ b/kitty-specs/extract-template-startup-scripts-01KRCDD7/spec.md @@ -0,0 +1,168 @@ +# Mission Specification: Extract Template Startup Scripts + +**Mission ID:** `01KRCDD730HK8SWWHAADCM8KQH` +**Mission slug:** `extract-template-startup-scripts-01KRCDD7` +**Mission type:** software-dev +**Source:** GitHub issue [ddev/coder-ddev#76](https://github.com/ddev/coder-ddev/issues/76) +**Feature branch:** `extract-template-startup-scripts` (off `upstream/main`) +**Final merge target:** `ddev/coder-ddev:main` (draft PR) + +## 1. Problem & Motivation + +The four Coder workspace templates — `drupal-contrib/`, `drupal-core/`, `freeform/`, `user-defined-web/` — each define their `coder_agent.main.startup_script` as a large inline bash heredoc inside `template.tf`. Today the inline bash spans roughly: + +| Template | startup_script heredoc range (in `template.tf`) | Approx. lines | +| ------------------- | ----------------------------------------------- | ------------- | +| `drupal-contrib` | line 295 → 987 | ~692 | +| `drupal-core` | line 324 → 1245 | ~921 | +| `freeform` | line 196 → 421 | ~225 | +| `user-defined-web` | line 230 → 570 | ~340 | + +Total: **~2,178 lines** of bash embedded in HCL across four files. + +Consequences today: +- Bash is interpolated inside Terraform strings, so shellcheck, formatters, and IDE jump-to-definition do not work. +- Reviewers cannot diff a behavior change in startup logic without scrolling through `template.tf` noise. +- Logic that recurs across templates (e.g., DDEV setup, `coder-files` hydration, dockerd bring-up) is copy-pasted rather than factored. +- Contributors cannot easily run a startup step in isolation for debugging. + +Issue author's framing: *"Currently there is lots of poor inline bash in the templates. This should go into scripts, many of which can be shared between templates."* + +CLAUDE.md already documents the canonical startup flow (Permissions → Home init → Git SSH → File copy → dockerd → DDEV config → DDEV verify → Environment), so the structural decomposition target is well-understood. + +## 2. Goal + +Extract the inline bash inside each template's `coder_agent.main.startup_script` heredoc into versioned `.sh` files, factor cross-template duplication into a shared library, and have the templates load these scripts via Terraform's `file()` (or `templatefile()` where Terraform-level variable interpolation is required). Preserve current runtime behavior exactly. + +## 3. Scope + +### In scope +- The single `startup_script = <<-EOT ... EOT` block inside each of the four templates' `template.tf`. +- Creation of new directories: `scripts/templates//` and `scripts/shared/` at the repo root. +- Refactoring duplicated logic across the four startup scripts into shared helpers. +- Updating each `template.tf` to consume the extracted script via `file()` or `templatefile()`. +- Confirming the existing test surface from issue #71 (`terraform -chdir=