Skip to content

Implement Road record declarations and named constructors - #7

Draft
blackboxprogramming wants to merge 1 commit into
work/road-object-modelfrom
codex/road-record-types-20260919
Draft

blackboxprogramming wants to merge 1 commit into
work/road-object-modelfrom
codex/road-record-types-20260919

Conversation

@blackboxprogramming

Copy link
Copy Markdown
Owner

The documented type Device: syntax currently enters an unimplemented parser path and never finishes. This implements the next language step identified by PR #4: record syntax over the existing dictionary-based Road object model.

Changes:

  • Parse record declarations and Device{name: "Lucidia"} expressions, including nested and multiline constructors.
  • Reject duplicate, unknown, and missing required fields. Validate constructor shape before evaluating supplied expressions or defaults.
  • Evaluate explicit values in caller scope, then omitted defaults in declaration scope. Literal mutable defaults are fresh per construction; referenced mutable values retain normal sharing.
  • Preserve ordinary dictionary behavior, existing verb dispatch, permission-as-data boundaries, and type annotations as metadata.
  • Handle expression grouping without corrupting surrounding block indentation; report malformed delimiters with source locations.
  • Add a runnable example, semantics documentation, and 31 regression cases.

Validation on Python 3.12.14:

  • Before the change: 61 tests passed, 1 pre-existing skip. The new CLI regression failed with a 5-second timeout on the parser stub.
  • After the change: python -m pytest tests/ -q92 passed, 1 pre-existing skip.
  • python3 roadc.py run examples/record_types.road printed Lucidia / False / 1 / 0.
  • Example parse, py_compile for changed Python files/tests, and git diff --check passed.
  • Published Git tree bf146b82a9205d1027c7cc9f43f62c3f52e5b7a3 matches the locally verified tree exactly.

Boundaries:

  • Python interpreter support only; the C compiler is unchanged.
  • Field annotations are retained but do not enforce value types or later assignments.
  • Record data does not authenticate identities, grant authority, resolve Routes, or dispatch providers/devices. Default expressions keep ordinary Road expression effects.
  • The existing skipped else parsing test remains skipped. This does not claim to fix other parser stubs.

Continuity:

  • Stacked on PR #4, branch work/road-object-model, pinned parent f0ea7961abac1dcdf568bec8e22b8543fae28b5d.
  • New commit: a143553a89e1e33e6799209156a120223a72e4ff.
  • PR Road object model: compose state, capabilities, identity, and verbs #4 remains open and unchanged. Merge/reconcile that foundation first, then retarget and reconcile this draft against main.
  • Existing workflow filters target main; this stacked draft is locally verified and does not claim a hosted CI pass.

Continue the object-model work from PR #4 with dictionary-backed records,
lexically scoped defaults, strict constructor field shape, and multiline
expression grouping. Preserve annotations as metadata and runtime authority
boundaries.

Validation: Python 3.12.14; 92 passed, 1 existing skip. Record example run
and parse, py_compile, and git diff --check passed.
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