Skip to content

docs(adr): ADR-0028 — Phase-2 runtime: concurrent connections, admission limits, graceful shutdown - #122

Merged
gonzafg2 merged 3 commits into
mainfrom
docs/adr-0028-phase-2-runtime
Jul 18, 2026
Merged

gonzafg2 merged 3 commits into
mainfrom
docs/adr-0028-phase-2-runtime

Conversation

@gonzafg2

Copy link
Copy Markdown
Owner

What

Adds ADR-0028 (Status: Proposed), the governance piece for the Phase-2 runtime/concurrency workstream tracked in #109 — the ADR extending ADR-0022 that the scoping note (docs/plans/phase2-scoping.md) maps for this lane. Per project practice, the ADR lands before any implementation.

The decision it records

  • Replace the Phase-1 spawn-and-join accept loop with a concurrent loop on tokio::task::JoinSet (select! over accept / join_next / shutdown), preserving ADR-0022's panic-isolation and audit-trace guarantees.
  • Admission control with documented defaults (threat-model §5.1.3): global cap 256, total half-open cap 100, per-source half-open cap 10 (IPv4 addr / IPv6 /64), per-source token bucket (burst 10, 1/s). First-party implementation, no new dependency. Over-cap connections close pre-banner and log a new connection.refused event (freeze-checklist interaction with ADR-0024 noted).
  • Graceful shutdown: signal feature, SIGTERM/SIGINT → stop accepting → broadcast → drain deadline (30 s) → abort remainder. The systemd ADR will consume this.
  • Feature delta to ADR-0022's allowlist: signal, plus macros on quantumssh-core. The tokio 1.51 LTS pin (chore(deps): restore the ADR-0022 tokio LTS pin and enforce it in dependabot #119) is untouched.

Defaults are anchored on OpenSSH MaxStartups prior art and marked not yet validated under load — the §5.1.3 slow-handshake test scenario is the acceptance gate for the implementation.

Why Proposed, not Accepted

Follows the Phase-1 pattern (#86): forward-looking ADRs land as Proposed and flip when their implementing PRs merge.

Refs #109.

https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa

…ion limits, graceful shutdown

Extends ADR-0022 for the Phase-2 runtime/concurrency workstream (#109):
JoinSet-based concurrent accept loop, half-open and per-source
admission caps with documented defaults, first-party token-bucket rate
limiting, and SIGTERM/SIGINT graceful shutdown with a drain deadline.
Discharges the threat-model §5.1.3 test handles and closes the
pre-auth availability ceiling accepted in Phase 1.

Status: Proposed — flips to Accepted when the implementing PRs merge.

Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa
Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2 gonzafg2 added the documentation Improvements or additions to documentation label Jul 18, 2026
Copilot AI review requested due to automatic review settings July 18, 2026 04:55
@gonzafg2 gonzafg2 added the documentation Improvements or additions to documentation label Jul 18, 2026
@opencode-agent

Copy link
Copy Markdown

Review complete. No blocking findings. This is a well-constructed ADR.

Design soundness against the five MANIFIESTO commitments

  1. Memory-safe by construction — No unsafe, no new dependency. Token bucket and source map are first-party code using existing tokio::sync primitives. RAII guard for connection counting (drop on panic → slot released) is correct.
  2. Post-quantum by default — KEX profile unchanged. No violation.
  3. Zero legacy — Not in scope. No violation.
  4. Small surface, sharp edges — Clean. Rejects governor dependency (Alternative 2). Feature delta (signal, macros on quantumssh-core) is minimal and each addition is justified: signal was deferred from ADR-0022; macros on the library is for select! (doesn't start a runtime — consistent with the ADR-0022 split). Tokio LTS pin explicitly untouched.
  5. Permanently open — License unchanged.

Threat-model alignment

  • §5.1.3 (connection exhaustion) — All three test handles are addressed: per-source rate limit (token bucket burst=10, 1/s), total half-open cap (100), handshake deadline (already shipped, 30s). Defaults are documented and anchored on OpenSSH's MaxStartups. Test scenario gating is explicit.
  • §8.3 (non-DoS posture) — Transparently acknowledged: address rotation grows the per-source map (but pruning bounds steady-state), distributed attacks are explicitly deferred to the network layer. No over-claiming.
  • Fail closed — Over-cap connections closed pre-banner, no version exchange. Correct.
  • Audit log (ADR-0024) — connection.refused event is a new audit-log event type; ADR correctly flags the freeze-checklist interaction (line 44) and notes it must be finalized before 0.1.0. Shape details deferred to implementation, consistent with ADR-0024's pattern.
  • Transport type-state machine — Explicitly untouched (line 37). Correct scope boundary.

Procedural

  • Status: Proposed — follows the Phase-1 pattern (governance: flip Phase-1 ADRs 0016–0024 from Proposed to Accepted #86): flips to Accepted when implementing PRs merge. Appropriate.
  • All cross-references resolve (docs/adr/0022-*, docs/adr/0023-*, docs/adr/0024-*, docs/plans/phase2-scoping.md).
  • Conforms to ADR template (Status, Date, Deciders, Context, Decision, Consequences, Alternatives, Links).
  • The docs/plans/phase2-scoping.md cross-reference is correctly labeled "non-authoritative" per ADR-0027.

Classification: ready to merge as-is.

github run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds ADR-0028 (Proposed) to record the Phase-2 runtime/concurrency decision that extends ADR-0022: moving from the Phase-1 spawn-and-join accept loop to concurrent connection handling with explicit admission control and graceful shutdown semantics.

Changes:

  • Defines a concurrent accept loop design using tokio::task::JoinSet and select! for accept / task reaping / shutdown.
  • Specifies admission-control defaults (global cap, half-open caps, per-source caps, per-source token bucket) and the connection.refused log event for refusals.
  • Specifies graceful shutdown behavior (SIGINT/SIGTERM → stop accept → broadcast → drain deadline → abort remainder) and the required tokio feature-set deltas.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@claude

claude Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

…ng with ADR-0024 schema

Review feedback (Copilot on #122): connection.refused inherits
peer_addr from the ADR-0024 connection span instead of carrying it as
an event field, and the JoinError panic reason is a structured field,
never interpolated into the message text.

Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa
Signed-off-by: Gonzalo Fleming <[email protected]>
@opencode-agent

Copy link
Copy Markdown

Review complete. No blocking findings.

Design soundness

  • MANIFIESTO: All five commitments hold — no new unsafe (token bucket + source map are first-party), KEX profile untouched, zero legacy not in scope, feature delta (signal, macros on quantumssh-core) is minimal and each addition is explicitly justified (MANIFIESTO chore(security): mark quantumssh.org aliases as live #4), license unchanged.
  • ADR-0022's bet pays out: the Send-bound spawn-and-join shape becomes concurrent by removing the .await on the JoinHandle — not a refactor. Panic isolation and audit-trace guarantees are preserved.
  • ADR-0024 alignment: connection.refused inherits peer_addr from the connection span (line 25: "never repeat it as a field"), consistent with ADR-0024's existing schema. Panic reason is a structured field, never interpolated into message text, with an explicit §4.3 cross-reference (line 20).

Threat-model alignment

  • §5.1.3: All three test handles now exist — per-source token bucket (burst 10, 1/s), total half-open cap (100), handshake deadline (already shipped). Defaults documented and anchored on OpenSSH MaxStartups. The slow-handshake scenario is the acceptance gate.
  • §8.3: Transparent — address rotation grows the map but pruning bounds steady-state; distributed attacks remain the network layer's problem. No over-claiming.
  • Fail closed: Over-cap connections closed pre-banner, no version exchange.

Addressing prior review comments

The copilot-reviewer's two flags are already handled by the ADR text:

  1. Panic payload leaking: Line 20 explicitly states the panic reason is a structured field, never interpolated into message text, and cross-references ADR-0024's discipline and threat-model §4.3. The ADR-0024 model (structured fields, not string interpolation) is the exact mitigation.
  2. connection.refused carrying peer_addr as a field: Line 25 explicitly states the event is "emitted inside the ADR-0024 connection span (events inherit peer_addr from the span, never repeat it as a field)." This is ADR-0024-consistent.

Procedural

Classification: ready to merge as-is.

github run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

… feature delta

Second Copilot pass on #122: Date follows the Proposed-era house style
(TBD until acceptance, as ADR-0022 did), and the feature-set delta is
signal only — quantumssh-core already enables tokio macros, so the
'previously binary-only' claim was wrong.

Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa
Signed-off-by: Gonzalo Fleming <[email protected]>
@opencode-agent

Copy link
Copy Markdown

RFC-0010 resolves. Now let me give my final review.


Review complete. No blocking findings. This ADR is well-constructed and all prior review flags are addressed.

Design soundness against the five MANIFIESTO commitments

  1. Memory-safe by construction — No unsafe. Token bucket and source map are first-party using existing tokio::sync primitives. RAII guard for connection counting (drop on panic → slot released). Correct.
  2. Post-quantum by default — KEX profile unchanged, transport machine explicitly untouched (line 37). No violation.
  3. Zero legacy — Not in scope. No violation.
  4. Small surface, sharp edges — Rejects governor dependency. Feature delta is signal only on the binary; macros on quantumssh-core was already present (verified against crates/quantumssh-core/Cargo.toml:17). Tokio LTS pin explicitly untouched. No new dependency. Correct.
  5. Permanently open — License unchanged. No violation.

Threat-model alignment

  • §5.1.3 — All three test handles addressed: per-source token bucket (burst 10, 1/s), total half-open cap (100), handshake deadline (already shipped). Defaults anchored on OpenSSH MaxStartups. Not-yet-validated-under-load disclaimer is explicit and honest.
  • §8.3 (non-DoS posture) — Transparent: address rotation grows the map (pruning bounds steady-state), distributed attacks deferred to network layer. No over-claiming.
  • Fail closed — Over-cap connections closed pre-banner, no version exchange. Correct.
  • Audit log (ADR-0024) — Panic reason is a structured field, never interpolated (line 20, cross-references §4.3). connection.refused emitted inside the ADR-0024 connection span, inheriting peer_addr (line 25). Both copilot-reviewer flags are resolved. Correct.
  • Transport type-state machine — Explicitly untouched (line 37). Correct scope boundary.

Procedural

Classification: ready to merge as-is.

github run

@gonzafg2
gonzafg2 merged commit 21ae970 into main Jul 18, 2026
15 checks passed
@gonzafg2
gonzafg2 deleted the docs/adr-0028-phase-2-runtime branch July 18, 2026 17:12
gonzafg2 added a commit that referenced this pull request Jul 19, 2026
…ce (#126)

The note's banner and workstream map predated RFC-0010's acceptance
(#116) and ADR-0028 (#122, amended #123): the banner claimed no Phase-2
governance existed beyond RFC-0008, and the config/runtime rows still
pointed at to-be-written lanes. Refresh both, and add the
connection.refused event to the freeze checklist — ADR-0028
§Consequences names it a freeze item, but the checklist here never
picked it up.

Mutable-note lane per ADR-0027; nothing here decides anything.

Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa

Signed-off-by: Gonzalo Fleming <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants