Skip to content

docs(specs): record decision not to batch DB writes - #62

Merged
fclairamb merged 2 commits into
mainfrom
docs/no-batched-writes-spec
May 16, 2026
Merged

fclairamb merged 2 commits into
mainfrom
docs/no-batched-writes-spec

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

Summary

Adds specs/discussions/2026-05-16-batched-writes.md — a written record of why we're not pursuing app-level batched DB inserts/updates with a 500ms delay.

This is the first file under specs/discussions/. The directory's purpose is to preserve "we considered this and didn't do it" reasoning so future contributors tempted by the same idea find the prior thinking first.

Why no batching (TL;DR)

  • Latency cost lands on the product's value prop. 500ms added to result submission → incident detection; heartbeats delayed; read-after-write breaks for dashboards, status pages, and the CLI.
  • Crash window. Anything in the in-memory buffer at SIGKILL / OOM / panic / eviction is silently lost.
  • Premise unproven. Write rate is bounded by `checks × frequency` — well within plain PG / SQLite-WAL territory. No telemetry currently points at writes as the bottleneck.
  • Complexity tax is permanent. Buffer, flush loop, shutdown drain, partial-batch failure semantics, backpressure — every future "stale data" bug will point here first.

Cheaper interventions documented in the spec

PG `synchronous_commit = off`, prepared statements / `pgx.Batch`, `COPY` for true bulk paths, index review, connection-pool tuning.

Conditions to reconsider

Documented in the file: real profile showing a specific write hotspot, cheaper interventions tried and insufficient, narrow scope (one path), starting window ~50ms not 500ms, never applied to incident state / auth / config / entitlements.

Test plan

  • No code changed — documentation only.
  • `ls specs/discussions/` shows the new file.

🤖 Generated with Claude Code

fclairamb and others added 2 commits May 16, 2026 19:17
Captures the discussion about whether to buffer inserts/updates with a
500ms delay. Conclusion: no — added latency on incident-detection path,
read-after-write breaks, crash window, and unproven premise outweigh the
speculative throughput gain. Lists cheaper interventions to try first
and the conditions under which the decision should be revisited.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The repo already has specs/questions/ for free-form decision records
(see 2026-05-03-oss-vs-paid-code-separation.md, 2026-01-03-saas-pricing.md).
No need for a parallel specs/discussions/ directory — fold this in.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@fclairamb
fclairamb force-pushed the docs/no-batched-writes-spec branch from 72509ae to 2ad105a Compare May 16, 2026 17:17
@fclairamb
fclairamb enabled auto-merge (squash) May 16, 2026 17:17
@fclairamb
fclairamb merged commit 43357f8 into main May 16, 2026
10 checks passed
@fclairamb
fclairamb deleted the docs/no-batched-writes-spec branch May 16, 2026 17:23
fclairamb added a commit that referenced this pull request Oct 11, 2026
## What & why

Deals with every open alert on the Security tab.

**Fixed in this PR**
- Dependabot #9: `github.com/moby/go-archive` v0.2.0 → v0.3.0 (tar
archive can write outside the extraction dir).
- Dependabot #10: `github.com/moby/sys/user` v0.4.0 → v0.4.1 (unbounded
parsing DoS).
- CodeQL #65 (clear-text logging, grdp `sec.go`): `sendFlagged` logged
the plaintext PDU in hex at debug level, and the client info PDU carries
the RDP password. It now logs the length only. Also removed the debug
logs of the client random and the four NTLM signing/sealing keys (same
class of leak, not flagged).
- CodeQL #61 (allocation-size overflow, `credentials/secret_fields.go`):
map size hint is now `max(a, b)` instead of `a + b`. Same change on
`MergePatch`.

**Dismissed (no code change)**
- #72-#81, #68-#71 (weak crypto / weak hashing in vendored
`third_party/grdp`): RC4, MD4, MD5, SHA-1 and DES are mandated by RDP
standard security and NTLM. Same reasoning as the VNC DES alerts
#94/#95.
- #31 (MD5 in `checksip`): SIP digest auth (RFC 3261/2617) is MD5.
- #33 (SHA-256 on password, `passwords/bcrypt.go`): pre-hash before
bcrypt to bypass the 72-byte limit. bcrypt is the slow hash.
- #54 (InsecureSkipVerify, `checkrdp`): leaf-only certificate inspection
by design, same as #62/#93.
- #47/#48 (cookie Secure, `statuspagelock`): `Secure: httpx.IsTLS(req)`,
same as #44/#59.
- #39 (request forgery, `jmap/client.go`): the JMAP session URL is set
by a super admin (instance operator), and reaching their own mail
server, often on the LAN, is the feature. Same as the Freebox alert #35.
- #17 (clear-text logging, `slack/commands.go`): map-value taint through
the check config, the password never reaches the log. Same as #18.

## How to test

- `go build ./...` and `go test ./internal/crypto/credentials/
./internal/checkers/checkrdp/...` in `server/`
- `go test ./...` in `server/third_party/grdp`
- `golangci-lint` v2.14.0 on `internal/crypto/...`: 0 issues

## Checklist
- [x] `go build`, lint and tests pass on the touched packages (full
`make test` left to CI)
- [ ] Tests added or updated for the change (log-only and size-hint
changes, existing tests cover behaviour)
- [ ] Docs updated (not user-visible)
- [ ] Schema changes (none)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
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