fix(agent): stop stack overflow in agent_factory test under full features - #6711
Merged
Conversation
bug-ops
enabled auto-merge (squash)
July 28, 2026 19:01
bug-ops
force-pushed
the
fix/6699-agent-factory-stack-overflow
branch
from
July 28, 2026 19:01
25f778b to
7714806
Compare
bug-ops
disabled auto-merge
July 28, 2026 19:01
…ures VigilGate::try_new recompiled the entire bundled injection-pattern bank on every Agent construction instead of caching it like every other consumer of RAW_INJECTION_PATTERNS. Under --features full, one bundled pattern's regex_automata Teddy prefilter build overflowed the default test-thread stack, reached ~25 frames deep through the two-agent construction chain in build_agent_factory_gates_trust_state_independently_per_session. Cache the bundled-pattern compile behind a process-wide LazyLock in vigil.rs, matching the six existing sibling call sites, and give the affected test a dedicated 32 MiB-stack thread matching both MAIN_THREAD_STACK_SIZE and the coverage job's existing RUST_MIN_STACK (added in 9a1efb8 for this same test under instrumented coverage). Closes #6699
bug-ops
force-pushed
the
fix/6699-agent-factory-stack-overflow
branch
from
July 28, 2026 19:01
7714806 to
2f3ed71
Compare
bug-ops
enabled auto-merge (squash)
July 28, 2026 19:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VigilGate::try_new(crates/zeph-core/src/agent/vigil.rs) recompiled the entire 14-pattern bundled injection bank viaregex::Regex::new()on everyAgentconstruction — the only one of 7 consumers ofRAW_INJECTION_PATTERNSthat didn't already cache the compile behind aLazyLock. Cached it behind a process-widestatic, matching the six sibling call sites (zeph-sanitizer,zeph-mcp,zeph-skills). Independent perf fix, not itself sufficient to prevent the crash (nextest runs each test in its own process, so the cache is cold on first touch regardless).--features full, one bundled pattern triggersregex_automata's SIMD Teddy-prefilter builder, whose frame overflowed the default 2 MiB test-thread stack when reached ~25 frames deep throughserve::agent_factory::tests::build_agent_factory_gates_trust_state_independently_per_session's two-Agentconstruction chain (inflated further byfull's unboxedAnyProvider::Candle/Gonka/Cocoonvariants). Gave that test a dedicated 32 MiB-stack thread (named, with aresume_unwindpanic passthrough), matching bothMAIN_THREAD_STACK_SIZE(src/main.rs, zeph --daemon crashes with stack overflow on every invocation #5394) and thecoveragejob's existingRUST_MIN_STACK: "33554432"(added in9a1efb89afor this exact test under instrumented coverage) — the explicitstack_size()would otherwise have silently overridden that CI protection down from 32 MiB to a smaller value.coveragejob's CI comment to reflect that this test now self-manages its stack, while keeping the env var (it still protects other, unnamed multi-agent tests).Closes #6699
Test plan
cargo test -p zeph --bin zeph --features full serve::agent_factory::tests::build_agent_factory_gates_trust_state_independently_per_session -- --exact— passes (previously SIGABRT)cargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler,testing" --lib --bins— 15258 passed, 0 failedcargo +nightly fmt --check— cleancargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings— cleanRUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"— cleangitleaks protect --staged— no leaks