Skip to content

chore(workspace): land the first two crates — M0 of the walking skeleton - #62

Merged
gonzafg2 merged 3 commits into
mainfrom
chore/workspace-scaffolding
Jun 12, 2026
Merged

gonzafg2 merged 3 commits into
mainfrom
chore/workspace-scaffolding

Conversation

@gonzafg2

Copy link
Copy Markdown
Owner

Summary

The first Rust code in the repository: the two-crate workspace (ADR-0017), the unsafe_code = "forbid" flip (ADR-0018, in this same PR as that ADR requires), and the minimal functional server — quantumssh-core::server with the ADR-0022 sequential spawn-and-join accept loop, plus the quantumssh binary as the thin entrypoint with the ADR-0024 logging posture. This is M0 of the walking skeleton (#9): protocol milestones (wire → kex → transport → auth → channel → interop gate) follow as separate PRs.

With this merge, the CI workspace-state guards (ADR-0011) self-enable for the first time: the full check matrix (fmt, clippy -D warnings with pedantic+nursery, test, build --release, cargo deny, and cargo audit once the lockfile is seen) becomes load-bearing.

What lands

  • crates/quantumssh-core — server module only, all of it functional (the project forbids stubs):
    • Server::bind (emits server.started with listen_addr), local_addr (ephemeral-port support for tests), serve — the sequential spawn-and-join loop: tokio::spawn(handle(...)).await keeps effective concurrency at one while the compiler enforces Send on the per-connection future from line one, and a panicking handler surfaces as a captured and logged JoinError (connection.closed with reason) — never let _ = discarded, per the ADR-0022 review.
    • M0 connection contract: accept → connection.accepted → clean shutdown (explicit FIN) → connection.closed. The version exchange lands in M1.
  • crates/quantumssh — the ≤150-line entrypoint: std-only CLI (--listen, --log-format, --help, --version; no clap — not decided by any ADR, not needed yet), #[tokio::main] multi-thread, and the only subscriber construction: all logs to stderr (threat model §2.7), JSON when stderr is not a TTY, human-readable on a TTY, EnvFilter honouring RUST_LOG.
  • Workspace root: members, the forbid flip, pinned deps with tokio = "~1.51" (the tilde keeps the 1.51.x LTS line per ADR-0022 — a bare "1.51" resolved to 1.52.3; resolved now to 1.51.3), Cargo.lock committed and un-ignored (the .gitignore note anticipated exactly this moment; audit.yml's guard keys on the lockfile).
  • Test: integration test on an ephemeral port asserting the M0 contract — connect, read EOF without bytes, and a second connection succeeds (the loop survives, it is not one-shot).

Deliberately not in M0 (per the no-stubs rule)

  • No wire/kex/transport/auth/channel modules — they land with their logic in M1–M5.
  • No crypto dependencies yet — the ADR-0019 pins land with the kex milestone that uses them.
  • The ADR-0024 two-layer audit subscriber and the control-byte-escaping field formatter land with the first audit events (M4); server.started carries host_key_fingerprint from M2 when a host key exists.
  • ADRs 0016–0024 stay Proposed: they advance to Accepted when the walking skeleton completes (M6), not at M0.

Verification

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings (pedantic + nursery), cargo test --workspace — all green locally.
  • Smoke: ./target/release/quantumssh --listen 127.0.0.1:0 emits server.started as JSON (stderr non-TTY detection working); --version/--help behave.
  • This PR is the first real run of the CI matrix — its checks going green is part of the point.

Type of change

  • First-party code (Rust) — M0 of Phase 1

Checklist

  • Commits signed off under the DCO (git commit -s).
  • Conventional Commits.
  • unsafe_code = "forbid" — zero first-party unsafe.

Security considerations

No protocol surface yet: the server accepts TCP and closes with a clean FIN. The pre-auth path starts existing in M1, where the parser rules (bounded allocations, fuzzable-by-construction) apply. The logging posture (stderr, JSON off-TTY) follows ADR-0024 as reviewed.

Refs #9.

…ntumssh

The workspace gains its members (ADR-0017: two crates, flat layout)
and the lint flip ADR-0018 requires in this same PR:
unsafe_code = 'forbid', no allow escape hatch.

Only functional code, per the no-stubs rule: quantumssh-core ships
the server module — Server::bind/local_addr/serve with the ADR-0022
sequential spawn-and-join accept loop (Send enforced from line one,
JoinError captured and logged as connection.closed, never discarded)
— and the quantumssh binary is the thin entrypoint: std-only CLI
(--listen, --log-format, --help, --version), tokio multi-thread
runtime, and the only subscriber construction (ADR-0024: all logs to
stderr, JSON when stderr is not a TTY, human on a TTY, EnvFilter).
Protocol modules land with their logic in later milestones; M0's
observable contract — accept TCP, clean FIN, survive to the next
connection — is asserted by an integration test on an ephemeral port.

Dependencies (each per its decision record): tokio ~1.51 (tilde keeps
the 1.51.x LTS line per ADR-0022; resolved 1.51.3), tracing,
tracing-subscriber. The crypto pins (ml-kem 0.3.0 et al., ADR-0019)
land with the kex milestone that uses them. Cargo.lock committed and
un-ignored — the .gitignore note anticipated exactly this moment, and
audit.yml's guard (ADR-0011) keys on the lockfile's presence.

Pre-existing scaffold fix activated by the first member: the 'unused'
lint group needed priority -1 next to individual lints.

Refs #9 (M0 of the walking skeleton).

Signed-off-by: Gonzalo Fleming <[email protected]>
Comment thread Cargo.lock Resolved
Comment thread crates/quantumssh-core/src/server.rs Resolved
Comment thread crates/quantumssh/src/main.rs Resolved
Comment thread crates/quantumssh/src/main.rs Resolved
…ers, schema

Three findings from #62, applied:

- ADR-0022's handshake budget was specified but not implemented: new
  --handshake-timeout flag (default 30 s, documented in --help, zero
  rejected), Config.handshake_timeout, and tokio::time::timeout
  wrapping each connection — expiry logs connection.closed with
  reason 'handshake-timeout'. The slow-handshake test lands in M1
  with the first read that can actually be slow.
- ADR-0024's two-layer subscriber was deferred to M4; now in place
  from the first crate: the audit layer's filter is compiled in and
  never consults the environment, the general layer is RUST_LOG-
  governed with the audit target excluded — the guarantee exists
  before its first consumer.
- server.started is deferred to the host-key milestone: its schema
  mandates host_key_fingerprint, and the posture is schema-complete
  or nothing. M0 emits only events it can emit completely
  (connection.accepted / connection.closed).

The fourth finding (fabricated serde tree) is refuted with registry
evidence in the thread: serde_core and zmij are the real, current
crates.io dependency graph; index checksums match the lockfile.

Signed-off-by: Gonzalo Fleming <[email protected]>
@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Code review

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

cargo deny's bans check treats a version-less path dependency as a
wildcard (error[wildcard]); the explicit version on
quantumssh-core = { path, version } satisfies it without loosening
deny.toml. Advisories, licenses and sources all passed on the first
real run.

Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2
gonzafg2 merged commit 063f83b into main Jun 12, 2026
7 checks passed
gonzafg2 added a commit that referenced this pull request Jun 12, 2026
…ange (#63)

The entry of the pre-authentication path (threat model 4.1), with the
security rules as structural properties rather than conventions:

- Reader: zero-copy parser over byte slices where EVERY
  variable-length read takes an explicit caller-supplied bound — the
  no-unbounded-allocation rule is the API's type signature, not a
  guideline. No panics on input; all failures are typed WireError.
  Pure functions, fuzzable by construction.
- sshtype primitives (RFC 4251 sec. 5): byte/boolean/uint32/uint64/
  string/name-list/mpint. Strict parsing, fail closed: non-canonical
  mpints (redundant leading zero, negative, non-empty zero) and
  malformed name-lists (non-ASCII, empty names, stray commas) are
  rejected, not normalised.
- Binary Packet Protocol framing (RFC 4253 sec. 6), plaintext phase:
  encode with random padding (getrandom), packet_length validated
  against the 35000 hard cap and block alignment BEFORE any
  allocation — the first attacker-controlled length the server
  observes is bounded at the door.
- Version exchange (RFC 4253 sec. 4.2): SSH-2.0 only (SSH-1.99
  compatibility marker rejected — zero legacy), peer line bounded
  byte-by-byte at 255, integrated into the connection handler: the
  server now sends its banner, validates the peer's, and closes
  (KEXINIT picks up from here in M2).
- getrandom 0.3 added (workspace-pinned): BPP padding now, KEXINIT
  cookie in M2.

Tests: 23 unit (round-trips per type, RFC 4251 worked examples for
mpint, truncation/oversize/misalignment/padding attacks, bound-trips-
before-data proof, identification edge cases) + 4 integration over
real TCP, including the threat-model 5.1.3 slow-handshake scenario
promised in the #62 review (client sends nothing, server cuts at the
budget) and the oversized-line cut.

Refs #9 (M1 of the walking skeleton).

Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2
gonzafg2 deleted the chore/workspace-scaffolding branch July 18, 2026 04:15
gonzafg2 added a commit that referenced this pull request Sep 22, 2026
…each edit touched

Claude checked the Links lines against the milestone PRs' file
lists and found four wrong attributions: server.rs (ADR-0016) and
everything ADR-0022 names landed in M0 (#62), not M5/M3;
transport.rs (ADR-0021) landed in M3 (#65), not M2; and
log_fields.rs (ADR-0024) came with #101 on 2026-07-06, after the
ADR's acceptance. All four corrected, with the banners' milestone
references.

Each banner now says which section the edit touched (Context in
0018/0019, Related in 0021/0023/0024, both in 0022) instead of the
same sentence everywhere. ADR-0020's Links line no longer carries a
note about the unimplemented package pin — that is decision-level
content and lives in ADR-0034 (#161). ADR-0023 no longer points at
"PR #50 in review" for the event schema, and ADR-0021 drops a "(TBD)"
next to the kex module.

docs/adr/README.md step 5 distinguishes the governance state from the
file's Status line and lists what actually happened (ADR-0027 merged
Accepted; 0028/0029 flipped in their implementing PRs; 0030-0032 in
#158) instead of calling one instance the practice.
docs/infrastructure.md says first-party unsafe would need a
superseding ADR, as ADR-0018 states, not an RFC. Findings by Claude
and opencode on #159.

Claude-Session: https://claude.ai/code/session_018UmL9wcgKBGFjdjGSSLafa
Signed-off-by: Gonzalo Fleming <[email protected]>
gonzafg2 added a commit that referenced this pull request Sep 22, 2026
…ame every edited section

README.md's vision bullet still allowed a justified unsafe; it now
states the forbid posture the rest of the repository already
describes. ADR-0024's Links line attributed the tracing-subscriber
initialisation to M4/M5; it landed in M0 (#62). ADR-0018's Decision
and Consequences and ADR-0022's Alternative 2 still spoke of the
current deny lint and the empty workspace; they now read as of
drafting time. The banners of ADR-0018, 0021, 0022 and 0023 name
every section their edits touched. Raised by Claude and opencode on
#159.

Claude-Session: https://claude.ai/code/session_018UmL9wcgKBGFjdjGSSLafa
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant