fix(oschema): delimiter-aware marker parser (closes #67) #78
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_blueprint!78
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-67-marker-parser"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #67. Replaces substring-based
[rootobject]/ header-delimiter detection in the OSchema parser with a delimiter- and string-literal-aware marker module, and routes the generator through the same helpers so the two crates can't diverge on what counts as a marker.What changed
crates/oschema/src/markers.rs—parse_markers,has_marker,strip_markers,is_header_delimiter_line. Tokenises bracketed identifiers, skips OSchema-style"..."literals (with\"escape handling), and rejects malformed brackets ([],[123], unclosed).oschema/parser.rs—[rootobject]detection now goes throughhas_marker; the# ===SCHEMA===split is whole-line via a newsplit_headerhelper, so a longer comment that merely mentions the delimiter mid-sentence no longer truncates the schema body.generator/src/{domain,generator,schemas/oschema}.rs— delegateparse_markersto the oschema crate; remove the remainingc.text.contains("[rootobject]")ands.contains('[')substring checks.Regression coverage (the failure modes #261 hit)
[rootobject][index]now yields two distinct markers and the type stays a root object.[root]does NOT promote a type to root-object even though[rootobject]would; the two stay independent in both directions.# example: "use [rootobject]"is no longer matched.# Notes — see# ===SCHEMA===belowno longer eats the schema body.Test plan
markers.rs(cargo test -p hero_rpc_oschema --lib markers)parser.rs(marker_regression_*)oschema/tests/real_schemas.rsparsing every.oschemashipped in the repo (basic OSIS example, recipe_serverschemas/+src/recipes/+src/recipes/core/,example/recipe_server) — root-object sets unchanged.🤖 Generated with Claude Code
Adds the regression coverage demanded by the issue and removes the two remaining substring-style marker checks elsewhere in the workspace so that the oschema crate is the single source of truth. oschema/parser.rs - marker_regression_adjacent_markers: `[rootobject][index]` keeps both markers distinct, and the type is still detected as a root object. - marker_regression_prefix_collision: `[root]` does not promote the type to a root object even though `[rootobject]` would; the two prefix-colliding marker names stay independent. - marker_regression_string_literal_mention_does_not_match: a quoted example string mentioning `[rootobject]` is no longer parsed as a real marker. - marker_regression_header_delimiter_must_be_whole_line: a comment that merely mentions `# ===SCHEMA===` mid-sentence no longer truncates the schema body. oschema/tests/real_schemas.rs - New integration tests parse every `.oschema` file shipped in the repo (basic OSIS example, recipe_server schemas/src/core variants, example/recipe_server) and assert the set of root objects is unchanged. generator/domain.rs, generator/schemas/oschema.rs, generator/generator.rs - Delegate `parse_markers` to the oschema crate; route the remaining `c.text.contains("[rootobject]")` and `s.contains('[')` checks through `has_marker` / `parse_markers` so the generator and the parser cannot diverge on which strings count as markers.