Skip to content

Commit 6cf8f69

Browse files
committed
refactor(library)!: a documented public entry and an internal one; one naming family per layer
1 parent 798fc42 commit 6cf8f69

71 files changed

Lines changed: 1015 additions & 665 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/scripts/changed-sections.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const ALL_SELECTING_PREFIXES = [
4949
// Cross-cutting: gap files define supplemental route typing across sections.
5050
"src/upstream-gaps/",
5151
"src/index.ts",
52+
"src/internal.ts",
5253
"src/io.ts",
5354
"src/main.ts",
5455
"src/plain-data.ts",

‎.github/scripts/package-smoke.ts‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* The package smoke, the gate behind the npm library build: build lib/pkg/,
33
* judge the package shape (publint, attw), pack a tarball, install it into a
4-
* fresh consumer project, import it under Node (the entry and the schema
4+
* fresh consumer project, import it under Node (both entries and the schema
55
* subpath), and compile a TypeScript consumer against the bundled index.d.ts
6-
* with skipLibCheck off - a declaration that leaks a devDependency type, or a
6+
* and internal.d.ts with skipLibCheck off - a declaration that leaks a devDependency type, or a
77
* type the emitter could not name, fails here instead of on a consumer's
88
* machine. The installed bin is run under Node too: its help must name every
99
* subcommand, and `validate` must accept a small settings file.
@@ -42,22 +42,24 @@ const SCHEMA_ID =
4242
*/
4343
const NODE_CONSUMER = `import { deepStrictEqual } from "node:assert/strict";
4444
import { SECTION_KEYS, validateSettings } from "${PACKAGE}";
45+
import { INPUT_DECLS } from "${PACKAGE}/internal";
4546
import schema from "${PACKAGE}/settings.schema.json" with { type: "json" };
4647
const result = validateSettings({ labels: [] });
4748
if (result.isErr()) throw new Error("validateSettings rejected an empty labels list: " + result.error.code);
48-
deepStrictEqual(result.value, { settings: { labels: [] }, warnings: [] });
49+
deepStrictEqual(result.value, { settings: { labels: [] }, log: [] });
4950
deepStrictEqual([...SECTION_KEYS], ${JSON.stringify(SECTION_KEYS)});
5051
deepStrictEqual(schema.$id, ${JSON.stringify(SCHEMA_ID)});
51-
console.log("imported " + SECTION_KEYS.length + " section keys and the schema");
52+
deepStrictEqual(INPUT_DECLS["on-missing-permission"].default, "fail");
53+
console.log("imported " + SECTION_KEYS.length + " section keys, the internal entry, and the schema");
5254
`;
5355

5456
/**
55-
* The consumer compiled against index.d.ts, no client behind it. The expect-error lines are the
57+
* The consumer compiled against index.d.ts and internal.d.ts, no client behind it. The expect-error lines are the
5658
* controls that the bundle keeps DenialPolicy nominal (the literal is its public shape, so only the
5759
* private member rejects it) and keeps the context branded with its section's key.
5860
*/
5961
const TS_CONSUMER = `import {
60-
type GithubClient,
62+
type GitHubClient,
6163
planContext,
6264
type RepoRef,
6365
SECTION_KEYS,
@@ -69,10 +71,13 @@ const TS_CONSUMER = `import {
6971
snapshotContext,
7072
validateSettings,
7173
} from "${PACKAGE}";
74+
import { type InputName, INPUT_DECLS } from "${PACKAGE}/internal";
7275
const first: SectionKey | undefined = SECTION_KEYS[0];
76+
export const policy: InputName = "on-missing-permission";
77+
export const policyDefault: string = INPUT_DECLS["on-missing-permission"].default;
7378
const result = validateSettings({ labels: [] });
7479
export const ok: boolean = result.isOk() && first === "repository";
75-
declare const client: GithubClient;
80+
declare const client: GitHubClient;
7681
declare const repo: RepoRef;
7782
const labels = sectionModule("labels");
7883
const snapshotCtx = snapshotContext(labels, client, repo, "warn");

‎architecture.yml‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ layers:
88
action: [src/action/]
99
cli: [src/cli.ts, src/cli/]
1010
library: [src/index.ts]
11+
internal: [src/internal.ts]
1112
flows: [src/flows/]
1213
engine: [src/engine/]
1314
sections: [src/sections/]
@@ -29,12 +30,14 @@ exclude:
2930
- "src/**/*.d.ts"
3031

3132
# from -> the layers it may import; a layer absent here imports nothing outside itself.
32-
# The action and the CLI are consumers of the library: their one edge is src/index.ts.
33+
# The action and the CLI are consumers of the two entries: src/index.ts (the documented library) and src/internal.ts
34+
# (the rest; the action draws only the first).
3335
edges:
3436
main: [action]
3537
action: [library]
36-
cli: [library]
37-
library: [discovery, engine, flows, github, io, problem, report, schema, sections, types]
38+
cli: [library, internal]
39+
library: [discovery, engine, flows, github, io, problem, report, schema, sections]
40+
internal: [discovery, engine, flows, github, problem, report, schema, sections, types]
3841
flows: [discovery, engine, github, io, plain-data, private, problem, report, schema, types]
3942
engine: [discovery, github, io, plain-data, problem, schema, sections, types]
4043
sections: [discovery, engine, github, schema, types, upstream-gaps]

‎docs/reference/architecture.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ flowchart TD
2222
repo["src/engine/orchestrate.ts<br>runForRepo()"]
2323
sections["src/sections/registry.ts<br>SECTIONS"]
2424
plan["each section plans<br>src/sections/contract/plan.ts planContext() SectionPlan<br>src/engine/diff.ts deltas()"]
25-
api["src/github/api.ts<br>GithubClient"]
25+
api["src/github/api.ts<br>GitHubClient"]
2626
drift["check: the plan's drift lines<br>src/sections/contract/plan.ts planDrift() planCheckNotes()"]
2727
exec["apply: the plan's writes<br>src/engine/execute.ts executePlan()"]
2828
report["src/flows/deliver.ts<br>concludeRun()"]
@@ -232,6 +232,7 @@ graph TD
232232
action["src/action/"]
233233
cli["src/cli.ts<br>src/cli/"]
234234
library["src/index.ts"]
235+
internal["src/internal.ts"]
235236
flows["src/flows/"]
236237
engine["src/engine/"]
237238
sections["src/sections/"]
@@ -248,6 +249,7 @@ graph TD
248249
main --> action
249250
action --> library
250251
cli --> library
252+
cli --> internal
251253
library --> discovery
252254
library --> engine
253255
library --> flows
@@ -257,7 +259,15 @@ graph TD
257259
library --> report
258260
library --> schema
259261
library --> sections
260-
library --> types
262+
internal --> discovery
263+
internal --> engine
264+
internal --> flows
265+
internal --> github
266+
internal --> problem
267+
internal --> report
268+
internal --> schema
269+
internal --> sections
270+
internal --> types
261271
flows --> discovery
262272
flows --> engine
263273
flows --> github

0 commit comments

Comments
 (0)