# TOSV - The Only Safe Vault - Complete Implementation Document - Version: 0.5.3 - Status: Approved, M1-M11 complete, v0.6.1: in-tree PQ TLS 1.3 (no external library), PQ-only SSH by default, restore-v2, Gate 2 377/377, v0.6.1 tagged - Date: 2026-11-05 - Owner: retoor ## 0. Document control ### 0.1 Conventions - Normative IDs: FR, SEC, OPS, NFR, UX, PG, D, PIN, A, TRK, DOC. BIL family unused, see D-11. Goals use G-NN, non-goals NG-NN. - IDs are never reused once retired. Cross-reference by ID, never by paraphrase. Each ID is defined once in a table row below. - No open gaps: every would-be gap is a decided default with rationale in section 9, or a tracked assumption in 0.2 with owner plus verify-by plus fallback. - Single source: this file is canonical. Mirrors (BUILD-TRACK.md, ADR bodies, runbooks, tosv.AGENTS.md) sync in the same commit. - Prose: no em dashes anywhere. Hard caps in 0.3 are ceilings. Floors in 0.4 page a human instead of auto-acting. ### 0.2 Assumptions (tracked, all need fallback) | ID | Assumption | Owner | Verify by | Fallback | |----|-----------|-------|-----------|----------| | A-01 | Single operator per host, no multi-tenancy in v1 | retoor | 2026-11-30 | Add operator field to DB plus ADR, minor bump | | A-02 | Loopback plus stunnel covers remote use, no WAN bind needed | retoor | 2026-11-30 | Pin WAN allowlist plus in-binary TLS via new ADR | | A-03 | Load stays under 100k blobs and 10k grants per host | retoor | 2027-01-31 | Shard store by UUID prefix plus index, ADR first | ### 0.3 Hard global caps | Cap | Value | Enforced at | |-----|-------|-------------| | layers | 1 to 8, default 3, clamped on load, v1 blobs only | server-side | | stream chunk | 64KB | server-side | | request header | 64KB max, 413 beyond | server-side | | single blob | 512MB max, 413 beyond | server-side | | blobs per store | 100000 max, 507 beyond | server-side | | grants per DB | 10000 max, grant refused beyond | server-side | | sessions | 1000 concurrent max, oldest dropped | server-side | | rate login | 5 per 300s per IP, 429 beyond | server-side | | rate store | 20 per 300s per peer, 429 beyond | server-side | | block strikes | 20 per 300s closes IP for 3600s, duress first | server-side | | connections | 64 concurrent max, 503 beyond | server-side | | form bodies | 64KB max on login plus grant, 413 beyond | server-side | | rate entries | 10000 ATT plus 10000 BLK max, oldest evicted | server-side | | audit file | 100MB, external rotation only | ops-side | | log dir total | 500MB, weekly prune check | ops-side | | grant pass | 22 chars from 64-alphabet | server-side | | hex rand | creds 8, session 16, duress suffix 8 | server-side | ### 0.4 Floors (never crossed by automation alone) | Floor | Rule | On hit | |-------|------|--------| | audit retention | keep 30 days minimum | page human, stop rotation | | blob delete | binary deletes only on duress wipe | page human | | DB delete | binary deletes only on duress wipe | page human | | protected paths | .env.json, tosv_db.txt, tosv_store never auto-pruned | page human | | signal shutdown | close only, no wipe | log line, no page | | drill interval | restore drill at least monthly | mark ops gate red | ### 0.5 Changelog (ascending, one row per change) | Version | Date | Change | |---------|------|--------| | 0.1.0 | 2026-10-31 | Initial Mode A spec, zero open gaps, G0 review | | 0.1.1 | 2026-10-31 | Register security deep-dive docs plus concept plus implementation root as synced mirrors | | 0.1.2 | 2026-10-31 | G0 passed by owner instruction; M1-M4 built: loopback, streaming, DAV crypt, WORM, caps, Gate 2 54/54, runbooks, drill pass | | 0.1.3 | 2026-10-31 | M5 issue-zero: FR-10 blocks, FR-13 tags, FR-14 clock guard, D-13 to D-16, v6, expiry, DB locks, mlock probe | | 0.1.4 | 2026-10-31 | M6 critical pass: FR-15 robustness, per-blob layers, tw radio plus keep, DB injection fix, crash class closed, Gate 2 145/145 | | 0.2.0 | 2026-10-31 | M7 v2 AEAD: secretstream plus Argon2id, pinned static libsodium, v1 legacy read, leg-hash finding frozen, layers v1-only, Gate 2 178/178, NFR-04 p95 153ms, NFR-05 29s plus 567528B | | 0.2.1 | 2026-10-31 | M8 load tests: locustfile plus runner plus make targets, 10u smoke green, 64u soak green, 80u 503-shed proof, Gate 2 178/178 | | 0.3.0 | 2026-10-31 | M9 key cache: bounded LRU 128 plus TTL 300 plus guarded keys, 64u median 4.0s to 6ms, Gate 2 192/192, ADR 0007 | | 0.4.0 | 2026-11-01 | M10 own SSH/SFTP daemon: strict-kex X25519 plus chacha20-poly1305 plus ed25519, gateway identity plus in-band grant, SFTP v3 vault-native, Gate 2 348/348, libFuzzer clean, sftp soak, wipe pass, live caps, rclone, bench graphs, ADR 0008, NG-01 retired | | 0.5.0 | 2026-11-03 | M11 post-quantum SSH KEX: mlkem768x25519-sha256 hybrid via pinned static mlkem-native 2.0.0, curve25519 fallback, SF-61, ADR 0009, R-04 part 1, gate2 cap-clear E2BIG fix, Gate 2 351/351 | | 0.5.1 | 2026-11-05 | Quantum posture audit: SEC-09, docs/quantum-posture.md, gaps R-16 to R-20; fixes SEC-10 PQ-only SSH switch (SF-62), SEC-11 optional TLS 1.3 build with X25519MLKEM768 (ADR 0010, static link pending), FR-17 restore-v2; R-19 closed as no change | | 0.5.2 | 2026-11-05 | SEC-11 TLS build now fully static: pinned vendored OpenSSL 3.5.5 (make openssl, 41s build), make TLS=1 binary 7.98MB, static live test X25519MLKEM768 plus 8MB roundtrip, NFR-05 exception for TLS build, R-16 mitigated | | 0.5.3 | 2026-11-05 | SF-63 fix: server closes the SSH channel on client EOF and waits for peer CLOSE (OpenSSH 10.2 sftp -b hung after a failed command, reproduced on pre-0.5.0 code; the root cause of the gate2 stalls); gate2 x-surface HTTP stores use a fresh server instance (store rate cap 20 per 300s was spent); Gate 2 364/364 | | 0.6.0 | 2026-11-05 | In-tree TLS 1.3 replaces OpenSSL (ADR 0011, D-23): no new dependency, binary 723KB, X25519MLKEM768 only by default, `tosv --tls-selfsign`; SFTP now PQ-only by default (TOSV_SFTP_ALLOW_CLASSICAL=1 opts out); OpenSSL vendoring and TLS=1 removed; R-16 and R-17 closed by default | | 0.6.1 | 2026-11-05 | tls13.inc: HelloRetryRequest toward X25519MLKEM768, handshake mutation-fuzz run, gate +1 assert | ## 1. Goals and non-goals | ID | Goal (measurable) | |----|-------------------| | G-01 | One operator stores and fetches blobs via wizard plus HTTP plus WebDAV plus SFTP with zero manual key handling | | G-02 | Every new blob sealed with secretstream AEAD in 64KB chunks, keys via Argon2id, v1 blobs stay readable, keys wiped after use | | G-03 | Every grant bound to random creds plus UUIDv4 plus optional IP list plus optional time window | | G-04 | Bootstrap creds work once then burn; duress creds wipe store plus DB with audit line | | G-05 | Suite plus smoke green, docs synced same commit, all gates green before serve | | ID | Non-goal (decided, not deferred) | |----|-------------------------------| | NG-01 | RETIRED 0.4.0: SFTP delivered per D-21, see docs/sftpserver.md | | NG-02 | No external TLS library; TLS is in-tree (tls13.inc, SEC-11, ADR 0011), stunnel not needed | | NG-03 | No multi-tenant operators in v1, see A-01 | | NG-04 | No billing or metering, BIL unused, see D-11 | | NG-05 | No compliance certifications in v1, see section 6.4 | | NG-06 | No container image in v1, single binary, see D-09 | ## 2. Scope Personas: Operator (runs vault, creates grants, drills restore); Storer (holds store creds, uploads blobs); Fetcher (holds grant creds, downloads within IP plus window). One human may hold several roles; the binary does not distinguish beyond creds, see FR-04. Use cases: (1) Operator bootstraps once, opens wizard, creates a grant with IP plus window. (2) Storer uploads a file, gets a UUID. (3) Fetcher downloads by UUID inside the window from an allowed IP. (4) Operator revokes by deleting the grant line (manual, audited). (5) Under duress, anyone with duress creds wipes the vault. Out of scope: in-binary TLS, multi-tenancy, billing, certifications, containers, see NG-02 through NG-06. (SFTP joined scope in 0.4.0, NG-01 retired.) ## 3. Requirements ### Functional | ID | Requirement | |----|-------------| | FR-01 | Bootstrap: first run creates .env.json admin plus 16-char pass if missing; one POST /login with those sets used=1, issues store creds plus duress, burns bootstrap | | FR-02 | Wizard: GET / session-only shows IPs field, from and to datetime fields, two-way radio default append-only, layers 1 to 8 default 3, omitted tw and layers keep current values, layers inert for v2 blobs | | FR-03 | Grant: POST /grant session-only creates get_* user plus 22-char pass plus UUIDv4, stores ips, frm, to; returns retrieve plus store creds plus mode | | FR-04 | Store: POST /store with Basic store creds streams v2 AEAD seal to tosv_store/UUID.bin, returns id JSON; 403 on bad auth, 429 on rate, 413 on oversize | | FR-05 | Fetch: GET /fetch/UUID with Basic grant creds enforces IP then window, streams octet-stream; 403 denied, 404 missing, 403 too early or expired | | FR-06 | Streaming: store and fetch both stream in 64KB chunks; never more than one chunk plus key plus stream state in RAM for payload; one KDF at a time bounds transient to 64MB | | FR-07 | Logout: GET /logout clears tosv cookie, 302 to /login | | FR-08 | Duress: POST /login with duress value audits duress then wipes store plus DB, replies 403 wiped | | FR-09 | WebDAV: /dav* serves class 1 (OPTIONS, PROPFIND, MKCOL, PUT, GET, HEAD, DELETE, COPY, MOVE, LOCK, UNLOCK, PROPPATCH) with grant auth plus IP check, strips dot-dot; PUT crypts same as FR-04, GET decrypts same as FR-05, HEAD reports plaintext length with empty body | | FR-10 | Rates plus blocks: login 5 per 300s per IP, store 20 per 300s per peer, 429 beyond; SFTP twins: auth 5 per 300s, stores 20 per 300s; 20 strikes per 300s blocks an IP for 3600s with 403, duress evaluated first | | FR-11 | Audit: append UTC ISO plus IP plus action plus id for bootstrap, login, grant, store, fetch, dav ops, sftp ops (connect, auth, open, read, write, close, list, remove, mkdir, rename, escape, reject), duress; never secrets or PII | | FR-12 | DB: flat key=value plus grant lines, escape backslash and equals plus pipes plus newlines in grants, atomic tmp plus rename save, clamp layers on load, reload-modify-save under lock, checked writes with 500 on failure | | FR-13 | Integrity: sidecar per blob carrying hash plus layers plus version (v2 real SHA256 with 0 2, v1 legacy hash), crypto verified before serve, 500 plus aead-fail or integrity-fail audit on mismatch, unknown version 500, transparent backfill when missing | | FR-14 | Clock guard: hourly SNTP skew check against TOSV_NTP (empty disables), audit past 60s, never blocks | | FR-15 | Robustness: catch-all 500 per request, 64 conn cap with 503, 30s recv timeout, 64KB form cap, chunked 501, no-store on all replies, 0600 on env plus DB, fid charset, 10k ATT cap, fatal bind, port validation, logout erases server session | | FR-16 | SFTP surface: tosv-sftp serves SSH-2.0 plus SFTP v3 per docs/sftpserver.md (strict-kex X25519, chacha20-poly1305, ed25519 pubkey, gateway-bound gids, in-band grant pass, shared store plus gates plus audit); exec, pty, forward refused | | FR-17 | Offline v1 to v2 re-store: `tosv --restore-v2` dry-run lists v1 blobs, `--apply` converts each (v1 decrypt, v2 seal, plaintext SHA-256 compared before swap), originals moved to tosv_v1_bak/, integrity-failing blobs skipped loudly with audit, run with server stopped | ### Security | ID | Requirement | |----|-------------| | SEC-01 | Layers 1 to 8 set per grant batch, default 3, stored in DB; v1 blobs only, inert for v2 | | SEC-02 | Keys v2: 32B via Argon2id INTERACTIVE from store auth plus per-blob salt; fetch keys memoized in a bounded cache (128 LRU, 300s TTL, guarded allocs, wipe-on-evict, salt-bound, verification never skipped); v1 legacy chain kept for old-blob read; wipe plus munlock after use | | SEC-03 | Crypt v2: secretstream XChaCha20-Poly1305 over 64KB MESSAGE chunks with FINAL terminator, verify-before-serve pre-pass; v1 XOR path read-only for legacy blobs | | SEC-04 | UUIDv4 custom with RFC variant bits, no uuid library | | SEC-05 | IP gate: exact match or CIDR mask compare, comma list, empty means open | | SEC-06 | Window gate: compare UTC %FT%H:%M strings, empty bound means open | | SEC-07 | Session: cookie tosv=s_hex16, HttpOnly, Path=/; missing session 302 to /login | | SEC-08 | No TLS in binary; loopback default plus stunnel front for remote, see OPS-01 | | SEC-11 | In-tree TLS 1.3 (tls13.inc, ADR 0011, no external library): TOSV_TLS_CERT plus TOSV_TLS_KEY (Ed25519 PEM, or `tosv --tls-selfsign`), group X25519MLKEM768 only unless TOSV_TLS_ALLOW_CLASSICAL=1, TOSV_BIND non-loopback refused without TLS, 128 conn cap, 30s handshake, 60s idle; default binary 723KB | | SEC-10 | SSH PQ-only by default: tosv-sftp offers and accepts only mlkem768x25519-sha256 (plus strict-kex marker); TOSV_SFTP_ALLOW_CLASSICAL=1 restores curve25519 (SF-62, ADR 0011) | | SEC-09 | Quantum posture: at-rest v2 AEAD and SHA-256 are quantum-resistant; SSH KEX is PQ hybrid with classical fallback; HTTP transit, Ed25519 host and user auth, Argon2id INTERACTIVE and v1 blobs are open gaps R-16 to R-20, see docs/quantum-posture.md | ### Ops | ID | Requirement | |----|-------------| | OPS-01 | Bind 127.0.0.1 default, port arg default 8765, print bind line on start | | OPS-02 | Logging: stdout start line, audit file append, external rotation at 100MB | | OPS-03 | Backup: daily restic to off-site, keep 7 daily 4 weekly 6 monthly, monthly restore drill | | OPS-04 | Runbooks: seven indexed runbooks written and drilled before launch, see 6.5 | | OPS-05 | DTAP: dev, test, accept, prod use separate ports plus data dirs, zero shared state | | OPS-06 | Incidents: every alert names owner plus runbook; SEV-2 or higher gets postmortem in 48h | ### Non-functional | ID | Requirement | |----|-------------| | NFR-01 | Two single-file mains (tosv.cpp, tosv-sftp.cpp) plus shared vault.inc, C++17, whole app | | NFR-02 | One pinned dep: stdlib plus POSIX plus pthreads plus static libsodium 1.0.22 from hash-pinned source, see PIN-02 | | NFR-03 | Memory flat vs blob size: 64KB chunks, see FR-06 | | NFR-04 | p95 fetch under 2s for 10MB on loopback; measured 2026-10-31: p50 139ms p95 153ms idle; under load p95 370ms at 10 users; with key cache 64u median 6ms p95 8ms at 1MB; 503 shed beyond 64 conns | | NFR-05 | Build under 60s on 2-core, each binary under 5MB (tosv 723KB with TLS, tosv-sftp 691KB, 2026-11-05); measured 2026-10-31: 29s taskset 2-core from scratch, 567528 bytes; re-measured 2026-11-01: PENDING full ci | ### UX | ID | Requirement | |----|-------------| | UX-01 | Wizard responsive single column at 360px phone width, no horizontal scroll | | UX-02 | Grant result shows retrieve plus store creds in copy-safe code blocks plus mode line | | UX-03 | Errors are plain text reasons (denied, blocked, too early, expired, missing), no traces | ## 4. Surfaces | ID | Surface | Auth | Effect | |----|---------|------|--------| | PG-01 | GET and POST /login | bootstrap once, then store creds, duress always | session cookie or wipe | | PG-02 | GET / wizard | session | grant form | | PG-03 | POST /grant result | session | HTML plus JSON creds | | PG-04 | POST /store | Basic store | returns id JSON | | PG-05 | GET /fetch/UUID | Basic grant | octet-stream or error | | PG-06 | GET /logout | session | clear cookie | | PG-07 | /dav* methods | Basic grant or store | file ops per FR-09 | | PG-08 | SSH port, subsystem sftp | ed25519 gateway key plus in-band grant pass | SFTP v3 file ops per FR-16 | ## 5. Architecture Stack pins (no hedged clauses remain; each pin is one choice): | ID | Pin | |----|-----| | PIN-01 | Language C++17 | | PIN-02 | Libs: stdlib plus POSIX sockets plus pthreads plus pinned static libsodium 1.0.22, ADR 0005 supersedes zero-dep | | PIN-03 | Layout: single file tosv.cpp in repo root | | PIN-04 | Build: make build links pinned static libsodium with FORTIFY 3, SSP-strong, PIE, RELRO, BIND-NOW, CET | | PIN-05 | Storage: flat files (.env.json, tosv_db.txt, tosv_audit.log, tosv_store/) | | PIN-06 | Bind: 127.0.0.1 default, port 8765 default | | PIN-07 | TLS: in-tree TLS 1.3 over libsodium plus mlkem-native, no new dependency, see SEC-11 and ADR 0011 | | PIN-08 | Crypt: libsodium secretstream plus pwhash plus SHA256, 64KB stream, v1 legacy hash frozen | | PIN-09 | IDs: custom UUIDv4 plus hex rand, no libraries | | PIN-10 | Protocols: HTTP plus WebDAV class 1 in tosv, SFTP v3 in tosv-sftp since 0.4.0 | Flow: accept loop on one socket, one detached thread per conn, raw header parse to 64KB, Content-Length body read, route match, auth gate, handler, close. Shared maps (sessions, rates) plus audit plus DB save hold one mutex each; never held across socket IO. Threading: single accept thread plus short-lived conn threads. No queue, no cache, no retry policy beyond 429 replies. ## 6. Data model, API, security, compliance, ops ### 6.1 Data model - ENVF .env.json: {"user":"admin","pass":"16-char"}; created if missing; plaintext by design, single use, see FR-01. - DBF tosv_db.txt: used, su, sp, duress, tw, layers lines plus grant=gu|gp|gid|ips|frm|to lines; atomic save, see FR-12. - AUDF tosv_audit.log: one line per event, UTC ISO, IP, action, id; append only; rotation external, see FR-11. - STORED tosv_store/UUID.bin: v2 AEAD blobs (v1 legacy blobs stay readable); names are fetch UUIDs; no index file. ### 6.2 API | Route | Method | Auth | Effect | Codes | |-------|--------|------|--------|-------| | /login | GET | none | HTML form | 200 | | /login | POST | bootstrap, store, duress | cookie or wipe | 302, 403, 429, 500 | | / | GET | session | wizard HTML | 200, 302 | | /grant | POST | session | create grant | 200, 302, 400, 500, 507 | | /store | POST | Basic store | save blob | 200, 403, 413, 429, 500, 507 | | /fetch/UUID | GET | Basic grant | stream blob | 200, 403, 404, 500 | | /logout | GET | session | clear cookie | 302 | | /dav* | see FR-09 | Basic grant or store | file ops | 200, 201, 204, 207, 401, 403, 404, 500, 501, 507 | ### 6.3 Security properties What v2 gives: per-grant random creds, IP plus window gates, secretstream AEAD per blob (tamper, truncation, reorder, and salt attacks all fail closed with aead-fail audit), Argon2id keys, once-only bootstrap, audited duress wipe, rate caps, session HttpOnly, no key or secret in logs. What remains open: blobs leak length; no forward secrecy across blobs; v1 blobs keep legacy malleability until re-stored. See D-08 plus ADR 0005 (accepted). ### 6.4 Compliance Decided non-goals for v1: no GDPR erasure automation (manual grant delete plus blob unlink, audited); no SOC2 or ISO evidence pack; no third-party pentest (self-review plus smoke only); no data residency tags (single host). Each needs a launch-gate ADR before any regulated use. Audit log keeps 30 days minimum per floors. ### 6.5 Ops Logging: stdout gets the bind line; audit file gets events; no debug file in v1; levels fixed. Backups per OPS-03 with named commands backup-run, backup-verify, backup-prune (shell wrappers in M4). Runbooks indexed in docs/runbooks/README.md: bootstrap recovery, duress response, audit review, restore drill, stunnel front, incident comms, load testing (M8). DTAP per OPS-05. Incidents per OPS-06. Launch gates (all green or no launch): - Gate 0 spec: zero open gaps, ID defs unique, changelog ascends, forbidden scan clean, owner approves. - Gate 1 build: make build plus make smoke green. - Gate 2 function: FR-03 grant, FR-04 store, FR-05 fetch, SEC-05 IP gate, SEC-06 window gate, FR-09 WebDAV PUT plus GET with crypt, FR-08 duress on scratch data, all pass. - Gate 3 ops: runbooks written, restore drill pass, rotation check. - Gate 4 launch: docs synced, BUILD-TRACK rows DONE, tag v1.0.0. Living docs register plus tracking rules: | ID | Rule | |----|------| | TRK-01 | BUILD-TRACK.md is single build status; same-day updates; 7d stale fails docs CI; 14d escalates BLOCKED | | DOC-01 | Behavior, API, config, or ops change updates docs same PR; mirrors sync same commit; drift fails build | Register: SPEC.md plus mirrors (same commit, 0 days); track sheet (7 days); ADRs (before merge); runbooks (drill plus 30 days); CHANGELOG.md (same commit); risks section 8 (monthly plus incident); postmortems (48h after SEV-2 or higher); security deep-dives docs/security.md plus docs/sec-*.md (same PR as related SEC change, 30 days); concept plus implementation root (same PR as related scope change, 30 days). Minimum CI: lint touched files, serial smoke, doc-header check on every .md, forbidden-pattern scan, ID-def uniqueness. All green before merge. Migrations: DB changes are additive key lines with same-review rollback note; never edit a shipped line meaning, add a new key. ## 7. Estimates Person-weeks with drivers; range not theater: | Area | PW | Driver | |------|----|--------| | Spec plus ADRs | 1.0 | Normative spec plus pins plus gates | | Core HTTP, DB, auth, wizard | 2.0 | Raw POSIX parse plus session plus forms | | Crypto, store, fetch stream | 1.5 | secretstream plus Argon2id plus wipe | | WebDAV, rates, audit, duress | 1.5 | Eleven DAV methods plus gates | | Tests, runbooks, drill, gates | 1.5 | Smoke matrix plus six runbooks | | Total | 7.5 | Range 6 to 9 on DAV plus drill findings | Scope freeze: D-12 pins 0.1.0 scope. New ideas go to a later release unless a launch gate forces them. Owner override re-baselines the freeze the same day with new date plus cost. Never absorb scope silently. Note: legacy tosv.cpp exists as reference; M1 to M3 cost covers hardening fixes (FR-06 stream, PIN-06 bind, FR-09 crypt), not pure greenfield typing. ## 8. Risks and mitigations - Legacy fetch loaded whole blobs: violates NFR-03. Mitigation: FR-06 mandates streaming; Gate 2 checks 100MB fetch flat RAM. - Legacy bind was all interfaces: exposes vault to LAN. Mitigation: PIN-06 plus OPS-01 pin loopback; smoke asserts bind line. - XOR malleability: closed for new blobs 2026-10-31 by v2 AEAD (per-chunk Poly1305, FINAL terminator, verify-before-serve; Gate 2 proves tamper, truncation, salt cases). Legacy v1 blobs stay malleable until re-stored; re-store advised at next touch. - Quantum exposure: transit and auth are only partly PQ. Mitigation: SEC-09 plus docs/quantum-posture.md list gaps R-16 to R-20 with closures; at-rest data needs no change. - Audit growth: unbounded append fills disk. Mitigation: 100MB cap plus external rotation plus 500MB dir cap, see 0.3. - Clock skew defeats windows: VM clock jumps. Mitigation: UTC only, empty bounds open, NTP assumed per A-02 fallback review. - Grant DB races: two grants interleave save. Mitigation: mutex around load plus save in grant path; Gate 2 hammers 50 grants. - Duress misfire: typo wipes vault. Mitigation: duress value is 16-plus-8 random, never shown near login; drill on scratch only. - Single host loss: no replica in v1. Mitigation: OPS-03 restic daily plus monthly drill; RPO 24h, RTO 4h, measured. ## 9. Decisions | ID | Decision plus rationale | |----|-------------------------| | D-01 | Adopt seriousdevelopment Mode A: scattered intent across five sources needed one canonical spec | | D-02 | Use C++17 single-file over house Python: zero deps plus proven legacy shape, see ADR 0002 | | D-03 | Bind loopback by default: legacy bound all interfaces while printing loopback, that drift is banned | | D-04 | Signals close only, no auto-wipe: routine stops must never delete, floors page humans instead | | D-05 | No TLS in binary v1: single-file scope stays shippable, stunnel front covers remote | | D-06 | SFTP excluded v1: needs SSH lib, breaks PIN-02 zero-dep pin | | D-07 | Fetch streams 64KB: legacy whole-read violated NFR-03, fix in M2 | | D-08 | XOR layers were v1, v2 AEAD shipped: ADR 0005 accepted 2026-10-31, secretstream plus Argon2id, v1 path read-only | | D-09 | No container v1: single binary has nothing to compose, revisit with ADR | | D-10 | Makefile adapted for C++: method needs self-sufficient targets, Python targets do not fit | | D-11 | No billing: vault has no money flow, BIL family stays unused | | D-12 | Freeze 0.1.0 scope: estimates baseline 7.5 PW stands, re-baseline same day on change | | D-13 | Unkeyed tags plus AEAD: tag rot 500s, crypto tamper audits aead-fail, ADR 0005 accepted | | D-14 | Fail-open clock guard: detection without denial, weekly review closes the loop | | D-15 | Block list with duress priority: sprayers locked out, coercion path never blocked | | D-16 | Hygiene batch: v6 CIDR, 24h sessions, bias-free hex, DB locks, mlock probes | | D-17 | M6 robustness batch: every crash, injection, and silent-failure class closed with suite proof | | D-18 | v2 KDF INTERACTIVE: measured 90ms store plus p95 153ms fetch at 10MB, keeps NFR-04 headroom, MODERATE revisit if budget allows | | D-19 | Legacy hash frozen for v1 read: hand-rolled SHA256 failed known-answer test, kept byte-identical for old blobs only, v2 uses real SHA256 | | D-20 | Key cache over weaker KDF: memoize fetch keys within a 300s cryptoperiod instead of lowering Argon2id cost, ADR 0007 | | D-22 | Optional OpenSSL TLS build (ADR 0010), superseded by D-23 | | D-23 | In-tree TLS 1.3 server over libsodium plus mlkem-native, PQ hybrid by default on HTTP and SFTP, no external library, ADR 0011 | | D-21 | Own SSH/SFTP daemon over wolfSSH: no GPL and no commercial license, vault-native SFTP in-repo under single-file discipline, supersedes D-06, ADR 0008 | ## Appendix A. Research log No web queries: stack pins derive from in-repo sources, not vendor choice. Sources read 2026-10-31: tosv.cpp (120 lines dense, 22KB), ARCHITECTURE.md, README_TOSV.md, archive/README.md.legacy, archive/tosv.py.legacy (277 lines), uploads/paste.txt (vision plus protocols), plan.md (wizard history), pdf/931edaee4c9e/source.md (elite report, XChaCha20 v2 pointer), tasks/4ef6d085742c/report.md. Synthesis: pins PIN-01 through PIN-10 plus D-02 through D-09. Web research triggered once for the v2 AEAD choice, filed as docs/research/v2-crypto-2026-10-31.md (11 sources: libsodium docs, RFC 9106, OWASP, GitHub Releases API, Debian, GCC) plus accepted ADR 0005. M10 triggered SSH research, filed as docs/research/ssh-transport-2026-10-31.md plus normative docs/sftpserver.md (60 SF plus 8 INT) plus accepted ADR 0008. Further research triggers only on new load-bearing choice, filed as new ADR then. ## Appendix B. Verification mechanics Adapted to this repo (definition rows start with pipe plus ID): ```sh # ID definitions unique: must print nothing (1-3 letters covers G, D) rg -o '^\| ([A-Z]{1,3}-[0-9]+)' SPEC.md | sort | uniq -d # changelog ascends top to bottom rg '^\| [0-9]+\.[0-9]+' SPEC.md CHANGELOG.md # forbidden strings: must print nothing (pattern split to avoid self-match) rg -n 'TB[D]|\x{2014}' SPEC.md BUILD-TRACK.md docs/ AGENTS.md tosv.AGENTS.md # build plus smoke make build && make smoke ```