{
  "summary": "The 400-iteration count dates to the helper’s creation; 25 ms replaced 5 ms in 3f771e11 explicitly to accommodate loaded-runner flakes. At a9e786b2, the nominal 10-second budget concerns first new stream visibility at the responder, not full sync convergence.",
  "files": [
    {
      "path": "crates/spt-daemon/tests/sync.rs",
      "description": "At a9e786b2: helper lines 98–110; snapshot and pull orchestration lines 158–213. Git line history identifies introduction fa97b80ef3a560c4fd77311b202cf982d7674abc and budget adjustment 3f771e11c7d4762fc5721945866982dcd21e4a9c."
    }
  ],
  "architecture": "Test-side orchestration snapshots responder streams, starts the requester, polls for a stream absent from that snapshot, then invokes serve_sync and joins the requester. The poll budget precedes serving/completion; it is not a convergence deadline or a peer timeout.",
  "report": "## Provenance at/before a9e786b2\n\nRead-only evidence: `git log --format=fuller -L :wait_for_stream_except:crates/spt-daemon/tests/sync.rs a9e786b2` returned exactly two function-history commits, corroborated by `git blame a9e786b2 -L 85,220 -- crates/spt-daemon/tests/sync.rs`. No edits, builds, tests, formatters, or linters were run.\n\n### 1. Original helper: fa97b80ef3a560c4fd77311b202cf982d7674abc\nAuthor/commit date: 2026-06-03 23:55:00 -0700.\n\nExact commit subject:\n> feat(net,daemon): M4-D6c-2 bundle sync over broker streams — wire records, server-side gate, reconcile wiring (REQ-NET-3, REQ-INST-5)\n\nExact relevant message excerpt:\n> Loopback two-daemon tests: two-tier scoping byte-identical + unsynced/\n> hidden refused server-side; concurrent writes surface on both nodes →\n> elected node reconciles → merge propagates + clears artifacts everywhere;\n> torn pull errors clean and recovers by re-pulling (apply idempotent).\n> Test harness lesson: the broker stream table holds locally-opened streams\n> too — responders must snapshot before waiting for the inbound request.\n\nOriginal source, `crates/spt-daemon/tests/sync.rs`, introduced at line 101:\n```rust\nfn wait_for_stream_except(brain: &mut Brain, skip: &[u64]) -> (u64, String) {\n    for _ in 0..400 {\n        let reply = brain.net_streams().expect(\"net-streams\");\n        if let Some(s) = reply.streams.iter().find(|s| !skip.contains(&s.stream_id)) {\n            return (s.stream_id, s.remote_id_hex.clone());\n        }\n        thread::sleep(Duration::from_millis(5));\n    }\n    panic!(\"sync stream never appeared at the responder's broker\");\n}\n```\nThus 400 was present from creation; the original nominal sleep allowance was 400 × 5 ms = 2 seconds. This original function and quoted commit text do not specify a numeric product requirement for that allowance.\n\n### 2. Patience increase: 3f771e11c7d4762fc5721945866982dcd21e4a9c\nAuthor/commit date: 2026-06-04 01:10:20 -0700.\n\nExact commit subject:\n> feat(daemon): M4-D7.5-2 Psyche outbound relay + sanitize boundary (REQ-HAZARD-PSYCHE-OUTBOUND-PROXY)\n\nExact relevant commit-message paragraph:\n> Also: harden the sync/propagate int-test stream-wait budgets 2s -> 10s\n> (polls exit early on success; the 2s bound flaked on gravity under a\n> parallel full-workspace run, rerun green — load, not logic).\n\nExact inserted source comment:\n```rust\n    // 10s budget: polls exit early when the stream appears, so the long bound\n    // only pays on a loaded runner (2s flaked on gravity under a parallel\n    // full-workspace run — 2026-06-04).\n```\nExact functional change:\n```diff\n-        thread::sleep(Duration::from_millis(5));\n+        thread::sleep(Duration::from_millis(25));\n```\n`for _ in 0..400` was unchanged. The source comment and commit message explicitly identify loaded-runner/test patience as the reason for 10 seconds.\n\n### 3. Candidate scope and precise meaning\nAt `a9e786b2:crates/spt-daemon/tests/sync.rs:98–110`, the helper retains that comment (99–101), `for _ in 0..400` (102), `brain.net_streams()` (103), first non-skipped stream predicate/return (104–105), 25 ms sleep (107), and the panic (109).\n\nExact orchestration comment at candidate lines 161–164:\n> The broker's stream table holds BOTH inbound and locally-opened\n> streams, so the responder must not grab one of its own (or an earlier\n> pull's) rows: snapshot the table before the requester opens its\n> stream, then wait for the genuinely new one.\n\nCandidate lines 172–178 snapshot stream IDs; lines 188–199 spawn the requester. Line 201 calls `wait_for_stream_except`; lines 203–212 subsequently call `serve_sync`; line 213 subsequently evaluates `(puller.join().expect(\"pull thread\"), outcome)`.\n\nTherefore the observed condition is **the first new, non-skipped broker stream becoming visible**, not bundle transfer/application, reconciliation, or full convergence. The helper returns before the responder begins `serve_sync`. No peer-timeout parameter is set by this helper.\n\nThe phrase “10s budget” is nominal: its code limits polling attempts and sleeps, not elapsed wall-clock time with an absolute deadline. `net_streams()` call time and scheduler delays are additional; an error in that call also panics immediately through `expect`. Consequently this is not source evidence of a hard end-to-end 10-second upper bound.\n\n### 4. Scope of conclusion\nFor this helper’s traced line history through a9e786b2, the explicit recorded rationale for changing 2 seconds to 10 seconds is test-load accommodation. The creation commit names REQ-NET-3 and REQ-INST-5 for sync behavior, while its numeric polling allowance is not described as a requirement in the inspected introduction/message. This investigation does not assert that no numeric sync requirement exists elsewhere in the repository, issue history, or external specification. General bounded-read requirements and independently configured peer timeouts must be assessed separately; this helper’s history does not establish either as the origin of its 10-second allowance."
}
