Repository navigation
Move janitor's test bench routes onto HttpApi - #136
Merged
Merged
Conversation
The testBench group (listItems, run, startRuleTest, getRuleTest and getRuleTestInput) joins JanitorApi, and the cluster serves it from Ingress/TestBench.ts through HttpApiBuilder behind the API middleware. RuleTestJob moves into Labeling/Policy/Test. RuleTestNotFound (404) joins Labeling/Policy/Configuration for a missing job or an expired input snapshot. startRuleTest answers BadRequest unless it tests one item against a draft or a policy, PolicyInvalid for a draft that fails validation, and drops the 202's Retry-After header. RuleTestJobs fails with RepositoryBlocked when the repository is no longer connected; SQL, outbox, row decode and configuration failures die, as do LabelingTest's infrastructure failures in the handlers. TestRequest's numbers key becomes optional, because the derived client sends the schema's Type; LabelingTest reads an absent list as empty. The raw LabelingRoutes drop the test bench routes.
The test bench runs through api.testBench.run, the workspace loads test items through listItems, and the rule editor starts, polls and inspects rule tests through startRuleTest, getRuleTest and getRuleTestInput. Each command decodes its plain-string subject into the domain TestRequest before sending, and owns the copy for each tag. The labeling-wire TestEntity, TestResponse and AiInputDetails copies and testEndpoint go. TestSubject stays as the editor's free-JSON form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the
testBenchgroup ontoHttpApi:listItems,run,startRuleTest,getRuleTestandgetRuleTestInput(R9, R10, R11, W3, W13).Cluster and domain
packages/domain/src/Api/TestBench.tsdefines the group, andJanitorApiadds it.apps/cluster/src/Ingress/TestBench.tsserves it, andRoutes.tsmerges that layer.RuleTestJobmoves toLabeling/Policy/Test.ts. The cluster'sPayloadandRowstructs stay where they are.RuleTestNotFound { testId }(404) inLabeling/Policy/Configuration.ts. It covers a missing job and an expired input snapshot.startRuleTestanswersHttpApiError.BadRequestunless it tests exactly one item against a draft or a policy. A draft that fails validation getsPolicyInvalid { diagnostic }. The 202 no longer sendsRetry-After: 1.RuleTestJobsnow fails withRepositoryBlocked { reason: "disconnected" }on both enqueue and get when the repository is no longer connected. Before, that case returnedRepositoryNotFound. SQL, outbox, row decode and configuration failures die. The handlers also turnLabelingTestErrorandLabelingConfigurationErrorinto defects.LabelingTestitself keeps its error types, because the rule-test workflow matches on its failures to record "The test could not finish".TestRequest.numbersis now optional in the type as well as on the wire. This followsCreateRuleRequestfrom Move janitor's rules routes onto HttpApi #135, because the derived client sends the schema's Type.LabelingTestreads an absent list as empty.LabelingRoutes.tsdrops the five test bench routes.Web
test-bench.tsruns throughapi.testBench.run.workspace.tsloads test items throughlistItems.rule-editor.tsstarts, polls and inspects rule tests throughstartRuleTest,getRuleTestandgetRuleTestInput.TestRequestbefore sending. They turn tags into page copy withcatchTag/catchTags, andorElseSucceedcovers everything else.labeling-wire.tscopies ofTestEntity,TestResponseandAiInputDetailsgo, along withtestEndpoint.TestSubjectstays, because it is the editor's free-JSON form, likeProgramSource.Validation
vp check: 0 errors. No new warnings in the changed files.vp test: 820 passed, 2 failed. Tests were kept unchanged on purpose for this run, so both failures are known test problems, to be fixed in a separate test cleanup:test/Ingress/LabelingRoutes.test.ts> "runs tests, sets AI consent and refuses cross-site writes" still posts to the raw/testroute, which now lives in the HttpApi group. Its/testassertion and theLabelingTestandRuleTestJobsstubs should go. The same stubs inRoutes.test.tsare now unused, but harmless.test/Ingress/TestBench.test.ts> "lists items, runs a test…" expects the enqueued draft exactly as sent. The server decodes the payload, which adds the condition's defaultcaseSensitive: false. The fixture'smatchesWhenneedscaseSensitive: false.Closes EFF-2522