Repository navigation
Description
Context
Part of #2963. Source-verified finding from the 2026-10-25 multi-agent test-value audit at c670449d3bf1b0639e50ce554d728961f4313add. Broad inventory screening was followed by detailed inspection of this finding; this is not a claim of exhaustive manual review or measured CI savings.
Classification: confirmed false-positive performance/schema guard; low cost.
Suggested issue title: Assert the cron lookup index rather than SQLite's ORDER BY result.
Evidence:
- Test “cron_runs index works for job lookup,” packages/ui-server/tests/db.test.ts:83-97, inserts five rows and asserts that ORDER BY started_at DESC LIMIT 1 returns the latest row.
- Fixture setup executes the shipped initial migration: packages/ui-server/tests/db.test.ts:10-18.
- Production index declaration: packages/ui-server/migrations/001_initial.sql:22, CREATE INDEX IF NOT EXISTS idx_cron_runs_job ON cron_runs(job_name, started_at DESC).
- Production status reader: createCronScheduler / getCronStatus, packages/ui-server/src/cron/scheduler.ts:168-204, uses the actual latest-per-job query. It is independently exercised by “getCronStatus returns latest run per job,” packages/ui-server/tests/cron-scheduler.test.ts:76-86.
What can pass while broken:
Delete idx_cron_runs_job from the migration. SQLite still scans and sorts these five rows, so the named index test passes. It also does not call getCronStatus; it cannot prove that the production status query uses a suitable access path.
Read-only verification performed:
On a disposable in-memory database created from the shipped migration, the exact latest-row predicate stayed true before and after DROP INDEX idx_cron_runs_job. EXPLAIN QUERY PLAN changed from:
- SEARCH cron_runs USING INDEX idx_cron_runs_job (job_name=?)
to: - SCAN cron_runs
- USE TEMP B-TREE FOR ORDER BY
The remaining index lookup returned null after DROP INDEX. Repository SQL/source was untouched. An initial probe hit SQLITE_LOCKED because its read statements were not finalized; rerunning with explicit finalization produced the result above. The initial diagnostic failure is not counted as mutation proof.
Alternate proof and value to keep:
Latest-run functional behavior already has a real scheduler test at cron-scheduler.test.ts:76-86, and multi-job separation at :88-99. Initial-schema defaults/constraints in db.test.ts remain useful schema proof. Index existence/shape needs its own observation if it is an intended invariant.
Safe change:
Replace the misleading row-order assertion with a shipped-schema index shape assertion using PRAGMA index_list / index_xinfo or a narrowly justified query-plan check. Preserve independent functional ordering at the scheduler layer. Do not add a benchmark/time threshold to five-row data.
Acceptance criteria:
- Removing or misordering the declared cron lookup index makes the index test fail for that index.
- Removing latest-per-job ordering from the scheduler makes the scheduler behavior test fail.
- Schema defaults/uniqueness/check constraints remain covered.
- The test name states exactly what is protected (declared index shape versus production query plan).
Focused verification/mutation proposal:
bun run test ./packages/ui-server/tests/db.test.ts ./packages/ui-server/tests/cron-scheduler.test.ts. In an isolated checkout, omit/change the index and observe the named index assertion fail; separately break the latest-run ordering and observe the real scheduler test fail. The in-memory index deletion above already proves the present test's blind spot.
Count/cost:
Rewrite one test rather than remove a meaningful index requirement. Present test measured 0.47 ms locally. No net runtime saving asserted.
Scope
Replace the misleading latest-row assertion with an observation of the shipped index shape, keeping production scheduler ordering proof.
Out of scope
Changing product behavior, public contracts, required proof gates, offline guards, runtime pins or unrelated tests. Every distinct native, security, lifecycle and adapter obligation identified above remains. This issue does not authorize deleting the surviving owner named by another audit issue.
Acceptance criteria
- Removing the declared index, reversing its key-column order, or changing
started_at DESCto ascending fails the named index assertion. Pin the shipped(job_name ASC, started_at DESC)key shape; do not count the implicit rowid entry as a key column. - The actual scheduler latest-per-job tests retain functional ordering and multi-job separation; no tiny-data performance timeout is introduced.
- Record an assertion-to-owner mapping for every moved or removed case, including shared-helper obligations; do not count matching test names as proof of equivalence.
- Run the proposed focused production mutation(s), observe failure on the intended assertion, restore, and record passing focused proof. A module-load error is not a behavioral receipt.
- Any performance claim separates scenario/body cost, setup and total elapsed time and uses comparable observations; structural counts alone are not a speedup.
Verification
bun run test ./packages/ui-server/tests/db.test.ts ./packages/ui-server/tests/cron-scheduler.test.ts
bun run check:pr --base origin/mainPreserve the existing offline/keyless harness. Browser/native commands require the documented real runtime and OS-offline prerequisites; missing prerequisites are not passing or skipped proof. The mutation proposals and retained boundary checks are detailed above.
Contract impact
No integration-contract or product-behavior change is selected. This is test/proof maintenance; retain the current CLI/MCP/wire/schema/frontmatter envelopes. No release-content change is selected.
2026-10-26 source clarification: the shipped migration declares idx_cron_runs_job on (job_name, started_at DESC). A disposable in-memory database on Bun 1.4.3 reports key entries job_name: desc=0, started_at: desc=1 through PRAGMA index_xinfo; index_info reports names/order but omits direction. The acceptance criteria now protect the existing direction too. No repository schema or test was changed.
Activity
schlessera commentedon Oct 25, 2026
2026-10-26 triage at main
c670449d3bf1b0639e50ce554d728961f4313add: verified the cited current test/production boundary and native #2963 parent. The scope names the retained proof, exclusions, checkable acceptance criteria, focused verification and mutation requirements; no unresolved design, decision, access or reproduction prerequisite prevents starting this test-maintenance task. Set priority p2 for wanted, unscheduled work and add agent-ready. Keep native/browser/SDK qualification required by the brief as implementation proof; this source/readiness review supplies no completed repair, post-change equivalence or measured CI saving.test: reduce redundant work and strengthen regression proof (#3164)