Skip to content

Add routing MVP template#4560

Draft
backspace wants to merge 7 commits intomainfrom
routing-types-and-validation-cs-10052
Draft

Add routing MVP template#4560
backspace wants to merge 7 commits intomainfrom
routing-types-and-validation-cs-10052

Conversation

@backspace
Copy link
Copy Markdown
Contributor

@backspace backspace commented Apr 28, 2026

No description provided.

@backspace backspace self-assigned this Apr 28, 2026
@backspace backspace changed the base branch from main to routing-realm-config-cs-10051 April 28, 2026 21:18
@github-actions
Copy link
Copy Markdown
Contributor

Preview deployments

@github-actions
Copy link
Copy Markdown
Contributor

Realm Server Test Results

    1 files      1 suites   19m 19s ⏱️
1 087 tests 1 087 ✅ 0 💤 0 ❌
1 159 runs  1 159 ✅ 0 💤 0 ❌

Results for commit e28a3fe.

@github-actions
Copy link
Copy Markdown
Contributor

Host Test Results

    1 files      1 suites   2h 37m 28s ⏱️
2 474 tests 2 459 ✅ 15 💤 0 ❌
2 493 runs  2 478 ✅ 15 💤 0 ❌

Results for commit e28a3fe.

@backspace backspace force-pushed the routing-types-and-validation-cs-10052 branch from e28a3fe to 80ebed7 Compare April 29, 2026 23:16
backspace and others added 5 commits April 29, 2026 18:16
Adds a generic `sameRealm: boolean` option to `linksTo()` that, when
set, makes `LinksTo.validate` reject a linked card whose realm does
not match the containing card's realm. The check uses the existing
`getRealmURLString` helper (now exported from field-support) so it
works whether the parent is a FieldDef (via [realmContext]) or a
CardDef (via meta.realmURL); it skips silently when either realm is
unknown so synthetic in-memory construction is unaffected.

Apply the option to `RoutingRuleField.instance` so RealmConfig
hostRoutingRules can only reference cards within the same realm —
the constraint called out in the Host Mode Routing MVP spec.

Tests for the validation path land in a follow-up; CI will exercise
the existing instance-of failure case to confirm no regression in
the surrounding LinksTo.validate logic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add a unit test in card-basics-test that exercises the new
sameRealm option on linksTo across three cases:

- same-realm assignment is accepted
- cross-realm assignment throws the expected validation error
- assignment is allowed when the parent has no realm meta (the
  silently-skip-if-unknown safety valve for synthetic in-memory
  construction)

Realm meta is injected on the synthetic test cards by setting the
exported `[meta]` symbol directly, mirroring the pattern used in
serialization-test.gts. Endpoint-level coverage of the same path
will land with the planned defense-in-depth /_config 400 commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror the linksTo plumbing on LinksToMany so any future card that
needs a same-realm constraint on a multi-link gets it from the same
RelationshipOptions flag. Each element in the array runs through the
same realm check; nulls and not-loaded references are skipped (as
they already are for the existing instance-of and FileDef-id checks).

No current consumer — RoutingRuleField uses linksTo, not linksToMany —
but this keeps the option behaviour symmetric across the two
relationship field types.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Renders the rule as `<path> → <instance.cardTitle>`, using
@fields.instance @Format='atom' to delegate the linked card's
display. Edit / embedded / fitted templates are intentionally
deferred to the realm-config UI work in CS-10056.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Surface sameRealm on the Field interface and pass it through to the
chooseCard call as preselectConsumingRealm so the card picker opens
with the consuming realm's filter on by default. The user can still
deselect the filter and pick a card from another realm — schema-level
validate.same-realm rejects the assignment in that case, so this is
purely a UX nudge that steers users toward valid candidates.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@backspace backspace force-pushed the routing-types-and-validation-cs-10052 branch from 80ebed7 to a315e93 Compare April 29, 2026 23:16
@backspace backspace changed the base branch from routing-realm-config-cs-10051 to main April 30, 2026 13:44
Reverts the sameRealm option on linksTo / linksToMany. CS-10052 was
treating "routing rules must reference same-realm cards" as a
schema-level constraint, but the rule is a UX/product expectation,
not a security boundary — Boxel supports cross-realm card loads, and
the failure modes for a cross-realm rule (403s for viewers, weird
published-realm bundles) are confusing rather than dangerous.

The right home for the constraint is a custom edit template on
RealmConfig (or RoutingRuleField) that hard-scopes the picker to the
consuming realm. That work belongs with CS-10056, the realm-config
edit UI ticket.

Reverts:
- sameRealm? on RelationshipOptions / FieldConstructor / Field interface
- LinksTo / LinksToMany sameRealm field, constructor wiring, validate hook
- RoutingRuleField.instance: sameRealm: true
- LinksToEditor preselectConsumingRealm wiring
- card-basics-test sameRealm test case
- getRealmURLString export (back to private in field-support.ts)

The atom template on RoutingRuleField stays — that's an independent
rendering improvement.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Host Test Results

    1 files      1 suites   1h 43m 7s ⏱️
2 558 tests 2 543 ✅ 15 💤 0 ❌
2 577 runs  2 562 ✅ 15 💤 0 ❌

Results for commit 62ac830.

@backspace backspace changed the title Add routing MVP types and same-realm validation Add routing MVP template May 4, 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.

1 participant