Skip to content

feat(seed): local dev seed wired across every surface - #21

Merged
AndresL230 merged 9 commits into
mainfrom
feat/local-seed-data
Jul 7, 2026
Merged

feat(seed): local dev seed wired across every surface#21
AndresL230 merged 9 commits into
mainfrom
feat/local-seed-data

Conversation

@AndresL230

@AndresL230 AndresL230 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What

Restores a local dev seed that lights up every Canopy surface — My Work, Feed, Docs, Roadmap, Triage, Search — against the current schema. The old scripts/seed-dev.sql had rotted: it INSERTs into focus (dropped in 0014) so it aborts outright, and it never touched the tables My Work and Roadmap now read from (events, people, plan, milestone_progress, pr_summaries, issue_summaries, identity_tasks).

How it works

Plain JSON fixtures under fixtures/dev/ are the source of truth. npm run seed resets local D1 and loads them; the app's existing D1 read paths run unchanged, and FTS5 triggers auto-index on insert (so Search needs no direct seeding). It pairs with the pre-existing DEV_LOGIN toggle — flip DEV_LOGIN=AndresL230 in .dev.vars, run npm run seed, and every surface has data as that user.

  • scripts/seed/build.mjs — pure, dependency-free SQL builder (buildSeedStatements, targetsRemote), unit-tested.
  • scripts/seed/reset.mjs — the canonical data-table reset, now imported by test/apply-migrations.ts too, so the harness and the seed share one truncation list (no silent drift when a migration adds a table).
  • fixtures/dev/*.json — docs (incl. a staged version), feed, ADRs, triage, roadmap (plan + phase + progress), events (subject AndresL230), an unmapped-login identity task.
  • scripts/seed-dev.mjs — local-only CLI loader; refuses --remote and hardcodes --local, so it is structurally unable to touch prod. Never imported by the worker.
  • test/seed-coverage.test.ts — a guard that runs the real builder against Miniflare D1 and asserts every surface returns data (My Work activity + to-dos, roadmap progress, search hits, all four triage queues, feed tag join).

Verification

  • Scoped suite: 53 files / 392 tests passing; npm run typecheck clean.
  • Live wrangler dev E2E confirmed /roadmap, /me/dashboard (person=Andres, 2 PRs + 2 to-dos), /search, and /proposals all render seeded data.

Notes

  • .dev.vars is git-ignored; the DEV_LOGIN=AndresL230 change is local only and not in this PR.
  • Out of scope: the remote/prod seed (build-prod-seed.mjs / seed-prod.sql) and the separate pre-existing issue that a nested .claude/worktrees checkout pollutes bare npm test collection.

Design: docs/superpowers/specs/2026-07-06-local-seed-data-design.md · Plan: docs/superpowers/plans/2026-07-06-local-seed-data.md

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a local-only seed workflow with expanded fixture data so My Work, Feed, Docs, Roadmap, Triage, and Search render with realistic content.
    • Introduced a one-command local seeding script (npm run seed) that generates and applies ordered SQL to local D1.
    • Added detailed planning/design documentation for the restored local seed system.
  • Bug Fixes
    • Fixed local seeding failures that previously led to empty or incomplete development views.
  • Tests
    • Added automated coverage checks and SQL builder tests to ensure seeded surfaces return non-empty results and stable SQL output ordering.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b218258a-a2ff-4d20-9005-347e3f5d65ad

📥 Commits

Reviewing files that changed from the base of the PR and between 2dc257e and 5a6d016.

📒 Files selected for processing (9)
  • fixtures/dev/adrs.json
  • fixtures/dev/docs.json
  • fixtures/dev/events.json
  • fixtures/dev/feed.json
  • fixtures/dev/identity.json
  • fixtures/dev/roadmap.json
  • fixtures/dev/triage.json
  • scripts/seed/build.mjs
  • test/seed-coverage.test.ts
✅ Files skipped from review due to trivial changes (6)
  • fixtures/dev/adrs.json
  • fixtures/dev/feed.json
  • fixtures/dev/identity.json
  • fixtures/dev/roadmap.json
  • fixtures/dev/triage.json
  • fixtures/dev/docs.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/seed/build.mjs
  • test/seed-coverage.test.ts

📝 Walkthrough

Walkthrough

Adds a local-only D1 seeding system with shared reset statements, SQL generation from JSON fixtures, a local seed CLI, npm wiring, coverage tests, and supporting planning/design docs.

Changes

Local Seed Data Implementation

Layer / File(s) Summary
Planning and design docs
docs/superpowers/plans/2026-07-06-local-seed-data.md, docs/superpowers/specs/2026-07-06-local-seed-data-design.md
Adds implementation and design documents describing the local seed approach, constraints, fixture layout, coverage matrix, and verification steps.
Canonical reset statements and shared test usage
scripts/seed/reset.mjs, scripts/seed/reset.d.mts, test/apply-migrations.ts
Adds the shared reset statement array and its type declaration, then updates the migration test harness to reuse those statements.
SQL builder for seed statements
scripts/seed/build.mjs, scripts/seed/build.d.mts, test/seed-build.test.ts
Adds SQL literal helpers, remote-target detection, and ordered seed statement generation across docs, feed, adrs, triage, roadmap, events, and identity data, with unit tests for escaping and conditional inserts.
Local seed CLI and npm wiring
scripts/seed-dev.mjs, package.json, fixtures/dev/*.json, test/seed-coverage.test.ts
Adds the local-only seeding CLI, fixture loading, temporary SQL execution through wrangler, the npm seed script, dev fixtures, and the seed coverage test that populates Miniflare D1 from those fixtures.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Dev
  participant SeedCLI
  participant Builder
  participant Wrangler

  Dev->>SeedCLI: npm run seed
  SeedCLI->>SeedCLI: reject --remote
  SeedCLI->>SeedCLI: load fixtures/dev/*.json
  SeedCLI->>Builder: buildSeedStatements(fixtures)
  Builder-->>SeedCLI: SQL statements
  SeedCLI->>Wrangler: d1 execute canopy --local
  Wrangler-->>Dev: local D1 seeded
Loading

Related issues: None found.

Related PRs: None found.

Suggested labels: documentation, tooling, tests

Suggested reviewers: None identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: a local dev seed wired across multiple app surfaces.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/local-seed-data

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
canopy 5a6d016 Commit Preview URL

Branch Preview URL
Jul 07 2026, 02:26 AM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/superpowers/specs/2026-07-06-local-seed-data-design.md (1)

122-124: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Clarify that identity_tasks is seeded explicitly.

The loader writes identity_tasks from fixtures/dev/identity.json; it does not infer that row from the unmapped-login event. Reword this so the spec doesn’t imply an automatic generation step that the implementation doesn’t have.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/superpowers/specs/2026-07-06-local-seed-data-design.md` around lines 122
- 124, The spec text is implying that the `identity_tasks` row is generated from
the unmapped-login event, but the loader actually seeds it explicitly from
`fixtures/dev/identity.json`. Reword the affected passage to state that the
staged doc version, ADR draft, milestone proposal, and one explicitly seeded
`identity_tasks` row are present so Triage’s Review and Maintenance surfaces
both have something to act on. Keep the wording aligned with the loader behavior
and the `identity_tasks`/`fixtures/dev/identity.json` symbols so it is clear no
inference step exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/superpowers/plans/2026-07-06-local-seed-data.md`:
- Around line 115-120: The seed data mapping is using the wrong field for
roadmap state values: update the fixture generation in the local seed data
script to read and emit milestones.status instead of phase. Keep the
human-readable phase labels separate, and ensure the code that builds the INSERT
statements for the roadmap entries uses the status field so the seeded values
match done, in_progress, and upcoming.

---

Nitpick comments:
In `@docs/superpowers/specs/2026-07-06-local-seed-data-design.md`:
- Around line 122-124: The spec text is implying that the `identity_tasks` row
is generated from the unmapped-login event, but the loader actually seeds it
explicitly from `fixtures/dev/identity.json`. Reword the affected passage to
state that the staged doc version, ADR draft, milestone proposal, and one
explicitly seeded `identity_tasks` row are present so Triage’s Review and
Maintenance surfaces both have something to act on. Keep the wording aligned
with the loader behavior and the `identity_tasks`/`fixtures/dev/identity.json`
symbols so it is clear no inference step exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c9cbf00d-93e7-4add-8304-99ab734d5d8d

📥 Commits

Reviewing files that changed from the base of the PR and between afdf1aa and 2dc257e.

📒 Files selected for processing (18)
  • docs/superpowers/plans/2026-07-06-local-seed-data.md
  • docs/superpowers/specs/2026-07-06-local-seed-data-design.md
  • fixtures/dev/adrs.json
  • fixtures/dev/docs.json
  • fixtures/dev/events.json
  • fixtures/dev/feed.json
  • fixtures/dev/identity.json
  • fixtures/dev/roadmap.json
  • fixtures/dev/triage.json
  • package.json
  • scripts/seed-dev.mjs
  • scripts/seed/build.d.mts
  • scripts/seed/build.mjs
  • scripts/seed/reset.d.mts
  • scripts/seed/reset.mjs
  • test/apply-migrations.ts
  • test/seed-build.test.ts
  • test/seed-coverage.test.ts

Comment on lines +115 to +120
`${num(f.id)}, ${q(f.author)}, ${q(f.summary)}, ${q(f.body)}, ${jsonLit(f.artifacts)}, ${q(f.created_at)})`
);
for (const t of f.tags ?? []) {
s.push(`INSERT INTO entry_tags (tag, entry_type, entry_id) VALUES (${q(t)}, 'feed', ${q(String(f.id))})`);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use status here, not phase.

The values you list (done / in_progress / upcoming) are milestones.status; phase in the fixture is the human label (Now, Weeks 3-4, Next). This mismatch will confuse anyone updating the roadmap seed or validating the coverage matrix.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/superpowers/plans/2026-07-06-local-seed-data.md` around lines 115 - 120,
The seed data mapping is using the wrong field for roadmap state values: update
the fixture generation in the local seed data script to read and emit
milestones.status instead of phase. Keep the human-readable phase labels
separate, and ensure the code that builds the INSERT statements for the roadmap
entries uses the status field so the seeded values match done, in_progress, and
upcoming.

AndresL230 and others added 2 commits July 6, 2026 22:14
Builder emits the 0018 structured columns (pr_summaries title/what/why/impact,
issue_summaries title/next_step) from structured fixture objects; event fixtures
carry PR base.ref and issue milestone title/due_on. Greatly expanded every
surface's fixtures (11 docs across both spaces, 14 feed entries, 6 ADRs, 5 triage
+ 3 milestone proposals, 7 roadmap milestones across phases, 13 events, 2 identity
tasks). Coverage guard asserts the structured DTO fields and the wider dataset.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@AndresL230
AndresL230 merged commit 6a49723 into main Jul 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant