Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ plus response-local symbol, alias, and declaration provenance. An isolated
Rust/OXC consumer exercises that contract as a reference and migration harness;
TypeScript 7's Go checker remains the semantic oracle.

The current [migration decision](docs/adr/0016-port-occurrence-attachment-before-semantic-categories.md)
The current [migration decision](docs/adr/0019-compute-primitive-literals-independently-in-rust.md)
and [measured evidence](docs/evidence/ts7-oxc-spike-2026-08-17.json) approve no
Rust semantic replacement. Primitive/literal record construction is the next
candidate for independent Rust output and differential comparison. The
Rust semantic replacement. An independent Rust/OXC primitive/literal producer
now runs under exact differential comparison while Go remains the production
fallback and semantic authority. The
compatibility boundary and current exclusions are tracked in the
[migration contract](docs/porting/migration-contract.md), and durable
implementation choices are recorded in [ADRs](docs/adr/README.md).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ADR-0017: Project primitive/literal candidates from Go graph identity

- Status: accepted
- Status: superseded
- Date: 2026-08-17
- Deciders: TypeScript Semantic Kernel maintainers
- Supersedes: —
- Superseded by:
- Superseded by: ADR-0019

## Context

Expand Down
4 changes: 2 additions & 2 deletions docs/adr/0018-gate-rust-semantics-against-the-go-oracle.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ADR-0018: Gate Rust semantics against the Go oracle

- Status: accepted
- Status: superseded
- Date: 2026-08-17
- Deciders: TypeScript Semantic Kernel maintainers
- Supersedes: —
- Superseded by:
- Superseded by: ADR-0019

## Context

Expand Down
84 changes: 84 additions & 0 deletions docs/adr/0019-compute-primitive-literals-independently-in-rust.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# ADR-0019: Compute primitive/literal candidates independently in Rust

- Status: accepted
- Date: 2026-08-17
- Deciders: TypeScript Semantic Kernel maintainers
- Supersedes: ADR-0017 and ADR-0018
- Superseded by: —

## Context

ADR-0017 defined structured primitive/literal candidate records, but projected
them from the graph already produced by the Go checker. ADR-0018 added an exact
shadow comparison, but that comparison could only verify the projection. It
could not establish that Rust/OXC derived the semantic answer independently.

The first independent slice must preserve the existing shadow boundary. It
must not change the TS7 producer protocol, affect external consumers, route
production traffic to Rust, or weaken Go's role as semantic authority and
fallback.

## Decision

The isolated OXC workspace contains a version-2 primitive/literal producer that
accepts project source, selections, capabilities, and budgets. It parses and
builds OXC semantics, resolves selected identifiers through OXC references and
symbol declarations, and derives the following forms without reading a Go
`TypeGraph`:

- boolean, string, number, and bigint primitives;
- boolean, string, number, and bigint literal values;
- null, undefined, and void;
- unions whose members are all in the supported set; and
- contextual primitive annotations for supported literal initializers.

The producer owns response-local type interning, emits actual, contextual,
widened, apparent, and declared roots in fixed order, and retains explicit
complete, unsupported, and truncated states. Boxed apparent types are outside
this narrow category and therefore remain named unsupported/truncated records
instead of being approximated. Unsupported type syntax is also explicit.
Recoverable OXC parser or semantic diagnostics mark every selected fact in that
file as recovered and therefore incomplete, matching the producer's file-level
recovery contract without reading Go diagnostics.

`run-conformance.sh` invokes the Go oracle and the Rust producer independently.
Only the comparator receives both outputs. It requires exact occurrence and OXC
node mapping, compares the five view roots and structured records recursively,
and validates response-local identity with a bijection rather than requiring
the two producers to allocate equal ID strings. Repeated Rust output must be
byte-identical.

The executable shadow threshold is at least 15 complete supported records,
1,000,000 parts-per-million structured agreement, and zero semantic,
transport, or mapping differences. The tagged baseline contains 11 facts: 10
supported facts plus one named unsupported object, 50 compared roots with 50
identity matches, and 11 exact OXC mappings. Expected apparent-type truncation
and unsupported states remain visible outside the supported denominator.

This producer remains an internal shadow implementation. The Go checker stays
the semantic authority and production fallback. No TS7 producer protocol,
external consumer, capability negotiation, or production routing changes are
part of this decision.

## Consequences

- Primitive/literal conformance now measures independently computed Rust/OXC
semantics instead of a Go-graph projection.
- The narrow category has deterministic source-to-record and graph-identity
evidence, including contextual literals, literal unions, unsupported forms,
and budget truncation.
- Graph inspection continues to describe Go responses; it no longer embeds a
misleading projected Rust candidate.
- Passing this shadow gate does not itself authorize a production authority
switch. Broader project loading, recovery, inference, flow, object, generic,
and callable semantics remain Go-authoritative.
- Any future authority switch requires a separate decision, maintained Go
fallback, supported-matrix CI, and evidence for the production integration.

## References

- [RFC 0001](../../rfcs/0001-semantic-facts-kernel.md)
- [ADR-0016](0016-port-occurrence-attachment-before-semantic-categories.md)
- [ADR-0017](0017-project-primitive-literal-candidates-from-go-graph-identity.md)
- [ADR-0018](0018-gate-rust-semantics-against-the-go-oracle.md)
- [Issue #45](https://github.com/swernerx/typescript-semantic-kernel/issues/45)
17 changes: 9 additions & 8 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ decision is recorded in a successor ADR that links to the record it replaces.
| [0014](0014-isolate-the-oxc-reference-consumer.md) | Accepted | Isolate the OXC reference consumer |
| [0015](0015-attach-semantic-facts-without-expanding-graph-identity.md) | Accepted | Attach semantic facts without expanding graph identity |
| [0016](0016-port-occurrence-attachment-before-semantic-categories.md) | Accepted | Port occurrence attachment before semantic categories |
| [0017](0017-project-primitive-literal-candidates-from-go-graph-identity.md) | Accepted | Project primitive/literal candidates from Go graph identity |
| [0018](0018-gate-rust-semantics-against-the-go-oracle.md) | Accepted | Gate Rust semantics against the Go oracle |
| [0017](0017-project-primitive-literal-candidates-from-go-graph-identity.md) | Superseded | Project primitive/literal candidates from Go graph identity |
| [0018](0018-gate-rust-semantics-against-the-go-oracle.md) | Superseded | Gate Rust semantics against the Go oracle |
| [0019](0019-compute-primitive-literals-independently-in-rust.md) | Accepted | Compute primitive/literal candidates independently in Rust |

## Current migration decision

Expand All @@ -36,9 +37,9 @@ Rust/OXC consumer remains a reference and migration harness; the evidence does
not establish compiler equivalence, production readiness, or a performance
advantage.

[ADR-0018](0018-gate-rust-semantics-against-the-go-oracle.md) runs that first
Rust-owned primitive/literal candidate over the complete Go corpus and enforces
exact supported structured agreement in shadow CI. The candidate is still a
projection of the Go-produced graph, not an independent producer. Passing the
shadow gate therefore leaves primitive/literal construction Go-authoritative;
no semantic category is currently approved for replacement.
[ADR-0019](0019-compute-primitive-literals-independently-in-rust.md) runs an
independent Rust/OXC primitive/literal producer over the tagged shared corpus
and enforces exact structured agreement in shadow CI. It owns its type graph
and receives no Go semantic graph input. Passing the gate still leaves
primitive/literal construction Go-authoritative in production; no semantic
category is currently approved for replacement.
11 changes: 6 additions & 5 deletions docs/evidence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ count is zero.
The checked record supports the migration decision in
[ADR-0016](../adr/0016-port-occurrence-attachment-before-semantic-categories.md):
occurrence identity and attachment plumbing may be ported behind the Go oracle.
[ADR-0017](../adr/0017-project-primitive-literal-candidates-from-go-graph-identity.md)
subsequently adds a structured primitive/literal Rust candidate over that
Go-produced graph. It is not an approved replacement or an independent
producer. The TypeScript 7 Go checker remains authoritative until independent
Rust output passes the differential compatibility gates.
[ADR-0019](../adr/0019-compute-primitive-literals-independently-in-rust.md)
subsequently adds a structured primitive/literal producer that derives its
answer from source and OXC semantics without receiving the Go graph. It passes
an exact shadow differential gate but is not an approved production
replacement. The TypeScript 7 Go checker remains authoritative and available
as the production fallback.
22 changes: 10 additions & 12 deletions docs/porting/migration-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ source remains Go-only because the current OXC parse fails; its facts are
reported as consumer differences rather than omitted.

ADR-0016 selects occurrence identity and attachment plumbing as the first safe
mechanical port. ADR-0017 adds the first Rust-owned primitive/literal candidate
record over the Go-produced graph so future comparisons can use structured
kinds, literal values, union edges, roots, and states. It is not an independent
producer. ADR-0018 adds the corpus-wide shadow gate and exact compatibility
threshold, but passing it does not transfer semantic authority. No category may
replace Go until independent Rust output completes ADR-0018's replacement
checklist with no completeness/state downgrade, new unsupported form, or
unexplained mapping gap. Project loading, resolution, binding, symbols,
inference, contextual/widened types, overloads, generic instantiation,
narrowing, and recovery remain Go-authoritative.
mechanical port. ADR-0019 replaces the earlier Go-graph projection with a
narrow independent Rust/OXC primitive/literal producer. The corpus-wide shadow
gate compares its five roots, structured graph identity, states, mapping, and
truncation against Go at an exact threshold. Passing it does not transfer
semantic authority or alter production routing. Project loading, resolution,
binding, symbols, inference beyond the supported contextual literals,
overloads, generic instantiation, narrowing, recovery, and all production
fallback behavior remain Go-authoritative.

## Gate ladder

Expand All @@ -116,8 +114,8 @@ narrowing, and recovery remain Go-authoritative.
8. `./internal/oxc_reference/run-evidence.sh --output <path>` produces stable
repeated observations and passes ADR-0016's occurrence/attachment gate.
9. `./internal/oxc_reference/run-conformance.sh --output <path>` emits the
deterministic ADR-0018 report and fails on any unexplained semantic or
transport mismatch while retaining mapping, unsupported, and budget cases.
deterministic ADR-0019 report and fails on any semantic, transport, or
mapping mismatch while retaining named unsupported and budget cases.

## Upstream synchronization

Expand Down
44 changes: 22 additions & 22 deletions internal/oxc_reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ Run the deterministic Go-versus-Rust shadow conformance gate with:
--output /tmp/ts7-rust-conformance.json
```

The command runs the same corpus through the Go oracle and the version-1 Rust
primitive/literal candidate. Its JSON compares fact identity, all five roots,
response-local graph identity, structured payloads, diagnostics, unsupported
and error states, and truncation. Every entry is classified as `semantic`,
`transport`, `mapping`, `unsupported`, or `budget`. Unexplained semantic or
transport differences fail the command; expected unsupported/budget cases and
the known recovery-file mapping gap remain separately reported. The gate is a
shadow comparison and does not change the producer or production routing. See
[ADR-0018](../../docs/adr/0018-gate-rust-semantics-against-the-go-oracle.md).
The command runs the same corpus through the Go oracle and the version-2 Rust
primitive/literal candidate. Rust derives its records independently from the
project source and OXC semantic nodes; the Go graph is supplied only to the
comparator. Its JSON compares fact identity, exact OXC mapping, all five roots,
response-local graph identity through a Go-to-Rust ID bijection, structured
payloads, recovery, unsupported states, and truncation. Every entry is
classified as `semantic`, `transport`, `mapping`, `unsupported`, or `budget`.
Unexplained
semantic, transport, or mapping differences fail the command; named
unsupported and budget cases remain separately reported. The gate is a shadow
comparison and does not change the producer or production routing. See
[ADR-0019](../../docs/adr/0019-compute-primitive-literals-independently-in-rust.md).

The first test suite applies the Rust implementation of the portable contract
to every shared JSON fixture in `internal/occurrencemap/testdata/v1` and checks
Expand All @@ -94,14 +97,11 @@ diagnostics remain visible. Depth, node, and edge budgets are consumer-local
guards and do not rewrite or reinterpret producer records. See
[ADR-0015](../../docs/adr/0015-attach-semantic-facts-without-expanding-graph-identity.md).

Each inspection also contains the internal version-1 primitive/literal Rust
candidate documented by
[ADR-0017](../../docs/adr/0017-project-primitive-literal-candidates-from-go-graph-identity.md).
It records the occurrence, fact status, all five roots, structured primitive or
literal values, ordered union member TypeIDs, and explicit candidate/source
states. Candidate records intentionally omit display text. The shared
`primitive-literal-candidate` canonical fixture is round-tripped by Go and
attached, inspected, and asserted here through OXC.
Graph inspection remains a consumer of the Go response and does not synthesize
Rust candidate records. The independent primitive/literal producer lives beside
the inspector and is exercised only by focused tests and the shadow conformance
runner. It accepts source/project inputs, owns its response-local type identity,
and never receives the Go graph used as the oracle.

## Migration boundary

Expand All @@ -115,11 +115,11 @@ negotiation in Go. The intended migration sequence is:
explicit and met.

Occurrence identity and attachment plumbing is the first approved mechanical
port category. The primitive/literal projection is the first implemented
semantic candidate record, but it consumes Go-produced graph facts and does
not constitute an independent producer. All semantic answers remain
Go-authoritative until an independent Rust producer completes ADR-0018's
replacement checklist.
port category. Primitive/literal construction is now independently implemented
for the narrow, tagged conformance corpus and satisfies the shadow threshold in
ADR-0019. This does not transfer semantic authority: the implementation is not
wired into production, Go remains the fallback, and broader TypeScript
semantics remain Go-authoritative.

Adding a projection does not transfer semantic authority. New parser-boundary
normalizations require a shared fixture and the versioned portable contract.
Loading