Skip to content

docs: add coding standards drawn from the ADRs - #92

Open
m-murphy wants to merge 9 commits into
docs/agents-md-restructurefrom
docs/adr-coding-standards
Open

m-murphy wants to merge 9 commits into
docs/agents-md-restructurefrom
docs/adr-coding-standards

Conversation

@m-murphy

@m-murphy m-murphy commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds the coding rules taken from the ADRs to CODING_STANDARDS.md. They were split out of #91 so each one can be reviewed before code-review starts enforcing it.

 ## API
 ### Database
+### Domain modules     registerSpecimens (0010), ContainerWriteInput and no removed
+                       field aliases (0006), resolveSpecimenSource(s) (0007),
+                       loadContainerReadViews (0009)
+### Routes             typed errors, RouteError, no console.error catch blocks,
+                       observability vs error-logger (0004); wire DTOs, no row
+                       spreads, no toWireJson in handlers (0005)
 ### API tests
 ## Web
+  settingsApi (0002), container wire parsers (0005), inline read errors and
+  mutation errors (0001), domain mutation hooks (0001), Scan move core and
+  gateway (0008), Modal (0001)
 ### Web tests

Scoping decisions

A rule code-review enforces must hold for the code at head, or be scoped to new or changed code with the known exceptions named. Where a rule is scoped, it says so and lists what predates it:

  • Specimen registration (0010): new write paths only. Names the paths still on createContainerForSpecimen until their slice lands (POST /specimens, POST /specimens/:id/containers, derivations and the derivation CSV, control batches), and the ADR's exception: a caller whose own writes come first wraps the whole write in withRolledBackTransaction.
  • Settings (0002): allows every form the ADR does: getValue, get(key).value, putValue, update, and the bulk *ConfigurationsApi.update wrappers.
  • Logging (0004): states the split (observability for stdout, error-logger for error_logs, never the other way) and the ADR's exception for bootstrap, migration and script prose. Two request-time console uses predate the rule: logTemplateError in qpcr-experiments.ts and the seeding lines in POST /setup/initialize.
  • Row spreads (0005): new or changed handlers; three existing spreads named.
  • .optional() (0005): container wire schemas from @sampledb/contract/wire only, for fields added from now on. The existing .nullable().optional() fields in container-wire.ts and other parsers are out of scope.
  • Mutations (0001): the ADR says "should", so the rule covers new code. Workflow submit and resolve calls (0001, 0008) and settings forms stay direct; existing direct calls on CRUD screens are named.
  • Errors on migrated screens (0001): read errors inline; mutation errors by toast or an existing inline banner, as the ADR allows.
  • Scan move (0008): names the two Scan move pages and says ContainerMovePapers.tsx and CollectionMove.tsx are out of scope.

Evidence

  • Each rule was checked against the code at head with git grep: every named symbol and file exists, and every rule either holds at head or names the code that breaks it. The first draft said it found no violations; that was wrong (unmigrated registration callers, request-time console calls, direct mutations, row spreads, .nullable().optional() wire fields), and those are now listed in the rules.
  • Review question for each rule: is it a standing rule, or only a description of how the code works today?

Merge Danger

Door: two-way

Blast Radius: code-review

Every rule here becomes something code-review flags. A rule that is too strict will produce noisy findings until it is removed.

🤖 Generated with Claude Code

m-murphy and others added 8 commits October 6, 2026 16:11
Domain modules (ADRs 0006, 0007, 0009, 0010), routes (0004, 0005), and
web rules (0001, 0002, 0005, 0008), each citing its ADR so code review
can enforce it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Each rule now applies to new or changed code, keeps its ADR's strength,
scope and exemptions, and names the paths still migrating. Adds the
missing rules from ADRs 0001, 0004, 0005, 0006 and 0008.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ules to their ADRs and name the code that predates them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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