Skip to content

docs: architecture review — deepening ADRs 0011–0015#7

Merged
ryanntannn merged 2 commits into
masterfrom
arch-review-deepening-adrs
Jun 25, 2026
Merged

docs: architecture review — deepening ADRs 0011–0015#7
ryanntannn merged 2 commits into
masterfrom
arch-review-deepening-adrs

Conversation

@ryanntannn

Copy link
Copy Markdown
Contributor

Architecture review — deepening opportunities

Records five architectural deepening opportunities as proposed ADRs
(00110015) plus a consolidating review doc (docs/architecture-review-2026-06.md).
Docs only — no code changes.

The recurring shape

SynergyPlus has an excellent domain glossary, but several concepts it names
(Run Queue, Claim, Content Hash, per-User cap) own no module.
Their definitions are copied as raw SQL strings and hash recipes across three
runtimes (Go, Python, KEDA YAML), bound together only by CONTRACT.md prose. Each
ADR proposes the same move: give the concept one home, consumed through a narrow seam.

Candidates

ADR Candidate Strength
0011 Claim eligibility predicate triplicated (db.py:43-45, runnerpool_controller.go:167, scaledobject.yaml:31) — violates ADR-0005's own stated consequence Strong
0012 Content Hash derived twice (queue.go:27 Go / loop.py:26 Python), no shared vector Strong
0013 Lease lifecycle transitions + runner_id fence split across Runner (Python) and Reaper (Go) Worth exploring
0014 API-key hash duplicated TS↔Go untested; allow-list tripled in portal Worth exploring
0015 Engine Version (~8 sites) & cap (~7) scattered; derive from RunnerPool CR Speculative

Top recommendation: ADR-0011. Highest blast radius (a claim/scaler drift is a
production autoscaling bug), and it's the keystone — fixing it dissolves the cap
literal (0015) and anchors the lease transitions (0013).

Provenance

Findings came from a multi-agent validation pass and were then re-verified
first-hand
— every file:line confirmed by direct reading. The review doc also
records, for honesty, that the automated QA loop self-contaminated (an agent with
write access materialized a proposed migration the loop then "verified"); that
artifact was removed and no conclusion here depends on it. The ADRs rest only
on duplication that exists in the committed source.

Status

All five ADRs are marked proposed — recommendations for the team to ratify or
reject, not yet-accepted decisions.

🤖 Generated with Claude Code

https://claude.ai/code/session_019p51SPdbrjmGXJVeZnwTrD

Ryan Tan bdgv224 and others added 2 commits June 25, 2026 17:37
Records five architectural deepening opportunities as proposed ADRs, plus a
consolidating review doc. The recurring theme: domain concepts named in
CONTEXT.md (Run Queue, Claim, Content Hash, per-User cap) own no module — their
definitions are copied as raw SQL/hash recipes across Go, Python, and KEDA YAML,
bound only by CONTRACT prose.

- 0011 (Strong): the Claim eligibility predicate is triplicated across db.py,
  the operator's KEDA query, and scaledobject.yaml — an unguarded violation of
  ADR-0005's own stated consequence. Give it one home.
- 0012 (Strong): Content Hash is derived twice (Go queue.go, Python loop.py)
  with no shared vector; pin the two adapters with a checked-in test vector.
- 0013: the lease lifecycle's running-phase transitions and runner_id fence are
  split across the Runner (Python) and Reaper (Go); own them in guarded SQL.
- 0014: API-key hash duplicated TS↔Go untested; domain allow-list tripled in the
  portal. One source + a create→validate contract test.
- 0015: Engine Version (~8 sites) and cap (~7) scattered across manifests;
  derive them from the RunnerPool CR (largely subsumed by 0011).

Docs only; no code changes. Every file:line was verified first-hand.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019p51SPdbrjmGXJVeZnwTrD
Re-ran the multi-agent validation with each agent confined to its own git
worktree off master (strictly read-only, with a git ls-files contamination
guard). Isolation held — all five worktrees ended with zero writes and the
contamination check passed for every candidate — and the independent pass
corrected several first-pass claims:

- 0011: the naive `app.eligible_simulations(...) FOR UPDATE SKIP LOCKED` wrap
  silently DROPS the row lock on Postgres 16 (verified via EXPLAIN + a two-session
  concurrency test). Corrected design: the function owns the predicate+ordering
  only; the claim keeps `FOR UPDATE OF <base table> SKIP LOCKED` as a membership
  gate. Also softened the cap-50 framing — the cap is largely single-sourced via
  pool.Spec.DefaultUserConcurrency; the predicate is the real duplication.
- 0013: the reaper does NOT fence on runner_id (it is expiry-only); the fence is
  two Python sites (db.py:57,221), not three.
- 0014: the two auth.ts enforcement sites share one isAllowedEmail helper; the
  duplication is the domain *list* defined 3×, not logic re-implemented.
- 0015: refuted the "live KEDA query doesn't derive from the CR" premise — it does
  (controller.go:161,165-169); residuals are the in-CR image tag and the Compose
  path. Dropped the false "subsumed by 0011" dependency.
- Review doc: replaced the contamination caveat with the full two-pass method note.

Docs only; no code changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019p51SPdbrjmGXJVeZnwTrD
@ryanntannn

Copy link
Copy Markdown
Contributor Author

Re-validated under worktree isolation ✅

Re-ran the five-candidate adversarial QA loop with each agent confined to its own git worktree off master, strictly read-only, with a mandatory git ls-files contamination guard (every "already exists in-tree" claim must be proven against committed source).

Isolation held cleanly — all five worktrees ended with zero writes, the real tree was never touched, and the contamination check passed for every candidate. The independent pass also corrected several first-pass claims (now folded into the ADRs):

  • 0011 — the naive app.eligible_simulations(…) FOR UPDATE SKIP LOCKED wrap silently drops the row lock on Postgres 16 (verified via EXPLAIN + a two-session concurrency test). Corrected to a membership-gate design that keeps FOR UPDATE OF <base table> SKIP LOCKED on the caller. Cap-50 framing softened — it's largely single-sourced; the predicate is the real duplication.
  • 0013 — the Reaper does not fence on runner_id (expiry-only); the fence is two Python sites, not three.
  • 0014 — the two auth.ts sites share one isAllowedEmail helper; the duplication is the domain list (defined 3×), not the logic.
  • 0015 — the "live KEDA query doesn't derive from the CR" premise was refuted — it does (controller.go:161,165-169). Residuals narrowed to the in-CR image tag + the Compose path.

The first pass had self-contaminated (an agent wrote a proposed migration the loop then "verified"); the worktree isolation in this pass is what prevented a recurrence. Method note is in docs/architecture-review-2026-06.md.

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