go: dedupe-and-types — shared stdio/store helpers, typed kinds #141

Closed
opened 2026-07-26 22:04:10 +00:00 by ben · 1 comment
Owner

Parent

Standards debt (duplicated code, primitive obsession). Filed from Ben's rulings 2026-07-26 after the review sweep of 6596977..9e946b7: integration-last was deliberate seam-first sequencing — now build the integration layer; and pay all standards debt now.

What to build

The three verbatim NDJSON serve-stdio loops collapse into one shared helper; the four hand-rolled JSON load/mutate/save store shapes collapse into one; the access-kind bare string gains a proper type with named constants on the Go side and a string-literal union on the TS side (per the documented idiom), replacing the magic literals and switches.

Acceptance criteria

  • One stdio serve helper, one JSON store helper — the duplicates are gone and all consumers use them.
  • Access kind is a named type / literal union at every boundary; no bare magic strings remain.
  • All suites green; wire frames unchanged.

Blocked by

  • standards:wire-snake-case — same files; land the tag flip first.

Task manifest

task: standards:go-dedupe-and-types
implements_flow: none
implements_edge: "none — dedupe + typing refactor"
wireframe: "none; the seam contract IS the design"
interface: "shared stdio + store helpers; typed access kinds both sides of the wire"
seam: "suites green; duplication sweep finds one copy of each shape"
acceptance: "see Acceptance criteria above"
depends_on: [standards:wire-snake-case]
out_of_scope: [protocol changes, new store backends]
needs_human_decision: []
## Parent Standards debt (duplicated code, primitive obsession). Filed from Ben's rulings 2026-07-26 after the review sweep of `6596977..9e946b7`: integration-last was deliberate seam-first sequencing — now build the integration layer; and pay all standards debt now. ## What to build The three verbatim NDJSON serve-stdio loops collapse into one shared helper; the four hand-rolled JSON load/mutate/save store shapes collapse into one; the access-kind bare string gains a proper type with named constants on the Go side and a string-literal union on the TS side (per the documented idiom), replacing the magic literals and switches. ## Acceptance criteria - [ ] One stdio serve helper, one JSON store helper — the duplicates are gone and all consumers use them. - [ ] Access kind is a named type / literal union at every boundary; no bare magic strings remain. - [ ] All suites green; wire frames unchanged. ## Blocked by - standards:wire-snake-case — same files; land the tag flip first. ## Task manifest ```yaml task: standards:go-dedupe-and-types implements_flow: none implements_edge: "none — dedupe + typing refactor" wireframe: "none; the seam contract IS the design" interface: "shared stdio + store helpers; typed access kinds both sides of the wire" seam: "suites green; duplication sweep finds one copy of each shape" acceptance: "see Acceptance criteria above" depends_on: [standards:wire-snake-case] out_of_scope: [protocol changes, new store backends] needs_human_decision: [] ```
Author
Owner

Done in 86b0297 (on origin/main). Duplication + primitive-obsession debt paid on three behaviour-preserving axes; wire frames unchanged, all suites green.

1. One stdio serve helper. The three verbatim NDJSON serve-stdio loops (founding, breakglass, clan) now delegate to one generic internal/stdiobridge.Serve[Req,Resp] — the 4 MiB-line framing, blank-line skip, and one-response-per-line contract live once. Each bridge supplies only its request/response types, dispatch, and fail helper.

2. One JSON store helper. Seven hand-rolled load/mutate/save JSON round-trip stores collapse onto one generic internal/jsonstore (Memory[T] + atomic File[T]). The refuse-or-migrate schema guard is passed as a per-consumer Check[T] closure, so founding/update keep their own ErrSchemaNewer sentinels while the schema-less member/rescue ledgers pass nil. Rebound consumers: founding FileStore/MemoryStore, update FileBackend/MemoryBackend, member ledger/invite/reset/audit, rescue share + operator-key ledgers. (The sweep found three more member stores beyond the four the ticket named — invite/reset/audit — all folded in, so no copy of the shape survives.)

3. Typed access kinds at every boundary. The founding access/address kinds are now named Go types (AccessKind/AddressKind + constants) and TS string-literal unions (per CODING-STANDARDS.md). Every switch and comparison keys off a constant; no bare magic string remains; the installPathOwnVPS entanglement is decoupled from the access kind.

Acceptance:

  • One stdio serve helper, one JSON store helper — duplicates gone, all consumers use them (duplication sweep finds one copy of each shape).
  • Access kind is a named type / literal union at every boundary; no bare magic strings.
  • All suites green; wire frames unchanged.

New packages carry direct tests. Evidence: go build/vet/test/lint green on both modules; app vue-tsc + 309 vitest green; dashboard vue-tsc green.

Done in `86b0297` (on `origin/main`). Duplication + primitive-obsession debt paid on three behaviour-preserving axes; wire frames unchanged, all suites green. **1. One stdio serve helper.** The three verbatim NDJSON serve-stdio loops (`founding`, `breakglass`, `clan`) now delegate to one generic `internal/stdiobridge.Serve[Req,Resp]` — the 4 MiB-line framing, blank-line skip, and one-response-per-line contract live once. Each bridge supplies only its request/response types, dispatch, and `fail` helper. **2. One JSON store helper.** Seven hand-rolled load/mutate/save JSON round-trip stores collapse onto one generic `internal/jsonstore` (`Memory[T]` + atomic `File[T]`). The refuse-or-migrate schema guard is passed as a per-consumer `Check[T]` closure, so `founding`/`update` keep their own `ErrSchemaNewer` sentinels while the schema-less member/rescue ledgers pass `nil`. Rebound consumers: founding `FileStore`/`MemoryStore`, update `FileBackend`/`MemoryBackend`, member ledger/invite/reset/audit, rescue share + operator-key ledgers. (The sweep found three more member stores beyond the four the ticket named — invite/reset/audit — all folded in, so no copy of the shape survives.) **3. Typed access kinds at every boundary.** The founding access/address kinds are now named Go types (`AccessKind`/`AddressKind` + constants) and TS string-literal unions (per CODING-STANDARDS.md). Every switch and comparison keys off a constant; no bare magic string remains; the `installPathOwnVPS` entanglement is decoupled from the access kind. **Acceptance:** - [x] One stdio serve helper, one JSON store helper — duplicates gone, all consumers use them (duplication sweep finds one copy of each shape). - [x] Access kind is a named type / literal union at every boundary; no bare magic strings. - [x] All suites green; wire frames unchanged. New packages carry direct tests. Evidence: `go build/vet/test/lint` green on both modules; app `vue-tsc` + 309 vitest green; dashboard `vue-tsc` green.
ben closed this issue 2026-07-27 11:33:42 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#141
No description provided.