Skip to content

Commit b955f52

Browse files
committed
fix(store): per-type index dirs eliminate full-store list walks (0.37.4 → 0.37.7)
Store::list(<unindexed-type>) on FsStore used to walk the entire object fanout and JSON-deserialize every object just to filter by type. On a real-world 94k-object / 33 GB store that turned every caller into a multi-minute hang. This bundle closes the surface area in three iterations, all of which land here together: 0.37.4 — short-hash prefix lookup (`morph certify --commit <prefix>`) stops scanning all 10 types via Store::list. New `Store::list_hashes_with_prefix` method; FsStore (fanout layout) walks only the matching `objects/<2chars>/` subdir with zero JSON reads. 0.37.5 — `morph status` and `morph eval gaps` stop hanging. Both call `list_stale_certifications`, which lists Annotation objects. Annotations gain a per-type index dir + lazy rebuild for legacy stores. 0.37.7 — every remaining unindexed type (Blob, Tree, Pipeline, Commit, Artifact, TraceRollup) gets a dedicated `<type>/` index dir maintained by Store::put. Newly indexed types use zero-byte marker files so a 33 GB blob-heavy store doesn't double when `blobs/` materializes; the five legacy indexes (runs/, traces/, evals/, prompts/, annotations/) keep full-content format because `morph tap` migration code reads them. Legacy stores trigger a single unified rebuild on the first `list(<unindexed-type>)` call: one fanout walk classifies every object and populates EVERY missing index dir simultaneously, then drops `.indexed` markers everywhere. Verified on the morph repo (94k objects): - cold morph status: 24.6s (one-time unified rebuild) - warm morph status: 0.05s - warm morph eval gaps: 0.022s - morph certify --commit <8-char-prefix>: 0.36s Tests: - 5 new morph-core unit tests pinning the index contract (`list_every_type_uses_index_not_get` proves zero deserialization via a panic-on-`get` proxy; the others cover legacy rebuild, marker-vs-full-content, and the prompt-blob kind-subset case). - 3 new acceptance suites: certify_prefix_lookup.yaml, annotations_indexed.yaml, type_indexes_complete.yaml. - count_dir_entries (working.rs) and the cucumber then_repo_has_n_run_records assertion now filter on `*.json` so the `.indexed` marker doesn't inflate counts. - cargo test --workspace: 1141 / 1141 passing. - cargo test -p morph-e2e: 34 passed / 3 pre-existing skips. Bundled site change: - site/index.html hero now leads with a copy-able `brew tap r/morph` / `brew install morph` block and demotes `cargo install --path …` to a clearly-labelled fallback. CHANGELOG entry tracks this as the 0.37.6 release; per-version site changelog entries kept. Made-with: Cursor
1 parent d405289 commit b955f52

12 files changed

Lines changed: 1415 additions & 121 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,155 @@ metrics — see `.cursor/rules/behavioral-commits.mdc`.
1616

1717
## [Unreleased]
1818

19+
## [0.37.7] — 2026-04-29
20+
21+
### Fixed
22+
23+
- **Every `Store::list(t)` is now fast on `FsStore`.** 0.37.4 and
24+
0.37.5 fixed the two acute symptoms of an unindexed type
25+
(short-hash prefix lookup, then `morph status` / `morph eval gaps`),
26+
but every remaining unindexed type — `Blob`, `Tree`, `Pipeline`,
27+
`Commit`, `Artifact`, `TraceRollup` — was a latent version of the
28+
same bug: any code path calling `Store::list(<that-type>)` walked
29+
the whole object fanout and JSON-deserialized every object just to
30+
filter by type. This release closes that surface area: every
31+
top-level object type now has a dedicated `<type>/` index dir
32+
maintained by `Store::put`, and `fs_list` reads directly from it.
33+
Newly-indexed types use zero-byte marker files instead of full JSON
34+
copies — on a 33 GB blob-heavy store, copying every blob into
35+
`.morph/blobs/` would have doubled disk usage; a marker only costs
36+
an inode. The five pre-existing indexes (`runs/`, `traces/`,
37+
`evals/`, `prompts/`, `annotations/`) keep their full-content
38+
format because at least one fallback path (`morph tap`) reads them.
39+
Legacy stores (≤0.37.6) trigger a one-shot lazy rebuild on the
40+
first `list(<unindexed type>)` call: the rebuild walks the store
41+
*once* and populates *every* missing index simultaneously, so
42+
whichever list call happens first amortizes the cost for all
43+
subsequent list calls of every type.
44+
45+
### Tests
46+
47+
- New unit tests in `morph-core::store::tests`:
48+
- `list_every_type_uses_index_not_get` — wraps a real `FsStore` in
49+
a proxy whose `Store::get(...)` panics, populates one object of
50+
each easily-constructible type via `put`, and asserts `list(t)`
51+
returns the right hashes via the index alone (no deserialize).
52+
- `list_pipeline_uses_index_after_put` — separate fixture for the
53+
Pipeline type, which has a heavier `PipelineGraph` field surface.
54+
- `list_legacy_store_rebuilds_every_missing_type_index_in_one_walk`
55+
— writes raw object JSON into the fanout (bypassing `put`) so no
56+
index dirs exist, then asserts the first `list(Blob)` call
57+
creates *every* `<type>/.indexed` marker, not just `blobs/`.
58+
- `type_index_files_are_markers_for_new_types_full_content_for_legacy`
59+
— asserts `blobs/<hash>.json` is a zero-byte marker while
60+
`annotations/<hash>.json` keeps full JSON content.
61+
- `prompt_blob_lands_in_both_blobs_and_prompts_indexes` — covers
62+
the kind-subset case so `list(Blob)` surfaces prompts via the
63+
new `blobs/` index without `prompts/` having to widen its scope.
64+
- `count_dir_entries` (in `working.rs`) and the cucumber
65+
`then_repo_has_n_run_records` step both now filter to `*.json`,
66+
so the `.indexed` marker doesn't inflate counts.
67+
68+
## [0.37.6] — 2026-04-29
69+
70+
### Changed
71+
72+
- **Homepage leads with the Homebrew install path.** The hero on
73+
`site/index.html` now shows a copy-able `brew tap r/morph` /
74+
`brew install morph` block above the CTA buttons, with a
75+
click-to-copy button and a footnote pointing at the source-build
76+
alternative for non-macOS users. The `#install` section was
77+
rewritten to lead with the Homebrew path and keep
78+
`cargo install --path …` as the cross-platform fallback. Goal: cut
79+
the time from "land on the page" to "actually try Morph" on macOS
80+
to two commands.
81+
82+
### CI
83+
84+
- **Releases auto-tag from `Cargo.toml`.** A new
85+
`.github/workflows/auto-tag.yml` watches the workspace version on
86+
`main`; when it advances to a value that has not yet been tagged on
87+
origin, the workflow creates `vX.Y.Z` (annotated) and dispatches
88+
`release-homebrew.yml` against that tag. Cutting a release is now
89+
"bump `Cargo.toml`, push to `main`" — no more manual
90+
`git tag && git push origin <tag>`. The dispatch indirection is
91+
required because `GITHUB_TOKEN`-pushed refs do not retrigger
92+
workflows; dispatching against the tag's ref makes
93+
`release-homebrew`'s metadata step see
94+
`GITHUB_REF=refs/tags/v<version>` and run the full tag-release path
95+
(`is_tag_release=true`, formula update, etc.).
96+
97+
## [0.37.5] — 2026-04-29
98+
99+
### Fixed
100+
101+
- **`morph status` and `morph eval gaps` no longer hang on stores with
102+
many objects.** Both commands route through
103+
`list_stale_certifications`, which calls
104+
`Store::list(ObjectType::Annotation)`. Annotation was the only
105+
top-level object type without a per-type index dir, so on `FsStore`
106+
the call fell through to `fs_list`'s slow path: walk the entire
107+
object fanout and JSON-deserialize every object just to filter by
108+
type. On a 94k-object / 33 GB store that was a ~2-minute walk on
109+
every invocation. Annotations now have an `annotations/` type-index
110+
directory maintained opportunistically by `Store::put`. Legacy
111+
stores (≤0.37.4) trigger a one-shot lazy rebuild on first
112+
`list(Annotation)` and drop a `.indexed` marker so subsequent calls
113+
use the fast path. Verified on the bug-surfacing repo: first call
114+
after upgrade pays the ~2 min rebuild once; second call drops to
115+
**0.18 s** (a ~600× speedup), and `morph status` lands in **0.17 s**.
116+
117+
### Tests
118+
119+
- New unit tests in `morph-core::store::tests`:
120+
- `list_annotation_lazily_builds_index_on_legacy_store` — writes
121+
annotation objects directly into the fanout (bypassing `put`),
122+
asserts `list(Annotation)` rebuilds the index dir, returns every
123+
annotation, and writes the `.indexed` marker.
124+
- `list_annotation_after_marker_does_not_deserialize_objects` —
125+
drops a poison file in the object fanout, asserts a marker-present
126+
`list(Annotation)` returns the indexed result without touching
127+
the fanout.
128+
- `list_annotation_filters_to_annotations_only_after_rebuild` —
129+
mixes 20 noise blobs with 4 annotations, asserts only the
130+
annotations come back via the indexed fast path.
131+
- New acceptance suite `annotations_indexed.yaml` (3 cases) covers
132+
`morph certify` populating the index, `morph status` rendering
133+
cleanly post-certification, and `morph eval gaps` succeeding on a
134+
certified branch.
135+
136+
## [0.37.4] — 2026-04-29
137+
138+
### Fixed
139+
140+
- **`morph certify --commit <prefix>` no longer hangs on stores with
141+
many objects.** Short-hash prefix resolution (`resolve_hash_prefix`,
142+
used by `certify`, `show`, `run show`, `trace show`, `annotate`,
143+
`revert`, etc.) iterated all 10 object types and called
144+
`Store::list(t)` for each. For backends without a per-type index
145+
(every type except Run, Trace, EvalSuite on `FsStore`),
146+
`list(t)` deserialized every object on disk just to filter by type —
147+
turning a single prefix lookup into O(7·N) JSON reads. On a real repo
148+
with thousands of objects this looked like a hang. Resolution now
149+
goes through a new `Store::list_hashes_with_prefix` method; `FsStore`
150+
with fanout layout (the default since 0.4) walks only the matching
151+
`objects/<2chars>/` subdirectory and performs zero JSON
152+
deserialization. Behavior is unchanged — same matches, same
153+
ambiguous/not-found errors — just fast.
154+
155+
### Tests
156+
157+
- New unit test `resolve_hash_prefix_does_not_iterate_object_types`
158+
in `morph-core::store::tests` wraps a real `FsStore` in a proxy whose
159+
`Store::list(type)` panics, proving the prefix path never iterates
160+
types again.
161+
- New unit test `list_hashes_with_prefix_fanout_walks_only_target_subdir`
162+
drops a poison file into an unrelated fanout subdirectory and
163+
asserts the fast path leaves it untouched.
164+
- New acceptance suite `certify_prefix_lookup.yaml` (2 cases) covers
165+
`morph certify --commit <8-char prefix>` and `<12-char prefix>`
166+
on repos seeded with multiple commits and runs.
167+
19168
## [0.37.3] — 2026-04-29
20169

21170
### Fixed
@@ -152,7 +301,11 @@ Three coordinated changes to repo setup, adoption, and migration.
152301
- 15 new YAML acceptance spec cases in the default eval suite:
153302
`init_at_latest:*` ×4, `init_in_git_dir:*` ×6, `upgrade:*` ×5.
154303

155-
[Unreleased]: https://github.com/r/morph/compare/v0.37.3...HEAD
304+
[Unreleased]: https://github.com/r/morph/compare/v0.37.7...HEAD
305+
[0.37.7]: https://github.com/r/morph/compare/v0.37.6...v0.37.7
306+
[0.37.6]: https://github.com/r/morph/compare/v0.37.5...v0.37.6
307+
[0.37.5]: https://github.com/r/morph/compare/v0.37.4...v0.37.5
308+
[0.37.4]: https://github.com/r/morph/compare/v0.37.3...v0.37.4
156309
[0.37.3]: https://github.com/r/morph/compare/v0.37.2...v0.37.3
157310
[0.37.2]: https://github.com/r/morph/compare/v0.37.1...v0.37.2
158311
[0.37.1]: https://github.com/r/morph/compare/v0.37.0...v0.37.1

‎Cargo.lock‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ resolver = "2"
33
members = ["morph-core", "morph-cli", "morph-mcp", "morph-serve", "morph-e2e"]
44

55
[workspace.package]
6-
version = "0.37.3"
6+
version = "0.37.7"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# `morph status` and `morph eval gaps` both call
2+
# `list_stale_certifications`, which used to scan every object on disk
3+
# looking for annotation objects (no per-type index). On a real-world
4+
# 94k-object / 33 GB store that turned both commands into multi-minute
5+
# hangs. Starting in 0.37.5, annotations get a per-type index dir
6+
# (`.morph/annotations/`) maintained by `put`, plus a one-shot lazy
7+
# rebuild on legacy stores.
8+
#
9+
# These cases check the user-visible contracts:
10+
# 1. Issuing a certification populates the annotations/ index.
11+
# 2. After indexing, morph status and morph eval gaps both stay
12+
# correct (no false positives, no missed annotations).
13+
# The morph-core unit tests
14+
# (`list_annotation_lazily_builds_index_on_legacy_store`,
15+
# `list_annotation_after_marker_does_not_deserialize_objects`,
16+
# `list_annotation_filters_to_annotations_only_after_rebuild`)
17+
# cover the perf contract directly.
18+
19+
- name: certify_populates_annotations_index
20+
files:
21+
a.txt: "hello"
22+
metrics.json: '{"acc": 0.95, "tests_passed": 1}'
23+
steps:
24+
- morph: [add, a.txt]
25+
- morph: [commit, -m, "initial", --allow-empty-metrics]
26+
- morph: [certify, --metrics-file, metrics.json]
27+
stdout_contains: "PASS"
28+
# The certification annotation must end up in the index dir,
29+
# not just the object fanout.
30+
- shell: 'test -d .morph/annotations && ls .morph/annotations/*.json | head -1'
31+
- shell: 'ls .morph/annotations/*.json | wc -l | grep -E "^\s*1\s*$"'
32+
33+
- name: status_succeeds_after_certifications
34+
files:
35+
a.txt: "v1"
36+
metrics.json: '{"acc": 0.95, "tests_passed": 1}'
37+
steps:
38+
- morph: [add, a.txt]
39+
- morph: [commit, -m, "c1", --allow-empty-metrics]
40+
- morph: [certify, --metrics-file, metrics.json]
41+
- write_file: { path: a.txt, content: "v2" }
42+
- morph: [add, a.txt]
43+
- morph: [commit, -m, "c2", --allow-empty-metrics]
44+
- morph: [certify, --metrics-file, metrics.json]
45+
# `morph status` should render cleanly with certifications
46+
# indexed (no hang, no incorrect output). The "Eval suite:" line
47+
# is emitted unconditionally and only after the certification
48+
# walk completes, so it's a reliable proof-of-completion marker.
49+
- morph: [status]
50+
stdout_contains: "Eval suite:"
51+
52+
- name: eval_gaps_succeeds_after_certifications
53+
files:
54+
a.txt: "hello"
55+
metrics.json: '{"acc": 0.95, "tests_passed": 1}'
56+
steps:
57+
- morph: [add, a.txt]
58+
- morph: [commit, -m, "initial", --allow-empty-metrics]
59+
- morph: [certify, --metrics-file, metrics.json]
60+
- morph: [eval, gaps, --json]
61+
stdout_contains: "gaps"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# `morph certify --commit <prefix>` must resolve a short hash prefix
2+
# without scanning every object in the store. Before the fix in 0.37.4,
3+
# `resolve_hash_prefix` iterated all 10 object types and called
4+
# `store.list(t)` for each — for the 7 types without a type index,
5+
# `fs_list` walked the whole fanout and deserialized every object.
6+
# On a repo with even a few hundred objects this looked like a hang.
7+
#
8+
# These cases populate the store with multiple commits and runs (so the
9+
# fanout has many entries), then certify by short hex prefix and assert
10+
# the call succeeds. Combined with the morph-core unit test
11+
# `resolve_hash_prefix_does_not_deserialize_objects`, this nails the
12+
# behavior down: short-prefix certify works, and it doesn't read every
13+
# object on the way there.
14+
15+
- name: certify_resolves_short_prefix_with_many_objects
16+
files:
17+
a.txt: "v1"
18+
metrics.json: '{"acc": 0.95}'
19+
steps:
20+
- morph: [add, a.txt]
21+
- morph: [commit, -m, "c1", --json, --allow-empty-metrics]
22+
capture_json_field:
23+
var: target_hash
24+
field: hash
25+
# Generate a bunch of additional objects (commits + runs + traces +
26+
# blobs) so the prefix lookup has real surface area to cover.
27+
- morph: [run, record-session, --prompt, "p1", --response, "r1"]
28+
- morph: [run, record-session, --prompt, "p2", --response, "r2"]
29+
- morph: [run, record-session, --prompt, "p3", --response, "r3"]
30+
- write_file: { path: a.txt, content: "v2" }
31+
- morph: [add, a.txt]
32+
- morph: [commit, -m, "c2", --allow-empty-metrics]
33+
- write_file: { path: a.txt, content: "v3" }
34+
- morph: [add, a.txt]
35+
- morph: [commit, -m, "c3", --allow-empty-metrics]
36+
- morph: [run, record-session, --prompt, "p4", --response, "r4"]
37+
- morph: [run, record-session, --prompt, "p5", --response, "r5"]
38+
# Certify the original commit by an 8-char prefix. This must succeed
39+
# without scanning the whole store.
40+
- morph: [certify, --metrics-file, metrics.json, --commit, "${target_hash:.8}"]
41+
stdout_contains: "PASS"
42+
43+
- name: certify_resolves_12char_prefix
44+
files:
45+
a.txt: "hello"
46+
metrics.json: '{"acc": 0.99}'
47+
steps:
48+
- morph: [add, a.txt]
49+
- morph: [commit, -m, "initial", --json, --allow-empty-metrics]
50+
capture_json_field:
51+
var: commit_hash
52+
field: hash
53+
- morph: [run, record-session, --prompt, "x", --response, "y"]
54+
- morph: [run, record-session, --prompt, "x2", --response, "y2"]
55+
- morph: [certify, --metrics-file, metrics.json, --commit, "${commit_hash:.12}"]
56+
stdout_contains: "PASS"

0 commit comments

Comments
 (0)