Repository navigation
Conversation
|
Scope checkThis PR changes 655 lines across 7 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-do | 15d92da | Jul 12 2026, 09:20 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | 15d92da | Jul 12 2026, 09:21 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | 15d92da | Jul 12 2026, 09:21 PM |
There was a problem hiding this comment.
This is the right change for W8.1. It introduces a clear, policy-derived normalized finding contract, validates it against the allowlist and the run’s recorded evidence, and gates finalization with a non-retryable error — all consistent with the labeler architecture and the stated production-boundary scope.
I read the diff and full changed files, traced the new validator through the orchestrator, checked the public/private boundary in evidence.ts, verified SQL parameterization in listEvidenceObjectIds, and confirmed the type-only import cycle is runtime-safe under verbatimModuleSyntax. Tests cover the validation surface and abort path.
Headline conclusion: clean overall, with one minor suggestion. The validateFinding contract claims it returns an object built solely from validated locals and never passes input through, but the array helper returns the original array reference for evidenceRefs, affectedFiles, and affectedImages. Arrays are element-wise validated, so the current orchestrator path is not unsafe, but a caller that mutates the input array after validation would mutate the supposedly immutable validated finding. Copying the array in requireStringArray aligns the implementation with the contract claim.
A future tightening opportunity (not a finding): validateFinding does not enforce that source and sourceMetadata.kind are consistent (e.g., source: "deterministic" with sourceMetadata.kind: "model"). The spec phrasing suggests a relationship, so this may be worth codifying once the stage adapters are real.
| `${field} entries must be at most ${MAX_ARRAY_ENTRY_LENGTH} characters`, | ||
| ); | ||
| } | ||
| return value; |
There was a problem hiding this comment.
[suggestion] requireStringArray returns the original input array reference after validating it, so the arrays assigned to evidenceRefs, affectedFiles, and affectedImages in validateFinding are the caller’s arrays passed through rather than freshly built. The PR description says validated findings are “built solely from validated locals” and that unexpected input fields are “never passed through,” but these arrays are passed through.
In the current orchestrator path this is harmless because the stage adapter cannot mutate a finding after returning it, but it makes the contract fragile for other callers and means a mutated array could change a validated finding later.
| return value; | |
| return [...value]; |
This single change fulfills the stated contract without affecting behavior elsewhere.
Add the canonical NormalizedFinding shape every analysis stage produces, with validateFinding/validateFindings enforcing it against the policy-derived allowed-category set (automated-block union warning) and a run's recorded evidence objects before an assessment finalizes. toPublicFindingView routes through evidence.ts's never-typed PrivateFindingRecord -> PublicFindingView narrowing so private fields can't leak. The orchestrator now validates collected findings before resolving policy outcome; an invalid finding aborts the run as a non-retryable stage-adapter bug.
ae8055d to
f4a547f
Compare
…nput requireStringArray returned the caller's array by reference, so mutating the input array after validation would mutate the validated finding. Return a copy so the finding matches the contract's immutability claim.
|
Applied your suggestion. On the future tightening (source ↔ sourceMetadata.kind consistency): agreed it's worth codifying, and I'm deferring it exactly as you framed — to when the stage adapters are real. Enforcing it now would bake in a mapping the adapters haven't pinned down (e.g. whether Also FYI: rebased onto the freshly-merged #1989 (clean; the only overlap was non-adjacent additions in |
There was a problem hiding this comment.
Re-review of the W8.1 normalized finding contract follow-up.
The one item from the previous review — validateFinding returning the original input array references for evidenceRefs/affectedFiles/affectedImages despite claiming validated-locals-only output — is now fixed. requireStringArray returns a shallow copy ([...value]) and apps/labeler/test/findings.test.ts adds a regression test confirming the validated finding is decoupled from caller mutations.
I re-read the full changed files (findings.ts, evidence.ts, policy.ts, assessment-orchestrator.ts, assessment-store.ts, and the tests) and found no new issues:
- The public/private boundary is still enforced by routing through
evidence.ts’snever-typedtoPublicFinding;toPublicFindingViewnever constructs a public view literal itself. - Validation covers the enumerated source/severity values, policy-derived category allowlist, confidence range, evidence-ref resolution, string bounds, array bounds, and typed
sourceMetadata. - The orchestrator validates collected findings before finalization, aborts (non-retryable) on the first validation failure, and remains behind the documented production boundary (
AssessmentOrchestratoris test-only perproduction-boundary.test.ts). - SQL in
listEvidenceObjectIdsis parameterized; no migration, no admin UI, no public API change, and no changeset are needed for this private Worker app.
No new findings. The only remaining tightening opportunity is the source/sourceMetadata.kind consistency check already noted as future work in the prior review.
14402a3
into
feat/plugin-registry-labelling-service
What does this PR do?
Adds the labeler's normalized finding contract — plan item W8.1. This is the single validated shape every analysis stage (deterministic, capability, model, image, history) produces, and the gate that enforces it before an assessment finalizes. It's the foundation the W7 (deterministic + capability) and W8 (AI code + image) analyses populate and the operator console (W9.3) reads.
findings.ts—NormalizedFinding(source, policy-validatedcategory, severity, optional confidence, public/private summaries, evidence refs, optional affected files/images, and a discriminatedsourceMetadata—toolfor deterministic/capability/history,modelfor model/image).validateFinding/validateFindingsthrowFindingValidationErroron an unknown category, a source/severity outside the enums, a confidence outside[0,1], an evidence ref that doesn't resolve to a recorded evidence object, or malformed/oversized strings — and return an object built solely from validated locals (unexpected input fields are dropped, never passed through).allowedFindingCategories(policy)= the automated-block ∪ warning label values (via the newwarningCategories, mirroringautomatedBlockCategories), derived from the versioned policy rather than hardcoded. Eligibility and manual-system label values are not finding-derivable.toPublicFindingViewroutes throughevidence.ts's existingnever-typedPrivateFindingRecord → PublicFindingViewnarrowing rather than constructing a public view itself, so a private field can't leak by drifting out of sync.PublicFindingViewis unchanged;PrivateFindingRecordgains the new optional fields but still carries the non-optionalprivateDetail/evidenceRefsthat make it non-assignable to the public view.StageFindingis nowNormalizedFinding, and it validates collected findings against the policy allowlist + the run's recorded evidence ids before finalizing. An invalid finding is a non-retryable error (a stage-adapter bug), so it aborts the run rather than retrying.No migration (the
findingstable already exists), no lexicon change, no public-API change (findings are internal evidence — the publicpublicAssessmenthas no findings array).Reviewed with a focused adversarial (opus) pass targeting the private→public boundary, validation bypass, and the orchestrator wiring before opening.
Targets
feat/plugin-registry-labelling-service. Related to #1909 and RFC #694.Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.Admin i18n and changeset are n/a — this touches only
apps/labeler, a private, unpublished Worker app (no admin UI, not on npm).AI-generated code disclosure
Screenshots / test output
pnpm --filter @emdash-cms/labeler test: 150 pass (130 pre-existing + 20 new — 18 for the finding contract/validation/boundary, 2 for the orchestrator abort-on-invalid path)pnpm lint:jsondiagnostics unchanged at 19 (all pre-existing, 0 inapps/labeler)Try this PR
Open a fresh playground →
A full working EmDash site, deployed from this branch. Each visit gets its own session-scoped sandbox: no login needed and no shared state. Try the admin, edit content, hit the public site.
Tracks
feat/labeler-finding-contracts. Updated automatically when the playground redeploys.