Skip to content

refactor: Resolve options in a single pass shared by every insert path - #105

Merged
mhiro2 merged 4 commits into
mainfrom
refactor/option-resolution-stages
Oct 14, 2026
Merged

mhiro2 merged 4 commits into
mainfrom
refactor/option-resolution-stages

Conversation

@mhiro2

@mhiro2 mhiro2 commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Options now resolve in one pass shared by InsertOne, InsertMany, Build, and the Builder: traits expand in place, sequence options resolve per record, Ref resolves straight into its relation's option set, and placement rules are checked as each option resolves
  • Only under Ref is rejected together with the other root-only options, and the planner no longer carries a dead sequence field or a duplicate Only placement check
  • Option precedence is pinned by tests that run the same option lists through every insert path, and documented in the guide, godoc, architecture notes, and skill

Changes

  • 7576180 : refactor: resolve options in a single pass shared by every insert path
    • Each option resolves itself into its node's option set, replacing the separate expansion, collection, and validation passes
    • Root-only placement, Seq outside InsertMany, and after-insert callback types are rejected during resolution, wherever the option is written
    • Multiple Refs to the same relation merge into one child set in written order, and the unused planner Seqs field is removed
  • 74ba101 : refactor(planner): leave Only placement to option resolution
    • The planner drops its allowOnly flag and nested-Only check, since a nested option set can no longer carry Only
  • 5df3cc6 : test: pin option precedence across every insert path
    • Runs the same option lists through InsertOneE, BuildE, InsertManyE, and both Builder insert methods, covering Set/Generate/With stages, traits, merged Refs, Use, and WithContext
    • Checks that each path reports the same placement errors
  • 26dbffa : docs: describe the shared option resolution pass and its precedence rules
    • Documents which options replace, merge, or accumulate, the fixed Defaults → Generate → Set → With stages, and the root-only options, including Only

Each option now resolves itself into the node's option set: traits expand
in place, sequence options become the plain option for the current record,
and Ref options resolve straight into the child set of their relation. Root
placement, Seq outside InsertMany, and after-insert callback types are
checked as each option resolves, so the separate expansion, collection, and
validation passes and the dead planner sequence field are gone. Only under
Ref is now rejected alongside the other root-only options.
Only is rejected under Ref while the options resolve, so the planner no
longer threads an allowOnly flag through validation to repeat that check;
a nested option set simply never carries Only.
The same option streams now run through InsertOneE, BuildE, InsertManyE,
and both Builder insert methods, fixing the order in which Set, Generate,
With, traits, merged Refs, Use, and WithContext take effect and the
placement errors every path reports.
…ules

The guide, package godoc, architecture notes, and test-setup skill now
state the order options take effect in, which options replace, merge, or
accumulate, the fixed Defaults, Generate, Set, and With stages, and the
options limited to the root record, including Only.
@mhiro2 mhiro2 self-assigned this Oct 14, 2026
@github-actions

Copy link
Copy Markdown

Code Metrics Report

main (69d7a67) #105 (5646616) +/-
Coverage 86.6% 87.1% +0.4%
Code to Test Ratio 1:1.0 1:1.0 +0.0
Test Execution Time 1m18s 1m22s +4s
Details
  |                     | main (69d7a67) | #105 (5646616) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          86.6% |          87.1% | +0.4% |
  |   Files             |             59 |             60 |    +1 |
  |   Lines             |           4781 |           4761 |   -20 |
+ |   Covered           |           4145 |           4147 |    +2 |
+ | Code to Test Ratio  |          1:1.0 |          1:1.0 |  +0.0 |
  |   Code              |          17853 |          17808 |   -45 |
+ |   Test              |          18610 |          18853 |  +243 |
- | Test Execution Time |          1m18s |          1m22s |   +4s |

Code coverage of files in pull request scope (88.5% → 89.7%, patch 97.2%)

Files Coverage +/- Patch Coverage Status
cmd/seedling-gen/normalized_ir.go 90.9% +0.1% - affected
insert.go 87.5% +1.2% 100.0% modified
internal/errx/errors.go 79.3% +2.6% - modified
internal/planner/expand_relations.go 83.0% -0.2% - modified
internal/planner/validate.go 84.0% -0.4% 100.0% modified
option.go 94.5% +4.7% 100.0% modified
option_resolver.go 95.6% +95.6% 95.5% added
plan.go 86.5% +1.5% 100.0% modified
registry.go 99.0% +0.9% - affected
result.go 89.1% +0.5% - affected

Reported by octocov

@mhiro2
mhiro2 merged commit 0cbf441 into main Oct 14, 2026
11 checks passed
@mhiro2
mhiro2 deleted the refactor/option-resolution-stages branch October 14, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant