packstruct 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -53
- package/bin/cli.mjs +97 -22
- package/conformance/cases/env-claims/public/env-claims-pack/entry.js +4 -0
- package/conformance/cases/env-claims/public/env-claims-pack/pack.json +16 -0
- package/package.json +23 -5
- package/profiles/check.md +7 -27
- package/profiles/scenario.md +9 -24
- package/spec/SPEC.md +82 -118
- package/src/audit.mjs +75 -2
- package/src/lint.mjs +247 -97
- package/src/new.mjs +79 -0
- package/src/run-capped.mjs +16 -10
package/README.md
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
# packstruct 1.
|
|
1
|
+
# packstruct 1.1.0
|
|
2
2
|
|
|
3
|
-
The shared `/packs` spec. **One manifest + entry + lifecycle contract, many
|
|
4
|
-
hosts**, currently [crashtest](https://github.com/dhaupin/crashtest)
|
|
5
|
-
(scenario profile) and [poststruct](https://github.com/dhaupin/poststruct)
|
|
6
|
-
(check profile).
|
|
3
|
+
The shared `/packs` spec. **One manifest + entry + lifecycle contract, many hosts**, currently [crashtest](https://github.com/dhaupin/crashtest) (scenario profile) and [poststruct](https://github.com/dhaupin/poststruct) (check profile).
|
|
7
4
|
|
|
8
|
-
This repo ships the normative spec ([spec/SPEC.md](spec/SPEC.md)) plus a
|
|
9
|
-
zero-dependency lint CLI that kills the worst pack-authoring class at author
|
|
10
|
-
time: a manifest declaring an entry file that doesn't actually ship
|
|
11
|
-
(crashtest#16). Every fleet repo uses the same core check.
|
|
5
|
+
This repo ships the normative spec ([spec/SPEC.md](spec/SPEC.md)) plus a zero-dependency lint CLI that kills the worst pack-authoring class at author time: a manifest declaring an entry file that doesn't actually ship (crashtest#16). Every fleet repo uses the same core check.
|
|
12
6
|
|
|
13
7
|
## The directory contract
|
|
14
8
|
|
|
@@ -24,76 +18,70 @@ packs/
|
|
|
24
18
|
|
|
25
19
|
```bash
|
|
26
20
|
npx packstruct lint packs/ # human, exit 0 clean / 1 violations / 2 usage
|
|
27
|
-
npx packstruct lint packs/ --json # machine-readable: {schema, packsChecked, violations}
|
|
21
|
+
npx packstruct lint packs/ --json # machine-readable: {schema, packsChecked, localChecked, violations}
|
|
28
22
|
|
|
29
23
|
npx packstruct lint packs/ --deep # + entry import, default-export check, id census
|
|
30
24
|
npx packstruct lint packs/ --deep --json # adds mode, modulesProbed, idsCensused, libraryIds
|
|
31
25
|
npx packstruct lint packs/ --deep --against lib/ # + host-library id census (id-library-collision)
|
|
26
|
+
npx packstruct lint packs/ --local # + the gitignored local/ WIP lane (lane-tagged rows)
|
|
32
27
|
|
|
33
28
|
npx packstruct audit-conformance . \
|
|
34
29
|
--loader "node bin/load-packs.js {packs}" # audit a HOST loader (SPEC section 7)
|
|
30
|
+
|
|
31
|
+
npx packstruct new my-shapes # scaffold a conforming pack skeleton (packstruct#24)
|
|
35
32
|
```
|
|
36
33
|
|
|
37
|
-
The linter validates `schemaVersion === 1`, kebab-case name matching its
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`armedByKey` string. Host-owned keys the engine also recognizes (`env`,
|
|
41
|
-
`plugins`, `package`) are acknowledged by name and never refused. Everything
|
|
42
|
-
else (extra manifest keys, snapshot files beside the entry) is
|
|
43
|
-
minimum-spec and left alone.
|
|
44
|
-
|
|
45
|
-
`audit-conformance` is the next half of conformance (SPEC section 7): it
|
|
46
|
-
materializes bundled verdict-claiming fixture packs (one clean bundle, one
|
|
47
|
-
per refusal norm, a name-collision pair) into scratch roots and runs YOUR
|
|
48
|
-
loader command over each - a conforming loader exits 0 on clean and exits
|
|
49
|
-
non-zero naming the pack on every violation (identity match, refusal wording
|
|
50
|
-
stays host-owned). The `implements: packstruct@1` pin becomes verifiable,
|
|
51
|
-
not honorary.
|
|
34
|
+
The linter validates `schemaVersion === 1`, kebab-case name matching its directory, dotted versions, non-empty description, relative entry paths, and that the entry file physically exists under the pack dir. Optional `armedByKey` string. Host-owned keys the engine also recognizes (`env`, `plugins`, `package`) are acknowledged by name and never refused. Everything else (extra manifest keys, snapshot files beside the entry) is minimum-spec and left alone.
|
|
35
|
+
|
|
36
|
+
`audit-conformance` is the next half of conformance (SPEC section 7): it materializes bundled verdict-claiming fixture packs (one clean bundle, one per refusal norm, a name-collision pair, and an `env-claims` bundle carrying the host-owned `env` block) into scratch roots and runs YOUR loader command over each - a conforming loader exits 0 on clean and exits non-zero naming the pack on every violation (identity match, refusal wording stays host-owned). `--claims` goes further on the `env-claims` bundle: the loader must echo the declared block, so a loader that silently ignores `env` is named instead of passing. The `implements: packstruct@1` pin becomes verifiable, not honorary.
|
|
52
37
|
|
|
53
38
|
## Profiles
|
|
54
39
|
|
|
55
|
-
The two entry profiles are declared once, with the spec (one address per
|
|
56
|
-
the crashtest#19 ruling): [profiles/scenario.md](profiles/scenario.md)
|
|
57
|
-
(crashtest - links to the host-owned contract instead of copying it) and
|
|
58
|
-
[profiles/check.md](profiles/check.md) (poststruct).
|
|
40
|
+
The two entry profiles are declared once, with the spec (one address per the crashtest#19 ruling): [profiles/scenario.md](profiles/scenario.md) (crashtest - links to the host-owned contract instead of copying it) and [profiles/check.md](profiles/check.md) (poststruct).
|
|
59
41
|
|
|
60
42
|
## How the schema version was chosen
|
|
61
43
|
|
|
62
|
-
The baseline (formalized 2026-10-23) is exactly what crashtest's production
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
The baseline (formalized 2026-10-23) is exactly what crashtest's production packs already ship: `schemaVersion: 1` with the shared field set above. Therefore crashtest hosts v1 with **zero runtime changes**, and poststruct adopts v1 fresh. Neither host shares an implementation with the other. They share only this file convention.
|
|
45
|
+
|
|
46
|
+
## Family lanes (receipts, not asks)
|
|
47
|
+
|
|
48
|
+
Every consuming host keeps a receipt row here: engine, the exact source sha the row grates against, the lint result, and the cut date. The row is the receipt - `implements: packstruct@1` in a host README stops being honorary when the registry row is sha-pinned and cut before the consumer's publish wave. Bump a companion pin and the receipt moves in the same change, never silently (packstruct#25).
|
|
49
|
+
|
|
50
|
+
| Host | Pin (engine @ source sha) | Result | Cut |
|
|
51
|
+
|---|---|---|---|
|
|
52
|
+
| crashtest | `crashtest@1.1.0` @ `2d1fe79` (npm tag v1.1.0) | 8/8 packs clean shallow + deep, 44 ids, 63 library ids, zero collisions (`labs/corpus-receipt.md`) | 2026-10-29 |
|
|
53
|
+
| crashtest (dogfood) | `crashtest@1.1.0` @ `2d1fe79` | `crashtest run`: 53/53 catalog findings REFUSED (4 from `packstruct-lint-shapes`), 0 EXPLOITED, 0 BOUNDED (`labs/crashledger.json`) | 2026-10-29 |
|
|
54
|
+
| eyestruct | `eyestruct@1.0.0` @ `4b979c0` (tag v1.0.0) | 5/5 packs (eye-adapter, eye-bundle, eye-ci-gate, eye-shapes, eye-text-leg) clean shallow + deep through the packstruct@1 lane | 2026-10-29 |
|
|
55
|
+
| poststruct | staging in flight | row reserved - activates when it settles (honest absence, not padding) | - |
|
|
56
|
+
|
|
57
|
+
The registry is the natural home for companion-pin bump receipts (SPEC v1.1 section 8 row 5) and the checkable form of a traveler's onboarding (SPEC v1.1 section 10): a host exists when it holds a row, not when a session transcript mentions it. A non-additive schema event must update the affected rows (SPEC v1.1 section 11).
|
|
67
58
|
|
|
68
|
-
## Status (1.
|
|
59
|
+
## Status (1.1.0)
|
|
69
60
|
|
|
70
|
-
Version ladder follows [prestruct](https://github.com/dhaupin/prestruct)'s
|
|
71
|
-
convention: 0.9.x is the manual `npm publish` ladder (0.9.0 was the manual
|
|
72
|
-
release that seeded the package); 1.0.0 and later flip on the CI publish
|
|
73
|
-
lane - tag v1.0.0 and publish.yml runs (refuses 0.x, verifies the tag
|
|
74
|
-
matches the version, and publishes with `--provenance`, so v1.0.0 carries
|
|
75
|
-
provenance by construction).
|
|
61
|
+
Version ladder follows [prestruct](https://github.com/dhaupin/prestruct)'s convention: 0.9.x is the manual `npm publish` ladder (0.9.0 was the manual release that seeded the package); 1.0.0 and later flip on the CI publish lane - tag v1.0.0 and publish.yml runs (refuses 0.x, verifies the tag matches the version, and publishes with `--provenance`, so v1.0.0 carries provenance by construction).
|
|
76
62
|
|
|
77
63
|
## Related
|
|
78
64
|
|
|
79
65
|
- [crashtest](https://github.com/dhaupin/crashtest) (scenario-profile host)
|
|
80
66
|
- [poststruct](https://github.com/dhaupin/poststruct) (check-profile host)
|
|
81
|
-
- **The workshop** -> [Creadev.org](https://creadev.org) (the same home as the
|
|
82
|
-
docs, npm, and site surfaces above)
|
|
67
|
+
- **The workshop** -> [Creadev.org](https://creadev.org) (the same home as the docs, npm, and site surfaces above)
|
|
83
68
|
|
|
84
69
|
## Landing & docs
|
|
85
70
|
|
|
86
|
-
Landing: `packstruct.creadev.org` (Cloudflare Pages Git integration rooted at
|
|
87
|
-
`web/` - a Vite + React app prerendered by `prestruct build` into `web/dist/`
|
|
88
|
-
per-route; Pages Functions under `web/functions/`). Docs:
|
|
89
|
-
`docs.creadev.org/packstruct` (Jekyll + Pagefind + Freestruct via GitHub
|
|
90
|
-
Actions; see `.github/workflows/docs.yml` and `docs/`).
|
|
71
|
+
Landing: `packstruct.creadev.org` (Cloudflare Pages Git integration rooted at `web/` - a Vite + React app prerendered by `prestruct build` into `web/dist/` per-route; Pages Functions under `web/functions/`). Docs: `docs.creadev.org/packstruct` (Jekyll + Pagefind + Freestruct via GitHub Actions; see `.github/workflows/docs.yml` and `docs/`).
|
|
91
72
|
|
|
92
|
-
Build the site locally: `cd web && npm install && npm run build` - `prestruct`
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
73
|
+
Build the site locally: `cd web && npm install && npm run build` - `prestruct` runs the vite build, injects brand/SEO tags from `web/ssr.config.js`, and prerenders every route to static HTML (bots get HTML, the SPA hydrates for humans).
|
|
74
|
+
|
|
75
|
+
## Development
|
|
76
|
+
|
|
77
|
+
Zero runtime dependencies. The gate is `npm test && npm run check` - `check` composes the docs gates, a deep lint of the repo's own shipped pack, and the 9/9 conformance audit (the same command `prepublishOnly` runs, so a publish cannot ship an unverified SPEC or pack surface).
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm test # the lint + deep + audit + edge contract suite
|
|
81
|
+
npm run check # docs gates + lint:packs + conform:packs (the battery)
|
|
82
|
+
npx crashtest run # the dogfood: hostile manifests through the CLI wire
|
|
83
|
+
```
|
|
96
84
|
|
|
97
85
|
## Crashtest dogfood
|
|
98
86
|
|
|
99
|
-
`crashtest run` from the repo root drives `packs/public/packstruct-lint-shapes`: hostile pack.json corpora through an in-process lint double (the same CLI wire CI uses), asserting the SPEC v1 section 5 contract - instant nameable refusal, no crashes, no deep stacks, and strict tolerance for spec-allowed shapes. Pinned to dhaupin/crashtest v1.
|
|
87
|
+
`crashtest run` from the repo root drives `packs/public/packstruct-lint-shapes`: hostile pack.json corpora through an in-process lint double (the same CLI wire CI uses), asserting the SPEC v1 section 5 contract - instant nameable refusal, no crashes, no deep stacks, and strict tolerance for spec-allowed shapes. Pinned to dhaupin/crashtest v1.1.0.
|
package/bin/cli.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// bin/cli.mjs - the packstruct CLI, zero dependencies.
|
|
3
3
|
//
|
|
4
4
|
// packstruct lint <packs-dir> [--json] [--deep] [--against <path>]
|
|
5
|
-
// packstruct audit-conformance [<repo-dir>] --loader "<cmd> {packs}" [--json]
|
|
5
|
+
// packstruct audit-conformance [<repo-dir>] --loader "<cmd> {packs}" [--json] [--claims]
|
|
6
6
|
//
|
|
7
7
|
// The lint subcommand token is stripped when present, and a bare
|
|
8
8
|
// `packstruct <dir>` keeps working (the dir positionally implies lint; a
|
|
@@ -34,10 +34,21 @@
|
|
|
34
34
|
// 1 any case failed, 2 usage error - same ladder as lint.
|
|
35
35
|
import { lintPacks, deepLintPacks } from '../src/lint.mjs'
|
|
36
36
|
import { auditConformance } from '../src/audit.mjs'
|
|
37
|
+
import { newPack } from '../src/new.mjs'
|
|
38
|
+
import { readFileSync } from 'node:fs'
|
|
37
39
|
|
|
38
40
|
let args = process.argv.slice(2)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
// The version truth is package.json (the family rule): the publish lane's
|
|
42
|
+
// verify job probes the INSTALLED bin with --version, so the answer must
|
|
43
|
+
// come from the packaged tree, never a hardcoded literal that can drift.
|
|
44
|
+
if (args[0] === '--version') {
|
|
45
|
+
console.log(JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version)
|
|
46
|
+
process.exit(0)
|
|
47
|
+
}
|
|
48
|
+
const verb = args[0] === 'audit-conformance' ? 'audit-conformance'
|
|
49
|
+
: args[0] === 'new' ? 'new'
|
|
50
|
+
: 'lint'
|
|
51
|
+
if (args[0] === 'lint' || verb === 'audit-conformance' || verb === 'new') args = args.slice(1)
|
|
41
52
|
|
|
42
53
|
const exitUsage = (msg, usage) => {
|
|
43
54
|
if (msg) console.error(msg)
|
|
@@ -45,30 +56,85 @@ const exitUsage = (msg, usage) => {
|
|
|
45
56
|
process.exit(2)
|
|
46
57
|
}
|
|
47
58
|
|
|
59
|
+
// Usage strings, one per verb (the usage ladder's exit 2 surface).
|
|
60
|
+
const USAGE_LINT = 'packstruct lint <packs-dir> [--json] [--deep] [--local] [--against <library-path>]'
|
|
61
|
+
const USAGE_AUDIT = 'packstruct audit-conformance [<repo-dir>] --loader "<cmd> {packs}" [--json] [--claims]'
|
|
62
|
+
const USAGE_NEW = 'packstruct new <pack-name> [--dir <packs-root>] [--json]'
|
|
63
|
+
|
|
64
|
+
// Unknown-flag rejection (packstruct#18): a typo'd mode flag used to be
|
|
65
|
+
// silently ignored, so `--jso` ran text mode and `--dep` ran shallow - the
|
|
66
|
+
// wrong mode with no signal, the exact misfire class the tool exists to
|
|
67
|
+
// kill. Every leading-dash token must now be a recognized flag or the run
|
|
68
|
+
// refuses with the usage ladder's exit 2.
|
|
69
|
+
const rejectUnknownFlag = (a, have, usage) => exitUsage(`unknown flag "${a}" (have: ${have})`, usage)
|
|
70
|
+
|
|
71
|
+
// new (packstruct#24): generate a conforming pack skeleton at author time.
|
|
72
|
+
// The cheapest break class - a new author guessing the field list - dies
|
|
73
|
+
// even earlier if the starting point is generated correct. Refusals are
|
|
74
|
+
// the net; `new` is the trampoline. Its output is just another manifest
|
|
75
|
+
// the lint grades, so the lint stays the one truth.
|
|
76
|
+
if (verb === 'new') {
|
|
77
|
+
let dir
|
|
78
|
+
const dirIdx = args.indexOf('--dir')
|
|
79
|
+
if (dirIdx !== -1) {
|
|
80
|
+
dir = args[dirIdx + 1]
|
|
81
|
+
if (dir === undefined || dir.startsWith('-')) exitUsage('--dir needs a value (the packs root to write into)', USAGE_NEW)
|
|
82
|
+
}
|
|
83
|
+
const positional = []
|
|
84
|
+
for (let i = 0; i < args.length; i++) {
|
|
85
|
+
const a = args[i]
|
|
86
|
+
if (a === '--dir') { i++; continue }
|
|
87
|
+
if (a === '--json') continue
|
|
88
|
+
if (a.startsWith('-')) rejectUnknownFlag(a, '--dir <packs-root>, --json', USAGE_NEW)
|
|
89
|
+
positional.push(a)
|
|
90
|
+
}
|
|
91
|
+
const name = positional[0]
|
|
92
|
+
if (!name) exitUsage(undefined, USAGE_NEW)
|
|
93
|
+
if (positional.length > 1) exitUsage(`new takes one pack name (got ${positional.length})`, USAGE_NEW)
|
|
94
|
+
const r = newPack(name, { dir })
|
|
95
|
+
const json = args.includes('--json')
|
|
96
|
+
if (json) {
|
|
97
|
+
console.log(JSON.stringify({ schema: 1, mode: 'new', name, dir: r.dir, packDir: r.packDir, files: r.files, violations: r.violations }, null, 2))
|
|
98
|
+
} else {
|
|
99
|
+
if (r.violations.length) {
|
|
100
|
+
for (const v of r.violations) console.error(` REFUSED [${v.norm}]: ${v.message}`)
|
|
101
|
+
} else {
|
|
102
|
+
console.log(`packstruct new: created ${r.packDir}`)
|
|
103
|
+
for (const f of r.files) console.log(` created ${f}`)
|
|
104
|
+
console.log(` next: packstruct lint ${r.dir}`)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
process.exit(r.violations.length ? 1 : 0)
|
|
108
|
+
}
|
|
109
|
+
|
|
48
110
|
if (verb === 'audit-conformance') {
|
|
49
111
|
const loaderIdx = args.indexOf('--loader')
|
|
50
112
|
let loader
|
|
51
113
|
if (loaderIdx !== -1) {
|
|
52
114
|
loader = args[loaderIdx + 1]
|
|
53
115
|
if (loader === undefined || loader.startsWith('-')) {
|
|
54
|
-
exitUsage('--loader needs a value: --loader "<cmd> {packs}"',
|
|
116
|
+
exitUsage('--loader needs a value: --loader "<cmd> {packs}"', USAGE_AUDIT)
|
|
55
117
|
}
|
|
56
118
|
}
|
|
57
119
|
const positional = []
|
|
58
120
|
for (let i = 0; i < args.length; i++) {
|
|
59
|
-
|
|
60
|
-
if (
|
|
121
|
+
const a = args[i]
|
|
122
|
+
if (a === '--loader') { i++; continue }
|
|
123
|
+
if (a === '--json' || a === '--claims') continue
|
|
124
|
+
if (a.startsWith('-')) rejectUnknownFlag(a, '--loader <cmd>, --json, --claims', USAGE_AUDIT)
|
|
125
|
+
positional.push(a)
|
|
61
126
|
}
|
|
62
127
|
if (loader === undefined) {
|
|
63
|
-
exitUsage(undefined,
|
|
128
|
+
exitUsage(undefined, USAGE_AUDIT)
|
|
64
129
|
}
|
|
65
130
|
const repo = positional[0] ?? '.'
|
|
66
131
|
const json = args.includes('--json')
|
|
67
|
-
const
|
|
132
|
+
const claims = args.includes('--claims')
|
|
133
|
+
const r = await auditConformance({ loader, repo, json, claims })
|
|
68
134
|
if (json) {
|
|
69
|
-
console.log(JSON.stringify({ schema: 1, mode: 'audit', repo, cases: r.caseCount, honored: r.honored, violations: r.violations }, null, 2))
|
|
135
|
+
console.log(JSON.stringify({ schema: 1, mode: 'audit', repo, claims, cases: r.caseCount, honored: r.honored, violations: r.violations }, null, 2))
|
|
70
136
|
} else {
|
|
71
|
-
console.log(`packstruct audit-conformance: ${r.honored}/${r.caseCount} case(s) honored by the loader over ${repo}`)
|
|
137
|
+
console.log(`packstruct audit-conformance${claims ? ' --claims' : ''}: ${r.honored}/${r.caseCount} case(s) honored by the loader over ${repo}`)
|
|
72
138
|
for (const v of r.violations) console.log(` AUDIT ${v.pack} [${v.norm}]: ${v.message}`)
|
|
73
139
|
}
|
|
74
140
|
process.exit(r.violations.length ? 1 : 0)
|
|
@@ -80,34 +146,40 @@ let against
|
|
|
80
146
|
if (againstIdx !== -1) {
|
|
81
147
|
against = args[againstIdx + 1]
|
|
82
148
|
if (against === undefined || against.startsWith('-')) {
|
|
83
|
-
exitUsage(undefined,
|
|
149
|
+
exitUsage(undefined, USAGE_LINT)
|
|
84
150
|
}
|
|
85
151
|
}
|
|
86
152
|
const dirArgs = []
|
|
87
153
|
for (let i = 0; i < args.length; i++) {
|
|
88
|
-
|
|
89
|
-
|
|
154
|
+
const a = args[i]
|
|
155
|
+
if (a === '--against') { i++; continue }
|
|
156
|
+
if (a === '--deep' || a === '--json' || a === '--local') continue
|
|
157
|
+
if (a.startsWith('-')) rejectUnknownFlag(a, '--deep, --json, --local, --against <path>', USAGE_LINT)
|
|
158
|
+
dirArgs.push(a)
|
|
90
159
|
}
|
|
91
160
|
|
|
92
|
-
const dir = dirArgs
|
|
93
|
-
if (!dir) exitUsage(undefined,
|
|
94
|
-
const deep =
|
|
161
|
+
const dir = dirArgs[0]
|
|
162
|
+
if (!dir) exitUsage(undefined, USAGE_LINT)
|
|
163
|
+
const deep = args.includes('--deep')
|
|
164
|
+
const local = args.includes('--local')
|
|
95
165
|
if (against !== undefined && !deep) {
|
|
96
|
-
exitUsage('--against requires --deep (the host-library census runs on the deep pass)',
|
|
166
|
+
exitUsage('--against requires --deep (the host-library census runs on the deep pass)', USAGE_LINT)
|
|
97
167
|
}
|
|
98
168
|
|
|
99
169
|
const r = deep
|
|
100
|
-
? await deepLintPacks(dir, { against })
|
|
101
|
-
: lintPacks(dir)
|
|
102
|
-
if (
|
|
170
|
+
? await deepLintPacks(dir, { against, local })
|
|
171
|
+
: lintPacks(dir, { local })
|
|
172
|
+
if (args.includes('--json')) {
|
|
103
173
|
console.log(JSON.stringify({
|
|
104
174
|
schema: 1,
|
|
105
175
|
mode: deep ? 'deep' : 'manifest',
|
|
106
176
|
packsChecked: r.packsChecked,
|
|
177
|
+
localChecked: r.localChecked ?? 0,
|
|
107
178
|
modulesProbed: r.modulesProbed,
|
|
108
179
|
idsCensused: r.idsCensused,
|
|
109
180
|
libraryIds: r.libraryIds ?? 0,
|
|
110
181
|
violations: r.violations,
|
|
182
|
+
warnings: r.warnings ?? [],
|
|
111
183
|
}, null, 2))
|
|
112
184
|
process.exit(r.violations.length ? 1 : 0)
|
|
113
185
|
}
|
|
@@ -116,6 +188,9 @@ const probe = deep
|
|
|
116
188
|
? ` - ${r.modulesProbed} module(s) probed, ${r.idsCensused} id(s) censused` +
|
|
117
189
|
(against !== undefined ? `, ${r.libraryIds ?? 0} library id(s) seeded` : '')
|
|
118
190
|
: ''
|
|
119
|
-
|
|
120
|
-
|
|
191
|
+
const localNote = local ? `, ${r.localChecked ?? 0} local pack(s)` : ''
|
|
192
|
+
console.log(`packstruct ${mode}: ${r.packsChecked} pack(s) checked in ${dir}${localNote}${probe}`)
|
|
193
|
+
for (const v of r.violations) console.log(` VIOLATION ${v.pack}${v.lane === 'local' ? ' [local]' : ''} [${v.norm}]: ${v.message}`)
|
|
194
|
+
// Warnings are advisory: they never change the exit code (SPEC v1.1 section 2).
|
|
195
|
+
for (const w of r.warnings ?? []) console.log(` WARNING ${w.pack}${w.lane === 'local' ? ' [local]' : ''} [${w.norm}]: ${w.message}`)
|
|
121
196
|
process.exit(r.violations.length ? 1 : 0)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Inert conformance fixture entry for the env-claims case - imports cleanly,
|
|
2
|
+
// declares nothing to run. The point of this case is the MANIFEST: it carries
|
|
3
|
+
// the host-owned `env` block (SPEC section 2) and must be accepted.
|
|
4
|
+
export default { name: 'env-claims-pack' }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"name": "env-claims-pack",
|
|
4
|
+
"description": "SPEC v1.1 conformance pack - declares the host-owned env block (d1/kv/routes/seed). The accept case for packstruct#71: the block is spec'd, so a conforming loader must NOT refuse a pack for carrying it.",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"entry": "entry.js",
|
|
7
|
+
"env": {
|
|
8
|
+
"d1": { "DB": { "tables": ["charges"] } },
|
|
9
|
+
"kv": { "UPLOADS": {} },
|
|
10
|
+
"routes": ["charge"],
|
|
11
|
+
"seed": {
|
|
12
|
+
"kv": { "UPLOADS": { "canary": "seed-value" } },
|
|
13
|
+
"d1": { "DB": { "charges": { "rows": [{ "id": 1 }] } } }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "packstruct",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The shared /packs spec: one manifest, entry, and lifecycle contract for crashtest and poststruct packs - plus a zero-dependency lint CLI that kills broken pack manifests at author time.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -21,9 +21,22 @@
|
|
|
21
21
|
"LICENSE"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"test": "node test/run.mjs"
|
|
24
|
+
"test": "node test/run.mjs && node --test test/status.test.mjs test/refusal-matrix.test.mjs test/run-capped.test.mjs tests/ship-from-download.test.cjs tests/release-verify.test.cjs tests/check-action-pins.test.cjs && node --test tests/check-prestruct-pins.test.cjs",
|
|
25
|
+
"test:ship": "node --test tests/ship-from-download.test.cjs",
|
|
26
|
+
"lint:docs": "node scripts/check-docs-frontmatter.cjs && node scripts/check-docs-links.cjs && node scripts/check-docs-style.cjs && node scripts/check-jekyll-filters.cjs && node scripts/check-language.cjs",
|
|
27
|
+
"lint:pins": "node scripts/check-action-pins.cjs",
|
|
28
|
+
"lint:packs": "node bin/cli.mjs lint packs --deep",
|
|
29
|
+
"conform:packs": "node bin/cli.mjs audit-conformance . --loader \"node bin/cli.mjs lint {packs}\"",
|
|
30
|
+
"conform:claims": "node bin/cli.mjs audit-conformance . --loader \"node test/fixtures/audit/loader-claims.mjs {packs}\" --claims",
|
|
31
|
+
"check": "npm run lint:docs && npm run lint:pins && npm run lint:prestruct-pins && node scripts/check-legal.cjs && npm run matrix:check && npm run lint:packs && npm run conform:packs && npm run conform:claims",
|
|
32
|
+
"prepublishOnly": "npm test && npm run check",
|
|
33
|
+
"matrix:check": "node scripts/gen-refusal-matrix.mjs --check",
|
|
34
|
+
"matrix:gen": "node scripts/gen-refusal-matrix.mjs",
|
|
35
|
+
"lint:prestruct-pins": "node scripts/check-prestruct-pins.cjs"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20"
|
|
25
39
|
},
|
|
26
|
-
"engines": { "node": ">=20" },
|
|
27
40
|
"keywords": [
|
|
28
41
|
"packs",
|
|
29
42
|
"spec",
|
|
@@ -33,7 +46,12 @@
|
|
|
33
46
|
"ci",
|
|
34
47
|
"manifest"
|
|
35
48
|
],
|
|
36
|
-
"repository": {
|
|
37
|
-
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/dhaupin/packstruct.git"
|
|
52
|
+
},
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/dhaupin/packstruct/issues"
|
|
55
|
+
},
|
|
38
56
|
"homepage": "https://github.com/dhaupin/packstruct#readme"
|
|
39
57
|
}
|
package/profiles/check.md
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
# The check profile
|
|
2
2
|
|
|
3
|
-
Declared per SPEC v1 section 3 (normative) and filed here once, per the
|
|
4
|
-
one-address ruling on [crashtest#19](https://github.com/dhaupin/crashtest).
|
|
3
|
+
Declared per SPEC v1 section 3 (normative) and filed here once, per the one-address ruling on [crashtest#19](https://github.com/dhaupin/crashtest).
|
|
5
4
|
|
|
6
|
-
This is the profile [poststruct](https://github.com/dhaupin/poststruct) will
|
|
7
|
-
load. Note the honest status line: poststruct is not shipping yet, so this
|
|
8
|
-
page declares the shape the spec froze - the engine-first rule (code first,
|
|
9
|
-
spec formalizes after) means any poststruct loader change that contradicts
|
|
10
|
-
this page updates the SPEC first, then here.
|
|
5
|
+
This is the profile [poststruct](https://github.com/dhaupin/poststruct) will load. Note the honest status line: poststruct is not shipping yet, so this page declares the shape the spec froze - the engine-first rule (code first, spec formalizes after) means any poststruct loader change that contradicts this page updates the SPEC first, then here.
|
|
11
6
|
|
|
12
7
|
## The module shape
|
|
13
8
|
|
|
14
|
-
An entry module under this profile is an ES module with a default export
|
|
15
|
-
carrying a `checks` array:
|
|
9
|
+
An entry module under this profile is an ES module with a default export carrying a `checks` array:
|
|
16
10
|
|
|
17
11
|
```js
|
|
18
12
|
export default {
|
|
@@ -26,25 +20,11 @@ export default {
|
|
|
26
20
|
|
|
27
21
|
## What the spec guarantees
|
|
28
22
|
|
|
29
|
-
- **No transport, no network by default.** A check pack reads the files the
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- **Config-is-the-arm.** There is no arming key ceremony in this profile:
|
|
33
|
-
being enumerated in the host's `packs:` config IS the arm (SPEC section 3).
|
|
34
|
-
A `pack.json` may still carry `armedByKey` - the shared manifest surface
|
|
35
|
-
never forks between profiles - and the poststruct loader will simply not
|
|
36
|
-
give it a ceremony: its presence is optional surface, its semantics here
|
|
37
|
-
are the host's default lifecycle (config enumeration).
|
|
38
|
-
- **Namespaced ids.** Check ids live in the pack-slug namespace inside the
|
|
39
|
-
host's id space; cross-namespace collision at load = refuse to start
|
|
40
|
-
(SPEC section 4).
|
|
23
|
+
- **No transport, no network by default.** A check pack reads the files the host points it at. That whole boundary is the profile's point: check packs prove claims about files; scenario packs attack systems.
|
|
24
|
+
- **Config-is-the-arm.** There is no arming key ceremony in this profile: being enumerated in the host's `packs:` config IS the arm (SPEC section 3). A `pack.json` may still carry `armedByKey` - the shared manifest surface never forks between profiles - and the poststruct loader will simply not give it a ceremony: its presence is optional surface, its semantics here are the host's default lifecycle (config enumeration).
|
|
25
|
+
- **Namespaced ids.** Check ids live in the pack-slug namespace inside the host's id space; cross-namespace collision at load = refuse to start (SPEC section 4).
|
|
41
26
|
- **Refusals** are instant, one-line, and name the pack (SPEC section 5).
|
|
42
27
|
|
|
43
28
|
## Boundary charter
|
|
44
29
|
|
|
45
|
-
The load-time boundary between the struct apps is on record:
|
|
46
|
-
[poststruct#2](https://github.com/dhaupin/poststruct/issues/2) - the
|
|
47
|
-
manifest shape validates ONCE (this spec, section 2), packstruct owns the
|
|
48
|
-
pack shape, poststruct owns the text shape. A conformance story for a check
|
|
49
|
-
pack is: packstruct lint says the manifest is v1; the poststruct loader
|
|
50
|
-
says the checks are check-shaped; neither pretends to speak for the other.
|
|
30
|
+
The load-time boundary between the struct apps is on record: [poststruct#2](https://github.com/dhaupin/poststruct/issues/2) - the manifest shape validates ONCE (this spec, section 2), packstruct owns the pack shape, poststruct owns the text shape. A conformance story for a check pack is: packstruct lint says the manifest is v1; the poststruct loader says the checks are check-shaped; neither pretends to speak for the other.
|
package/profiles/scenario.md
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
# The scenario profile
|
|
2
2
|
|
|
3
|
-
Declared per SPEC v1 section 3 (normative) and filed here once, per the
|
|
4
|
-
one-address ruling on [crashtest#19](https://github.com/dhaupin/crashtest).
|
|
3
|
+
Declared per SPEC v1 section 3 (normative) and filed here once, per the one-address ruling on [crashtest#19](https://github.com/dhaupin/crashtest).
|
|
5
4
|
|
|
6
5
|
This is the profile [crashtest](https://github.com/dhaupin/crashtest) loads.
|
|
7
6
|
|
|
8
7
|
## The module shape
|
|
9
8
|
|
|
10
|
-
An entry module under this profile is an ES module with a default export
|
|
11
|
-
carrying three things:
|
|
9
|
+
An entry module under this profile is an ES module with a default export carrying three things:
|
|
12
10
|
|
|
13
11
|
```js
|
|
14
12
|
export default {
|
|
@@ -27,33 +25,20 @@ export default {
|
|
|
27
25
|
}
|
|
28
26
|
```
|
|
29
27
|
|
|
30
|
-
- Attack and step names join the host's id space under the pack-slug
|
|
31
|
-
|
|
32
|
-
silent dedupe.
|
|
33
|
-
- Exporting both a `run` and a `steps` chain on one attack: the host owns
|
|
34
|
-
that ruling (SPEC section 3: host-cherry-picks territory).
|
|
28
|
+
- Attack and step names join the host's id space under the pack-slug namespace (SPEC section 4). Collision at load = refuse to start, never silent dedupe.
|
|
29
|
+
- Exporting both a `run` and a `steps` chain on one attack: the host owns that ruling (SPEC section 3: host-cherry-picks territory).
|
|
35
30
|
|
|
36
31
|
## The authoritative contract is the host's
|
|
37
32
|
|
|
38
|
-
The full module-shape contract - what `ctx` carries, verdict semantics,
|
|
39
|
-
exit rules, ledger output - is **host-owned**. This page links to it rather
|
|
40
|
-
than copying it: doc drift is worse than indirection, ruled on crashtest#19
|
|
41
|
-
(the `register(ctx)` default-export shape in earlier drafts here was stale
|
|
42
|
-
and was deleted against the engine truth at `fc93ca6`).
|
|
33
|
+
The full module-shape contract - what `ctx` carries, verdict semantics, exit rules, ledger output - is **host-owned**. This page links to it rather than copying it: doc drift is worse than indirection, ruled on crashtest#19 (the `register(ctx)` default-export shape in earlier drafts here was stale and was deleted against the engine truth at `fc93ca6`).
|
|
43
34
|
|
|
44
|
-
**Authoritative reference:** [crashtest's scenario contract](https://github.com/dhaupin/crashtest/blob/main/docs/reference/scenario-contract.md)
|
|
45
|
-
(mirrored at [docs.creadev.org/crashtest/reference/scenario-contract](https://docs.creadev.org/crashtest/reference/scenario-contract)).
|
|
35
|
+
**Authoritative reference:** [crashtest's scenario contract](https://github.com/dhaupin/crashtest/blob/main/docs/reference/scenario-contract.md) (mirrored at [docs.creadev.org/crashtest/reference/scenario-contract](https://docs.creadev.org/crashtest/reference/scenario-contract)).
|
|
46
36
|
|
|
47
37
|
## What the spec guarantees anyway
|
|
48
38
|
|
|
49
39
|
Under any conforming host:
|
|
50
40
|
|
|
51
|
-
- the manifest that declares the entry - `pack.json` per SPEC section 2 -
|
|
52
|
-
|
|
53
|
-
- `armedByKey` presence is the arming ceremony's manifest surface: the host
|
|
54
|
-
MAY require an arming key before activation. Absent = the host's default
|
|
55
|
-
lifecycle governs;
|
|
41
|
+
- the manifest that declares the entry - `pack.json` per SPEC section 2 - is validated against the frozen v1 table before the entry ever imports;
|
|
42
|
+
- `armedByKey` presence is the arming ceremony's manifest surface: the host MAY require an arming key before activation. Absent = the host's default lifecycle governs;
|
|
56
43
|
- refusals are instant, one-line, and name the pack (SPEC section 5);
|
|
57
|
-
- load isolation is the host's job: hostile scenarios run against the
|
|
58
|
-
host's fake transport and opt-out postures, never a live target unless
|
|
59
|
-
the host's runbook arms it.
|
|
44
|
+
- load isolation is the host's job: hostile scenarios run against the host's fake transport and opt-out postures, never a live target unless the host's runbook arms it.
|