Skip to content

test(app): allow durable learning evidence retry in policy matrix - #2640

Merged
jbeda merged 1 commit into
mainfrom
fix/learning-matrix-flake
Nov 1, 2026
Merged

jbeda merged 1 commit into
mainfrom
fix/learning-matrix-flake

Conversation

@jbeda

@jbeda jbeda commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix a reproduced TestUsableAutoSkillsStockBuildPolicyMatrix flake: the test's three-second fake-time wait could expire during the intended five-second evidence-not-ready retry backoff.
  • Derive the test budget from the first retry backoff plus discovery intervals, without changing production retry policy.
  • Add a deterministic delayed-terminal case through the real durable learning pipeline, retaining exact policy state, receipt, activity, and publication assertions.
  • Give every matrix case its own XDG_CONFIG_HOME as well as explicit temporary UserModelDir.

Cause and regression

The engine saves the terminal aggregate and admits the durable learning attempt before emitting the terminal result event. This fixture appends streamed events to the durable log. Recovery can discover the admitted attempt before that terminal event has been appended, classify evidence as not ready, and persist its first five-second retry backoff.

Unmodified baseline reproduced empty learned skills with only one model call. Temporary observation of the actual durable attempt showed running, claim generation 1, no checkpoint, and claim expiry at fake second 5 while the test failed at fake second 3.

The regression withholds the terminal append until it observes that first short persisted backoff, confirms reflection has not called the provider, then releases the terminal evidence and requires the normal matrix assertions. Restoring only the old three-second polling budget makes this case fail with the same empty-skills/one-model-call signature.

Related: #2327, #1088, #1223. This fixes the reproduced current missing-skill timing failure only. It does not establish a fix for #1088's historical generic learned-skill RPC error or #1223's distinct inventory-catalog exhaustion warning; those issues should remain open. JSONL catalog consistency and cursor behavior are unchanged.

Verification

  • Baseline reproduced on multiple matrix cases; exact persisted-backoff observation captured.
  • Forced delayed-terminal case fails with the original three-second budget.
  • Full matrix: go test -race ./internal/app -run '^TestUsableAutoSkillsStockBuildPolicyMatrix$' -count=50 -cpu=1,2,4 -failfast -timeout=10m — passed 150 matrix executions / 1,650 subcase executions.
  • task test — passed.
  • task lint — passed.
  • task test:race — passed.
  • go run ./cmd/mecademo — passed, including tool call/result, permission ask/approval, and terminal result.
  • Independent Spec, Standards, Test Adequacy, and Go architecture reviews — no findings. Test Adequacy and architecture reviewers also passed focused tests.

API compatibility

Test-only change. No remote-observable behavior, exported Go API, protocol fields, stored-data format, API major, or feature identifier changes. No client upgrade required.

Account for the first evidence-not-ready backoff and force delayed terminal persistence in a regression case. Keep production retry policy and exact policy/publication assertions unchanged.

Co-authored-by: Mecatl <[email protected]>
@jbeda
jbeda merged commit b78d227 into main Nov 1, 2026
41 checks passed
@jbeda
jbeda deleted the fix/learning-matrix-flake branch November 1, 2026 17:52
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
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