Skip to content

refactor(compiler): split semantic IR source maps and target plans#755

Merged
cssbruno merged 4 commits into
mainfrom
codex/semantic-ir-identities
Jun 27, 2026
Merged

refactor(compiler): split semantic IR source maps and target plans#755
cssbruno merged 4 commits into
mainfrom
codex/semantic-ir-identities

Conversation

@cssbruno

@cssbruno cssbruno commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Split standalone Go endpoint source fidelity out of the semantic IR by replacing Program.GoEndpoints with Program.SourceMap entries keyed by stable EndpointID.
  • Keep normalized standalone Go endpoints in Program.Endpoints so validation, binding lookup, route checks, and generated-output planners consume semantic records instead of raw declaration records.
  • Carry stable typed IDs for pages, components, layouts, routes, and endpoints through IR assembly, invariant checks, backend binding lookup, and appgen endpoint planning.
  • Document the semantic IR/source-map boundary and the target-plan boundary for buildgen/appgen consumers.

Issue Closure

Closes #668
Related: #664
Related: #667

Verification

  • I ran the relevant tests, lint, and build commands.
  • I ran scripts/test-go-modules.sh when Go code or compiler behavior changed.
  • I ran go build ./cmd/gowdk when CLI, compiler, runtime, addon, or release behavior changed.
  • I ran node --check editors/vscode/extension.js when editor files changed.
  • I updated docs for behavior, setup, or architecture changes.
  • I added or updated tests for changed behavior.
  • I considered security-sensitive surfaces such as auth, CSRF, redirects, request-time handlers, logs, diagnostics, embedded assets, editor commands, WASM, contracts, and realtime behavior.

Commands run:

  • go test ./internal/gwdkir ./internal/gwdkanalysis
  • go test ./internal/compiler
  • go test ./internal/appgen
  • go test ./internal/buildgen ./internal/lsp
  • go test ./internal/diagnostics ./internal/diagnosticfix
  • go build ./cmd/gowdk
  • go run ./cmd/gowdk inspect ir examples/pages/home.page.gwdk
  • scripts/check-docs-links.sh
  • scripts/check-docs-style.sh
  • scripts/test-go-modules.sh

LLM Assistance

@github-actions github-actions Bot added compiler Compiler internals, pipeline, and generated metadata IR Internal compiler IR and phase handoffs docs Documentation work labels Jun 27, 2026
@cssbruno cssbruno changed the title [codex] add semantic IR identities refactor(compiler): add semantic IR identities Jun 27, 2026
@cssbruno cssbruno marked this pull request as ready for review June 27, 2026 10:01

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af0b3a5623

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/gwdkir/invariants.go Outdated
Comment on lines +89 to +90
if previous, exists := endpointIDs[endpointID]; exists {
report("endpoint %q duplicates semantic id %q from endpoint %q", endpoint.Path, endpointID, previous.Path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid treating duplicate endpoints as IR invariants

When a user declares the same endpoint block twice with the same page/name/method/path (for example two Save actions inheriting /profile), both builder-created endpoints get the same semantic ID, so this new invariant returns an internal compiler error before validateRouteMethodConflicts/page validators can report a normal author diagnostic. Duplicate route registrations are authoring errors, not compiler invariants, so this uniqueness check should either be moved into validation or limited to cases that cannot be produced from user input.

Useful? React with 👍 / 👎.

Comment thread internal/gwdkir/identity.go Outdated
Comment on lines +71 to +73
escaped = append(escaped, url.PathEscape(part))
}
return strings.Join(escaped, ":")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape the identity separator

Because url.PathEscape leaves : unchanged while : is also the tuple separator, different semantic tuples can collapse into the same ID. For example, RouteIdentity("GET", "/foo:bar", "baz") and RouteIdentity("GET", "/foo", "bar:baz") both become GET:%2Ffoo:bar:baz; literal route segments and page IDs with colons are accepted today, so valid pages can get the same RouteID and trip the duplicate-ID invariant as an internal compiler error. Use an encoding that also escapes the separator, or switch to a length-prefixed/structured key.

Useful? React with 👍 / 👎.

@cssbruno cssbruno changed the title refactor(compiler): add semantic IR identities refactor(compiler): split semantic IR source maps and target plans Jun 27, 2026
@cssbruno cssbruno merged commit ab095e0 into main Jun 27, 2026
24 checks passed
@cssbruno cssbruno deleted the codex/semantic-ir-identities branch June 27, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler Compiler internals, pipeline, and generated metadata docs Documentation work IR Internal compiler IR and phase handoffs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split gwdkir.Program into semantic IR and target-specific plans

1 participant