Skip to content

011 follow-up: relax ingest matching for real incoming-data patterns#146

Merged
IanMayo merged 1 commit into
mainfrom
claude/gram-image-matching-metadata-365z6d
Jul 10, 2026
Merged

011 follow-up: relax ingest matching for real incoming-data patterns#146
IanMayo merged 1 commit into
mainfrom
claude/gram-image-matching-metadata-365z6d

Conversation

@IanMayo

@IanMayo IanMayo commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the merged feature 011 (#145). Real author-delivered screenshots drift from source/ in ways the first pass didn't handle. This relaxes the matching engine to absorb the benign drift while still reporting genuine mismatches, and adds a container-layout variant.

Changes to scripts/ingest_gram_images.py:

  • Duration separator is a space or an underscore, sometimes after the minutes, sometimes after the seconds — 10m_0 - 600 Hz.jpg, 7m20s_0 - 441 Hz.jpg, 11m Wav 1.jpg. The token is now split on the first [ _] instead of the first space. All six real examples the maintainer listed now parse.
  • Case-insensitive matching at every level: document folders, gram folders, and image-stem-to-wav. An incoming 7m_WAV 1.jpg matches a source Wav 1.wav. Whitespace and token content stay exact, so missing spaces and mistyped words are still reported for the operator to fix. Two case-variant screenshots for one wav collapse to ambiguous.
  • Copied image takes the wav's own casing (Wav 1.jpg beside Wav 1.wav), not the incoming screenshot's — fixes a latent bug where the copy used the incoming stem's case, which would have produced an inconsistent WAV 1.jpg beside Wav 1.wav.
  • Container-less publications: one publication omits the <doc> Files tier and holds its gram folders directly under the document folder. A document folder with ≥ 8 subdirectories is read as that flat layout (the doc folder is the container); a single subdirectory is the normal container; an in-between count (2–7) stays reported-and-skipped.

Changes

  • scripts/ingest_gram_images.py — separator regex, casefolded folder/stem matching, wav-cased copy name, flat-container resolution (FLAT_DOC_MIN_GRAMS = 8)
  • tests/test_ingest_gram_images.py — regressions for underscore separators (after minutes and after seconds), case-insensitive folder + stem match, wav-cased copy, case-variant ambiguity, flat publication, and the sub-threshold ambiguity boundary
  • specs/011-import-gram-images/{spec,research,data-model,contracts/ingest-contract}.md and README.md — docs updated to match

Full suite green: python -m unittest discover tests/ → 406 tests, 1 pre-existing skip.

Notes

The still-open design question from #145 is unchanged by this PR: a wav-backed .glc that already carries <bitmap_crop_values> is warned-and-skipped rather than relinked. Flag if the real corpus wants relink-and-preserve instead.

🤖 Generated with Claude Code

https://claude.ai/code/session_01H5E6YjrQ6V7d2t1otjFYiN


Generated by Claude Code

The author's delivered screenshots drift from source/ in ways the first
run surfaced:

- Duration separator is a space OR an underscore, sometimes after the
  minutes, sometimes after the seconds (10m_0 - 600 Hz.jpg,
  7m20s_0 - 441 Hz.jpg) — split on the first [ _] instead of the first
  space.
- Folder names (doc + gram) and image stem <-> wav matching are now
  case-insensitive (incoming 7m_WAV 1.jpg matches source Wav 1.wav);
  whitespace and token content stay exact so real drift is still
  reported. The copied image takes the wav's own casing, keeping each
  gram folder internally consistent (fixes a latent bug where the copy
  used the incoming stem's casing).
- One publication omits the "<doc> Files" container tier and holds its
  gram folders directly under the doc folder; a doc folder with >= 8
  subdirectories is read as that flat layout, while an in-between count
  (2-7) stays reported-and-skipped.

Adds regression tests for every pattern (underscore separators,
case-insensitive folder/stem match, wav-cased copy, case-variant
ambiguity, flat publication, sub-threshold ambiguity) and updates the
spec/plan-era contract, research, data-model, README docs to match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H5E6YjrQ6V7d2t1otjFYiN
github-actions Bot added a commit that referenced this pull request Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📄 HTML preview for this PR is live:

Rebuilt on every push to this PR; removed when the PR closes. (May take a minute for GitHub Pages to refresh.)

@IanMayo IanMayo merged commit af3ef73 into main Jul 10, 2026
4 checks passed
@IanMayo IanMayo deleted the claude/gram-image-matching-metadata-365z6d branch July 10, 2026 16:05
github-actions Bot added a commit that referenced this pull request Jul 10, 2026
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.

2 participants