Skip to content

perf(adapter-manifest): validate a manifest once per call, CC-637 batch 1 (guard hook 5.3 s to 3.4 s on Windows) - #681

Merged
screenleon merged 3 commits into
mainfrom
perf/cc637-adapter-manifest-revalidation
Oct 6, 2026
Merged

screenleon merged 3 commits into
mainfrom
perf/cc637-adapter-manifest-revalidation

Conversation

@screenleon

Copy link
Copy Markdown
Owner

Summary

  • adapter_manifest_runner_kind, adapter_manifest_effective_route and adapter_manifest_dispatch_path re-ran the full manifest validation (two directory resolutions, two manifest reads) once per nested helper, about five times in dispatch_path. They now validate once and share a new internal _adapter_manifest_runner_kind_of. The checks and their order are unchanged.
  • Why it matters beyond tests: guard-executor-write.sh calls these on every codex write; on native Windows one hook call took 5.3 s.
  • Records CC-637 (this batch is requirement 1; requirements 2 to 4 are open) and links it to the existing CC-612, which found the same hotspot by profiling (CC-612 is now partial: no cache was added, only the nested repeats were removed).

Evidence (one machine, single measurements, noisy)

  • dispatch_path 1757 to 740 ms, effective_route 711 to 399 ms, guard-executor-write.sh call 5.3 to 3.4 s.
  • Differential run, old library from main versus new: 4 real adapters and 13 broken manifests (bad schema, name, runner_kind, route, entrypoint, duplicate keys), 4 functions each = 80 outputs, stdout, stderr and exit code byte-identical. A critic subagent ran an independent 97-line version under plain, set -e and set -u: identical.
  • test-executor-router.sh: 36 passed, 1 failed; the failure ('missing nonexec directory and symlinks rejected', no symlink or exec-bit support on this host) is identical on main (34 passed, 1 failed there, before the two new cases). test-hook-profile-parity.sh: 5 passed. test-guards.sh --filter exw:: 30 passed.
  • Mutation checks: removing the new helper's export -f fails the child-shell case; skipping runner_kind_valid fails the direct invalid-kind case.

Gate and review

  • Full pr-gate: NOT run (not feasible on this host); no gate result artifact.
  • Five reviewers ran individually as subagents (same model family as the author): critic, security, architecture approve; qa-tester approve with a coverage gap; risk WARN. Risk found a real bug in the first commit (the new helper was missing from the export -f block, so a child bash that inherits the exported public functions failed with command not found); fixed in the second commit with a regression case. QA's surviving mutant (no test for an invalid runner_kind called directly) got a case too.
  • Known gaps: the full test-guards.sh was not run (over 10 minutes here, and one background attempt was killed for memory pressure); symlink, exec-bit and boundary checks cannot be exercised on this host, so CI is the evidence for them; test-doctor.sh, test-install.sh and test-pmctl-adapter-generate.sh (partly) not re-run for this PR. adapter_manifest_dispatch_path already fails in a child shell that only inherited the exported functions (its safety patterns do not survive the export round trip); identical on main, not addressed here.
  • Permanent test admissions: two cases added to tests/shell/test-executor-router.sh (an existing suite).
    • adapter_manifest: exported functions work in a child shell: stable supported boundary (the library exports its public API for child shells), high-impact regression (a missing export made every public function fail there), implementation-independent observable (exit code and output), low maintenance, direct contract; killed by the missing-export mutant.
    • adapter_manifest_runner_kind: invalid runner_kind is rejected directly: same criteria; the shared validation helper is what the refactor touched and no test reached it directly; killed by the skip-validation mutant.

🤖 Generated with Claude Code

https://claude.ai/code/session_011c6rVDk6zyfgLPEfbVrZi9

screenleon and others added 3 commits October 6, 2026 12:39
…once per nested helper (CC-637)

dispatch_path called adapter_manifest_file about five times; on native
Windows that made a guard-executor-write hook call take 5.3 s.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011c6rVDk6zyfgLPEfbVrZi9
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011c6rVDk6zyfgLPEfbVrZi9
…alid runner_kind behavior, link CC-612 (CC-637)

Review (risk) found _adapter_manifest_runner_kind_of missing from the
export -f block: a child bash inheriting the exported public functions
failed with command not found. QA found no direct test for an invalid
runner_kind. Architecture: document the validate-once convention.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011c6rVDk6zyfgLPEfbVrZi9
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