Change workflows¶
Task-shaped guides for the changes contributors make most often. See Repository architecture for the map these refer to.
Adding or changing an API endpoint¶
- Edit
api/design/*.go: add theMethod, itsPayload/Result, HTTP verb and path, and any newError(...). make generate. Commit the regeneratedapi/gen/andfrontend/src/api/schema.gen.tsalongside the design change; CI'sLintjob fails if they drift.- Implement the handler in
internal/service/. - Add a unit test (
test/unit/service/...) and, if it touches the database, an integration test (test/integration/...). - Update API reference (and
API errors for a new error code) in the same
change;
make docs-contract-checkfails on a documented route/error set that disagrees with the code.
Adding configuration¶
- Add the field to the right struct in
internal/config/config.go, read with the matchinggetEnv*helper and a literal default. - If it needs a production restriction, add the check to
Validate()ininternal/config/validate.goand a test invalidate_test.go. - Add it to Configuration reference, same
variable name, same literal default, in the same change.
docs-contract-checkextracts everygetEnv*call fromconfig.goand fails on a mismatch or an undocumented variable. - If it's user-facing in production, add it to
.env.exampleand, if relevant,deploy/helm/pgquerynarrative/values.yaml/deploy/kubernetes/configmap.yaml.
Adding a migration¶
- Add
internal/db/migrations/0000N_name.up.sqland the matching.down.sql. - If it changes a guarantee the server depends on at boot, bump
RequiredMigrationVersionininternal/db/migrations_check.goto the new highest number. - Run
make migrate-cycle-docker(up → down -all → up) to prove it's reversible; CI'sMigration up/down/upjob runs the same check. - If it changes grants or RLS policies, re-run
make db-security-verify-docker.
Adding a rewrite rule¶
A dedicated guide, because rewrite correctness is a trust boundary: Adding a rewrite rule.
Adding a plan finding¶
- Add the detection to
internal/queryrunner/plan_analysis.go, naming the newnode_typevalue. - Add it to the table on Evidence and status vocabulary: plan findings and, if it changes user-facing guidance, to Understand plan findings.
- Add a unit test with a captured
EXPLAINfixture that should (and one that should not) trigger it.
Adding a documentation page¶
- Check this site's nav for whether the content belongs on an existing page first; the goal is fewer, more complete pages, not maximum page count.
- If a new page is warranted, add it under the right top-level section in
mkdocs.yml'snav;make docs-contract-checkfails if a page underdocs/isn't listed there. - Verify every claim against the code it describes; this documentation is held to the same standard as the code: cite what you can, and don't restate a default or a route from memory when you can read it.
- Run
make docs-check(strict build: broken links and anchors are errors) before committing.