@hxp-tools/godplans 0.0.0-stage → 2.0.1
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.
- package/CHANGELOG.md +1202 -0
- package/LICENSE +21 -0
- package/PROMPT.md +4006 -0
- package/README.md +245 -2
- package/bin/godplans.js +93 -0
- package/docs/ARCHITECTURE.md +136 -0
- package/docs/RELEASING.md +107 -0
- package/docs/assets/badge-approved.svg +12 -0
- package/docs/assets/badge-done.svg +11 -0
- package/docs/assets/badge-graded.svg +12 -0
- package/docs/assets/badge-validated.svg +10 -0
- package/docs/assets/hero.svg +37 -0
- package/docs/assets/quest-map.svg +53 -0
- package/evals/README.md +295 -0
- package/evals/cases/brownfield-cli/EXPECTATIONS +15 -0
- package/evals/cases/brownfield-cli/INPUT/package.json +9 -0
- package/evals/cases/brownfield-cli/INPUT/src/cli.js +4 -0
- package/evals/cases/brownfield-cli/INPUT/src/format.js +3 -0
- package/evals/cases/brownfield-cli/INPUT/test/cli.test.js +7 -0
- package/evals/cases/brownfield-cli/REQUEST.baseline.md +10 -0
- package/evals/cases/brownfield-cli/REQUEST.md +10 -0
- package/evals/cases/compliance-refusal/EXPECTATIONS +4 -0
- package/evals/cases/compliance-refusal/REQUEST.baseline.md +9 -0
- package/evals/cases/compliance-refusal/REQUEST.md +8 -0
- package/evals/cases/greenfield-saas/EXPECTATIONS +21 -0
- package/evals/cases/greenfield-saas/REQUEST.baseline.md +11 -0
- package/evals/cases/greenfield-saas/REQUEST.md +11 -0
- package/evals/cases/nested-pillars/EXPECTATIONS +12 -0
- package/evals/cases/nested-pillars/REQUEST.baseline.md +10 -0
- package/evals/cases/nested-pillars/REQUEST.md +11 -0
- package/evals/cases/observability-evidence/EXPECTATIONS +10 -0
- package/evals/cases/observability-evidence/REQUEST.baseline.md +10 -0
- package/evals/cases/observability-evidence/REQUEST.md +11 -0
- package/evals/cases/product-business/EXPECTATIONS +18 -0
- package/evals/cases/product-business/REQUEST.baseline.md +13 -0
- package/evals/cases/product-business/REQUEST.md +14 -0
- package/evals/cases/product-form-routing/EXPECTATIONS +13 -0
- package/evals/cases/product-form-routing/REQUEST.baseline.md +11 -0
- package/evals/cases/product-form-routing/REQUEST.md +11 -0
- package/evals/cases/prose-integrity/EXPECTATIONS +19 -0
- package/evals/cases/prose-integrity/REQUEST.baseline.md +19 -0
- package/evals/cases/prose-integrity/REQUEST.md +20 -0
- package/evals/cases/replan-preserves-history/EXPECTATIONS +9 -0
- package/evals/cases/replan-preserves-history/INPUT/.godplans/PLAN.mdx +115 -0
- package/evals/cases/replan-preserves-history/INPUT/package.json +5 -0
- package/evals/cases/replan-preserves-history/REQUEST.baseline.md +10 -0
- package/evals/cases/replan-preserves-history/REQUEST.md +10 -0
- package/evals/cases/stale-prepublication/EXPECTATIONS +10 -0
- package/evals/cases/stale-prepublication/REQUEST.baseline.md +12 -0
- package/evals/cases/stale-prepublication/REQUEST.md +13 -0
- package/evals/cases/stale-source-evidence/EXPECTATIONS +10 -0
- package/evals/cases/stale-source-evidence/INPUT/package.json +8 -0
- package/evals/cases/stale-source-evidence/REQUEST.baseline.md +11 -0
- package/evals/cases/stale-source-evidence/REQUEST.md +12 -0
- package/evals/cases/weekend-library/EXPECTATIONS +19 -0
- package/evals/cases/weekend-library/REQUEST.baseline.md +10 -0
- package/evals/cases/weekend-library/REQUEST.md +11 -0
- package/evals/cases-roster.txt +19 -0
- package/evals/external/GRADE.schema.json +39 -0
- package/evals/external/README.md +42 -0
- package/evals/external/RUBRIC.md +32 -0
- package/evals/metrics/context-cost.json +154 -0
- package/evals/outcomes/README.md +65 -0
- package/evals/outcomes/cases/tenant-notes-api/REQUEST.baseline.md +14 -0
- package/evals/outcomes/cases/tenant-notes-api/REQUEST.md +13 -0
- package/evals/outcomes/cases/tenant-notes-api/VERIFY.sh +13 -0
- package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/README.md +93 -0
- package/evals/outcomes/results/2026-07-23-tenant-notes-api-codex/treatment/plan/PLAN.json +547 -0
- package/evals/runners/claude-baseline.sh +4 -0
- package/evals/runners/claude-grade.sh +3 -0
- package/evals/runners/claude.sh +4 -0
- package/evals/runners/codex-baseline.sh +181 -0
- package/evals/runners/codex-builder.sh +96 -0
- package/evals/runners/codex-godaudits.sh +84 -0
- package/evals/runners/codex.sh +147 -0
- package/evals/runners/gemini-baseline.sh +4 -0
- package/evals/runners/gemini-grade.sh +3 -0
- package/evals/runners/gemini.sh +4 -0
- package/evals/runners/vendor-cli.sh +257 -0
- package/evals/runners/vendor-grade.sh +82 -0
- package/install.sh +323 -0
- package/package.json +91 -4
- package/requirements/skills-ref.txt +2 -0
- package/scripts/build-catalog.js +114 -0
- package/scripts/build-prompt.sh +257 -0
- package/scripts/context-metrics.js +118 -0
- package/scripts/eval-external.js +226 -0
- package/scripts/eval-matrix.sh +172 -0
- package/scripts/eval-outcome.js +143 -0
- package/scripts/eval.sh +321 -0
- package/scripts/lint-parity.js +331 -0
- package/scripts/lint.sh +743 -0
- package/scripts/outcome-summary.js +126 -0
- package/scripts/release-check.sh +108 -0
- package/scripts/release-prepare.js +41 -0
- package/scripts/summarize-eval.js +91 -0
- package/scripts/summarize-matrix.js +101 -0
- package/scripts/version-sync.js +65 -0
- package/skills/godplans/SKILL.md +192 -0
- package/skills/godplans/references/agent-memory.md +168 -0
- package/skills/godplans/references/architecture.md +189 -0
- package/skills/godplans/references/build.md +130 -0
- package/skills/godplans/references/business.md +252 -0
- package/skills/godplans/references/code-quality.md +165 -0
- package/skills/godplans/references/compliance.md +59 -0
- package/skills/godplans/references/database.md +157 -0
- package/skills/godplans/references/deploy.md +146 -0
- package/skills/godplans/references/discovery.md +297 -0
- package/skills/godplans/references/doc-set.md +243 -0
- package/skills/godplans/references/exemplar.md +228 -0
- package/skills/godplans/references/launch.md +162 -0
- package/skills/godplans/references/llm.md +132 -0
- package/skills/godplans/references/observe.md +178 -0
- package/skills/godplans/references/plan-format.md +340 -0
- package/skills/godplans/references/product.md +130 -0
- package/skills/godplans/references/repo.md +184 -0
- package/skills/godplans/references/roadmap.md +158 -0
- package/skills/godplans/references/security.md +156 -0
- package/skills/godplans/references/seo.md +133 -0
- package/skills/godplans/references/stack.md +133 -0
- package/skills/godplans/references/style-genome.md +198 -0
- package/skills/godplans/references/ui.md +153 -0
- package/skills/godplans/references/ux.md +150 -0
- package/skills/godplans/schemas/PLAN.schema.json +275 -0
- package/skills/godplans/schemas/PLAN.v1.schema.json +258 -0
- package/skills/godplans/scripts/plan-halflife.sh +76 -0
- package/skills/godplans/scripts/style-stats.py +630 -0
- package/skills/godplans/scripts/validate-plan.sh +1709 -0
- package/skills/godplans/templates/PLAN.template.mdx +269 -0
- package/tests/agent-memory-guidance.sh +32 -0
- package/tests/build-catalog.sh +81 -0
- package/tests/codex-runner.sh +139 -0
- package/tests/eval-harness.sh +377 -0
- package/tests/evidence-harnesses.sh +243 -0
- package/tests/fixtures/plan-json-v1-1.13.0.json +472 -0
- package/tests/install-regression.sh +246 -0
- package/tests/lib/plan-schema-check.js +163 -0
- package/tests/lint-selftest.sh +582 -0
- package/tests/package-contents.sh +143 -0
- package/tests/portable-prompt.test.sh +261 -0
- package/tests/release-tooling.sh +204 -0
- package/tests/run.sh +14 -0
- package/tests/script-usage.sh +37 -0
- package/tests/style-stats.sh +170 -0
- package/tests/validate-plan.sh +1970 -0
- package/tests/vendor-runner.sh +291 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Database planning module
|
|
2
|
+
|
|
3
|
+
Plans the data layer so checks a database auditor would perform later become requirements before schema work begins. The orchestrator loads this module for any archetype that persists state (saas-dashboard, api-service, mobile-app backend, ml-pipeline metadata); it is excluded, with a stated reason, only for stateless CLIs, static marketing sites, and pure libraries.
|
|
4
|
+
|
|
5
|
+
## Lineage
|
|
6
|
+
|
|
7
|
+
Descends from dbauditor (hannsxpeter/auditor-suite), the read-only after-the-fact audit of schema, relationships, indexing, queries, transactions, migrations, data protection, search, and scale. dbauditor grades shipped DDL, never the ORM's promise, and hunts paper controls (FK NOT VALID never VALIDATEd, RLS ENABLEd but not FORCEd, inert @Transactional). This module inverts every one of its checks into a plan-time obligation: the discipline that carries over is evidence over assertion, the substitution test on every sentence, one owning dimension per defect class, and the rule that a control which does not bind in the database does not count.
|
|
8
|
+
|
|
9
|
+
## Decisions to force
|
|
10
|
+
|
|
11
|
+
1. Engine and workload paradigm.
|
|
12
|
+
- Question: OLTP relational, document/KV, analytics warehouse, or mixed, and which engine?
|
|
13
|
+
- Why locked in: every later choice (types, constraints, index kinds, migration mechanics) is engine-specific; a paradigm swap is a rewrite, not a refactor.
|
|
14
|
+
- Options: Postgres (native uuid, jsonb, RLS, EXCLUDE, partial indexes), MySQL 8+ (only if the team owns it; CHECK enforced from 8.0.16, utf8mb4 mandatory), SQLite (single-writer tools only; PRAGMA foreign_keys per connection), document store (only when access patterns are genuinely aggregate-shaped).
|
|
15
|
+
- Default: Postgres.
|
|
16
|
+
2. Primary key strategy.
|
|
17
|
+
- Question: BIGINT identity, UUIDv7/ULID, or UUIDv4, decided per table class?
|
|
18
|
+
- Why locked in: the PK type is mirrored into every FK column and every index; migrating an INT PK approaching 2.1 billion rows is a multi-deploy expand-contract under load.
|
|
19
|
+
- Options: BIGINT identity (internal, high-insert), UUIDv7/ULID as native uuid (externally exposed IDs, distributed writers). Never random UUIDv4 as a clustered PK on hot tables; never INT/SERIAL on tables that can grow.
|
|
20
|
+
- Default: BIGINT identity internally, UUIDv7 for anything exposed in a URL or API.
|
|
21
|
+
3. Tenancy isolation model.
|
|
22
|
+
- Question: shared schema with RLS FORCEd, schema-per-tenant, or database-per-tenant?
|
|
23
|
+
- Why locked in: retrofitting isolation onto a shared schema means touching every table, every query, and every index.
|
|
24
|
+
- Options: shared schema with tenant_id plus Postgres RLS FORCEd (fits most SaaS), schema- or database-per-tenant (few large or regulated tenants). App-layer WHERE alone is not an option; dbauditor scores it a hard Critical.
|
|
25
|
+
- Default: shared schema, tenant_id NOT NULL on every tenant-owned table, RLS FORCEd with policies that survive pooled connections.
|
|
26
|
+
4. Money representation.
|
|
27
|
+
- Question: integer minor units or NUMERIC(p,s), and where does currency live?
|
|
28
|
+
- Why locked in: float contamination spreads through backfills, reports, and downstream copies; correcting it means re-deriving balances from history.
|
|
29
|
+
- Options: BIGINT minor units plus currency column, or NUMERIC(p,s) with explicit precision and scale. FLOAT/DOUBLE/REAL for money is a hard Critical and a grade cap.
|
|
30
|
+
- Default: integer minor units with a currency column.
|
|
31
|
+
5. Time representation.
|
|
32
|
+
- Question: which columns are instants and which are wall-clock concepts, and what does the DDL say?
|
|
33
|
+
- Why locked in: a TIMESTAMP-without-tz column filled from mixed zones is unrecoverable; you cannot reconstruct the original offsets.
|
|
34
|
+
- Options: TIMESTAMPTZ written in UTC for all instants; date or plain timestamp only for genuine wall-clock concepts (birthdays, local opening hours).
|
|
35
|
+
- Default: TIMESTAMPTZ + UTC, decided per column in the plan's data model.
|
|
36
|
+
6. Soft-delete policy.
|
|
37
|
+
- Question: hard delete, deleted_at soft delete, or archive tables, per table class?
|
|
38
|
+
- Why locked in: soft delete changes every UNIQUE (partial index WHERE deleted_at IS NULL), every FK story (parent invisible but children satisfied), and GDPR erasure reach.
|
|
39
|
+
- Options: hard delete for disposable rows; soft delete with declared partial-unique and child-visibility rules; archive-and-purge for audit data.
|
|
40
|
+
- Default: hard delete unless a requirement names recovery or audit; if soft delete, the plan states the full ruleset.
|
|
41
|
+
|
|
42
|
+
## Plan requirements
|
|
43
|
+
|
|
44
|
+
1. R-DB-1 PLAN.mdx declares the workload paradigm (OLTP/analytics/document/mixed), engine and version, data sensitivity classes present (PII/PHI/financial), tenancy model, and per-table expected scale (rows at 12 months, write rate); any deliberate denormalization names its maintenance mechanism.
|
|
45
|
+
Criterion: WHEN the database domain is applicable THE PLAN SHALL contain a data-layer profile block stating paradigm, engine, sensitivity, tenancy, and per-table scale, and SHALL pair every denormalized or derived column with the job or trigger that maintains it.
|
|
46
|
+
2. R-DB-2 The plan's data model (erDiagram plus table list) gives every table a primary key, models every M:N through a junction table with composite PK and both FKs, and contains no CSV/JSON id lists, no repeating-group columns (phone1/2/3), and no unjustified EAV.
|
|
47
|
+
Criterion: WHEN the plan defines a table THE PLAN SHALL state its PK, and IF a many-to-many relationship exists THE PLAN SHALL model it as a junction table, never as a delimited or JSON list column.
|
|
48
|
+
3. R-DB-3 Status and type fields are single state columns constrained by CHECK, lookup FK, or (non-Postgres-native) enum, never boolean-flag explosions; polymorphic associations use per-parent FK columns with an exclusive-arc CHECK; a naming convention is declared and applied; any planned triggers or stored procedures are listed with an owner.
|
|
49
|
+
Criterion: WHEN a lifecycle or category is modeled THE PLAN SHALL specify one constrained state column, and IF a row can belong to one of several parent types THE PLAN SHALL specify per-parent FKs with an exclusive-arc CHECK rather than an unenforceable type+id pair.
|
|
50
|
+
4. R-DB-4 Money columns are integer minor units or NUMERIC with explicit precision and scale, always beside a currency column; the plan contains no floating-point money anywhere, including intermediates.
|
|
51
|
+
Criterion: IF the system stores or moves money THE PLAN SHALL type it as integer minor units or NUMERIC(p,s) with a currency column, and SHALL state that FLOAT/DOUBLE/REAL is banned for monetary values.
|
|
52
|
+
5. R-DB-5 Temporal, identifier, and storage types are decided per column: TIMESTAMPTZ in UTC for instants, native uuid (or BINARY(16)) never VARCHAR(36), UUIDv7/ULID or BIGINT for high-insert PKs, jsonb never json/TEXT, utf8mb4 at server, table, and driver DSN on MySQL, intentional string lengths, BIGINT on any table or mirrored FK that can approach 2.1 billion, blobs in object storage by reference, NULL instead of sentinel values.
|
|
53
|
+
Criterion: WHEN the plan types a column THE PLAN SHALL use the native type for its semantic (timestamptz, uuid, jsonb, boolean), and IF a table can exceed INT range THE PLAN SHALL type its PK and every mirroring FK as BIGINT.
|
|
54
|
+
6. R-DB-6 Every column referencing another table's key gets a real DB FOREIGN KEY with an intentional ON DELETE/ON UPDATE decided per child: CASCADE only for disposable children (sessions, tokens, join rows), RESTRICT or managed delete for independently valuable data (orders, invoices, ledger, audit); FK types and collations match both sides; mandatory relationships are NOT NULL; cascade behavior lives in DDL, not only in ORM options.
|
|
55
|
+
Criterion: WHEN the plan defines a relationship THE PLAN SHALL specify the DDL FOREIGN KEY and its ON DELETE action with a one-line justification, and SHALL NOT specify CASCADE reaching financial or audit tables.
|
|
56
|
+
7. R-DB-7 The soft-delete policy (if any) states how children, hard FKs, and partial-unique indexes behave when the parent is soft-deleted; cross-database or cross-service references are paired with an outbox or reconciliation job plus a periodic orphan check; right-to-erasure reaches denormalized copies, caches, and logs.
|
|
57
|
+
Criterion: IF soft delete or a cross-service reference exists THE PLAN SHALL state the child-row and orphan-handling policy, and IF PII is stored THE PLAN SHALL trace erasure through every denormalized copy.
|
|
58
|
+
8. R-DB-8 Constraints are DB-enforced: NOT NULL on every required column, DB DEFAULTs mirroring app defaults, CHECK constraints for domain and range invariants (qty >= 0, start <= end), CHECK ((a IS NULL) = (b IS NULL)) for paired nullables, natural business keys (email, sku, (tenant_id, slug)) under DB UNIQUE beside any surrogate PK, tenant-scoped UNIQUEs including tenant_id, and nullable-UNIQUE semantics decided explicitly (NULLS NOT DISTINCT or a partial index).
|
|
59
|
+
Criterion: WHEN the plan states an invariant THE PLAN SHALL bind it with a named DDL constraint, and SHALL NOT delegate uniqueness or ranges to application validation alone.
|
|
60
|
+
9. R-DB-9 Every payment, webhook, or dedup path persists a UNIQUE-constrained idempotency key in the same transaction as its effect; overlap invariants (bookings, reservations) use EXCLUDE USING gist, not check-then-act.
|
|
61
|
+
Criterion: IF a retried or externally triggered write path exists THE PLAN SHALL specify its UNIQUE idempotency key and the transaction it is written in.
|
|
62
|
+
10. R-DB-10 The plan maps every hot query (list endpoints, joins, auth lookups, search) to the exact index that serves it, in a table: query shape -> index DDL. Every FK child column is indexed on Postgres/Oracle; composites are ordered equality-first-range-last and aligned with ORDER BY direction; case-insensitive lookups get an expression index or citext.
|
|
63
|
+
Criterion: WHEN the plan names a query path THE PLAN SHALL name the index that serves it including column order, and WHEN a FOREIGN KEY is planned on Postgres THE PLAN SHALL index the child column.
|
|
64
|
+
11. R-DB-11 Index types match access patterns: GIN for jsonb/array/tsvector/trigram, GiST for ranges and nearest-neighbor, BRIN for append-only time order; no redundant prefix-duplicate indexes, no lone low-cardinality single-column indexes, few composites rather than many singles on write-heavy tables.
|
|
65
|
+
Criterion: IF a non-scalar or pattern-match access exists THE PLAN SHALL choose the matching index type, and SHALL NOT plan a B-tree for a leading-wildcard or jsonb predicate.
|
|
66
|
+
12. R-DB-12 The query layer section specifies the eager-loading primitive per relation to prevent N+1, explicit column projections on hot paths, mandatory pagination with a hard cap on every list path using keyset/seek (deep OFFSET banned), sargable predicates with typed bind parameters, batch reads via WHERE id = ANY(:ids), and a COUNT strategy (estimate, counter, or LIMIT k+1) for large tables.
|
|
67
|
+
Criterion: WHEN the plan defines a list endpoint THE PLAN SHALL specify keyset pagination with a hard cap and the index it rides, and WHEN a relation is rendered in a collection THE PLAN SHALL name its eager-load mechanism.
|
|
68
|
+
13. R-DB-13 Runtime posture is planned: statement, lock, and idle-in-transaction timeouts set at the role default and verified to survive the pooler; connection pool sized against max_connections (including serverless fan-out); session and connection cleanup on all error paths.
|
|
69
|
+
Criterion: WHEN the plan configures the database THE PLAN SHALL state the three timeouts and pool sizing arithmetic, and IF a transaction-mode pooler is used THE PLAN SHALL forbid session state it cannot carry (prepared statements, SET, advisory locks) or choose a compatible mode.
|
|
70
|
+
14. R-DB-14 Every multi-statement write is wrapped in one transaction with try/finally commit/rollback; read-modify-write is replaced by atomic SET col = col + delta, version-checked UPDATE (version in the WHERE, rowcount checked), or SELECT FOR UPDATE; one canonical lock ordering is declared; bulk writes are chunked; isolation level is chosen per invariant with a 40001 retry loop wherever SERIALIZABLE is used.
|
|
71
|
+
Criterion: WHEN the plan defines a write path touching mutable shared values THE PLAN SHALL name the concurrency mechanism (atomic update, optimistic version, or row lock) and the transaction boundary.
|
|
72
|
+
15. R-DB-15 No external I/O (HTTP, payment, email) inside an open transaction: commit first or use a transactional outbox; cross-service workflows get sagas or compensation plus a durable outbox; cache-fronted reads get an explicit invalidation and stampede policy implementing the tier, staleness budget, and trigger set by R-ARCH-23.
|
|
73
|
+
Criterion: IF a write path calls an external service THE PLAN SHALL sequence it as commit-then-call or route it through an outbox table written in the same transaction.
|
|
74
|
+
16. R-DB-16 Migration policy is expand-contract for every rename, drop, and type change (add, dual-write, backfill in batches with separate commits, cut over, tombstone, drop across deploys); CREATE INDEX CONCURRENTLY outside a transaction; ADD COLUMN without volatile defaults then batched backfill; SET NOT NULL via CHECK NOT VALID -> VALIDATE -> SET NOT NULL; every NOT VALID constraint has its VALIDATE step scheduled in the same plan; lock_timeout set for the migration session.
|
|
75
|
+
Criterion: WHEN the plan schedules a schema change on a populated table THE PLAN SHALL decompose it into lock-safe steps across deploys, and SHALL NOT plan a single-step rewrite, rename, or direct SET NOT NULL.
|
|
76
|
+
17. R-DB-17 Every migration is reversible with a tested down path or an explicit backup gate for destructive steps; DDL is idempotent; a single migration head is enforced; a CI migration safety gate (strong_migrations or squawk lint, dry-run, up-then-down round trip) is a task in the pipeline from day one.
|
|
77
|
+
Criterion: WHEN the plan introduces migration tooling THE PLAN SHALL include a CI gate task that lints migrations and round-trips up-then-down, and IF a migration is destructive THE PLAN SHALL require a backup gate before it runs.
|
|
78
|
+
18. R-DB-18 Access is parameterized queries only, with an allowlist for dynamic sort and table identifiers; the app connects as a least-privilege role with DML only on its tables; a separate migration identity owns DDL; secrets live in env or vault, never in the repo (rotation required on any historical exposure); TLS is verify-full; encryption at rest is declared in IaC; the database binds to a private network only.
|
|
79
|
+
Criterion: WHEN the plan defines database access THE PLAN SHALL specify parameterized queries, the two-role split (app DML vs migration DDL), verify-full TLS, and private binding, and SHALL NOT place a connection string in any committed file.
|
|
80
|
+
19. R-DB-19 Data protection is DB-enforced: multi-tenant isolation in the database (never app WHERE alone), any RLS policy pooler-safe; column-level encryption or tokenization for PII/PHI; passwords hashed with the KDF R-SEC-6 names (argon2id by default); CVV never stored; an audit trail on sensitive tables; views over PII scoped and security_invoker.
|
|
81
|
+
Criterion: IF the system is multi-tenant THE PLAN SHALL enforce isolation at the database: FORCEd RLS on a shared schema, else a per-tenant schema or database bound through the connection's role (the only option without RLS), and IF PII/PHI/financial data is stored THE PLAN SHALL name the column-level protection per sensitive column.
|
|
82
|
+
20. R-DB-20 If a search surface exists, the plan picks the primitive per feature up front: pg_trgm GIN for substring and fuzzy, tsvector plus GIN with a matching config for FTS, relevance ranking always specified; external engines sync via transactional outbox plus CDC with delete propagation and a documented reindex path (handler dual-write banned); vector columns get an ANN index whose operator class matches the query's distance operator, built after load; tenant and ACL filtering is enforced in the source of truth.
|
|
83
|
+
Criterion: WHEN the plan includes a search feature THE PLAN SHALL name the index primitive and ranking function per feature, and IF an external engine is used THE PLAN SHALL specify outbox-plus-CDC sync with delete propagation.
|
|
84
|
+
21. R-DB-21 Every growth-bearing table (events, logs, audit, sessions, outbox) gets a retention or TTL policy with an automated reaper or partition drop; large append-only tables get declarative range partitioning with automated partition management; hot single-row counters become sharded counters or append-and-aggregate ledgers; partitioning and read routing implement the key and per-entity read stances set by R-ARCH-21, and post-write reads on money, auth, or inventory get read-your-writes routing; slow-query observability (pg_stat_statements or equivalent), backup/PITR posture, and any materialized-view refresh (scheduled, CONCURRENT) are stated.
|
|
85
|
+
Criterion: WHEN the plan defines an append-only or high-churn table THE PLAN SHALL pair it with its retention mechanism, and WHEN replicas serve reads THE PLAN SHALL declare read-your-writes routing for money, auth, and inventory paths.
|
|
86
|
+
22. R-DB-22 The plan enforces invariants in shipped DDL, not ORM annotations, bans every paper-control pattern by name (NOT VALID without a scheduled VALIDATE, UNIQUE on nullable without a semantics decision, RLS ENABLEd but not FORCEd, @Transactional without verified semantics, timeouts that die at the pooler), and includes a strengths-to-preserve inventory (real FKs, NUMERIC or integer money, keyset pagination, DB-enforced uniqueness) that later tasks must not regress.
|
|
87
|
+
Criterion: WHEN the plan claims an integrity or security control THE PLAN SHALL bind it to specific DDL a later audit can read, and SHALL list the strengths inventory that executing agents are forbidden to regress.
|
|
88
|
+
23. R-DB-23 The plan requires money flows to reconcile end to end across every stage and store: the amount authorized or charged equals the amount persisted on the order or booking, the invoice, the settlement, any refund, and any marketplace payout or transfer, with add-ons, discounts, credits, and tax accounted on every side; provider status (payment, refund, transfer, payout) is confirmed before a local record is marked final; a marketplace refund reverses the already-released transfer; and a later price or status change reconciles the already-settled invoice rather than silently diverging.
|
|
89
|
+
Criterion: WHEN a payment, refund, payout, or transfer path is planned THE PLAN SHALL name the fields compared at each reconciliation point and SHALL include a test that drives a paid order through an add-on change, a refund, and a marketplace payout and asserts every side of the ledger balances.
|
|
90
|
+
|
|
91
|
+
## Task seeds
|
|
92
|
+
|
|
93
|
+
- [ ] GP-xxx Author initial schema migration with DDL-enforced invariants
|
|
94
|
+
- Files: db/migrations/0001_init.sql, docs/data-model.md
|
|
95
|
+
- Acceptance: every CREATE TABLE has a PRIMARY KEY; every *_id column has REFERENCES with an explicit ON DELETE; money columns are BIGINT or NUMERIC with a currency column; instants are TIMESTAMPTZ; natural keys carry UNIQUE; required columns carry NOT NULL
|
|
96
|
+
- Verify: ! grep -niwE 'float|double|real' db/migrations/0001_init.sql && test "$(grep -c REFERENCES db/migrations/0001_init.sql)" -eq <relationship-count>
|
|
97
|
+
- Requirements: R-DB-2, R-DB-4, R-DB-5, R-DB-6, R-DB-8
|
|
98
|
+
- [ ] GP-xxx Build the query-to-index map and index migration
|
|
99
|
+
- Files: docs/index-map.md, db/migrations/0002_indexes.sql
|
|
100
|
+
- Acceptance: docs/index-map.md is a table mapping every list endpoint, join, and auth lookup to one index DDL line; every FK child column appears; composites are equality-first-range-last; CREATE INDEX uses CONCURRENTLY
|
|
101
|
+
- Verify: test "$(grep -c 'CREATE INDEX CONCURRENTLY' db/migrations/0002_indexes.sql)" -eq "$(($(grep -c '^|' docs/index-map.md) - 2))"
|
|
102
|
+
- Requirements: R-DB-10, R-DB-11
|
|
103
|
+
- [ ] GP-xxx Implement transaction and concurrency policy on write paths
|
|
104
|
+
- Files: src/db/tx.ts, src/services/payments.ts, docs/concurrency.md
|
|
105
|
+
- Acceptance: multi-statement writes go through one withTransaction helper with try/finally; balance updates are atomic SET or version-checked UPDATE with rowcount asserted; no HTTP client import inside a transaction body; idempotency key insert shares the effect's transaction
|
|
106
|
+
- Verify: grep -q withTransaction src/db/tx.ts && ! grep -nE 'fetch|axios|http' src/db/tx.ts && grep -qE 'FOR UPDATE|SET .* = .* \+|version =' src/services/payments.ts
|
|
107
|
+
- Requirements: R-DB-9, R-DB-14, R-DB-15
|
|
108
|
+
- [ ] GP-xxx Wire the migration CI safety gate
|
|
109
|
+
- Files: .github/workflows/migrations.yml, db/README.md
|
|
110
|
+
- Acceptance: CI job lints migrations (squawk or strong_migrations), asserts a single migration head, and round-trips up-then-down against a disposable database; destructive ops require an explicit allow marker with justification
|
|
111
|
+
- Verify: grep -qE 'squawk|strong_migrations' .github/workflows/migrations.yml && grep -q down .github/workflows/migrations.yml
|
|
112
|
+
- Requirements: R-DB-16, R-DB-17
|
|
113
|
+
- [ ] GP-xxx Establish DB security baseline: roles, RLS, TLS, binding
|
|
114
|
+
- Files: db/migrations/0003_roles_rls.sql, infra/db.tf, .env.example
|
|
115
|
+
- Acceptance: app role has DML only, migration role owns DDL; every tenant-owned table has ALTER TABLE ... FORCE ROW LEVEL SECURITY and a tenant policy; infra declares private binding, TLS verify-full, encryption at rest; .env.example carries placeholders only
|
|
116
|
+
- Verify: test "$(grep -c 'FORCE ROW LEVEL SECURITY' db/migrations/0003_roles_rls.sql)" -eq <tenant-owned-table-count> && ! grep -rn --include='*.ts' --include='*.yml' --exclude-dir=node_modules 'postgres://' .
|
|
117
|
+
- Requirements: R-DB-18, R-DB-19
|
|
118
|
+
- [ ] GP-xxx Add retention, partitioning, and observability posture
|
|
119
|
+
- Files: db/migrations/0004_partitions.sql, jobs/reaper.ts, docs/db-operations.md
|
|
120
|
+
- Acceptance: every table listed as growth-bearing in the plan has a partition-drop schedule or reaper job; pg_stat_statements enabled; statement, lock, and idle-in-transaction timeouts set at role level; backup/PITR posture documented
|
|
121
|
+
- Verify: test "$(cat db/migrations/0004_partitions.sql jobs/reaper.ts | grep -cE 'PARTITION BY RANGE|DROP PARTITION|delete_before')" -ge <growth-table-count> && grep -q statement_timeout db/migrations/0004_partitions.sql
|
|
122
|
+
- Requirements: R-DB-13, R-DB-21
|
|
123
|
+
- [ ] GP-xxx Implement search primitives per the plan's search table
|
|
124
|
+
- Files: db/migrations/0005_search.sql, src/search/query.ts
|
|
125
|
+
- Acceptance: each search feature uses its planned primitive (pg_trgm GIN, tsvector GIN, or ANN index) with the index expression matching the query expression; ranking function present; no LIKE '%term%' without a trigram index
|
|
126
|
+
- Verify: test "$(grep -ciE 'USING (gin|gist|hnsw)' db/migrations/0005_search.sql)" -ge <search-feature-count> && { ! grep -qi "LIKE '%" src/search/query.ts || grep -q gin_trgm_ops db/migrations/0005_search.sql; }
|
|
127
|
+
- Requirements: R-DB-20
|
|
128
|
+
|
|
129
|
+
## Self-audit rubric
|
|
130
|
+
|
|
131
|
+
Base weights mirror dbauditor; drop N/A dimensions and re-normalize to 100, never zero-and-keep.
|
|
132
|
+
|
|
133
|
+
- Referential integrity (14): every relationship has a DDL FK with a justified ON DELETE, matched types both sides, NOT NULL where mandatory; soft-delete and cross-service policies stated; no cascade path reaches financial or audit data.
|
|
134
|
+
- Indexing (13): the query-to-index map exists and is total over hot paths; FK children indexed; composite order and index types justified per pattern; no planned redundancy.
|
|
135
|
+
- Query layer (12): eager-loading named per relation, keyset pagination with caps on every list path, sargable typed predicates, batch reads, a COUNT strategy, timeouts and pool arithmetic that survive the pooler.
|
|
136
|
+
- DB security (12): parameterized-only access, two-role split, verify-full TLS, private binding, secrets never committed, DB-enforced tenancy, per-column PII protection, erasure reach traced.
|
|
137
|
+
- Schema design (11): PKs everywhere, junction tables for M:N, constrained state columns, exclusive-arc polymorphism, declared naming convention, denormalization paired with maintenance.
|
|
138
|
+
- Constraints (10): NOT NULL, DEFAULTs, CHECKs, tenant-scoped and natural-key UNIQUEs, idempotency keys, nullable-UNIQUE semantics all decided in DDL terms.
|
|
139
|
+
- Transactions (9, if write path): transaction boundaries, concurrency mechanism per mutable value, lock ordering, no I/O in transactions, outbox and saga coverage, isolation with retry.
|
|
140
|
+
- Types (7): money, time, uuid, jsonb, charset, BIGINT headroom, blob placement, and NULL-over-sentinel all decided per column.
|
|
141
|
+
- Migrations (6, if tooling): expand-contract policy, lock-safe step decomposition, scheduled VALIDATEs, reversibility or backup gates, CI gate task present.
|
|
142
|
+
- Search (4, if search surface): primitive, ranking, sync architecture, and ANN operator-class match specified per feature.
|
|
143
|
+
- Scale and operations (2, re-weight up on growth signals): retention per growth table, partitioning, counter strategy, read-your-writes routing, observability and backup posture.
|
|
144
|
+
|
|
145
|
+
Full marks require the criterion of every requirement in that dimension to be checkable against the plan text alone. A module total below 85 forces a revision before the plan ships. One unmitigated hard-Critical pattern in the plan (float money, app-only tenancy, plaintext PII, missing idempotency UNIQUE on a payment path) caps the module score at 69.
|
|
146
|
+
|
|
147
|
+
## Anti-patterns refused
|
|
148
|
+
|
|
149
|
+
- ORM-promise integrity: validations, unique flags, and associations declared only in models while the DDL enforces nothing. Refusal: the planner writes invariants as DDL in the schema tasks; model annotations are documentation, never the control.
|
|
150
|
+
- Paper controls: NOT VALID without a VALIDATE step, UNIQUE on a nullable column with no semantics decision, RLS ENABLEd but not FORCEd, @Transactional with unverified semantics, timeouts that a transaction pooler discards. Refusal: every planned control names the exact DDL and the condition under which it binds; known-inert forms are banned by requirement R-DB-22.
|
|
151
|
+
- Float money: FLOAT/DOUBLE/REAL on ledger or balance columns. Refusal: the planner types money before any table is written and marks the choice as a hard-to-reverse decision; a plan containing float money does not pass the self-audit gate.
|
|
152
|
+
- App-only uniqueness: SELECT-then-INSERT dedup on identity, payment, or idempotency keys. Refusal: the planner adds the DB UNIQUE at design time and routes retried paths through R-DB-9.
|
|
153
|
+
- Lock-heavy migration theater: single-step renames, volatile-default ADD COLUMN, direct SET NOT NULL, CREATE INDEX without CONCURRENTLY on populated tables. Refusal: every schema-evolution task is pre-decomposed into expand-contract steps with lock_timeout set; the CI gate task rejects regressions.
|
|
154
|
+
- Dual-write search sync: the request handler writing to both the database and the search engine. Refusal: search sync is planned as transactional outbox plus CDC with delete propagation, or the feature stays in-database.
|
|
155
|
+
- Add-indexes platitude: recommendations that would read true for any repo. Refusal: the substitution test applies to every plan sentence; each index, constraint, and policy names its table, columns, and the query it serves.
|
|
156
|
+
- App-WHERE tenancy: multi-tenant isolation living only in query builders. Refusal: tenancy is a forced decision (Decision 3); shared-schema plans require FORCEd RLS with pooler-safe policies before the plan can emit.
|
|
157
|
+
- Invented database work: planning database sections for a project with no persistent state. Refusal: the orchestrator excludes the domain with a stated reason instead of fabricating tables.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Deployment planning module
|
|
2
|
+
|
|
3
|
+
Plans the shipping mechanics of PLAN.mdx: how a known-green build reaches real user-facing environments safely, repeatably, and reversibly. The orchestrator loads this module for any archetype that runs a service users hit (saas-dashboard, api-service, marketing-site with a server, ml-pipeline serving, mobile-app backend). A library or CLI tool that users install fires the `shipped-artifact` overlay, so deploy is never excluded for it: the matrix row is applicable or defers with the trigger before the first distribution task (discovery.md), and when the pass runs, the requirements that assume a running service (migrations, rollout, readiness probe, cold start, post-deploy verification) drop through the `form` layer while package release mechanics stay with R-REPO-13 and R-REPO-14. Only a local-only tool nobody else installs may exclude the domain, with a `by-design:` reason and a `revisit when:` predicate. Tool choice belongs to stack.md, monitoring wiring to observe.md, secret vault selection to security.md.
|
|
4
|
+
|
|
5
|
+
## Lineage
|
|
6
|
+
|
|
7
|
+
Descends from deploy-ready, the shipping-tier ready-suite skill built on the principle that what rolls back is code, not data. The disciplines that carry over: same-artifact promotion (one hermetic build, one content hash, never rebuilt per environment), the reversible-vs-data-forward change classification, expand/contract as a multi-deploy calendar rather than a migration, the paper-canary four-field rule, the Mode-A first-deploy cold-start gates, and the eight-gate pipeline with an enforced approval. godplans inverts these from ship-time enforcement into plan-time requirements: the plan is written so that a deploy-ready audit run after the project ships finds every gate already satisfied by construction.
|
|
8
|
+
|
|
9
|
+
## Decisions to force
|
|
10
|
+
|
|
11
|
+
1. Artifact identity: one hermetic build promoted unchanged, or rebuild per environment?
|
|
12
|
+
Why hard to reverse: once per-environment rebuilds exist, environment-specific build flags, caches, and baked config accrete around them; artifact drift becomes invisible and no promotion is ever again a promotion. Options: (a) single content-hashed artifact promoted dev -> staging -> prod, hash verified at the final promote (default); (b) platform-native per-region rebuild with the source commit and build config pinned and recorded as the artifact identity. Never an unpinned rebuild.
|
|
13
|
+
|
|
14
|
+
2. Migration policy: expand/contract calendar as the standing rule, or single-deploy migrations?
|
|
15
|
+
Why hard to reverse: a single-deploy migration habit bakes ACCESS EXCLUSIVE lock risk into every future schema change, and every expand left uncontracted compounds debt a later session must rediscover before it can ship anything. Options: (a) every data-forward change decomposed into expand, migrate, cutover, and contract, each its own deploy at a distinct calendar point (default); (b) expand-only-by-design with a one-line reason recorded per change. Never contract bundled with expand.
|
|
16
|
+
|
|
17
|
+
3. Promotion ladder: which rungs exist (build -> preview -> staging -> canary -> prod) and what parity gap each accepts?
|
|
18
|
+
Why hard to reverse: each rung accretes DNS, TLS, IAM, data, and cost; adding a rung later means a fresh cold-start deploy, and removing one silently deletes a gate. Options: full ladder (default when real users or money are on the line); compact build -> staging -> prod with the parity gap of every rung written down (default for a solo pre-launch project). Never a silent parity gap.
|
|
19
|
+
|
|
20
|
+
4. Approval gate mechanism: what makes shipping a choice rather than a side effect of committing?
|
|
21
|
+
Why hard to reverse: once tooling and habit assume auto-deploy-on-push, unwinding it is a workflow migration, and the first bad push to main is a prod incident. Options: (a) environment protection rule requiring review (default for teams); (b) solo-builder distinct second action: signed tag, explicit deploy command, or deploy-marker commit (default solo). Never a Slack-ping convention.
|
|
22
|
+
|
|
23
|
+
5. Rollout strategy default: canary, or all-at-once with a named blast radius?
|
|
24
|
+
Why hard to reverse: a canary needs a metric path that observability planning must budget now; claiming canary without one manufactures paper canaries on every future change. Options: (a) canary with all four fields, when observe.md is applicable (default in that case); (b) all-at-once with a named blast-radius justification (default otherwise). Never "we will watch Grafana for a bit".
|
|
25
|
+
|
|
26
|
+
6. Secrets and identity split: how does config reach the runtime, and is the deploy identity distinct from the runtime identity?
|
|
27
|
+
Why hard to reverse: a secret baked into an image layer or git history cannot be unbaked; rotation, audit, and incident forensics all inherit the mistake. Options: platform environment injection at runtime (default); vault-sourced injection (vault choice routes to security.md). Always: least-privileged runtime identity, distinct from the identity that deploys.
|
|
28
|
+
|
|
29
|
+
## Plan requirements
|
|
30
|
+
|
|
31
|
+
R-DEPLOY-1. The plan states build provenance: one deterministic hermetic build producing one content-hashed artifact, promoted unchanged across every environment; platform-native per-region rebuilds record the source commit and build config pin as the artifact identity.
|
|
32
|
+
Criterion: WHEN the plan describes the pipeline THE PLAN SHALL name the single build step, the hash check at the final promote, and contain no per-environment rebuild step.
|
|
33
|
+
|
|
34
|
+
R-DEPLOY-2. The plan separates artifact from configuration: config and secrets inject at runtime, never at build time.
|
|
35
|
+
Criterion: WHEN the plan defines the artifact THE PLAN SHALL state that the image contains no environment-specific values and no build-time secrets.
|
|
36
|
+
|
|
37
|
+
R-DEPLOY-3. Every change the plan ships is classified: reversible (code-only), data-forward (schema or data mutation), mixed, or side-effectful (emails sent, payments captured).
|
|
38
|
+
Criterion: WHEN a phase contains tasks that alter production behavior THE PLAN SHALL assign each task one of the four change classes.
|
|
39
|
+
|
|
40
|
+
R-DEPLOY-4. Each change class carries its required rollback artifact: reversible gets the exact revert command plus a time-to-revert estimate; data-forward gets a compensating-forward plan plus a pre-migration restore point; side-effectful gets an idempotency guard plus an explicit acknowledgement that rollback does not recall sent effects.
|
|
41
|
+
Criterion: WHEN a change is classified THE PLAN SHALL attach the class-matched artifact and SHALL NOT pair "rollback: redeploy previous image" with any schema or data migration.
|
|
42
|
+
|
|
43
|
+
R-DEPLOY-5. Every data-forward change is decomposed into an expand/contract calendar: expand (additive), migrate (dual-write or backfill), cutover, and contract phases, each its own deploy, with contract in a later wave than expand.
|
|
44
|
+
Criterion: WHEN any schema or data mutation appears THE PLAN SHALL schedule the four phases as separate deploys at distinct calendar points, or mark the change expand-only-by-design with a one-line reason.
|
|
45
|
+
|
|
46
|
+
R-DEPLOY-6. Migrations against populated tables use R-DB-16's guardrail forms, and this module schedules them: each step that briefly takes an ACCESS EXCLUSIVE lock (ADD COLUMN, ADD CONSTRAINT ... NOT VALID, SET NOT NULL after a validated CHECK) runs under an explicit lock_timeout and statement_timeout; backfills run outside transactions; no rename of a column still read by running code; destructive DDL only with a restore point and a one-cycle read gap.
|
|
47
|
+
Criterion: IF a planned migration touches a populated table THE PLAN SHALL cite the R-DB-16 form for it, SHALL set lock_timeout on every step that takes an ACCESS EXCLUSIVE lock, and SHALL NOT contain any step that holds that lock while scanning or rewriting the table.
|
|
48
|
+
|
|
49
|
+
R-DEPLOY-7. The plan names the full promotion ladder and the parity gap at every rung: traffic source, data source, scale, feature-flag defaults, observability reach.
|
|
50
|
+
Criterion: WHEN the plan names environments THE PLAN SHALL list each rung with its five parity properties; a compact ladder is allowed, a silent parity gap is not.
|
|
51
|
+
|
|
52
|
+
R-DEPLOY-8. The pipeline is planned as eight named gates in order: build, test, security scan on the artifact, promote-to-non-prod, promote-to-staging, approval, promote-to-prod, post-deploy verification.
|
|
53
|
+
Criterion: WHEN the plan defines the pipeline THE PLAN SHALL name all eight gates in that order and SHALL NOT plan a single job that builds, tests, and deploys on push to main.
|
|
54
|
+
|
|
55
|
+
R-DEPLOY-9. The approval gate is enforced by mechanism, not convention: an environment protection rule, or for a solo builder a distinct second action (signed tag, deploy command, deploy-marker commit).
|
|
56
|
+
Criterion: WHEN the approval gate is planned THE PLAN SHALL name the enforcing mechanism, and auto-deploy-on-push to production SHALL NOT appear anywhere in the plan.
|
|
57
|
+
|
|
58
|
+
R-DEPLOY-10. The secrets path is planned upfront: runtime-only injection; zero secrets in image layers, git history, or workflow literals; no pull_request_target checkout of untrusted fork code with secret access; least-privileged runtime identity distinct from the deploy identity.
|
|
59
|
+
Criterion: WHEN the plan covers deploy credentials THE PLAN SHALL specify all four properties and SHALL NOT rely on a personal access token on an individual account.
|
|
60
|
+
|
|
61
|
+
R-DEPLOY-11. Rollout strategy is chosen per change (all-at-once, rolling, blue-green, canary, ring). A canary requires all four fields: named success metric, numeric threshold, time-or-request-bounded window, automated rollback trigger. No change reaches 100 percent of traffic in one uniform step untested in that environment.
|
|
62
|
+
Criterion: WHEN a rollout is planned THE PLAN SHALL name the strategy per change; IF the strategy is canary THE PLAN SHALL state all four fields or refuse the canary and record all-at-once with a named blast-radius justification instead.
|
|
63
|
+
|
|
64
|
+
R-DEPLOY-12. The first deploy to any environment carries the cold-start checklist as hard blocks: environment reachable, DNS propagated, TLS provisioned with more than 30 days validity, database provisioned with migrations through expand, env vars set in the platform, IAM role existing and least-privileged, image in the registry with valid pull credentials, truthful healthcheck, log aggregation reaching the environment, rollback dry-run completed in non-prod.
|
|
65
|
+
Criterion: WHEN a deploy is the first to its environment THE PLAN SHALL include the ten-gate checklist as a blocking task and SHALL label every deploy task as first or subsequent.
|
|
66
|
+
|
|
67
|
+
R-DEPLOY-13. The readiness probe is truthful: it returns healthy only when the service can serve a real request, exercising at least one critical dependency, never on socket bind.
|
|
68
|
+
Criterion: WHEN health checking is planned THE PLAN SHALL require the probe to fail while a critical dependency is down and SHALL NOT accept a 200-on-bind probe.
|
|
69
|
+
|
|
70
|
+
R-DEPLOY-14. Feature-flag lineage is audited: no flag name is reused from a prior deploy until the old code path behind it is confirmed removed. When R-BIZ-23 lands, the flag mechanism, its fallback, owners and expiry, and runtime kill switches are its; otherwise this module plans them. This requirement always owns name reuse, and its flag inventory (name, owner, expiry, lineage per flag) is the documentation set's `build.feature-flags` row.
|
|
71
|
+
Criterion: IF the plan introduces or reuses feature flags THE PLAN SHALL include a lineage-audit step before any name reuse.
|
|
72
|
+
|
|
73
|
+
R-DEPLOY-15. Every production deploy is followed by planned verification: healthcheck healthy, p99 latency and error rate within the canary threshold for at least 15 minutes, critical-path smoke run, and the contract phase scheduled if an expand shipped.
|
|
74
|
+
Criterion: WHEN a production deploy task is planned THE PLAN SHALL schedule a post-deploy verification task naming those four checks.
|
|
75
|
+
|
|
76
|
+
R-DEPLOY-16. Rollback is rehearsed and incidents are logged: the revert command runs against a non-prod copy within 90 days of first deploy, and every rollback or close call writes an incident file regardless of blast radius.
|
|
77
|
+
Criterion: WHEN rollback paths exist THE PLAN SHALL schedule the dry-run cadence and name the incident-log location and template.
|
|
78
|
+
|
|
79
|
+
R-DEPLOY-17. The plan emits deploy handoff artifacts: a topology doc (consumed by observability planning for what to monitor and by launch planning for public URLs), a healthcheck inventory, a per-service rollback doc, and a migration calendar tracking in-progress expand/contract cycles so a resuming session neither ships a contract phase early nor forgets it.
|
|
80
|
+
Criterion: WHEN the deployment section is complete THE PLAN SHALL contain tasks producing all four artifacts with exact file paths.
|
|
81
|
+
|
|
82
|
+
R-DEPLOY-18. Destructive deploy-time commands (terraform destroy, kubectl delete, prisma migrate reset, rm -rf) never run against production without explicit confirmation and a named, verified backup.
|
|
83
|
+
Criterion: IF any planned task runs a destructive command against a production resource THE PLAN SHALL gate it behind a confirmation step and a named restore point.
|
|
84
|
+
|
|
85
|
+
## Task seeds
|
|
86
|
+
|
|
87
|
+
- [ ] GP-xxx Define the deploy pipeline with eight named gates
|
|
88
|
+
- Files: .github/workflows/deploy.yml, docs/deploy/pipeline.md
|
|
89
|
+
- Acceptance: exactly one build job produces a content-hashed artifact; promote jobs contain no build step; approval mechanism documented; a post-deploy verification job exists
|
|
90
|
+
- Verify: test "$(grep -c 'docker build\|run build' .github/workflows/deploy.yml)" -eq 1
|
|
91
|
+
- Requirements: R-DEPLOY-1, R-DEPLOY-8, R-DEPLOY-9
|
|
92
|
+
- [ ] GP-xxx Write the promotion ladder and parity map
|
|
93
|
+
- Files: docs/deploy/topology.md
|
|
94
|
+
- Acceptance: every rung listed with traffic source, data source, scale, flag defaults, and observability reach; parity gap stated per rung; public URLs listed for launch handoff
|
|
95
|
+
- Verify: grep -c "parity" docs/deploy/topology.md
|
|
96
|
+
- Requirements: R-DEPLOY-7, R-DEPLOY-17
|
|
97
|
+
- [ ] GP-xxx Ship the expand phase migration for the target table
|
|
98
|
+
- Files: migrations/NNN_expand_table.sql
|
|
99
|
+
- Acceptance: additive-only DDL (nullable column, CHECK NOT VALID); lock_timeout and statement_timeout set; no single-step NOT NULL, no non-CONCURRENT index, no backfill in transaction
|
|
100
|
+
- Verify: grep -q "lock_timeout" migrations/NNN_expand_table.sql && ! grep -qiE "(alter column|add column)[^;]*not null|set not null" migrations/NNN_expand_table.sql
|
|
101
|
+
- Requirements: R-DEPLOY-5, R-DEPLOY-6
|
|
102
|
+
- [ ] GP-xxx Schedule the cutover and contract deploys on the migration calendar
|
|
103
|
+
- Files: docs/deploy/migration-calendar.md
|
|
104
|
+
- Acceptance: cutover and contract are separate calendar entries in later waves than expand; the rollback target between phases is named; expand-only entries carry a one-line reason
|
|
105
|
+
- Verify: grep -c "contract" docs/deploy/migration-calendar.md
|
|
106
|
+
- Requirements: R-DEPLOY-5, R-DEPLOY-17
|
|
107
|
+
- [ ] GP-xxx Implement the truthful readiness probe
|
|
108
|
+
- Files: src/health/readiness.ext, tests/health/readiness.test.ext
|
|
109
|
+
- Acceptance: probe checks database connectivity and one critical dependency before returning healthy; returns 503 during warmup; no bare 200-on-bind path exists; a test makes the database unreachable and asserts the probe returns 503
|
|
110
|
+
- Verify: npm test -- tests/health/readiness.test.ext
|
|
111
|
+
- Requirements: R-DEPLOY-13, R-DEPLOY-15
|
|
112
|
+
- [ ] GP-xxx Execute the first-deploy cold-start checklist for the target environment
|
|
113
|
+
- Files: docs/deploy/cold-start-env.md
|
|
114
|
+
- Acceptance: all ten Mode-A gates checked with evidence lines (dig output, cert expiry date, IAM role name, registry pull test, observed log line, rollback dry-run timestamp)
|
|
115
|
+
- Verify: test "$(grep -c '^- \[x\]' docs/deploy/cold-start-env.md)" -eq 10
|
|
116
|
+
- Requirements: R-DEPLOY-12, R-DEPLOY-16
|
|
117
|
+
- [ ] GP-xxx Write and rehearse the rollback doc per service
|
|
118
|
+
- Files: docs/deploy/rollback.md
|
|
119
|
+
- Acceptance: exact revert command per service; time-to-revert measured against a non-prod copy; a `Last drilled: YYYY-MM-DD` line; compensating-forward plan present for every data-forward change; incident-log template linked
|
|
120
|
+
- Verify: grep -c "time-to-revert" docs/deploy/rollback.md
|
|
121
|
+
- Requirements: R-DEPLOY-4, R-DEPLOY-16
|
|
122
|
+
|
|
123
|
+
## Self-audit rubric
|
|
124
|
+
|
|
125
|
+
- Artifact and promotion integrity (20): single hermetic build named, content hash verified at the final promote, no per-environment rebuild anywhere in the plan, runtime-only config injection stated.
|
|
126
|
+
- Rollback truth per change class (20): every shipped change classified into one of the four classes, class-matched rollback artifact attached, no "redeploy previous image" adjacent to a schema migration, side effects acknowledged as non-recallable.
|
|
127
|
+
- Migration calendar and guardrails (20): every data-forward change decomposed into expand/contract phases as separate deploys, guardrail forms specified per migration, the calendar itself planned as an artifact with in-progress cycles tracked.
|
|
128
|
+
- Rollout rigor (15): strategy named per change, every canary carries all four fields or is correctly refused, no untested uniform 0-to-100 step.
|
|
129
|
+
- Pipeline gates and secrets (15): eight gates named in order, approval enforced by mechanism, secrets path clean on all four properties, runtime identity split from deploy identity.
|
|
130
|
+
- First-deploy and post-deploy discipline (10): cold-start checklist planned as hard blocks with first-vs-subsequent labeling, truthful probe required, post-deploy verification scheduled, rollback rehearsal cadence and incident log named.
|
|
131
|
+
|
|
132
|
+
## Anti-patterns refused
|
|
133
|
+
|
|
134
|
+
- Paper canary: a canary with no metric, threshold, window, or automated trigger; "we will watch Grafana for a bit". Refusal: delete the canary claim; plan all-at-once with a named blast radius, or budget the metric path in the observability section first.
|
|
135
|
+
- Rollback theater: "rollback: redeploy previous image" written next to a schema migration. Refusal: replace with a compensating-forward plan plus a pre-migration restore point.
|
|
136
|
+
- Per-environment rebuild: the pipeline builds a fresh artifact for each environment. Refusal: plan one build plus promotes, or record the source and config pin as artifact identity.
|
|
137
|
+
- Slack-ping approval: the prod gate is a convention, not a mechanism. Refusal: plan an environment protection rule or a solo-builder distinct second action.
|
|
138
|
+
- Baked secrets: secrets in image layers, git history, workflow literals, or exposed to untrusted forks via pull_request_target. Refusal: plan runtime injection and the deploy-vs-runtime identity split.
|
|
139
|
+
- Table-locking migration: ALTER COLUMN type change, single-step NOT NULL, or non-CONCURRENT index on a populated table. Refusal: decompose into the guardrail form before the task is written.
|
|
140
|
+
- Expand-only trap: expand ships and contract is never scheduled. Refusal: the contract entry lands on the migration calendar in the same planning pass, or the change is marked expand-only-by-design with a reason.
|
|
141
|
+
- Flag necromancy: a reused flag name wakes dormant code (the Knight Capital shape). Refusal: a lineage-audit task precedes any flag name reuse.
|
|
142
|
+
- 200-on-bind probe: the healthcheck passes the moment the socket opens. Refusal: the probe must exercise a real dependency before reporting healthy.
|
|
143
|
+
- Assumed cold start: a first deploy that assumes DNS, TLS, IAM, env vars, and registry access exist. Refusal: the ten-gate Mode-A checklist is a blocking task, never skipped because "it is just like the other env".
|
|
144
|
+
- Uniform 0-to-100: an untested change reaches all traffic in one step (the CrowdStrike shape). Refusal: require a prior-rung exercise or a named blast-radius justification.
|
|
145
|
+
- Untested rollback: a revert path that has never been run. Refusal: schedule the non-prod dry-run within 90 days of first deploy.
|
|
146
|
+
- Destructive deploy command: terraform destroy or migrate reset pointed at prod without a backup. Refusal: gate behind explicit confirmation and a named, verified restore point.
|