Skip to content

fix(query,export,migrate): deterministic order over the HashMap-backed store (REQ-160, #415)#417

Merged
avrabe merged 1 commit into
mainfrom
fix/deterministic-query-export-order
Jun 3, 2026
Merged

fix(query,export,migrate): deterministic order over the HashMap-backed store (REQ-160, #415)#417
avrabe merged 1 commit into
mainfrom
fix/deterministic-query-export-order

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Jun 3, 2026

Follow-up to #416 (REQ-159) — the site-migration half of #415.

What

Audited every store.iter().collect() site. Order-irrelevant ones (HashSet<id> membership) left as-is; render/externals.rs already sorted. Fixed the output-producing sites:

  • query::execute → returns results ascending by id. This is the shared set behind rivet list (whose default path did not sort → nondeterministic order), the MCP query tool, and {{query:…}} embeds — so all become deterministic at one chokepoint.
  • cmd_export (ReqIF/etc.) + cmd_export_zola → sort by id before emitting → byte-reproducible exports (matters for diffing/CI).
  • rivet schema migrate → sorts before computing the rewrite map → reproducible generated migration.

Verify

  • rivet list --format json id order identical across runs.
  • New execute_returns_results_sorted_by_id unit test.
  • Order-sensitive integration suites still pass: export_reqif_roundtrip (2), export_zola (2), migrate_integration (11); rivet-core query (19) + cli_commands (112) green.
  • rivet validate PASS; docs check PASS; clippy --all-targets + fmt clean.

With this, #415 is fully addressed (core + sites); the optional "back the store with an ordered map" remains as a possible future simplification but isn't needed now.

Implements: REQ-160

🤖 Generated with Claude Code

…d store (REQ-160, #415)

Follow-up to REQ-159: migrate the `store.iter().collect()` sites that
produce ordered, user-facing output so they're reproducible across runs.

Audited every site. Order-irrelevant ones (HashSet<id> membership) left
as-is; render/externals.rs already sorted. Fixed the output sites:
- `query::execute` returns results ascending by id — the shared set behind
  `rivet list` (whose default path did NOT sort), the MCP query tool, and
  `{{query:…}}` embeds, so all become deterministic at one chokepoint.
- `cmd_export` (ReqIF/etc.) and `cmd_export_zola` sort by id before
  emitting, so exports are byte-reproducible.
- `rivet schema migrate` sorts before computing the rewrite map so the
  generated migration is reproducible.

Verified: `rivet list --format json` id order identical across runs; new
`execute_returns_results_sorted_by_id` test; export_reqif_roundtrip /
export_zola / migrate_integration suites still pass; rivet-core query (19)
+ cli_commands (112) green; rivet validate PASS, docs check PASS; clippy
--all-targets + fmt clean.

Implements: REQ-160
Refs: REQ-159
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

📐 Rivet artifact delta

Change Count
Added 1
Removed 0
Modified 0
Downstream impacted (depth ≤ 5) 0

Graph

graph LR
  REQ_160["REQ-160"]:::added
  classDef added fill:#d4edda,stroke:#28a745,color:#155724
  classDef removed fill:#f8d7da,stroke:#dc3545,color:#721c24
  classDef modified fill:#fff3cd,stroke:#ffc107,color:#856404
  classDef overflow fill:#e2e3e5,stroke:#6c757d,color:#495057,stroke-dasharray: 3 3
Loading
Added
  • REQ-160

📎 Full HTML dashboard attached as workflow artifact rivet-delta-pr-417download from the workflow run.

Posted by rivet-delta workflow. The graph shows only changed artifacts; open the HTML dashboard (above) for full context.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rivet Criterion Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 4bfecc7 Previous: 8e9a9d1 Ratio
query/1000 11314 ns/iter (± 29) 6734 ns/iter (± 133) 1.68
query/10000 173338 ns/iter (± 6247) 101496 ns/iter (± 580) 1.71

This comment was automatically generated by workflow using github-action-benchmark.

@avrabe avrabe merged commit debde09 into main Jun 3, 2026
18 of 38 checks passed
@avrabe avrabe deleted the fix/deterministic-query-export-order branch June 3, 2026 04:28
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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