Skip to content

Commit f08fd11

Browse files
committed
chore(cli): make the reference standalone, not a demo artifact
Follows the subpath rename through the code. The `sg` and `vale` entries are reference material too -- they are simply not what the demo command writes -- so scoping the corpus to "demo" was wrong in the same way the published name was. Moves, by what each file is actually about rather than by where it started: src/rules/demo/reference.ts -> src/rules/reference.ts src/rules/demo/constraints.ts -> src/rules/constraints.ts The constraints move furthest and had the least business being there: they describe what `verify` and `test` enforce on ANY rule. Nothing about them is demonstration-specific, and filing them under `demo/` implied a scope they never had. `src/rules/demo/` keeps `manifest.ts` and `rule.ts`, which really are the rules the demo command writes. Identifiers follow: buildDemoReference -> buildReference, DemoReference -> Reference, DEMO_REFERENCE_* -> REFERENCE_*. Script and task follow too: `write-demo-reference.ts` -> `write-reference.ts`, and `demo:reference` -> `reference`. Tests renamed to match the modules they cover. `demo:manifests` and `print-demo-manifests.ts` keep the prefix, and that is the line: they exist so CI can stage what the demo command writes, which is genuinely about the demo. No behaviour change. The payload is byte-identical -- regenerated after the move and it matched -- and the asset guard was re-broken to confirm it still refuses a mis-declared export under the new path.
1 parent 938dad8 commit f08fd11

7 files changed

Lines changed: 31 additions & 38 deletions

File tree

‎packages/cli/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"prebuild": "tsx scripts/fetch-rule-hash-vectors.ts",
2121
"test": "vitest run",
2222
"typecheck": "tsc --noEmit",
23-
"demo:reference": "tsx scripts/write-demo-reference.ts",
24-
"demo:manifests": "tsx scripts/print-demo-manifests.ts"
23+
"demo:manifests": "tsx scripts/print-demo-manifests.ts",
24+
"reference": "tsx scripts/write-reference.ts"
2525
},
2626
"type": "module",
2727
"module": "./dist/index.js",

packages/cli/scripts/write-demo-reference.ts renamed to packages/cli/scripts/write-reference.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
*
88
* Reads the asset files directly rather than importing `rule.ts`, whose `?raw`
99
* specifiers only resolve under a vite transform. Both read `DEMO_MANIFESTS`,
10-
* and `test/demo-reference.test.ts` asserts they agree.
10+
* and `test/reference.test.ts` asserts they agree.
1111
*
12-
* Run: pnpm --filter @taskless/cli demo:reference
12+
* Run: pnpm --filter @taskless/cli reference
1313
*/
1414

1515
import { readFile, writeFile } from "node:fs/promises";
1616
import { join } from "node:path";
1717

18-
import { buildDemoReference } from "../src/rules/demo/reference";
18+
import { buildReference } from "../src/rules/reference";
1919
import { DEMO_MANIFESTS } from "../src/rules/demo/manifest";
2020

2121
const packageRoot = join(import.meta.dirname, "..");
@@ -48,7 +48,7 @@ const rules = await Promise.all(
4848
const target = join(packageRoot, "assets", "reference.json");
4949
await writeFile(
5050
target,
51-
`${JSON.stringify(buildDemoReference(rules), undefined, 2)}\n`,
51+
`${JSON.stringify(buildReference(rules), undefined, 2)}\n`,
5252
"utf8"
5353
);
5454
console.log(`Wrote ${target}`);

packages/cli/src/rules/demo/constraints.ts renamed to packages/cli/src/rules/constraints.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EngineName } from "../layout";
1+
import type { EngineName } from "./layout";
22

33
/**
44
* What `verify` enforces beyond the engine's own schema.
@@ -19,7 +19,7 @@ import type { EngineName } from "../layout";
1919
* "`verify` never reads `language`", which stopped being true when
2020
* `validateLanguage` landed. Nothing failed, because prose has no test.
2121
*
22-
* `test/rule-constraints.test.ts` builds a rule that violates each entry and
22+
* `test/constraints.test.ts` builds a rule that violates each entry and
2323
* asserts `verify` rejects it, keyed on `id`. An entry describing a check that
2424
* no longer fires fails the suite; a check with no entry is invisible to that
2525
* test and is the gap this list is trying to close, so add one when you add a

‎packages/cli/src/rules/demo/manifest.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* The paths therefore live here, stated once. `rule.ts` embeds exactly these
1010
* lists, the generator reads exactly these lists off disk, and
11-
* `test/demo-reference.test.ts` asserts the two agree — so the rules the CLI
11+
* `test/reference.test.ts` asserts the two agree — so the rules the CLI
1212
* writes and the payload handed to other teams cannot come to describe
1313
* different things.
1414
*
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { DeliveredFile } from "../deliver";
2-
import type { EngineName } from "../layout";
1+
import type { DeliveredFile } from "./deliver";
2+
import type { EngineName } from "./layout";
33
import { RULE_CONSTRAINTS, type RuleConstraint } from "./constraints";
44

55
/**
@@ -21,10 +21,10 @@ import { RULE_CONSTRAINTS, type RuleConstraint } from "./constraints";
2121
* and both tiers are inert, so a signature on them would imply a gate that does
2222
* not exist.
2323
*/
24-
export const DEMO_REFERENCE_SIGNATURE = `1;h=sha-256;d=${"0".repeat(64)}`;
24+
export const REFERENCE_SIGNATURE = `1;h=sha-256;d=${"0".repeat(64)}`;
2525

2626
/** Bumped when a consumer would have to change code to keep reading this. */
27-
export const DEMO_REFERENCE_VERSION = 1;
27+
export const REFERENCE_VERSION = 1;
2828

2929
/**
3030
* The check this corpus exists to make possible, stated in the artifact itself.
@@ -44,7 +44,7 @@ export const DEMO_REFERENCE_VERSION = 1;
4444
* disagreement about our validator. Any consumer would have hit it on their
4545
* first run.
4646
*/
47-
export const DEMO_REFERENCE_PROTOCOL = [
47+
export const REFERENCE_PROTOCOL = [
4848
"Generate a rule from `prompt`, using your own pipeline.",
4949
"Run `taskless verify` over what you generated. It enforces constraints beyond the engine's own schema, listed in `constraints` below, so a rule the engine executes correctly can still be refused. A rule that fails here is not deliverable however well it behaves, and every later step would be measuring the wrong thing. Check `enforcedBy` before concluding anything: some constraints are only decided once the fixtures run.",
5050
"Run your generated rule against your own cases. It should pass; if it does not, the disagreement is inside your pipeline and nothing below will be informative.",
@@ -53,7 +53,7 @@ export const DEMO_REFERENCE_PROTOCOL = [
5353
];
5454

5555
/** One rule as this corpus carries it. */
56-
export interface DemoReferenceRule {
56+
export interface ReferenceRule {
5757
engine: EngineName;
5858
id: string;
5959
/** The generation request, as a caller would phrase it. */
@@ -66,7 +66,7 @@ export interface DemoReferenceRule {
6666
signature?: string;
6767
}
6868

69-
export interface DemoReference {
69+
export interface Reference {
7070
version: number;
7171
protocol: string[];
7272
/**
@@ -78,11 +78,11 @@ export interface DemoReference {
7878
* enforces it, which decides the order an eval has to run in.
7979
*/
8080
constraints: RuleConstraint[];
81-
rules: DemoReferenceRule[];
81+
rules: ReferenceRule[];
8282
}
8383

84-
/** The input shape `buildDemoReference` reads, satisfied by both callers. */
85-
export interface DemoReferenceInput {
84+
/** The input shape `buildReference` reads, satisfied by both callers. */
85+
export interface ReferenceInput {
8686
engine: EngineName;
8787
ruleId: string;
8888
prompt: string;
@@ -106,22 +106,18 @@ const plain = (files: readonly DeliveredFile[]) =>
106106
* Built from the rules rather than restating them, so the corpus and what the
107107
* CLI writes cannot describe different things.
108108
*/
109-
export function buildDemoReference(
110-
rules: readonly DemoReferenceInput[]
111-
): DemoReference {
109+
export function buildReference(rules: readonly ReferenceInput[]): Reference {
112110
return {
113-
version: DEMO_REFERENCE_VERSION,
114-
protocol: DEMO_REFERENCE_PROTOCOL,
111+
version: REFERENCE_VERSION,
112+
protocol: REFERENCE_PROTOCOL,
115113
constraints: [...RULE_CONSTRAINTS],
116114
rules: rules.map((rule) => ({
117115
engine: rule.engine,
118116
id: rule.ruleId,
119117
prompt: rule.prompt,
120118
rule: plain(rule.ruleFiles),
121119
tests: plain(rule.testFiles),
122-
...(rule.engine === "runtime"
123-
? { signature: DEMO_REFERENCE_SIGNATURE }
124-
: {}),
120+
...(rule.engine === "runtime" ? { signature: REFERENCE_SIGNATURE } : {}),
125121
})),
126122
};
127123
}

packages/cli/test/rule-constraints.test.ts renamed to packages/cli/test/constraints.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { join } from "node:path";
55
import { afterEach, beforeEach, describe, expect, it } from "vitest";
66
import { stringify } from "yaml";
77

8-
import { RULE_CONSTRAINTS } from "../src/rules/demo/constraints";
8+
import { RULE_CONSTRAINTS } from "../src/rules/constraints";
99
import { testOneRule, verifyOneRule } from "../src/rules/inspect";
1010

1111
/**
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ import { join } from "node:path";
44
import { describe, expect, it } from "vitest";
55

66
import { parseSignature } from "../src/rules/rule-hash";
7-
import {
8-
buildDemoReference,
9-
type DemoReference,
10-
} from "../src/rules/demo/reference";
11-
import { RULE_CONSTRAINTS } from "../src/rules/demo/constraints";
7+
import { buildReference, type Reference } from "../src/rules/reference";
8+
import { RULE_CONSTRAINTS } from "../src/rules/constraints";
129
import { DEMO_MANIFESTS, writtenPaths } from "../src/rules/demo/manifest";
1310
import { DEMO_RULES } from "../src/rules/demo/rule";
1411

@@ -28,19 +25,19 @@ const referencePath = join(
2825
"reference.json"
2926
);
3027

31-
async function readReference(): Promise<DemoReference> {
32-
return JSON.parse(await readFile(referencePath, "utf8")) as DemoReference;
28+
async function readReference(): Promise<Reference> {
29+
return JSON.parse(await readFile(referencePath, "utf8")) as Reference;
3330
}
3431

35-
function ruleFor(reference: DemoReference, engine: string) {
32+
function ruleFor(reference: Reference, engine: string) {
3633
const rule = reference.rules.find((entry) => entry.engine === engine);
3734
if (rule === undefined) throw new Error(`reference has no ${engine} rule`);
3835
return rule;
3936
}
4037

4138
describe("the demo reference payload", () => {
42-
it("is current — regenerate with `pnpm --filter @taskless/cli demo:reference`", async () => {
43-
expect(await readReference()).toEqual(buildDemoReference(DEMO_RULES));
39+
it("is current — regenerate with `pnpm --filter @taskless/cli reference`", async () => {
40+
expect(await readReference()).toEqual(buildReference(DEMO_RULES));
4441
});
4542

4643
it("embeds exactly the files each manifest lists", () => {

0 commit comments

Comments
 (0)