Skip to content

[TST-E4] test: thirteen more declared-error doors become table rows, each area's rows in its own slice - #460

Merged
Blind-Striker merged 1 commit into
masterfrom
test/tst-e4a-p04a-door-rows
Oct 17, 2026
Merged

Blind-Striker merged 1 commit into
masterfrom
test/tst-e4a-p04a-door-rows

Conversation

@Blind-Striker

@Blind-Striker Blind-Striker commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

📝 Description

What does this PR do?
It is TST-E4a's first batch of declared-error door conversions. Thirteen methods move into the door table that #446 introduced: four in Config, four in Credentials, two in Debug, one in Experimental/FileWrite and two in Forms. Each of these methods proved only "door D answers declared status S with error type T", on one spine.

  • Each becomes a row, and every row runs on both spines. On the throwing spine it asserts OpenCodeApiException, the exact status and the exact type. On the NoThrow spine it asserts IsError, the exact status and the exact type. Each row is also checked against its declaration in the pinned spec/openapi.json by the one-way guard.
  • Each area's rows live in its own slice: Config/ConfigDeclaredErrors.cs, Credentials/…, Debug/…, Experimental/… and Forms/…, each with a static Rows() of 17 to 61 lines. DeclaredErrorTests.EveryDoor() is only their concatenation, so both spines and the guard still read one row source. The pilot row moves verbatim to Worktrees/WorktreesDeclaredErrors.cs. This layout keeps the table inside analyzer MA0051's 80-line method limit and the slice layout, as the table grows to about 100 rows.
  • Every other method in the touched classes is byte-identical. No product, record or test-method change.

Net line delta: +286 / −192 = +94 in test code. The conversions do not save lines; the six slice files add their own class scaffolding. The gains are fewer methods, coverage on both spines, and each row traced to the pin.

🔄 Type of Change

  • 🧪 Test improvements

🎯 Protocol & API Surface

  • No change to the public API surface
  • Nothing under external/, spec/ or src/ was touched

🧪 Testing

Test mapping (mechanical: e4_test_map.py over git diff 7738dc33 d61b521f)

File Base test method At head Target
tests/OpenCode.Sdk.Tests/Config/ConfigClientContractTests.cs GetShellsAsync_Should_Throw_The_Declared_400_Error row config.shells:400:InvalidRequestError
tests/OpenCode.Sdk.Tests/Config/ConfigClientContractTests.cs GetShellsAsync_Should_Return_The_401_Error_On_The_NoThrow_Spine row config.shells:401:UnauthorizedError
tests/OpenCode.Sdk.Tests/Config/ConfigClientContractTests.cs UpdateConfigAsync_Should_Throw_The_Declared_400_Error row experimental.config.update:400:InvalidRequestError
tests/OpenCode.Sdk.Tests/Config/ConfigClientContractTests.cs UpdateConfigAsync_Should_Return_The_401_Error_On_The_NoThrow_Spine row experimental.config.update:401:UnauthorizedError
tests/OpenCode.Sdk.Tests/Credentials/CredentialsClientContractTests.cs CreateCredentialAsync_Should_Return_The_Declared_409_Error_On_The_NoThrow_Spine row credential.create:409:ConflictError
tests/OpenCode.Sdk.Tests/Credentials/CredentialsClientContractTests.cs ListCredentialsAsync_Should_Throw_The_Declared_401_Error row credential.list:401:UnauthorizedError
tests/OpenCode.Sdk.Tests/Credentials/CredentialsClientContractTests.cs ActivateCredentialAsync_Should_Throw_The_Declared_400_Error row credential.activate:400:InvalidRequestError
tests/OpenCode.Sdk.Tests/Credentials/CredentialsClientContractTests.cs ActivateCredentialAsync_Should_Return_The_401_Error_On_The_NoThrow_Spine row credential.activate:401:UnauthorizedError
tests/OpenCode.Sdk.Tests/Debug/DebugClientContractTests.cs ListLocationsAsync_Should_Throw_The_Declared_400_Error row debug.location.list:400:InvalidRequestError
tests/OpenCode.Sdk.Tests/Debug/DebugClientContractTests.cs ListLocationsAsync_Should_Return_The_401_Error_On_The_NoThrow_Spine row debug.location.list:401:UnauthorizedError
tests/OpenCode.Sdk.Tests/Experimental/FileWriteContractTests.cs WriteFileAsync_Should_Throw_The_Declared_400_Error row experimental.fs.write:400:InvalidRequestError
tests/OpenCode.Sdk.Tests/Forms/FormsClientContractTests.cs ListFormsAsync_Should_Throw_The_Declared_400_Error row form.list:400:InvalidRequestError
tests/OpenCode.Sdk.Tests/Forms/FormsClientContractTests.cs ListFormsAsync_Should_Return_The_401_Error_On_The_NoThrow_Spine row form.list:401:UnauthorizedError

Unmapped: 0

File Assert.That at base at head delta
tests/OpenCode.Sdk.Tests/Common/Errors/DeclaredErrorTests.cs 12 12 +0
tests/OpenCode.Sdk.Tests/Config/ConfigClientContractTests.cs 26 14 -12
tests/OpenCode.Sdk.Tests/Config/ConfigDeclaredErrors.cs 0 0 +0
tests/OpenCode.Sdk.Tests/Credentials/CredentialsClientContractTests.cs 39 27 -12
tests/OpenCode.Sdk.Tests/Credentials/CredentialsDeclaredErrors.cs 0 0 +0
tests/OpenCode.Sdk.Tests/Debug/DebugClientContractTests.cs 11 5 -6
tests/OpenCode.Sdk.Tests/Debug/DebugDeclaredErrors.cs 0 0 +0
tests/OpenCode.Sdk.Tests/Experimental/ExperimentalDeclaredErrors.cs 0 0 +0
tests/OpenCode.Sdk.Tests/Experimental/FileWriteContractTests.cs 9 6 -3
tests/OpenCode.Sdk.Tests/Forms/FormsClientContractTests.cs 13 7 -6
tests/OpenCode.Sdk.Tests/Forms/FormsDeclaredErrors.cs 0 0 +0
tests/OpenCode.Sdk.Tests/Worktrees/WorktreesDeclaredErrors.cs 0 0 +0

The negative deltas are the deleted methods' assertions. The rows assert the same status and exact type on both spines; DeclaredErrorTests' 12 assertion sites run for every row.

Equivalence mutants: one per source class (scratch only; restored byte-identically)

In each class's response adapter, the declared tags for one door's status were emptied.

Adapter (src/OpenCode.Sdk/) Old method, red on base New row, red on both spines
Config/Internal/ConfigShellsResponseAdapter.cs:9 GetShellsAsync_Should_Throw_The_Declared_400_Error config.shells:400:InvalidRequestError
Credentials/Internal/CredentialCreateResponseAdapter.cs:11 CreateCredentialAsync_Should_Return_The_Declared_409_Error_On_The_NoThrow_Spine credential.create:409:ConflictError
Debug/Internal/DebugLocationListResponseAdapter.cs:9 ListLocationsAsync_Should_Throw_The_Declared_400_Error debug.location.list:400:InvalidRequestError
Experimental/Internal/ExperimentalFsWriteResponseAdapter.cs:9 WriteFileAsync_Should_Throw_The_Declared_400_Error experimental.fs.write:400:InvalidRequestError
Forms/Internal/FormListResponseAdapter.cs:9 ListFormsAsync_Should_Throw_The_Declared_400_Error form.list:400:InvalidRequestError

Base: 5 failed. Finished table: 10 failed (5 rows × 2 spines). Every failure received UnknownOpenCodeError at the exact-type assertion. Two row-oracle mutants are also killed: a wrong expected type turns both spines red, and a pointer into another operation turns the guard red.

Clone baseline (regenerated, totals fall)

Master 7738dc33 This PR
Test clones 641 603
Tests duplication 5.35% 5.12%

The baseline loses 98 fingerprints and gains 64. None of the 62 duplicates jscpd reports as new involves a file this PR changes. Every one sits between files this PR does not touch, whose text is byte-identical to master. They are the not-yet-converted declared-error methods: once their Config, Credentials and other twins are deleted, jscpd reports their remaining duplicates under new pairings and new fingerprints. 22 of them map to a same-pair predecessor; the other 40 are the same unchanged fragments paired differently. They shrink as later door PRs convert those methods.

Review

  • Coordinator: read the diff and the slice layout. One note for later: two cases of the same door repeat the door definition. That is not repeated per spine and not a detected clone, but a shared door per area could tighten it.
  • Sol (given only the requirements and the diff) found no defects and no out-of-scope changes. It checked every row against spec/openapi.json and matched all 14 nameof labels to the call their lambda makes. It could not verify the baseline-regrouping claim from hashes alone; the jscpd analysis above is that evidence.

✅ Completion Gate

Local check (quality-gates.md) on head d61b521f, base 7738dc33. Every step's own exit code was read:

  • slopwatch: zero findings
  • dotnet build --configuration Release: 0 warnings, 0 errors
  • dotnet format whitespace / dotnet format style --severity warn: no changes
  • verify-clones: passed, 0 new (tests 5.12%)
  • OpenCode.Sdk.Tools.Tests (all but NativeAot): 2081, 0 failed
  • OpenCode.Sdk.Tests (all but ServiceElection/NativeAot): 8519, 0 failed

The host runs Bun 1.4.3, a maintainer-named off-pin host (OPENCODE_SDK_TESTS_BUN_MISMATCH=allow); the pin is 1.4.2.

✅ Code Quality Checklist

  • No new suppression
  • No tests skipped or weakened; every removed method is mapped to its row above

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…'s rows in its own slice

TST-E4a P04a. The Config, Credentials, Debug, FileWrite and Forms contract classes' declared-error door methods become rows of DeclaredErrorTests, each now proven on both the throwing and the NoThrow spine and traced to its declaration in the pinned spec. Each area's rows live in its slice (<Area>/<Area>DeclaredErrors.cs, a static Rows() of at most 80 lines), and EveryDoor() concatenates them; the pilot row moves to Worktrees/WorktreesDeclaredErrors.cs. The clone baseline drops the replaced methods' duplicates; jscpd regroups the remaining declared-error duplicates in untouched files under new fingerprints, and the totals fall.
@Blind-Striker
Blind-Striker added this pull request to the merge queue Oct 17, 2026
Merged via the queue into master with commit 77bb1b5 Oct 17, 2026
12 checks 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