Skip to content
Myr

Close W1: fold the ports' provenance, keep every escape visible to debt, and fence Effect.sleep in packages/project

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- PROVENANCE.md: port rows for 102's two rules, 104's hook policy and its three adapters, and 107's vendor script; 105's mcp.ts row now says the hint annotations are restored from our own annotations, and lists listTools and toJsonSchema; ideas rows for the merged command catalog (cf) and the numbered playbooks (Rat Stack). LICENSES/t3code.MIT.txt was already in place. The debt-ledger row records this commit's changes. - fence/debt-ledger, closing the four holes 103's review found: eslint-disable* counts as oxlint-disable, since oxlint honours it; a directive counts only where a comment's line starts, as oxlint, eslint and tsc read it, so prose that names one mid-sentence is no escape (@effect-diagnostics still counts anywhere, because the language service reads it anywhere); an empty reason no longer leaves " --" in the directive; and every report sits at offset 0 with the escape's line in its message. Before, a reasoned file-wide /* oxlint-disable */ or an oxlint-disable-line hid every escape after it. A scratch plugin on oxlint 1.87 showed offset 0 is never suppressed, not by a named block disable at offset 0 or an oxlint-disable-line on line 1 either. ledgerFromOxlintJson reads the line from the message. The real count is unchanged at 4/4. - fence/no-effect-sleep-in-project (new, ours): refuses Effect.sleep and Effect.delay, as members or as named imports from effect/Effect, in packages/project/src, scoped by the rule itself through the exported workspacePath. At error in oxlint.config.ts. AGENTS.md principle 12 names it before "No fence yet:", closing 108's "(no wave yet)". - The closed env files beyond the shell, from 104's follow-ups: .claude/settings.json denies Claude Code's Read tool **/.env, **/.env.local and **/.env.*.local. A headless claude -p (haiku, --allowedTools Read) in a scratch repo with fake files was denied all three and read .env.schema; the same run without the rules read all four. The pi extension blocks pi's read, edit and grep of a closed path through isClosedEnvPath, a new export of scripts/hooks/lib/policy.ts. - AGENTS.md: principle 3 says retryable and next are fixed per tag (107); principle 9 points at .agent_sources/effect; Effect traps gains the TS377000 string-literal trap (103) and names gen.test.ts as the fence on the Infinity/null leak (105). - packages/config/test/root.ts holds repoRoot, which four test files defined and agents-table.ts computed inline (102). - Tests added, each red by assertion first: debt.test.ts's fixture gains an eslint-disable, mid-sentence prose, a doc-line directive, a disable-line and a file-wide disable over an unreasoned @ts-ignore; oxlint-fence.test.ts gains the sleep rule's bad and good fixtures (in project/src, project/test and another package) and lints the bad one through the root config; vcs-policy.test.ts drives the pi extension through a stand-in API and reads the Claude Code deny list; fence-wiring.test.ts reads the line from the ledger message. - Spot-checks, each planted, refused, then reverted: a module let in packages/git/src (check), Effect.runPromise in a packages/git test (check), an unreasoned oxlint-disable (debt: rose to 5, no reason), an @repo/cli import in apps/platform/src (imports:check, app-imports-app), a hand edit to docs/reference/mcp-tools.md (gen:check, GeneratedFilesDrifted), and scripts/replay-twice.ts named in principle 8 (agents-table: "the repo has no such file"). Also Effect.sleep in a planted packages/project/src/claim.ts (lint) and a reasoned file-wide disable over a @ts-ignore (debt now names the @ts-ignore at line 2). - Live hook proof in this checkout: echo '{"tool_input":{"command":"git commit -n -m x"}}' | bun scripts/hooks/vcs-policy.ts printed "vcs-policy refused this command (hook-bypass): Hooks are early feedback; fix the failure instead of skipping it (AGENTS.md principle 11)." and exited 2 in 0.1 s. A fresh claude -p 'run: git commit --no-verify -m x' --output-format json --model haiku (Claude Code 2.1.292) ended with HEAD unchanged and reported "permission_denials":[{"tool_name":"Bash","tool_input":{"command":"git commit --no-verify -m x"}}] and "result":"The vcs-policy hook blocked that command. According to AGENTS.md principle 11, ...". - bash scripts/vendor-agent-sources.sh ran here: it skipped effect@4.0.1 and wrangler@4.147.0 as present (.agent_sources/effect is in place). bun run gen left no diff. - No escape added, no rule or baseline loosened; debt stays 4/4. - ASSUMPTION: oxlint keeps leaving offset 0 unsuppressed. debt.test.ts's file-wide-disable case fails if an upgrade changes that.

authored by oscabriel · committed by oscabriel · parent c234e81 · Browse files · 25 files+497 added−114 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

25 files+497 added−114 removed

  • tests:+241 added−66 removed
  • other:+256 added−48 removed

25 files+497 added−114 removed

modified:.claude/settings.json+3 added
modified:.pi/extensions/vcs-policy/index.ts+38 added-10 removed
modified:.pi/extensions/vcs-policy/README.md+1 added-1 removed
modified:packages/config/test/agents-table.ts+2 added-2 removed
24 unmodified lines
25import { ChildProcess, ChildProcessSpawner } from "effect/process";26import type { DummyRule, OxlintConfig } from "oxlint";2728import oxlintConfig from "../../../oxlint.config.ts";29import { repoRoot } from "./root.ts";3031/** What the repo holds that a "Held by" cell may name. */32export interface Repo {33 /** Every file git tracks or would add, relative to the repo root. */
394 unmodified lines
428export const readAgentsTable = Effect.gen(function* () {429 const fs = yield* FileSystem.FileSystem;430 const path = yield* Path.Path;431 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;431 // Vitest runs in the package's folder, two below the repo root.432 const root = path.resolve("..", "..");432 const root = yield* repoRoot;433 const read = (file: string) => fs.readFileString(path.join(root, file));434435 const lsFiles = (...args: readonly string[]) =>436 spawner.lines(
35 unmodified lines
modified:packages/config/test/debt.test.ts+26 added-7 removed
15 unmodified lines
16 renderVerdict,17 tally,18 Verdict,19} from "../../../scripts/lib/debt.ts";20import { repoRoot } from "./root.ts";2121// Vitest runs in the package's folder, two below the repo root.22const repoRoot = Effect.map(Path.Path, (path) => path.resolve("..", ".."));2322const baseline: Baseline = {23 "@effect-diagnostics": 0,24 "@ts-expect-error": 0,25 "@ts-ignore": 0,
219 unmodified lines
245describe("the debt ledger rule", () => {246 // The fixture sits where the debt config ignores it, so the real count247 // never sees it. A copy outside the repo is linted with that same config.248 it.live(251 "reads every kind, and a reason only after ` -- ` on the directive's line",249 "reads every kind, a reason only after ` -- ` on the directive's line, and an escape no disable comment can hide",250 () =>251 Effect.gen(function* () {252 const fs = yield* FileSystem.FileSystem;253 const path = yield* Path.Path;
23 unmodified lines
277 const without = [278 at(4, "@ts-nocheck", "@ts-nocheck"),279 at(9, "oxlint-disable", "oxlint-disable-next-line no-console"),280 at(14, "@effect-diagnostics", effectDirective),283 at(19, "@ts-expect-error", "@ts-expect-error --"),281 at(19, "@ts-expect-error", "@ts-expect-error"),282 at(24, "@ts-ignore", "@ts-ignore"),283 at(36, "@ts-ignore", "@ts-ignore"),284 ];285286 expect(ledger).toStrictEqual([287 at(1, "@ts-nocheck", "@ts-nocheck", "a fixture, never typechecked"),
20 unmodified lines
308 ),309 without[3],310 at(22, "@ts-ignore", "@ts-ignore", "the fixture ignores it"),311 without[4],312 at(313 27,314 "oxlint-disable",315 "eslint-disable-next-line no-console",316 "oxlint honours eslint's name too"317 ),318 at(319 32,320 "@ts-ignore",321 "@ts-ignore",322 "a directive at a doc line's start still counts"323 ),324 at(34, "oxlint-disable", "oxlint-disable-line", "hides its own line"),325 at(326 35,327 "oxlint-disable",328 "oxlint-disable",329 "a file-wide disable hides nothing from the ledger"330 ),331 without[5],332 ]);333334 expect(335 judge(ledger, {336 "@effect-diagnostics": 2,337 "@ts-expect-error": 2,319 "@ts-ignore": 2,338 "@ts-ignore": 4,339 "@ts-nocheck": 2,321 "oxlint-disable": 2,340 "oxlint-disable": 5,341 })342 ).toStrictEqual(Verdict.Rose({ rises: [], unreasoned: without }));343 }).pipe(Effect.provide(NodeServices.layer))344 );
1 unmodified line
modified:packages/config/test/fence-wiring.test.ts+56 added-47 removed
12 unmodified lines
13 Tally,14} from "../../../scripts/lib/debt.ts";15import { drift, generate, Refusal } from "../../../scripts/lib/gen.ts";16import { findViolations } from "../../../scripts/lib/imports.ts";17import { repoRoot } from "./root.ts";1818// Vitest runs in the package's folder, two below the repo root.19const repoRoot = Effect.map(Path.Path, (path) => path.resolve("..", ".."));2019const readRootJson = <S extends Schema.Top>(file: string, schema: S) =>20 Effect.gen(function* () {21 const fs = yield* FileSystem.FileSystem;22 const path = yield* Path.Path;
6 unmodified lines
29const RootPackage = Schema.Struct({30 scripts: Schema.Struct({ verify: Schema.String }),31});3235/** What `fence/debt-ledger` reports as one diagnostic's message. */36const message = (directive: string, kind: string, reason?: string) =>37 JSON.stringify({ directive, kind, reason });33/**34 * What `fence/debt-ledger` reports as one diagnostic's message. The rule35 * reports at the file's first offset, so the escape's line is in the message.36 */37const message = (38 directive: string,39 kind: string,40 line: number,41 reason?: string42) => JSON.stringify({ column: 3, directive, kind, line, reason });4344const entry = (kind: Kind, line: number) => ({45 directive: kind,46 kind,
47 unmodified lines
94 expect(tally(ledger)).toStrictEqual(baseline);95 }).pipe(Effect.provide(NodeServices.layer))96 );9798 it.effect(99 "reads each directive, and its line, from oxlint's JSON report",93 it.effect("reads each directive from oxlint's JSON report", () =>94 Effect.gen(function* () {95 const report = JSON.stringify({96 diagnostics: [100 () =>101 Effect.gen(function* () {102 const report = JSON.stringify({103 diagnostics: [104 {105 code: "fence(debt-ledger)",106 filename: "packages/x/src/a.ts",107 labels: [{ span: { column: 1, length: 0, line: 1, offset: 0 } }],108 message: message(109 "oxlint-disable-next-line no-console",110 "oxlint-disable",111 12,112 "the CLI prints"113 ),114 severity: "error",115 },116 {117 code: "fence(debt-ledger)",118 filename: "packages/x/test/b.test.ts",119 labels: [{ span: { column: 1, length: 0, line: 1, offset: 0 } }],120 message: message("@ts-nocheck", "@ts-nocheck", 1),121 severity: "error",122 },123 ],124 number_of_files: 2,125 number_of_rules: 1,126 });127128 const ledger = yield* ledgerFromOxlintJson(report);129130 expect(ledger).toStrictEqual([131 {98 code: "fence(debt-ledger)",99 filename: "packages/x/src/a.ts",100 labels: [{ span: { column: 3, length: 0, line: 12, offset: 99 } }],101 message: message(102 "oxlint-disable-next-line no-console",103 "oxlint-disable",104 "the CLI prints"105 ),106 severity: "error",132 directive: "oxlint-disable-next-line no-console",133 kind: "oxlint-disable",134 line: 12,135 path: "packages/x/src/a.ts",136 reason: "the CLI prints",137 },138 {109 code: "fence(debt-ledger)",110 filename: "packages/x/test/b.test.ts",111 labels: [{ span: { column: 1, length: 0, line: 1, offset: 0 } }],112 message: message("@ts-nocheck", "@ts-nocheck"),113 severity: "error",139 directive: "@ts-nocheck",140 kind: "@ts-nocheck",141 line: 1,142 path: "packages/x/test/b.test.ts",143 },115 ],116 number_of_files: 2,117 number_of_rules: 1,118 });119120 const ledger = yield* ledgerFromOxlintJson(report);121122 expect(ledger).toStrictEqual([123 {124 directive: "oxlint-disable-next-line no-console",125 kind: "oxlint-disable",126 line: 12,127 path: "packages/x/src/a.ts",128 reason: "the CLI prints",129 },130 {131 directive: "@ts-nocheck",132 kind: "@ts-nocheck",133 line: 1,134 path: "packages/x/test/b.test.ts",135 },136 ]);137 })144 ]);145 })146 );147148 it.effect("refuses a report that is not oxlint's JSON", () =>149 Effect.gen(function* () {
47 unmodified lines
197 ];198199 expect(oxlintConfig.jsPlugins).toContainEqual(fence);200 expect(oxlintConfig.rules).toMatchObject({201 "fence/no-effect-sleep-in-project": "error",202 "fence/no-manual-effect-runtime-in-tests": "error",203 "fence/no-module-level-mutable-state": "error",204 });205 expect(enabled).not.toContain("fence/debt-ledger");
105 unmodified lines
modified:packages/config/test/oxlint-fence.test.ts+59 added-6 removed
1 unmodified line
2import { describe, expect, it } from "@effect/vitest";3import { Effect, FileSystem, Path, Random, Schema } from "effect";4import { ChildProcess, ChildProcessSpawner } from "effect/process";56import { noEffectSleepInProject } from "../../../tools/oxlint/fence/rules/no-effect-sleep-in-project.ts";7import { noManualEffectRuntimeInTests } from "../../../tools/oxlint/fence/rules/no-manual-effect-runtime-in-tests.ts";8import { noModuleLevelMutableState } from "../../../tools/oxlint/fence/rules/no-module-level-mutable-state.ts";9import { repoRoot } from "./root.ts";109// Vitest runs in the package's folder, two below the repo root.10const repoRoot = Effect.map(Path.Path, (path) => path.resolve("..", ".."));1111const fixtures = "tools/oxlint/fence/fixtures";1213const OxlintReport = Schema.Struct({14 diagnostics: Schema.Array(
15 unmodified lines
30 code.replace(/^(?<plugin>[^(]+)\((?<rule>[^)]+)\)$/u, "$<plugin>/$<rule>");3132/** Each message text the fence rules can report, mapped back to its id. */33const messageIds = new Map(35 [noManualEffectRuntimeInTests, noModuleLevelMutableState].flatMap((rule) =>34 [35 noEffectSleepInProject,36 noManualEffectRuntimeInTests,37 noModuleLevelMutableState,38 ].flatMap((rule) =>39 Object.entries(rule.meta?.messages ?? {}).map(([id, text]) => [text, id])40 )41);42
105 unmodified lines
148 }).pipe(Effect.provide(NodeServices.layer))149 );150});151152const sleepAt = (file: string, line: number) => ({153 file,154 line,155 messageId: "sleeps",156 ruleId: "fence/no-effect-sleep-in-project",157 severity: "error",158});159160describe("fence/no-effect-sleep-in-project", () => {161 it.live(162 "flags Effect.sleep and Effect.delay in packages/project/src, and nothing in its tests, other packages or other objects",163 () =>164 Effect.gen(function* () {165 const { files, findings } = yield* lint(166 `${fixtures}/oxlint.json`,167 fixtures,168 [169 "packages/project/src/bad-sleep.ts",170 "packages/project/src/good-sleep.ts",171 "packages/project/test/sleep.test.ts",172 "packages/demo/src/sleeps.ts",173 ]174 );175176 expect(files).toBe(4);177 expect(findings).toStrictEqual([178 sleepAt("packages/project/src/bad-sleep.ts", 2),179 sleepAt("packages/project/src/bad-sleep.ts", 2),180 sleepAt("packages/project/src/bad-sleep.ts", 4),181 sleepAt("packages/project/src/bad-sleep.ts", 5),182 sleepAt("packages/project/src/bad-sleep.ts", 6),183 ]);184 }).pipe(Effect.provide(NodeServices.layer))185 );186});187188describe("the fence messages", () => {150 it("say why module state is refused, and what a test runs Effects with", () => {189 it("say why module state is refused, what a test runs Effects with, and where a deadline goes", () => {190 expect(noModuleLevelMutableState.meta?.messages?.moduleState).toContain(191 "Worker isolate"192 );193 expect(noManualEffectRuntimeInTests.meta?.messages?.manualRunner).toMatch(194 /it\.effect\(.*it\.layer\(/u195 );196 expect(noEffectSleepInProject.meta?.messages?.sleeps).toContain(197 "Durable Object alarm"198 );199 });200});201202describe("the root lint config", () => {
18 unmodified lines
221 yield* Effect.acquireRelease(fs.makeDirectory(directory), () =>222 Effect.orDie(fs.remove(directory, { recursive: true }))223 );224225 // The sleep rule guards one package by name, so its copy keeps the226 // `packages/project/src/` shape inside the temporary package.227 const copies = [228 ["packages/demo/src/bad-state.ts", "src/state.ts"],229 ["packages/demo/test/bad-runtime.test.ts", "test/runtime.test.ts"],230 [231 "packages/project/src/bad-sleep.ts",232 "packages/project/src/sleep.ts",233 ],234 ] as const;235236 for (const [fixture, copy] of copies) {237 const target = path.join(directory, copy);
7 unmodified lines
245 workspace,246 copies.map(([, copy]) => copy)247 );248201 expect(files).toBe(2);249 expect(files).toBe(3);250 expect(findings).toStrictEqual([251 sleepAt("packages/project/src/sleep.ts", 2),252 sleepAt("packages/project/src/sleep.ts", 2),253 sleepAt("packages/project/src/sleep.ts", 4),254 sleepAt("packages/project/src/sleep.ts", 5),255 sleepAt("packages/project/src/sleep.ts", 6),256 moduleStateAt("src/state.ts", 3),257 moduleStateAt("src/state.ts", 6),258 manualRunnerAt("test/runtime.test.ts", 5),259 manualRunnerAt("test/runtime.test.ts", 9),
4 unmodified lines
added:packages/config/test/root.ts+6 added
modified:packages/config/test/vcs-policy.test.ts+87 added-4 removed
1import { NodeServices } from "@effect/platform-node";2import { describe, expect, it } from "@effect/vitest";3import { Effect, Path, Schema, Stream } from "effect";3import { Effect, FileSystem, Path, Schema, Stream } from "effect";4import { ChildProcess, ChildProcessSpawner } from "effect/process";56import vcsPolicy from "../../../.pi/extensions/vcs-policy/index.ts";7import type { PiApi } from "../../../.pi/extensions/vcs-policy/index.ts";8import {9 Decision,10 decide,11 reasons,12} from "../../../scripts/hooks/lib/policy.ts";13import type { Rule } from "../../../scripts/hooks/lib/policy.ts";14import { repoRoot } from "./root.ts";1516/** What a row expects: the command runs, or the rule that refuses it. */17type Verdict = "Allow" | Rule;18
282 unmodified lines
301 expect(decide("git status")).toStrictEqual(Decision.Allow());302 });303});304302// Vitest runs in the package's folder, two below the repo root.303const repoRoot = Effect.map(Path.Path, (path) => path.resolve("..", ".."));304305interface Ran {306 readonly exitCode: number;307 readonly stdout: string;308 readonly stderr: string;
123 unmodified lines
432 }433 })434 );435});436437/**438 * Calls the pi extension's `tool_call` handler as pi would, through a439 * stand-in for pi's API, and returns what the handler answers.440 */441const piToolCall = (442 toolName: string,443 input: Readonly<Record<string, string>>444) => {445 const handlers: Parameters<PiApi["on"]>[1][] = [];446447 vcsPolicy({ on: (_event, handler) => handlers.push(handler) });448449 return handlers.map((handler) => handler({ input, toolName }));450};451452const CLOSED_READ =453 "vcs-policy refused this read (closed-env-read): Never read .env, .env.local or .env.*.local, even in a recursive search (rg and git grep skip them); run bun run env:check.";454455describe("pi's own file tools", () => {456 it("block a read, an edit or a grep of a closed env file", () => {457 for (const [tool, input] of [458 ["read", { path: ".env" }],459 ["read", { path: "infra/.env.local" }],460 ["read", { path: "/repo/apps/platform/.env.production.local" }],461 ["edit", { path: "infra/.env.local" }],462 ["grep", { path: ".env", pattern: "TOKEN" }],463 ] as const) {464 expect(piToolCall(tool, input)).toStrictEqual([465 { block: true, reason: CLOSED_READ },466 ]);467 }468 });469470 it("pass the schema, other files, and tools that name no closed file", () => {471 for (const [tool, input] of [472 ["read", { path: ".env.schema" }],473 ["read", { path: "apps/platform/.env.schema" }],474 ["read", { path: "AGENTS.md" }],475 ["grep", { pattern: "TOKEN" }],476 ["ls", { path: "infra" }],477 ] as const) {478 expect(piToolCall(tool, input)).toStrictEqual([undefined]);479 }480 });481482 it("still judge pi's bash tool by the policy", () => {483 expect(piToolCall("bash", { command: "git push" })).toStrictEqual([484 {485 block: true,486 reason: `vcs-policy refused this command (push): ${PUSH}`,487 },488 ]);489 });490});491492const ClaudeSettings = Schema.fromJsonString(493 Schema.Struct({494 permissions: Schema.optionalKey(495 Schema.Struct({ deny: Schema.Array(Schema.String) })496 ),497 })498);499500describe("Claude Code's own file tools", () => {501 it.live("are denied the closed env files by the project settings", () =>502 Effect.gen(function* () {503 const fs = yield* FileSystem.FileSystem;504 const path = yield* Path.Path;505 const root = yield* repoRoot;506507 const settings = yield* fs508 .readFileString(path.join(root, ".claude/settings.json"))509 .pipe(Effect.flatMap(Schema.decodeEffect(ClaudeSettings)));510511 expect(settings.permissions?.deny).toStrictEqual([512 "Read(**/.env)",513 "Read(**/.env.local)",514 "Read(**/.env.*.local)",515 ]);516 }).pipe(Effect.provide(NodeServices.layer))517 );518});
modified:scripts/hooks/lib/policy.ts+7 added
319 unmodified lines
320321const isClosedName = (name: string) =>322 name === ".env" || name === ".env.local" || /^\.env\..+\.local$/u.test(name);323324/**325 * Whether a harness's own file tool (pi's `read`, say) would open a closed env326 * file at `path`. The shell rule above judges commands; this one judges a path.327 */328export const isClosedEnvPath = (path: string) =>329 isClosedName(basename(path.replace(/\/+$/u, "")));330331const GLOB = /[*?[]/u;332333const REGEXP_SPECIAL = /[$()*+.?[\\\]^{|}]/u;334
468 unmodified lines
modified:scripts/lib/debt.ts+6 added-6 removed
61 unmodified lines
62 "--format",63 "json",64];6566// The rule's message is itself JSON: `{directive, kind, reason?}`.66// The rule's message is itself JSON: `{directive, kind, line, reason?}`. The67// rule reports every escape at the file's first offset, where no disable68// comment can hide it, so the escape's own line travels in the message.69const Directive = Schema.Struct({70 directive: Schema.String,71 kind: Kind,72 line: Schema.Int,73 reason: Schema.optionalKey(Schema.String),74});7576const OxlintReport = Schema.Struct({77 diagnostics: Schema.Array(78 Schema.Struct({79 filename: Schema.String,77 labels: Schema.NonEmptyArray(78 Schema.Struct({ span: Schema.Struct({ line: Schema.Int }) })79 ),80 message: Schema.fromJsonString(Directive),81 })82 ),83});
10 unmodified lines
94): Effect.Effect<readonly LedgerEntry[], Schema.SchemaError> =>95 Schema.decodeEffect(Schema.fromJsonString(OxlintReport))(json).pipe(96 Effect.map(({ diagnostics }) =>97 diagnostics98 .map(({ filename, labels, message }) => {98 .map(({ filename, message }) => {99 const entry = {100 directive: message.directive,101 kind: message.kind,102 line: labels[0].span.line,102 line: message.line,103 path: filename,104 };105106 return message.reason === undefined
143 unmodified lines
modified:tools/oxlint/fence/fixtures/debt/escapes.ts+14 added-2 removed
1// @ts-nocheck -- a fixture, never typechecked2// The debt count's fixture: every kind of escape, first with a reason after3// " -- ", then without one. packages/config/test/debt.test.ts asserts each line.2// The debt count's fixture: each kind with a reason after " -- " and without,3// then each way around the ledger. debt.test.ts asserts every line it counts.4/* @ts-nocheck */56// oxlint-disable-next-line no-console -- the fixture prints7console.log("reasoned");
14 unmodified lines
22// @ts-ignore -- the fixture ignores it23const ignored: number = "c";24// @ts-ignore25const ignoredWithout: number = "d";2627// eslint-disable-next-line no-console -- oxlint honours eslint's name too28console.log("eslint");29// Prose that names @ts-ignore or oxlint-disable mid-sentence is no escape.30/**31 * Nor is a doc line that mentions @ts-nocheck after other words.32 * @ts-ignore -- a directive at a doc line's start still counts33 */34const sameLine = 1; // oxlint-disable-line -- hides its own line35/* oxlint-disable -- a file-wide disable hides nothing from the ledger */36// @ts-ignore37const hidden: number = "e";
added:tools/oxlint/fence/fixtures/packages/demo/src/sleeps.ts+4 added
1import { Effect } from "effect";23// Outside packages/project, sleeping is someone else's business.4export const waits = Effect.sleep("1 second");
added:tools/oxlint/fence/fixtures/packages/project/src/bad-sleep.ts+7 added
1import { Effect } from "effect";2import { delay, sleep } from "effect/Effect";34export const waits = Effect.sleep("1 second");5export const later = Effect.succeed(1).pipe(Effect.delay("1 second"));6export const bracketed = Effect["sleep"]("1 second");7export const named = [delay, sleep];
added:tools/oxlint/fence/fixtures/packages/project/src/good-sleep.ts+11 added
1import { Clock, Effect } from "effect";23// A lifecycle hands back its deadline as data; the Durable Object sets the4// alarm. Reading the clock is fine: waiting on it is not.5export const deadline = Effect.map(Clock.currentTimeMillis, (now) => ({6 alarmAt: now + 60_000,7}));89const Sleepy = { sleep: () => "a property of something else" };1011export const other = Sleepy.sleep();
added:tools/oxlint/fence/fixtures/packages/project/test/sleep.test.ts+5 added
1import { it } from "@effect/vitest";2import { Effect } from "effect";34// Tests may wait: the rule guards the package's runtime source only.5it.effect("waits", () => Effect.sleep("1 second"));
modified:tools/oxlint/fence/fixtures/oxlint.json+1 added
8 unmodified lines
9 "suspicious": "off"10 },11 "jsPlugins": [{ "name": "fence", "specifier": "../index.ts" }],12 "rules": {13 "fence/no-effect-sleep-in-project": "error",14 "fence/no-manual-effect-runtime-in-tests": "error",15 "fence/no-module-level-mutable-state": "error"16 }17}
modified:tools/oxlint/fence/rules/debt-ledger.ts+61 added-20 removed
8 unmodified lines
9 | "@ts-expect-error"10 | "@ts-ignore"11 | "@ts-nocheck";1213/**14 * Each kind's directive. oxlint, eslint and tsc read a directive only where a15 * comment's line starts, so prose that names one mid-sentence is no escape.16 * The Effect language service reads its directive anywhere, so that one17 * counts anywhere in a comment.18 */19const debtPatterns = [14 { kind: "oxlint-disable", pattern: /\boxlint-disable(?:-[a-z-]+)?\b/gu },20 {21 anywhere: false,22 kind: "oxlint-disable",23 // oxlint honours eslint's spelling of its directives too.24 pattern: /\b(?:oxlint|eslint)-disable(?:-[a-z-]+)?\b/gu,25 },26 {27 anywhere: true,28 kind: "@effect-diagnostics",29 pattern: /@effect-diagnostics(?:-next-line)?\b/gu,30 },19 { kind: "@ts-expect-error", pattern: /@ts-expect-error\b/gu },20 { kind: "@ts-ignore", pattern: /@ts-ignore\b/gu },21 { kind: "@ts-nocheck", pattern: /@ts-nocheck\b/gu },31 {32 anywhere: false,33 kind: "@ts-expect-error",34 pattern: /@ts-expect-error\b/gu,35 },36 { anywhere: false, kind: "@ts-ignore", pattern: /@ts-ignore\b/gu },37 { anywhere: false, kind: "@ts-nocheck", pattern: /@ts-nocheck\b/gu },38] as const satisfies readonly {39 readonly anywhere: boolean;40 readonly kind: DebtKind;41 readonly pattern: RegExp;42}[];4344/** What may come before a directive on a comment's line: space, `*` and `/`. */45const LINE_LEAD = /^[\s*/]*$/u;4647/** The ` -- ` that starts a reason, or a bare ` --` at the line's end. */48const REASON_MARK = /\s--(?=\s|$)/u;4950/**51 * Reports every escape directive in a comment, once, as JSON:29 * `{directive, kind, reason?}`. The reason is the text after ` -- `.52 * `{column, directive, kind, line, reason?}`. The reason is the text after53 * ` -- ` on the directive's own line.54 *55 * Each report sits at the file's first offset and carries its real line in56 * the message. No disable comment covers offset 0 (oxlint 1.87, held by the57 * fixture in `packages/config/test/debt.test.ts`), so a file-wide58 * `oxlint-disable` or an `oxlint-disable-line` can't hide an escape from the59 * count.60 */61export const debtLedger = defineRule({62 create(context) {63 return {
2 unmodified lines
66 if (comment.type === "Shebang") {67 continue;68 }6940 for (const { kind, pattern } of debtPatterns) {70 for (const { anywhere, kind, pattern } of debtPatterns) {71 for (const match of comment.value.matchAll(pattern)) {72 const index = match.index ?? 0;73 const lineStart = comment.value.lastIndexOf("\n", index) + 1;7444 const line = comment.value45 .slice(index)46 .split(/\r?\n/u, 1)[0]47 ?.replace(/^\*+\s*/u, "")48 .trim();4950 if (line === undefined) {75 if (76 !anywhere &&77 !LINE_LEAD.test(comment.value.slice(lineStart, index))78 ) {79 continue;80 }8154 const reason = /\s--\s*(?<reason>.*)$/u55 .exec(line)56 ?.groups?.reason?.trim();82 const text =83 comment.value.slice(index).split(/\r?\n/u, 1)[0]?.trimEnd() ??84 "";8558 const directive = line.split(" -- ", 1)[0]?.trim() ?? line;86 const mark = REASON_MARK.exec(text);8788 const directive = (89 mark === null ? text : text.slice(0, mark.index)90 ).trim();9192 const reason =93 mark === null94 ? ""95 : text.slice(mark.index + mark[0].length).trim();9697 const { column, line } = context.sourceCode.getLocFromIndex(98 comment.start + 2 + index99 );100101 context.report({61 loc: context.sourceCode.getLocFromIndex(62 comment.start + 2 + index63 ),102 loc: context.sourceCode.getLocFromIndex(0),103 message: JSON.stringify({104 column,105 directive,106 kind,107 line,108 reason: reason === "" ? undefined : reason,109 }),110 });111 }
13 unmodified lines
added:tools/oxlint/fence/rules/no-effect-sleep-in-project.ts+82 added
1import { defineRule } from "@oxlint/plugins";2import type { ESTree } from "@oxlint/plugins";34import { workspacePath } from "./no-module-level-mutable-state.ts";56/** Effect's two ways to wait on the clock in-process. */7const WAITS: ReadonlySet<string> = new Set(["delay", "sleep"]);89/** `packages/project`'s runtime source: the lifecycles and their service. */10const isProjectSource = (path: string) =>11 /^packages\/project\/src\/./u.test(path);1213/** Whether a member access reads a wait: `x.sleep` or `x["sleep"]`. */14const readsWait = (node: ESTree.MemberExpression) => {15 const { property } = node;1617 if (!node.computed && property.type === "Identifier") {18 return WAITS.has(property.name);19 }2021 return (22 property.type === "Literal" &&23 [...WAITS].some((wait) => wait === property.value)24 );25};2627/** The name an import specifier takes from its module. */28const importedName = (node: ESTree.ImportSpecifier) =>29 node.imported.type === "Identifier"30 ? node.imported.name31 : node.imported.value;3233/**34 * Refuses `Effect.sleep` and `Effect.delay` in `packages/project/src`. A35 * lifecycle is a pure transition, and a deadline is a Durable Object alarm set36 * from what the transition returns, so a replay converges and nothing waits37 * inside a request (AGENTS.md principle 12).38 */39export const noEffectSleepInProject = defineRule({40 create(context) {41 if (!isProjectSource(workspacePath(context.filename, context.cwd))) {42 return {};43 }4445 return {46 ImportDeclaration(node) {47 if (node.source.value !== "effect/Effect") {48 return;49 }5051 for (const specifier of node.specifiers) {52 if (53 specifier.type === "ImportSpecifier" &&54 WAITS.has(importedName(specifier))55 ) {56 context.report({ messageId: "sleeps", node: specifier });57 }58 }59 },60 MemberExpression(node) {61 if (62 node.object.type === "Identifier" &&63 node.object.name === "Effect" &&64 readsWait(node)65 ) {66 context.report({ messageId: "sleeps", node });67 }68 },69 };70 },71 meta: {72 docs: {73 description:74 "Keep Effect.sleep and Effect.delay out of packages/project: deadlines are Durable Object alarms.",75 },76 messages: {77 sleeps:78 "packages/project never waits in-process. Return the deadline from the lifecycle's transition and let the Durable Object alarm fire it (AGENTS.md principle 12).",79 },80 type: "problem",81 },82});
modified:tools/oxlint/fence/rules/no-module-level-mutable-state.ts+1 added-1 removed
9 unmodified lines
10 * layout anywhere (a lint fixture, a temporary tree) counts the same. The path11 * is made relative to oxlint's working directory first, so the folders above12 * the one oxlint runs from never match.13 */14const workspacePath = (filename: string, cwd: string) => {14export const workspacePath = (filename: string, cwd: string) => {15 const slashed = filename.replaceAll("\\", "/");16 const root = `${cwd.replaceAll("\\", "/")}/`;1718 const relative = slashed.startsWith(root)
80 unmodified lines
modified:tools/oxlint/fence/index.ts+2 added
4 unmodified lines
5 */6import { definePlugin } from "@oxlint/plugins";78import { debtLedger } from "./rules/debt-ledger.ts";9import { noEffectSleepInProject } from "./rules/no-effect-sleep-in-project.ts";10import { noManualEffectRuntimeInTests } from "./rules/no-manual-effect-runtime-in-tests.ts";11import { noModuleLevelMutableState } from "./rules/no-module-level-mutable-state.ts";1213export default definePlugin({14 meta: { name: "fence" },15 rules: {16 "debt-ledger": debtLedger,17 "no-effect-sleep-in-project": noEffectSleepInProject,18 "no-manual-effect-runtime-in-tests": noManualEffectRuntimeInTests,19 "no-module-level-mutable-state": noModuleLevelMutableState,20 },21});
modified:tools/oxlint/fence/UPSTREAM.md+3 added-2 removed
1# The fence plugin's upstreams23The `fence` plugin holds the repo's own lint rules. Three are ports; each file keeps a header naming its source. They are ours to change, and upstream is never synced in. Licence texts are in `LICENSES/`.3The `fence` plugin holds the repo's own lint rules. Three are ports; each file keeps a header naming its source. The fourth, `no-effect-sleep-in-project` (AGENTS.md principle 12), is ours and has no upstream. They are ours to change, and upstream is never synced in. Licence texts are in `LICENSES/`.45| Rule | Upstream | Commit | Licence |6| --- | --- | --- | --- |7| `no-module-level-mutable-state` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/oxlint-plugin-patterns.ts` l.28–43 (`workspacePath`, `isRuntimeSource`) and l.621–677 (`isModuleScopedVar` and the rule) | `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` |
6 unmodified lines
1415- Only this rule is ported from `oxlint-plugin-patterns.ts`. Its other rules (`acquire-release-constructs-in-acquire-body`, `contract-binding-matches-name`, `watch-effect-actors`) are not, by the AGENTS.md rejections.16- A named export registered in the `fence` plugin, not upstream's `rat-stack-patterns` plugin.17- `workspacePath` reads the path string alone. Upstream made the path relative to a repo root it found from its own location (`import.meta.dirname` and `node:path`, under a `nodeBuiltinImport` escape). Ours strips oxlint's working directory (`context.cwd`) by string, then finds the whole `(apps|packages)/<name>/src/` shape anywhere in what is left. A copy of that layout anywhere (the fixtures under `fixtures/packages/`, a temporary tree) counts as runtime source, and a folder named `apps` or `packages` above the checkout does not. No `node:path` import, so no escape.18- `workspacePath` is exported, so `no-effect-sleep-in-project` finds a file's workspace the same way.19- `isRuntimeSource` drops upstream's `.svelte` exclusion: this repo has no Svelte.20- A `declare let` or `declare var` is skipped: it is ambient and holds no state.21- Kept as upstream wrote them: the `let` check by scope (`module` or `global`), `isModuleScopedVar` for a hoisted `var`, the `moduleState` message id and its text, and the rule's description.22
9 unmodified lines
32See its row in `PROVENANCE.md` (issue 101).3334## Tests3535`packages/config/test/oxlint-fence.test.ts` runs the real oxlint binary over `fixtures/` with `fixtures/oxlint.json` (the fence plugin, both rules at error, every category off) and checks each rule's `{ruleId, line, messageId}` on a bad fixture and silence on a good one: an ambient `declare let`, a `var` that hoists only to its function, and an Effect run by hand in `src/`. It also lints a temporary copy of the bad fixtures with the root `oxlint.config.ts`, laid out as a package of its own (`packages/oxlint-fence-<id>.log/{src,test}`, gitignored), so a config change that switches a rule off for the files it guards fails the test, through an anchored glob such as `packages/*/src/**` too. Root lint, format and typecheck ignore `fixtures/`, so each fixture keeps the faults its test points at.36`packages/config/test/oxlint-fence.test.ts` runs the real oxlint binary over `fixtures/` with `fixtures/oxlint.json` (the fence plugin, its three lint rules at error, every category off) and checks each rule's `{ruleId, line, messageId}` on a bad fixture and silence on a good one: an ambient `declare let`, a `var` that hoists only to its function, an Effect run by hand in `src/`, and `Effect.sleep` in a test or in another package. It also lints a temporary copy of the bad fixtures with the root `oxlint.config.ts`, laid out as a package of its own (`packages/oxlint-fence-<id>.log/{src,test}`, gitignored, with the sleep fixture under `packages/project/src/` inside it), so a config change that switches a rule off for the files it guards fails the test, through an anchored glob such as `packages/*/src/**` too. Root lint, format and typecheck ignore `fixtures/`, so each fixture keeps the faults its test points at.
modified:AGENTS.md+5 added-4 removed
20 unmodified lines
21| # | Principle | Held by |22| --- | --- | --- |23| 1 | **Encode lessons in structure; prose is the last rung.** When a mistake repeats, make it unrepresentable, then a lint or test, then a skill. | `packages/config/test/agents-table.test.ts`: every enforcer this column names exists and is on |24| 2 | **Parse at the boundary, trust inside.** Decode every external input (HTTP, git, DO RPC, WebSocket, rule facts, env) with Effect Schema; inside, use branded types (`AskId`, `LandedSha`, `PatchId`). Decode the Worker `env` once, in one Layer. | The Effect diagnostics at error in `tsconfig.base.json`; `anti-slop/no-unknown-parameters`, `anti-slop/no-widen-then-assert` and `anti-slop/require-safety-comment-for-type-assertion`; the generated `apps/platform/worker-configuration.d.ts` types the env, and `apps/platform/test/platform.test.ts` proves a bad env fails at start. No fence yet: the decoded bindings equal `wrangler.jsonc`'s, with no `as` on `env` (`apps/platform/test/bindings.test.ts`, W3 317) |25| 3 | **Refusals are a closed `Schema.TaggedError` union and a public contract.** Handle them with `Match.exhaustive` or `catchTags`. Each carries a static `retryable`, a `next` command and an optional `at`, and no `message` field. A `_tag` is renamed only with an alias. `protocol/render` is the one renderer for git `remote:`, CLI and MCP text. Stage-1 refusals accumulate. | `packages/protocol/test/refusal.test.ts` (the tag list is closed; each refusal reaches MCP as JSON with retryable and next); `packages/protocol/test/render.test.ts`; `packages/protocol/test/mcp.test.ts` (a refusal from tools/call keeps its tag); `gen:check` on `docs/reference/refusals.md`; `anti-slop-effect/prefer-effect-match` and `anti-slop-effect/no-manual-tag-comparison`. No fence yet: the gate's stage-1 test that every refusal accumulates (W2 206); a `tools/call` test per refusing contract (W4 408) |25| 3 | **Refusals are a closed `Schema.TaggedError` union and a public contract.** Handle them with `Match.exhaustive` or `catchTags`. Each carries a `retryable` and a `next` command fixed per tag, an optional `at`, and no `message` field. A `_tag` is renamed only with an alias. `protocol/render` is the one renderer for git `remote:`, CLI and MCP text. Stage-1 refusals accumulate. | `packages/protocol/test/refusal.test.ts` (the tag list is closed; each refusal reaches MCP as JSON with retryable and next); `packages/protocol/test/render.test.ts`; `packages/protocol/test/mcp.test.ts` (a refusal from tools/call keeps its tag); `gen:check` on `docs/reference/refusals.md`; `anti-slop-effect/prefer-effect-match` and `anti-slop-effect/no-manual-tag-comparison`. No fence yet: the gate's stage-1 test that every refusal accumulates (W2 206); a `tools/call` test per refusing contract (W4 408) |26| 4 | **One schema, many surfaces.** Change `packages/protocol`, then run `bun run gen`. `skills/`, `plugins/` and `docs/reference/` are generated. Projections live only in `apps/*/src/surfaces.ts`. | `gen:check` (`scripts/gen.ts`, tested by `packages/config/test/gen.test.ts`) fails on a stale, missing or hand-written generated file; per-package `allowedUnstableApis` with `unstableApiUsage` at error keep Rpc and Tool construction in protocol and the apps |27| 5 | **The name lives only in `packages/brand`.** Internal packages use `@repo/*`. DO classes, Workflows, queues and databases carry job names. | `brand:check` (`scripts/brand.ts`, tested by `packages/brand/test/leaks.test.ts`) in `verify`. No fence yet: `scripts/acceptance.ts` renames the brand at random on a cold clone and runs `verify` (W7 714) |28| 6 | **Pure core, thin hosts.** Only `@repo/artifacts` calls Artifacts. Each beta dependency sits behind one job-named port with a `/memory` adapter in the owning package. Apps import packages only. Worker code stays free of `node:child_process`, `@effect/platform-bun` and OpenTUI. `rules` and `gate` run in both Workers and Bun. `alchemy/*` stays in `infra/`. | `imports:check` (`scripts/imports.ts`, tested by `packages/config/test/imports.test.ts`): the package matrix, apps never importing apps, host-free Worker code, adapters only through their subpaths, alchemy only in infra; scoped `allowedUnstableApis`; `fence/no-module-level-mutable-state`. No fence yet: Artifacts and each other beta dependency behind one port with a `/memory` adapter, composed from the decoded env (W2 202; W3 317 `apps/platform/src/ports.ts`) |29| 7 | **Deny by default for visibility.** Land the answer's tree, never the composed tree. Nothing from a layer enters a public tree. Snapshot before held-back files are written. Public-serving Workers have no private-namespace binding. Public commits, trailers, notes and errors name public paths only. | `PrivatePathInPublicTree` in the closed refusal union. No fence yet: the stage-1 path checks that raise it (W2 206 gate, W6 606 gateway); the web `Env` type test, no `ARTIFACTS_PRIVATE` (W5 501 `apps/web/test/env.test-d.ts`); the snapshot-order test (W3 315, W6 605) |30| 8 | **Deterministic and idempotent.** Rule evaluation sees frozen time and randomness and only injected facts. Re-running an operation converges. Check results are keyed by (tree SHA, check version), push events deduped by (repo, sha), and land requests carry a `requestId`. | `globalDate`, `globalRandom`, `globalTimers` and `cryptoRandomUUID` at error, with their in-Effect twins. No fence yet: the rules replay-twice test (W2 204); dedupe by `requestId` and event id (W2 210, W3 313); the Answer Workflow's replay test (W3 304); lifecycle model tests (W2 209, 219) |31| 9 | **Effect v4 only.** Read `node_modules/effect/src` as API truth. Off limits: `effect/unstable/*`, v3 `@effect/platform` and `@effect/cli`, and `effect/workflow` or `effect/cluster` on Workers. | `outdatedApi`; `no-restricted-imports`; `fence/no-manual-effect-runtime-in-tests` |31| 9 | **Effect v4 only.** Read `node_modules/effect/src`, or `.agent_sources/effect` (see Commands), as API truth. Off limits: `effect/unstable/*`, v3 `@effect/platform` and `@effect/cli`, and `effect/workflow` or `effect/cluster` on Workers. | `outdatedApi`; `no-restricted-imports`; `fence/no-manual-effect-runtime-in-tests` |32| 10 | **Escapes need a reason and only shrink.** Every `oxlint-disable`, `@effect-diagnostics` or `@ts-expect-error` carries a reason after `--` and is counted. The count rises only with sign-off. | `debt` (`scripts/debt.ts` over `oxlint.debt.config.ts`, tested by `packages/config/test/debt.test.ts`) against `debt.baseline.json` in `verify`; `check` fails on an unused directive |33| 11 | **Hooks are early feedback; `bun run verify` and CI are the authority.** Deploy only to an explicit stage, after `verify`, with smoke after. A red gate is fixed, never deployed around. | `scripts/hooks/vcs-policy.ts`, wired into Claude Code (`.claude/settings.json`), Cursor (`.cursor/hooks.json`) and pi (`.pi/extensions/vcs-policy/`), refusing every bypass variant in `packages/config/test/vcs-policy.test.ts`; `verify`. No fence yet: `infra/deploy.ts` refuses without a stage and runs `scripts/smoke.ts` (W3 308); `scripts/acceptance.ts` runs `verify` on a cold install in place of CI (W7 714) |34| 12 | **Lifecycles are pure transitions.** `transition(state, command, now)`. Per DO call: hydrate, transition, persist, settle. Deadlines run on DO alarms. Call them lifecycles. | `globalTimers` and `globalTimersInEffect` refuse JavaScript timers outside and inside Effect. No fence yet: lifecycle model tests over `effect/Arbitrary` histories with one planted bug (W2 209, 219); a lint banning `Effect.sleep` in `packages/project` (no wave yet) |34| 12 | **Lifecycles are pure transitions.** `transition(state, command, now)`. Per DO call: hydrate, transition, persist, settle. Deadlines run on DO alarms. Call them lifecycles. | `globalTimers` and `globalTimersInEffect` refuse JavaScript timers outside and inside Effect; `fence/no-effect-sleep-in-project` refuses Effect.sleep and Effect.delay in the project package's source. No fence yet: lifecycle model tests over `effect/Arbitrary` histories with one planted bug (W2 209, 219) |3536## Fence3738`bun run verify` is the gate (see Commands). Run it before you stop. When a hook or check fails, fix the cause. Loosening, skipping or disabling a check needs the user's sign-off.
61 unmodified lines
100- **Ported code is ours.** Change ported files freely and record each change in `PROVENANCE.md`. Upstream `main` is never synced in. Borrowed code stays under 15% of the codebase (aim for about 5%).101102## Effect traps103104- Wire schemas in `protocol` use `Schema.Int` or `Schema.Finite` in place of bare `Schema.Number`, and `Schema.optionalKey` in place of `Schema.optional`. The bare forms put `"Infinity"` strings and `null` into JSON Schema and MCP tool schemas.104- Wire schemas in `protocol` use `Schema.Int` or `Schema.Finite` in place of bare `Schema.Number`, and `Schema.optionalKey` in place of `Schema.optional`. The bare forms put `"Infinity"` strings and `null` into JSON Schema and MCP tool schemas, which `packages/config/test/gen.test.ts` refuses.105- The Effect language service reads an `@effect-diagnostics` directive anywhere in the source, string literals included, and a directive there fails `typecheck` (TS377000, "has no effect"). A test that needs the directive as data joins the string at run time.106- Promises and web streams enter Effect through `Effect.tryPromise` and `Stream.fromReadableStream`/`toReadableStream`; the `asyncFunction` diagnostic bans `async`.107- Tests that spawn processes or open sockets use `it.live`; `it.effect` runs on the TestClock.108- `McpServer.layerStdio` interrupts the fiber that started it when stdin ends; in tests, fork the server and await it.109- The RPC HTTP client carries Rpc headers inside the body, so send a credential as a plain HTTP header.
44 unmodified lines
modified:oxlint.config.ts+2 added
96 unmodified lines
97 "anti-slop/no-unsafe-dictionary-type": "error",98 "anti-slop/no-widen-then-assert": "error",99 "anti-slop/require-readable-spacing": "error",100 "anti-slop/require-safety-comment-for-type-assertion": "error",101 // The rule guards packages/project/src only (AGENTS.md principle 12).102 "fence/no-effect-sleep-in-project": "error",103 "fence/no-manual-effect-runtime-in-tests": "error",104 "fence/no-module-level-mutable-state": "error",105 // Effect: `Effect.gen(function* () {…})`; `Effect.fn("name")` names spans.106 "func-names": ["error", "always", { generators: "never" }],
38 unmodified lines
modified:PROVENANCE.md+8 added-2 removed
6 unmodified lines
7| Our file | Origin | Licence | Our changes |8| --- | --- | --- | --- |9| `tools/oxlint/anti-slop/` | [dmmulroy/anti-slop](https://github.com/dmmulroy/anti-slop) at `c44ef22` | MIT, `LICENSES/anti-slop.MIT.txt` | None; vendored by its own install script. See `UPSTREAM.md` there. |10| `packages/protocol/src/cli.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `packages/capability/src/to-command.ts` l.14–247 at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Projects an `Rpc` whose payload is a struct, not a capability, and calls it through an `RpcClient`. `--json` is always offered. A refusal prints `protocol/render`'s text on stderr, or its encoded JSON on stdout with `--json`, and the command fails with it. String flags check their value with the field's schema, so the parser refuses a malformed value by its flag. The description comes from the `Description` annotation. Dropped: `--yes` and approval, the reserved-field guards, and the `as never` casts. |11| `packages/protocol/src/mcp.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `packages/capability/src/to-toolkit.ts` l.18–146 at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Projects an `RpcGroup`'s Rpcs, not capabilities: the payload, success and error schemas become the tool's. Handlers call each Rpc through an `RpcClient`, passing the payload alone. The description comes from the `Description` annotation. Dropped: the empty-input dynamic tool, approval, the hint annotations and the file-wide diagnostics escape. |12| `tools/oxlint/fence/rules/debt-ledger.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/oxlint-plugin-debt-ledger.ts` at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Five kinds, one per `debt.baseline.json` key: the TypeScript kind is split by directive into `@ts-expect-error`, `@ts-ignore` and `@ts-nocheck`. A named export, registered in the `fence` plugin rather than its own, and run only through `oxlint.debt.config.ts`. The JSON message `{directive, kind, reason?}` and the reason after ` -- ` are upstream's. |11| `packages/protocol/src/mcp.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `packages/capability/src/to-toolkit.ts` l.18–146 at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Projects an `RpcGroup`'s Rpcs, not capabilities: the payload, success and error schemas become the tool's. Handlers call each Rpc through an `RpcClient`, passing the payload alone. The description comes from the `Description` annotation. Hint annotations restored from our own `ReadOnly`, `Idempotent` and `Destructive` annotations, with `OpenWorld` false; a `NeedsApproval` contract's description gains "Asks a person first." Added `listTools`, the tools as `tools/list` shows them, and `toJsonSchema`, which derives a schema the way `McpServer` does (top-level `$ref` inlined, definitions under `$defs`). Dropped: the empty-input dynamic tool, upstream's approval flow and the file-wide diagnostics escape. |12| `tools/oxlint/fence/rules/debt-ledger.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/oxlint-plugin-debt-ledger.ts` at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Five kinds, one per `debt.baseline.json` key: the TypeScript kind is split by directive into `@ts-expect-error`, `@ts-ignore` and `@ts-nocheck`. A named export, registered in the `fence` plugin rather than its own, and run only through `oxlint.debt.config.ts`. `eslint-disable` directives count as `oxlint-disable`, since oxlint honours them. A directive counts only where a comment's line starts, as oxlint, eslint and tsc read it, except `@effect-diagnostics`, which the Effect language service reads anywhere. Every report sits at the file's first offset, where no disable comment can hide it, and carries its line (and column) in the message. An empty reason (`-- ` with nothing after) leaves the directive text without the ` --`. The JSON message `{directive, kind, reason?}` and the reason after ` -- ` are upstream's. |13| `tools/oxlint/fence/rules/no-module-level-mutable-state.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/oxlint-plugin-patterns.ts` l.28–43 and l.621–677 at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Only this rule is ported from that file. A named export in the `fence` plugin. `workspacePath` reads the path string alone: it strips oxlint's `cwd`, then finds the whole `(apps\|packages)/<name>/src/` shape anywhere, so a fixture tree counts and folders above the checkout don't; no `node:path` import and no `nodeBuiltinImport` escape. `workspacePath` is exported, for `no-effect-sleep-in-project`. The `.svelte` exclusion is dropped, and `declare let`/`declare var` is skipped. The scope check, `isModuleScopedVar`, the `moduleState` message and the description are upstream's. See `tools/oxlint/fence/UPSTREAM.md`. |14| `tools/oxlint/fence/rules/no-manual-effect-runtime-in-tests.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/oxlint-plugin-effect-tests.ts` at `fba26d8`, adapted there from [pingdotgg/t3code](https://github.com/pingdotgg/t3code) `oxlint-plugin-t3code/rules/no-manual-effect-runtime-in-tests.ts` (Rat Stack names no commit; licence copied at `05d4042`) | MIT, `LICENSES/rat-stack.MIT.txt` and `LICENSES/t3code.MIT.txt` | A named export in the `fence` plugin. `manualRunnerName` (a string nobody read) became the boolean `isManualRunner`. The test-file pattern, the twelve `Effect.run*` methods plus `ManagedRuntime.make`, the `manualRunner` message and the description are Rat Stack's. t3code's later `maxOccurrences` ceiling and `Option` unwrapping are not ported. See `tools/oxlint/fence/UPSTREAM.md`. |15| `scripts/hooks/lib/policy.ts`, `scripts/hooks/vcs-policy.ts`, `.claude/settings.json`, `.cursor/hooks.json`, `.pi/extensions/vcs-policy/index.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/vcs-command-policy.js`, `scripts/hooks/block-git-no-verify.mjs`, `.claude/settings.json`, `.cursor/hooks.json` and `.pi/extensions/git-interceptor/index.ts` at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | The regex became argv parsing: a shell reader (`scripts/hooks/lib/shell.ts`: simple commands, quotes, `$'…'`, substitutions, heredocs, redirects) and an option parser (`scripts/hooks/lib/argv.ts`), both new, so flag text inside a quoted `-m` is a message. Five rules instead of one: hook bypasses (`--no-verify` and its prefixes, `commit -n` and bundles, `-c core.hooksPath`, `--config-env`, aliases, `git config core.hooksPath`, `LEFTHOOK=0`, `HUSKY=0`, `lefthook uninstall`), `git push`, deletes (wrangler; cf without `--dry-run`, read the way yargs reads it), cf's project commands (also through cf's second bin name, `cloudflare`), and reads of the closed env files (a recursive `grep` or `rg -uu` included). Each refusal carries its rule and a reason sentence. Deny-only: the `GIT_EDITOR=:` rewrite is dropped. The adapter decodes its input with Effect Schema, runs under `BunRuntime.runMain`, writes through `Stdio`, denies Claude Code by exit 2 and fails closed on input it cannot read (upstream exits 0). The Cursor hook has no `matcher`, so every shell command is judged; the pi extension blocks through a local structural type instead of importing pi. Beyond the shell: `.claude/settings.json` denies Claude Code's Read tool the closed env files, and the pi extension blocks pi's `read`, `edit` and `grep` of them (`isClosedEnvPath`). |16| `scripts/vendor-agent-sources.sh` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/vendor-agent-sources.sh` at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Two sources (Effect, workers-sdk) in place of six, in a flat `.agent_sources/<repo>` layout in place of `github.com/<owner>/<repo>`. The pins come from the root catalog's `effect` and `apps/platform`'s `wrangler`, refused unless each is one exact version. Every tag is checked with `git ls-remote --exit-code` before its clone, with no fallback. The clone's own package version must equal the pin. The metadata is written last and marks a finished clone; a pin that moved re-clones without `--refresh`. |17| `tsconfig.base.json` (compiler options and the Effect diagnostics map) | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `tsconfig.base.json` at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | `importFromBarrel` dropped (unknown to `@effect/tsgo` 0.48.1); `types` emptied, so each package opts into its host's types; `@effect/platform-bun` added to `namespaceImportPackages`; `outdatedApi`, `unstableApiUsage` and `experimentalApiUsage` raised to `error`; `allowedUnstableApis` emptied and granted per path through `overrides`. |1819## Ideas, no code20
1 unmodified line
22| --- | --- | --- |23| The stateless 2026-07-28 MCP request (`_meta` keys plus `Mcp-Method`, `Mcp-Name` and `MCP-Protocol-Version` headers) driven through `HttpRouter.toWebHandler` | Effect's `packages/effect/test/ai/McpServer/v2026_07_28.test.ts` and `TestUtils/McpHttpHarness.ts` | `packages/protocol/test/mcp.ts` |24| Counting escapes with a second oxlint config, run as `-A all -D <rule> --format json` | Rat Stack's `scripts/oxlint-debt-ledger.config.ts` and its content build | `oxlint.debt.config.ts`, `scripts/debt.ts` |25| A release-age gate and exact pins on every install | Rat Stack's `pnpm-workspace.yaml` (`minimumReleaseAge`, `minimumReleaseAgeExclude`) | `bunfig.toml` |26| A merged command catalog (`commands.json`) | cf's command catalog | `scripts/lib/gen.ts` |27| Skills as numbered playbooks: each step ends on a done-when, then a gate step and a Report list | Rat Stack's `skills/add-a-capability` and `skills/add-a-store` at `fba26d8` | `.agents/skills/{add-operation,add-refusal,add-check-kind,add-port}/SKILL.md` |