Skip to content

one_d4: motif_occurrences table, ORDER BY motif_count, sequence(), discovered_check#1050

Merged
aaylward merged 4 commits intomainfrom
motif_table
Feb 24, 2026
Merged

one_d4: motif_occurrences table, ORDER BY motif_count, sequence(), discovered_check#1050
aaylward merged 4 commits intomainfrom
motif_table

Conversation

@aaylward
Copy link
Copy Markdown
Collaborator

Adds normalized motif_occurrences table and ChessQL ORDER BY motif_count / sequence(); DiscoveredCheckDetector; tests and docs.

…eries, discovered_check motif

- Add normalized motif_occurrences table (ply, side, move_number, description per motif per game)
  with FK ON DELETE CASCADE and indexes on (game_url), (motif), (game_url, ply)
- Pipe occurrence data through IndexWorker -> GameFeatureDao.insertOccurrences()
- Expose occurrences in QueryController / GameFeatureRow API response
- Add DISCOVERED_CHECK motif detector (discovered attack that also gives check)
- ChessQL: add ORDER BY motif_count(X) [ASC|DESC] compiled to LEFT JOIN subquery
- ChessQL: add sequence(A THEN B [THEN C...]) compiled to EXISTS with ply-gap self-JOINs
- ChessQL: Parser.parse() now returns ParsedQuery(expr, orderBy); CompiledQuery now holds
  full SELECT SQL rather than a bare WHERE fragment
- Fix MotifOccurrence.from() guard: use ply <= 0 instead of lastMove == null so unit tests
  that pass null lastMove still produce occurrences
- DiscoveredCheckDetectorTest, roadmap motif accuracy + phase 9 dependencies

tests: fill gaps for motif_occurrences and ChessQL features

- GameFeatureDaoTest: insertOccurrences/queryOccurrences round-trip, empty list,
  unknown URL, ply-zero skip, query with CompiledQuery
- QueryControllerTest: query returns games with occurrences, empty store,
  blank/null query validation
- ParserTest: sequence(A THEN B) and ORDER BY motif_count(X) parsing
- IndexWorkerTest: recording store, process_whenGameHasMotifs asserts
  insertOccurrences called with CHECK occurrences (Scholar's mate PGN)
- IndexE2ETest: add CheckDetector and DiscoveredCheckDetector; e2e test
  createIndex then query returns games with occurrences
- MigrationTest: motif_occurrences table and has_discovered_check column
  exist; insert/select motif_occurrences

docs(one_d4): add architecture diagrams and discovered_check motif to README
chore(one_d4): set HikariCP log level to INFO, add logback config to binary
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Feb 24, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
1d4-web 34136cd Commit Preview URL

Branch Preview URL
Feb 24 2026, 10:27 PM

- Remove motifs_json field from GameFeature DTO
- Remove motifs_json column from game_features table schema
- Add migration to drop motifs_json column for both H2 and PostgreSQL
- Fix SQL INSERT statements to remove indexed_at from column list (using DEFAULT)
- Remove ObjectMapper dependency from IndexWorker
- Update all tests to use new GameFeature constructor without motifs_json
The previous commit dropped two ? placeholders from the H2 MERGE VALUES
clause when removing motifs_json, but only one should have been removed.
This caused a column count mismatch error on all H2 inserts.
- Rename the single job to format-check + add a new build-and-test job
- format-check: drop fetch-depth, disk cache, disk cleanup, and resource
  bazelrc flags — none are needed for a lightweight format check
- build-and-test: retains full history, disk cleanup, and disk cache
  needed for bazel-diff
@aaylward aaylward merged commit b8b5c8b into main Feb 24, 2026
11 checks passed
@aaylward aaylward deleted the motif_table branch February 24, 2026 22:48
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