feat: in-process critic, causal planner, and channel conjunction - #31
Conversation
The critic is the in-process second model (P0 critic-on-shortlist): corroboration gate on embed-only hits, agreement boosts for semantic plus structural evidence, identifier-collision penalty, and critic notes surfaced through hit_why and the agent JSON why array. Amp-Thread-ID: https://ampcode.com/threads/T-01a00262-72c5-75ac-9cfc-e9084ad6ac75 Co-authored-by: Amp <amp@ampcode.com>
Replace templated follow_up_queries and suggested_next with a deterministic planner (P0 causal-follow-ups). Follow-ups close the actual evidence gap: missing defs or callers channels, indecisive within-signal margin, critic-flagged identifier collisions. A settled hit gets no follow-ups. suggested_next derives from the actual top hit and stays executable asgrep commands only. Amp-Thread-ID: https://ampcode.com/threads/T-01a00262-72c5-75ac-9cfc-e9084ad6ac75 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a00262-72c5-75ac-9cfc-e9084ad6ac75 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a00262-72c5-75ac-9cfc-e9084ad6ac75 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a00262-72c5-75ac-9cfc-e9084ad6ac75 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a00262-72c5-75ac-9cfc-e9084ad6ac75 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a00262-72c5-75ac-9cfc-e9084ad6ac75 Co-authored-by: Amp <amp@ampcode.com>
|
Extended this PR with the last open P0 item, 7d5x.4 (multi-field conceptual eval), plus a real bug it flushed out.
|
| comparison | delta MRR | delta nDCG | delta Recall@20 |
|---|---|---|---|
hybrid (multi-field) vs --ab concat-embed |
0.000 | 0.000 | 0.000 |
hybrid vs --ab no-embed |
+0.008 | +0.020 | +0.059 |
Null result, recorded as such: on this gold, per-field rescoring changes nothing fusion had not already decided. The embed channel as a whole earns its seat (one conceptual query found only with embed on). Rows self-ab-concat-7d5x4-d18725e / self-ab-noembed-7d5x4-d18725e in baselines.md, tagged reproducible-in-tree with exact commands; explicitly not canonical MRR fingerprints. ONNX gate stays closed — no measured hole; a judged paraphrase eval on a foreign corpus remains the missing evidence and is named as such.
Validation: core lib 170, concat A/B 3, conjunction 5+11, e2e_smoke 8, evidence_merge 5, correctness epics 10, pattern_diff 3, plugins 19, embed lib, machine contracts 27 — all green. Tracker: 7d5x.4 and 5vur closed with evidence. All four P0 campaign items from the brief are now in this PR.
Implement fn $N($$$) { $STMT }, fn $N($$$) {}, if ($COND) { $BODY },
if $COND { $BODY }, and if $COND: $BODY as native in-process patterns
with exact statement-count semantics (single $BODY/$STMT = exactly one
named statement; comments are trivia; concrete conditions fail closed).
- Bypass pattern_nodes for nested templates since signatures cannot
encode statement counts; per-thread parser reuse + global compiled
query cache
- $OBJ.$METHOD($$$) now matches keyword receivers (self/this)
- Differential harness: ast-grep exit 1 means valid zero matches;
5/5 match-set equality vs ast-grep 0.45.1
- Fix clippy 1.97 lints across workspace; bench JSON contract test
pins ASGREP_BENCH_RATCHET=0; regenerate chain-expand golden
(score-only drift, hit identities unchanged)
- Docs: structural-patterns, mcp, comparison
Amp-Thread-ID: https://ampcode.com/threads/T-01a00262-72c5-75ac-9cfc-e9084ad6ac75
Co-authored-by: Amp <amp@ampcode.com>
|
Adds bead ast-sgrep-yira: native in-process nested structural templates.
|
…regex
Repo gate forbids #[test] in crates/*/src. Move keep_gate, scrub, and
golden inline test modules to tests/unit/{cli,testkit}/ via the
established #[path] include pattern; all 17 moved tests pass in place.
Pi package-security test still required the old cloud-embed disclosure
after commit 7a004f1 removed cloud/Ollama backends. Assert the current
truthful disclosure: source text is never sent to a remote embedding
API. All 23 pi launcher tests pass.
Amp-Thread-ID: https://ampcode.com/threads/T-01a00262-72c5-75ac-9cfc-e9084ad6ac75
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a003f3-e62e-75ca-950f-0de88d7fe0fe Co-authored-by: Amp <amp@ampcode.com> # Conflicts: # benchmarks/results/baselines.md # crates/ast-sgrep-cli/src/keep_gate.rs # crates/ast-sgrep-testkit/src/golden.rs # crates/ast-sgrep-testkit/src/scrub.rs
Amp-Thread-ID: https://ampcode.com/threads/T-01a003f3-e62e-75ca-950f-0de88d7fe0fe Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a003f3-e62e-75ca-950f-0de88d7fe0fe Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a006d4-a8ae-77c7-a203-288a069f14d5 Co-authored-by: Amp <amp@ampcode.com>
make the engine behave like a second model checking its own work, in-process, deterministic, no sidecar. Stacked on #30 (
feat/golden-assert-testkit, base7a004f1).What ships
1. Deterministic post-fusion critic (
a2dd668)crates/ast-sgrep-core/src/search/critic.rs, wired after fusion inSearcher:refreshin CSS vsauth_refresh) are penalized.whyon agent JSON: critic notes surface throughhit_whyand the agent envelope'swhyarray, built from field scores plus the contributor set.2. Causal follow-up queries (
035e7fc)crates/ast-sgrep-core/src/search/planner.rs:follow_up_queriesare computed from the actual top hit: kind, symbol, contributor gaps, critic notes, and margin. A weak-margin semantic hit onauth_refreshemitsdefs:auth_refresh/callers:auth_refreshas executable commands the engine would run.suggested_nextderives from the actual top hit; settled hits get no follow-ups.3. Two-channel conjunction queries (
c209752)crates/ast-sgrep-core/src/search/conjunction.rs:defs:/callers:/imports:/pattern:/literal:/regex:/word:/semantic:),AND/AND NOT.AND NOTsubtracts at the same scope, and matching right evidence merges into the contributor set.and, or multiple operators fall through to ordinary hybrid search, so plain English keeps its meaning (QG-023/QG-024 hold).semantic:exists only in this conjunction layer;ParsedQueryis unchanged.docs/QUERY_GRAMMAR.md(normative section + "not supported" updated).4. Honesty docs (
2021084)docs/comparison.md: adds a "Campaign goal (not current status)" section. No "replaces X" claim; the section names the keep-gates that must go green first.docs/progress/surface-deferrals.md:pattern-rewrites-not-in-productreopened on purpose, linked to beadast-sgrep-2t4q(blocked on nested patterns), row stays Open.Validation (RCH, all green)
Agent golden
tests/cli/fixtures/search_agent_hits.jsonregenerated for the newwhy/ follow-up shapes.Contracts kept
parity_score.jsonuntouched (certified=false,lower_bound=0); norelease_certificate.json..beads/, no.bench-history/, no incidentalkeep_gate.rs/ sqlite fmt noise in the diff.Tracker
Closed:
ast-sgrep-3xym(critic),ast-sgrep-z741(causal follow-ups),ast-sgrep-1rgt(conjunction).Created for the remaining campaigns:
yira(nested patterns),o8ng(pattern-diff keep-gate),k1ns(pattern-graph join),zxd9(literal-vs-rg fixture),o6i3(watch freshness),nusg(taint-lite),y7lj(nl fanout),2t4q(codemod dry-run, blocked on yira),ozcq(ONNX, blocked on 7d5x.4). Dependency graph acyclic.Not in this PR by design (the brief says do not boil the ocean in one PR): 7d5x.4 multi-field conceptual eval stays an open bead; P1+ campaigns are tracked, not started.
Adversarial review remediation
f1e0ae6c,f4f70d8e; stacked sync headeae486ea. CI was not awaited.