100%

03 — query-intel-up-front-ensure-fresh

Goal

Integrate the gate into scripts/intel-query.sh so EVERY query subcommand runs ensure_fresh up front: clean -> serve immediately; dirty -> scoped incremental (cheap legs only) then serve. Add an opt-out for callers that must not auto-refresh (status, explicit refresh, automation).

Implementation Sketch

Wrapper preflight: before dispatching any code/plan query, call ensure_fresh; on FRESH continue, on CHANGED (per-file content-hash divergence — never git) run sync-ori-graph.sh --changed <hash-diverged delta> (cheap legs sync per §04) then continue. Add --no-ensure-fresh (and honor it for status/refresh). Graceful degradation: gate failure logs + serves stale (never blocks a query on a broken gate).

Spec References

scripts/intel-query.sh (subcommand dispatch, graceful-degradation exit-0 contract); intel_repo/CLAUDE.md §CLI Routing Tests (dispatch-smoke harness); skill: query-intel

Work Items

  • Wrapper ensure_fresh preflight on every code/plan query subcommand
  • --no-ensure-fresh opt-out; auto-applied to status and refresh
  • Graceful degradation: gate error -> log + serve (never block/abort a query)
  • Extend tests/test_intel_query_cli.sh dispatch-smoke to assert the preflight runs + opt-out honored