Skip to content

test(hosting): record the long ACE-label CORS divergence and pin it with tested rows (#945) - #954

Merged
Blind-Striker merged 1 commit into
masterfrom
fix/945-ace-label-divergence-pr
Nov 17, 2026
Merged

Blind-Striker merged 1 commit into
masterfrom
fix/945-ace-label-divergence-pr

Conversation

@Blind-Striker

Copy link
Copy Markdown
Collaborator

📝 Description

What does this PR do?

The last part of #945. Upstream's CLI (WHATWG URL parsing, external/opencode/packages/cli/src/services/service-config.ts at the 2.3.0 pin) accepts valid ACE (xn--) labels of 64 and 65 characters in CORS origins. The SDK's CorsOriginPolicy refuses them, because .NET's IdnMapping always enforces the 63-character label limit. The maintainer decided to record this as a divergence and to pin it with tested rows rather than port Punycode or UTS-46 (2026-11-17, #945). This PR changes no production code.

  • Corpus. Four rows, with verdicts generated by bun tools/oracles/service-config.ts from upstream's own code:

    • http://xn--"-mga, valid;
    • http://xn--"-9ca, invalid;
    • a valid 64-character ACE label, valid;
    • a valid 65-character ACE label, valid.

    The two xn--" rows cover ACE labels that contain the characters fix(hosting): accept the remaining WHATWG host characters in CORS origins and pin the fallback's invariants (#945) #948 added, and the SDK matches upstream on both. No existing verdict changed.

  • Expected differences, tested both ways. CorsOriginPolicyTests names the two long-ACE origins.

    • IsOrigin_Should_Match_Every_Upstream_Cors_Verdict skips exactly those origins and still compares every other row, including the 63-character ACE rows.
    • IsOrigin_Should_Preserve_Recorded_Upstream_Differences asserts three things for each named origin: it is still in the corpus, upstream accepts it, and the SDK refuses it. The test goes red when either side changes or the row leaves the corpus.
  • Canon. docs/architecture/client-runtime.md, in the CorsOriginPolicy section, records the divergence in the file's existing form:

    • the reason: IdnMapping has no switch for the limit, and DNS limits a label to 63 octets, so no resolvable host is lost;
    • the maintainer's decision;
    • the reversal;
    • the test that pins it.
  • CHANGELOG. No entry: SDK behaviour does not change.

Related Issue(s):

🔄 Type of Change

  • 📚 Documentation update
  • 🧪 Test improvements

🎯 Protocol & API Surface

  • No change to the public API surface
  • The pinned snapshot (spec/) is untouched
  • Nothing under external/ was hand-edited

🧪 Testing

How has this been tested?

The oracle corpus grows from 172 to 176 rows, and the four new verdicts matched the predictions. After the commit, the oracle ran twice more, with a clean tree each time.

Red proofs (temporary test-side edits, each restored with a clean diff). Each one failed deterministically on net10.0 and net11.0:

  • Removing a long-ACE origin from the list fails the all-rows test with upstream True, SDK False for that row.
  • Listing http://example.com, which both sides accept, fails the new test on the SDK side.
  • Listing http://%65xample.com, which upstream refuses, fails the new test on the upstream side.

Local check on 75b8eae5 (macOS arm64, on master 31c7a3c8), all green:

  • the oracle pair;
  • slopwatch;
  • dotnet build -c Release, and again with -p:IncludeNet472Tests=true;
  • both format passes;
  • verify-clones;
  • Tools tests (2863, including the canon-section guard and the documentation gates);
  • SDK tests (9766, net10.0 and net11.0);
  • ServiceElection (22);
  • --help and generate --verify.

After the rebase onto master c764d7fb (#947), the Release build (0 warnings), whitespace, the Tools tests (2874) and CorsOriginPolicyTests (4 runs across net10.0 and net11.0) passed again. After the rebase onto master f5a26b8f (#953, docs only), whitespace and the Tools tests (2874, including the canon-section guard) passed on the head b831cc23.

Review: a fresh read found nothing blocking. It confirmed the label arithmetic (63 compared, 64 and 65 listed), the skip logic and the canon entry. It traced both xn--" rows through CorsOriginPolicy on ICU.

net472: no production code changed, so there are no mutants to replay. The xn--"-mga row has not run on .NET Framework 4.7.2 yet. On Windows, .NET Framework's IdnMapping uses the Win32 IDN functions rather than ICU, so the gate host runs a baseline-only CorsOriginPolicyTests pass on net472 before this PR is enqueued. If net472 refuses that row, the difference is recorded in this PR.

📚 Documentation

  • Canon updated in the same change
  • No CHANGELOG entry (no behaviour change)

Known follow-ups

  • CorsOriginPolicyTests repeats the expected-fixture name and its parse in both tests; one private constant or loader would remove the duplication.
  • The expected-difference list and its test carry generic names. Naming them for the long-ACE class, or asserting that each entry is an ACE label over 63 characters, would stop the list from absorbing unrelated differences.
  • CorsOriginPolicy's XML summaries still say it applies the CLI's exact policy. Now that one difference is recorded, they could say "the CLI's policy, with the recorded exceptions".
  • The new test stops at the first failing origin, where its sibling collects every disagreement before asserting.

@Blind-Striker Blind-Striker added this to the Next milestone Nov 17, 2026
@Blind-Striker
Blind-Striker added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit 4fc4c1b Nov 17, 2026
15 checks passed
@Blind-Striker
Blind-Striker deleted the fix/945-ace-label-divergence-pr branch November 17, 2026 14:46
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.

CORS origin policy: remaining WHATWG host characters, long ACE labels, and fallback invariant rows

1 participant