effect

Seeded Effect defects — tag branching in a broad catch, hand-built tagged errors, a service imported around its Layer.

9 deliberate defects, each with a marker naming the rule in standards/ it breaks. It measures recall: how many of the defects the reviewer flags at their severity or higher. The pass condition is that all 4 BLOCKER defects are flagged.

Because each marker names a rule, the scorer also grades attribution. A reviewer that finds the bug but cites the wrong rule counts as caught, and separately as misattributed.

Running it

Nothing here is ever merged. Open a throwaway pull request on a pilot repository already onboarded for this stack, adding this directory and seeded/clean together, wait for the automated review to finish, then score it.

seed-canary.yml does exactly this on a schedule and closes the pull request afterwards, including when the run fails.

terminal
$ GH_TOKEN=... npx redlinegate metrics score-seeds --repo <org>/<repo> --pr <n>

Flags and output are on redline metrics.

The 9 defects

SeedSeverityRule it violatesDefect
1BLOCKERcore/hardcoded-secretsAPI token committed in source
2BLOCKERcore/unsafe-assertiondouble assertion with no SAFETY justification
3BLOCKERtypescript/widen-then-assertknown value widened to unknown, then asserted back
4BLOCKERcore/type-checker-suppressiontype checker silenced with no explanation and no ticket
5HIGHeffect/manual-error-tag-in-catchtag branching inside a broad catch leaves NotFound in the error channel
6HIGHeffect/manual-tagged-constructionliteral _tag object instead of the tagged error constructor
7HIGHeffect/service-constructor-importservice constructor imported from a relative path instead of its Layer
8SUGGESTIONeffect/manual-tag-comparisonmanual _tag comparison instead of Match.tag
9SUGGESTIONeffect/prefer-matchchained literal ternary instead of Match

Scoring

The score reports BLOCKER recall, false positives, and rule attribution. The canary appends it to data/seed-scores.jsonl and fails the run if BLOCKER recall drops below 1.0 or the clean corpus attracts a false positive. Of the 9 defects here, 4 BLOCKER, 3 HIGH and 2 SUGGESTION — only the BLOCKER count is a pass condition.

Adding a defect

Add the code and one marker line above it. The format, and what scripts/validate.mjs checks, are on Seeded corpus.

The full file

seeded/effect/seeded-violations.ts · 46 lines · 2.3 KB
// DO NOT MERGE — Redline validation seed.
// Every `SEED n [SEVERITY] (rule-id)` marker must be flagged at that severity or higher,
// citing that rule id. Score with scripts/score-seeds.mjs.
import { Data, Effect } from 'effect';
import { makeIssueService } from './issue-service';

class NotFound extends Data.TaggedError('NotFound')<{ readonly id: string }> {}
class Forbidden extends Data.TaggedError('Forbidden')<{ readonly id: string }> {}

declare const loadIssue: (id: string) => Effect.Effect<string, NotFound | Forbidden>;

// SEED 1 [BLOCKER] (core/hardcoded-secrets) API token committed in source
const ISSUE_TRACKER_TOKEN = 'issuetracker-live-0f3a9c2e7b5d4a1f8c6e';

// SEED 2 [BLOCKER] (core/unsafe-assertion) double assertion with no SAFETY justification
export const asNotFound = (error: Forbidden): NotFound => error as unknown as NotFound;

// SEED 3 [BLOCKER] (typescript/widen-then-assert) known value widened to unknown, then asserted back
export function toForbidden(error: NotFound): Forbidden {
  const raw: unknown = error;
  return raw as Forbidden;
}

// SEED 4 [BLOCKER] (core/type-checker-suppression) type checker silenced with no explanation and no ticket
// @ts-ignore
export const issueId: string = 42;

// SEED 5 [HIGH] (effect/manual-error-tag-in-catch) tag branching inside a broad catch leaves NotFound in the error channel
export const issueOrEmpty = (id: string) =>
  loadIssue(id).pipe(
    Effect.catchAll((error) => (error._tag === 'NotFound' ? Effect.succeed('') : Effect.fail(error)))
  );

// SEED 6 [HIGH] (effect/manual-tagged-construction) literal _tag object instead of the tagged error constructor
export const missing = (id: string) => Effect.fail({ _tag: 'NotFound', id });

// SEED 7 [HIGH] (effect/service-constructor-import) service constructor imported from a relative path instead of its Layer
export const issues = makeIssueService({ token: ISSUE_TRACKER_TOKEN });

// SEED 8 [SUGGESTION] (effect/manual-tag-comparison) manual _tag comparison instead of Match.tag
export const isForbidden = (error: NotFound | Forbidden): boolean => error._tag === 'Forbidden';

// SEED 9 [SUGGESTION] (effect/prefer-match) chained literal ternary instead of Match
export const statusLabel = (status: 'open' | 'closed' | 'draft'): string =>
  status === 'open' ? 'Open' : status === 'closed' ? 'Closed' : 'Draft';