{
  "summary": "PRODUCTION TIMING FORENSICS — DONE\n\nConclusion\n- `spt endpoint list --json` latency is consumed by the CLI's local Git-backed project-column projection, not by the broker, mesh fanout, adapter discovery, or PTY/terminal attach.\n- The deterministic amplification is `local perches × project branches`: HFENDULEAM currently has 13 flat perches and 7 unique `p-*` project refs. For every local perch, `cmd_endpoint_list` calls `latest_project_ref`; that calls `project_refs_for`; that calls `project_history_for`; and that executes one `git for-each-ref` through `branches_by_recency` plus one `git show` through `read_at_tip` for each of the 7 project branches. That is exactly `13 × (1 + 7) = 104` sequential Git child processes before counting per-CWD project-ID probes (`git remote get-url origin`, with `git rev-parse --show-toplevel` fallback). The work is repeated from scratch on every list invocation, with no command-level cache or batch projection.\n- The 29–30 second shape is cumulative subprocess fanout, not one fixed 30-second wait. One repeated run completed in 29.223 seconds, below the generic 30-second Git bound, while producing a successful complete result. The controls scale with the projection: daemon status, which avoids it, took 0.335 seconds; endpoint-info for `hertz`, which has no CWD and exercises one endpoint's 8 branch-history Git children, took 1.210 seconds; list over 13 perches took about 29.6 seconds.\n\nDeterministic timing distribution\n- Existing controlled benchmark: `spt endpoint list --json` = 30.065 s, rc=0.\n- Reproduction 1: start_ms=1784091800862, end_ms=1784091830085, exact subtraction=29.223 s, rc=0. The probe report labeled it 29.232 s; the wall anchors differ by 29,223 ms, so 29.223 s is the exact value used here.\n- Reproduction 2: start_ms=1784091891635, end_ms=1784091921235, elapsed=29.600 s, rc=0, 2,654 output bytes. At this point the loaded subnet set was unexpectedly `[]`, yet the latency did not move materially.\n- Distribution over the three successful list measurements: min=29.223 s, median=29.600 s, max=30.065 s, arithmetic mean=29.629 s, range=0.842 s, population standard deviation≈0.344 s. All three returned rc=0.\n- Safe endpoint-run control: `spt endpoint run --help`, start_ms=1784092006855, end_ms=1784092007022, elapsed=0.167 s by exact subtraction (reported rounded as 0.168 s), rc=0, 2,319 bytes. Clap exits before endpoint-run dispatch, picker gathering, creation, or attach. This establishes that executable startup and argument parsing are fast; latency in real `endpoint run` invocations must begin after dispatch, where the picker calls `adapter_options`, `gather_endpoints`, and the same local project-history path.\n- No real `endpoint run` was executed, because direct or interactive forms can create, start, or attach.\n\nExact daemon-log correlation\n- Reproduction 1 command window: `[1784091800862, 1784091830085]`.\n  - `daemon.stderr.log:4420-4421`: conn=1520, wall_ms=1784091805108, `event=write-start`, then `event=transport-close poisoned=false timed_out=false` at the same millisecond.\n  - `:4422-4423`: conn=1521 at 1784091810151, clean start/close.\n  - `:4424-4425`: conn=1522 at 1784091815197/1815198, clean start/close.\n  - `:4426-4427`: conn=1523 at 1784091820250, clean start/close.\n  - `:4428-4429`: conn=1524 at 1784091825305, clean start/close.\n  - The next identical pair is conn=1525 at wall_ms=1784091830351 (`:4430-4431`), 266 ms after the CLI had already ended. Intervals among the in-window starts are 5,043, 5,046, 5,053, and 5,055 ms.\n- Reproduction 2 command window: `[1784091891635, 1784091921235]`.\n  - The preceding periodic pair is conn=1538 at wall_ms=1784091890898/0899 (`:4456-4457`), 737 ms before command start.\n  - In-window pairs are conn=1539 at 1784091895942 (`:4458-4459`), conn=1540 at 1784091900985 (`:4460-4461`), conn=1541 at 1784091906029 (`:4462-4463`), conn=1542 at 1784091911072 (`:4464-4465`), conn=1543 at 1784091916114 (`:4466-4467`), and conn=1544 at 1784091921164 (`:4468-4469`). Every close is same-millisecond and says `poisoned=false timed_out=false`. Intervals are 5,043, 5,044, 5,043, 5,042, and 5,050 ms. The last pair is 71 ms before command completion.\n- The same cadence exists continuously before, between, and after both commands (`daemon.stderr.log:4410-4475`). It is background brain traffic, not a request opened by endpoint-list. There are no role/endpoint/session attribution facts on these connections, no held connection spanning a command, and no delayed close at command end.\n- Help control window `[1784092006855, 1784092007022]` happens to contain the same periodic background pair: conn=1561 at wall_ms=1784092006935, clean start/close (`daemon.stderr.log:4502-4503`). The help command still finishes in 167 ms. This is a direct negative control showing that temporal overlap with these daemon connections does not cause list latency.\n- No `PUMP_PEER_FAIL`, `CONN_WRITE_POISONED`, or `CONN_WRITE_RETIRED` record appears anywhere in the exact list-command windows (`daemon.stderr.log:4410-4475`).\n\nSubsystem accounting\n1. Local broker request time: 0 ms attributable to endpoint-list. `cmd_endpoint_list` does not call `ensure_daemon`, `Brain::cold_start`, or any broker RPC. The wall-stamped daemon pairs are a pre-existing ≈5.04-second background cadence and close immediately.\n2. Registry/network fanout time: 0 ms attributable to endpoint-list. The command reads `identity/registry/*.json` with `wansend::load_snapshots`, a local `read_dir` + `read_to_string` + JSON parse. It never dials peers. During reproduction 2, `SubnetStore::load()` yielded no member subnets, so the JSON path's `names` vector was empty and it ran no per-subnet `resource_projection`; latency still measured 29.600 seconds.\n3. Local project/history projection: dominant delay. Thirteen `latest_project_ref` calls independently rescan the same Git-backed branch store. The exact minimum is 104 serial Git children, plus Git probes for each distinct non-owlery CWD. This is the only list-specific code path whose multiplicity and subprocess boundaries match the 29–30-second behavior and the single-endpoint control.\n4. Adapter discovery: 0 operations in endpoint-list. No adapter registry function appears in `cmd_endpoint_list`. A real endpoint-run picker does call `picker::data::adapter_options`, but that is local adapter record/manifest reading; it then calls `gather_endpoints`, whose project-history gathering can reproduce the same local fanout. The 167 ms `endpoint run --help` control stops before both.\n5. Terminal attach: 0 operations in both endpoint-list probes and the help control. No `rc::run_attach`, PTY creation, alternate-screen picker, controller writer, or viewer writer is entered.\n\nRelation to the mesh-isolation/address-bootstrap deletion trap\n- The mesh is independently unhealthy: the current daemon log contains ordinary `PUMP_PEER_FAIL:<peer>:submit-dial exceeded the 10s bound (peer unresponsive)` records, and source logs these from the daemon pump's per-peer dial path. Those records have no `wall_ms`, so they cannot be assigned to a command merely by textual adjacency.\n- In the exact command windows there are no such failure records. More decisively, the second list remained 29.600 seconds after the active subnet set became empty, eliminating per-subnet registry projection and any possible endpoint-list peer fanout. Therefore the mesh-isolation/address-bootstrap trap explains absent/stale remote data and background pump failures, but not this CLI delay.\n- The exact-route deletion and ID-only discovery failure are not consulted by endpoint-list. The list consumes persisted snapshots and local owlery/branch-store state only.\n\nRelation to the earlier PTY SharedSend freeze\n- Refuted. The historical pre-v0.30.6 wedge was a physical broker write held under `SharedSend`; its current diagnostic signature is `CONN_WRITE_POISONED` after a bounded write deadline, with a poisoned/timed-out connection and terminal/controller involvement.\n- Both list windows contain zero `CONN_WRITE_POISONED` records, zero timed-out closes, zero endpoint/controller/viewer attribution, and no attach call. Every coincident connection closed cleanly in 0–1 ms. The current log does contain older `CONN_WRITE_RETIRED` organic BrokenPipe events outside these windows, but the split token explicitly distinguishes those fast organic failures from deadline poison; neither class appears during the reproductions.\n- Thus the list delay neither shares the PTY code path nor exhibits its failure signature.\n\nSafe fix shape\n- First, specialize `latest_project_ref` for its actual contract. The current function computes the entire project history and then takes `.next()`. Preserve precedence exactly but short-circuit: inspect session entries newest-first, excluding owlery paths and duplicate CWDs; return the first valid derived project immediately; then inspect `info.cwd`; only if neither yields a project should it query Git-backed context branches for the first store-only project. For almost every HFENDULEAM perch this removes the branch-store scan entirely.\n- Second, when a surface truly needs histories for many endpoints, batch once per command. Run `branches_by_recency` once, inspect each `p-*` tree once, build `endpoint_id -> ordered project IDs`, and reuse it for all rows. Complexity changes from `O(P × B)` Git processes to `O(B)` Git processes for P perches and B branches.\n- Third, cache `project_id_and_display_for_dir` by normalized CWD for the command. Multiple HF endpoints point at the same `spt-core` directory; each currently repeats `git remote get-url origin` independently.\n- Do not alter broker deadlines, peer dial behavior, connection poisoning, PTY writes, adapter discovery, or mesh addressing for this latency. Those are different systems.\n\nSafe regression-test shape\n- Add a pure/injected `latest_project_ref_from` test proving output parity with `project_refs_for(...).first()` for: newest session CWD, duplicate CWDs, owlery-only history, origin-only history, no-CWD store fallback, and non-git folder fallback.\n- Inject/count the CWD derivation and store-history closures. Assert a newest valid session CWD invokes the derivation once and the store loader zero times. This observable call-count contract fails on the current eager full-history implementation without relying on wall-clock thresholds.\n- For batched history, seed P endpoint IDs and B project branches in a temp BranchStore and assert result equivalence to the old per-endpoint projection while an injected branch reader is invoked once per branch, not P times per branch.\n- Add endpoint-list JSON output parity covering local `project` fields before/after the change. Avoid a strict elapsed-time test; assert bounded operation counts, then retain a Windows smoke benchmark as evidence rather than as a flaky test gate.\n- Field verification after a fix should rerun the same three read-only controls with wall anchors: daemon status, endpoint-info hertz, and at least three endpoint-list JSON runs; confirm list latency no longer scales with `13 × 7`, output remains byte/JSON-equivalent, and daemon logs still show no command-attributable connection or poison activity.",
  "files": [
    {
      "path": "spt-core/crates/spt/src/cli.rs",
      "description": "`cmd_endpoint_list` at lines 2827+ is the CLI list implementation. The JSON branch loads local snapshot files, enumerates local perches, and at lines 2954-2978 maps every local row through `picker::data::latest_project_ref`; it has no daemon RPC, peer dial, adapter lookup, or terminal attach."
    },
    {
      "path": "spt-core/crates/spt/src/picker/data.rs",
      "description": "`latest_project_ref` at lines 457-463 calls full `project_refs_for(...).into_iter().next()`. `project_refs_for` at lines 469+ eagerly loads session history and `project_history_for`; `project_history_for` opens the shared BranchStore, calls `branches_by_recency`, then `read_at_tip` for every `p-*` branch. The endpoint-run picker also calls `adapter_options` and `gather_endpoints` here."
    },
    {
      "path": "spt-core/crates/spt-store/src/branchstore.rs",
      "description": "`branches_by_recency` at lines 237-257 shells out through `run_git_ok`; `read_at_tip`/`read_at` at lines 285-309 shell out once per branch. These calls are serial in `project_history_for`."
    },
    {
      "path": "spt-core/crates/spt-store/src/project.rs",
      "description": "`project_id_and_display_for_dir` at lines 92-139 performs `git remote get-url origin`, then a `git rev-parse --show-toplevel` fallback, each with a 10-second bound. Repeated CWDs are not cached across endpoint rows."
    },
    {
      "path": "spt-core/crates/spt-store/src/gitrun.rs",
      "description": "The single bounded Git subprocess runner. Every call spawns `git`, creates stdout/stderr drain threads, polls at 10 ms, and kills/reaps on timeout; default BranchStore bound is 30 seconds. Reproduction below 30 seconds rules out a single default-timeout wait in that run."
    },
    {
      "path": "spt-core/crates/spt/src/wansend.rs",
      "description": "`load_snapshots` at lines 690-710 is local filesystem work only: `read_dir`, `read_to_string`, and JSON parsing. It performs no network request."
    },
    {
      "path": "C:/Users/decid/AppData/Local/spt-core/owlery",
      "description": "Live HFENDULEAM state contains exactly 13 top-level `info.json` perches, the P multiplier in the 104-child minimum."
    },
    {
      "path": "C:/Users/decid/AppData/Local/spt-core/tracked/.seed.git/refs/heads",
      "description": "Live branch store contains 7 unique loose `p-*` project refs, the B multiplier. Packed refs duplicate some names but Git's ref projection resolves unique branch names."
    },
    {
      "path": "C:/Users/decid/AppData/Local/spt-core/logs/daemon.stderr.log",
      "description": "Exact wall-clock correlation source. Lines 4410-4431 cover reproduction 1; lines 4456-4469 cover reproduction 2; lines 4500-4503 cover the help control. Only periodic clean brain write-start/transport-close pairs occur; no peer failure, poison, retirement, controller, viewer, or attach event occurs in either list window."
    },
    {
      "path": "spt-core/crates/spt-daemon/src/conn.rs",
      "description": "Defines wall_ms/mono_ms stamps and the split diagnostics: `CONN_WRITE_POISONED` is reserved for bounded-write deadline failures; `CONN_WRITE_RETIRED` is an organic failure. This is the code basis for excluding the SharedSend wedge from the clean timed windows."
    },
    {
      "path": "spt-core/crates/spt-daemon/src/pump/mod.rs",
      "description": "Logs ordinary per-peer `PUMP_PEER_FAIL` records for failed 10-second submit-dials. This background mesh path is independent from endpoint-list and produced no failure record inside the exact command windows."
    }
  ],
  "architecture": "The observed path is entirely process-local: `CLI parse -> Cmd::Endpoint::List -> cmd_endpoint_list -> load SubnetStore + local registry snapshot JSON + enumerate owlery -> for each local perch latest_project_ref -> session ledger + Git-backed context branch scan + CWD Git probe -> serialize JSON`. The pathological edge is the per-row call into a whole-store projection: P local rows each rediscover B project branches and each spawn B readers, producing `P × (B+1)` sequential Git processes. The daemon architecture runs independently beside it: broker/brain/pump connections and peer dials continue on their own cadence, which is why clean wall-stamped background pairs appear during both slow list commands and the 167 ms help command. There is no edge from endpoint-list to broker IPC, QUIC discovery, adapter discovery, or PTY attachment. The correct architectural repair is to make latest-project derivation lazy and batch shared Git-backed history once per command, not to change network or write-deadline machinery."
}