monoforge 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +72 -2
- package/bin/forge.mjs +98 -0
- package/package.json +56 -4
- package/packs/README.md +62 -0
- package/packs/public/forge-shapes/index.mjs +161 -0
- package/packs/public/forge-shapes/pack.json +13 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/.github/workflows/publish.yml +11 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/.monoforge-stamp.json +12 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/package.json +14 -0
- package/packs/public/forge-shapes/test/fixtures/clean/.github/workflows/publish.yml +12 -0
- package/packs/public/forge-shapes/test/fixtures/clean/.monoforge-stamp.json +12 -0
- package/packs/public/forge-shapes/test/fixtures/clean/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/clean/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/clean/package.json +14 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/.github/workflows/publish.yml +12 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/.monoforge-stamp.json +13 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/package.json +14 -0
- package/packs/public/forge-shapes/test/fixtures/token/.github/workflows/publish.yml +12 -0
- package/packs/public/forge-shapes/test/fixtures/token/.monoforge-stamp.json +12 -0
- package/packs/public/forge-shapes/test/fixtures/token/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/token/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/token/package.json +14 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/.github/workflows/publish.yml +12 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/.monoforge-stamp.json +12 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/package.json +14 -0
- package/packs/public/forge-shapes/test/run.mjs +67 -0
- package/spec/refusals.json +35 -0
- package/src/cut.mjs +244 -0
- package/src/doctor.mjs +253 -0
- package/src/fs-adapter.mjs +143 -0
- package/src/fs-node.mjs +15 -0
- package/src/harness.mjs +118 -0
- package/src/index.mjs +19 -0
- package/src/lint-packs.mjs +77 -0
- package/src/lock.mjs +37 -0
- package/src/packs.mjs +200 -0
- package/src/paths.mjs +48 -0
- package/src/refusals.mjs +45 -0
- package/src/sha256.mjs +61 -0
- package/src/stamp.mjs +215 -0
- package/src/templates.mjs +147 -0
- package/src/workers.mjs +16 -0
- package/templates/monoforge/AGENTS.md +30 -0
- package/templates/monoforge/CHANGELOG.md +19 -0
- package/templates/monoforge/DEPLOY.md +53 -0
- package/templates/monoforge/LICENSE +21 -0
- package/templates/monoforge/README.md +16 -0
- package/templates/monoforge/TEMPLATE.md +19 -0
- package/templates/monoforge/docs/Gemfile +5 -0
- package/templates/monoforge/docs/_config.yml +36 -0
- package/templates/monoforge/docs/_layouts/default.html +29 -0
- package/templates/monoforge/docs/assets/css/style.css +14 -0
- package/templates/monoforge/docs/freestruct.config.yml +7 -0
- package/templates/monoforge/docs/index.md +27 -0
- package/templates/monoforge/docs/search.md +28 -0
- package/templates/monoforge/functions/api/health.js +10 -0
- package/templates/monoforge/gitignore.tmpl +9 -0
- package/templates/monoforge/horcrux/HORCRUX.md +7 -0
- package/templates/monoforge/labs/.eyes/ledger.json +1 -0
- package/templates/monoforge/labs/.eyes/manifest.yml +5 -0
- package/templates/monoforge/labs/TASKS.md +11 -0
- package/templates/monoforge/scripts/build-docs.sh +12 -0
- package/templates/monoforge/scripts/check-docs-frontmatter.cjs +112 -0
- package/templates/monoforge/scripts/check-docs-links.cjs +81 -0
- package/templates/monoforge/scripts/check-docs-style.cjs +79 -0
- package/templates/monoforge/scripts/check-fiction-signatures.cjs +69 -0
- package/templates/monoforge/scripts/check-jekyll-filters.cjs +62 -0
- package/templates/monoforge/scripts/check-language.cjs +171 -0
- package/templates/monoforge/site/robots.txt +4 -0
- package/templates/monoforge/wrangler.toml +11 -0
- package/templates/monoforge-headless/.github/workflows/docs.yml +102 -0
- package/templates/monoforge-headless/.github/workflows/publish.yml +141 -0
- package/templates/monoforge-headless/.github/workflows/staging-ff-sync.yml +44 -0
- package/templates/monoforge-headless/.github/workflows/test.yml +21 -0
- package/templates/monoforge-headless/TEMPLATE.md +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dhaupin (Rook) / Creadev.org
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
-
#
|
|
1
|
+
# monoforge 1.0.0
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The struct-family factory: stamp a fleet repo from proven template blocks, doctor it for truth, lock it verifiably.
|
|
4
|
+
|
|
5
|
+
One law: **generated green is never shipped.** The stamp layer carries only what two proven instances already validated (poststruct + packstruct); the doctor runs the same truth battery the fleet reads (tests, docs gates, release ladder, dash law); unfilled `FORGE-TODO` slots are failures, not warnings, because a shipped placeholder is a shipped lie.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 1. config: create factory.json in an empty directory
|
|
11
|
+
monoforge new ./my-tool # stamps template blocks + fills tokens, never the truth
|
|
12
|
+
monoforge doctor ./my-tool # the truth battery (refuses FORGE-TODO, broken gates, dash law)
|
|
13
|
+
monoforge lock ./my-tool # doctor must pass, then archive + checksum
|
|
14
|
+
monoforge cut ./family # release cuts: components/<name>/ from a living lib per cutlist.json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
factory.json:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"name": "my-tool",
|
|
22
|
+
"species": "one-liner",
|
|
23
|
+
"pitch": "the one-line pitch",
|
|
24
|
+
"description": "the long form",
|
|
25
|
+
"siteDomain": "https://my-tool.creadev.org",
|
|
26
|
+
"version": "0.9.0",
|
|
27
|
+
"profile": "monoforge"
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`docsPath` defaults to `docs.creadev.org/<name>`. `profile` defaults to
|
|
32
|
+
`monoforge` (the full scaffold); set it to `monoforge-headless` to stamp only the
|
|
33
|
+
`.github/` battery - a repo that brings its own docs tree still inherits the
|
|
34
|
+
gates, the docs lane, and the release ladder. Profiles CHAIN (the coreforge
|
|
35
|
+
shape): `monoforge` composes `monoforge-headless` first, so the battery lives
|
|
36
|
+
once. `node src/templates.mjs --list` names the profiles;
|
|
37
|
+
`node src/templates.mjs --resolve <name>` prints the resolved file set.
|
|
38
|
+
|
|
39
|
+
Component families take a `scope` field (npm scope for the cut packages) plus a `cutlist.json` beside `factory.json`:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"source": "/path/to/the/living/lib",
|
|
44
|
+
"shortfall": ["lazies", "allowed", "to", "degrade"],
|
|
45
|
+
"packages": [
|
|
46
|
+
{ "name": "my-lib", "sources": ["my-lib.js"], "deps": ["primitives"] },
|
|
47
|
+
{ "name": "primitives", "sources": ["primitives.js"] }
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Every unmapped internal dependency refuses; shortfall lazies must be declared and ship as documented call-site degrades (each package README carries the list). The realized receipt: the creadev-lib generation-1 cut, 7 packages from the vant lib, in the mono PRD.
|
|
53
|
+
|
|
54
|
+
## What stamps, what does not
|
|
55
|
+
|
|
56
|
+
| Layer | monoforge carries it | Source of truth |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| Docs system (Jekyll + Pagefind + Freestruct + 6 gates) | template | two proven instances |
|
|
59
|
+
| Workflows (test, docs, publish 0.x refusal, staging ff-sync) | template | same |
|
|
60
|
+
| Release ladder + DEPLOY runbook shape | template | same |
|
|
61
|
+
| `FORGE-TODO` slots (README pitch, AGENTS core law, coverage list) | **author** | the tool itself |
|
|
62
|
+
| the core code, the check catalog, the spec | **author** | the tool itself |
|
|
63
|
+
|
|
64
|
+
The template blocks were extracted 2026-10-24 from the proven trees; they follow the poststruct and packstruct shape, with names tokenized.
|
|
65
|
+
|
|
66
|
+
## Status
|
|
67
|
+
|
|
68
|
+
This cut: stamp + doctor + lock all negative-tested (bad configs refused, stray dirs refused, unfilled slots flagged, filled trees pass). Manual npm ladder; 1.0.0 flips OIDC.
|
|
69
|
+
|
|
70
|
+
## Related
|
|
71
|
+
|
|
72
|
+
- [poststruct](https://github.com/dhaupin/poststruct) + [packstruct](https://github.com/dhaupin/packstruct): the proven instances the templates were extracted from
|
|
73
|
+
- **The workshop** → [Creadev.org](https://creadev.org) (monoforge is made by Rook @ Creadev.org - the same home as the docs and site surfaces above)
|
package/bin/forge.mjs
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bin/forge.mjs - monoforge: stamp / doctor / lock. Zero dependencies.
|
|
3
|
+
// Law: generated green is never shipped - the doctor refuses placeholder
|
|
4
|
+
// text, missing entries, and broken gates; the lock refuses a dirty tree.
|
|
5
|
+
import { resolve } from 'node:path'
|
|
6
|
+
import { readFileSync } from 'node:fs'
|
|
7
|
+
import '../src/fs-node.mjs' // install the node:fs storage adapter as the default
|
|
8
|
+
|
|
9
|
+
const Help = `monoforge - the struct-family factory
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
monoforge new <dir> stamp a fleet repo from factory.json (config in <dir>)
|
|
13
|
+
re-running over a stamped tree overlays only the
|
|
14
|
+
files still matching its receipt; host-edited
|
|
15
|
+
files are skipped by name, never clobbered
|
|
16
|
+
monoforge doctor [dir] run the truth battery (default: cwd)
|
|
17
|
+
monoforge cut [dir] cut a component-family workspace (cutlist.json + factory.json required)
|
|
18
|
+
monoforge lock [dir] doctor, then archive with a checksum
|
|
19
|
+
monoforge lint-packs packstruct lint over the repo's own install (the factory's own packs)
|
|
20
|
+
monoforge packs [dir] run the check-profile packs over a tree (default: this repo)
|
|
21
|
+
monoforge loader <dir> load the packs under <dir> (the packstruct SPEC loader)
|
|
22
|
+
monoforge harness <verb> <dir> [--grant kind:scope]
|
|
23
|
+
the headless stamp harness (monoforge#23): drive
|
|
24
|
+
new|doctor|lock in-process and print the structured
|
|
25
|
+
result { verb, ok, verdicts, refusals, grant, receipt }
|
|
26
|
+
monoforge help this
|
|
27
|
+
|
|
28
|
+
factory.json (in <dir>, required):
|
|
29
|
+
{ "name": "kebab-name", "species": "one-liner", "pitch": "the one-line pitch",
|
|
30
|
+
"description": "the long form", "siteDomain": "https://x.creadev.org",
|
|
31
|
+
"docsPath": "docs.creadev.org/x (optional, defaults to that)",
|
|
32
|
+
"version": "0.9.0 (optional)" }
|
|
33
|
+
`
|
|
34
|
+
const [cmd, arg1, arg2] = process.argv.slice(2)
|
|
35
|
+
const dir = resolve(arg2 || arg1 || '.')
|
|
36
|
+
const show = (r) => { console.log(JSON.stringify(r, null, 2)); process.exit(r.ok ? 0 : 1) }
|
|
37
|
+
|
|
38
|
+
if (!cmd || cmd === 'help' || cmd === '--help') { console.log(Help); process.exit(0) }
|
|
39
|
+
// The version truth is package.json (the family rule, flowforge#28): the
|
|
40
|
+
// publish lane's verify job probes the INSTALLED bin with --version, and
|
|
41
|
+
// this is the bare global it answers.
|
|
42
|
+
if (cmd === '--version') { console.log(JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version); process.exit(0) }
|
|
43
|
+
if (cmd === 'new') {
|
|
44
|
+
const stamp = (await import('../src/stamp.mjs')).default
|
|
45
|
+
show(await stamp(resolve(process.argv[3] || '.')))
|
|
46
|
+
} else if (cmd === 'doctor') {
|
|
47
|
+
const doctor = (await import('../src/doctor.mjs')).default
|
|
48
|
+
const r = await doctor(dir)
|
|
49
|
+
for (const f of r.findings) console.log(`${f.level.toUpperCase()} ${f.id}: ${f.message}`)
|
|
50
|
+
console.log(`doctor: ${r.counts.fail} fail(s), ${r.counts.warn} warn(s) - ${r.ok ? 'PASS' : 'FAIL'}`)
|
|
51
|
+
process.exit(r.ok ? 0 : 1)
|
|
52
|
+
} else if (cmd === 'cut') {
|
|
53
|
+
const cut = (await import('../src/cut.mjs')).default
|
|
54
|
+
const r = await cut((await import('node:path')).resolve(process.argv[3] || '.'))
|
|
55
|
+
console.log(`cut: OK (${r.packages} packages from rev ${r.sourceRev.slice(0, 7)}) stamped ${r.files} files into ${r.dir}/`)
|
|
56
|
+
process.exit(0)
|
|
57
|
+
} else if (cmd === 'lock') {
|
|
58
|
+
const lock = (await import('../src/lock.mjs')).default
|
|
59
|
+
const r = await lock(dir)
|
|
60
|
+
if (!r.ok) { console.error(`lock: ${r.error}`); if (r.doctor) { for (const f of r.doctor.findings) console.log(` ${f.level.toUpperCase()} ${f.id}: ${f.message}`) } process.exit(1) }
|
|
61
|
+
console.log(`lock: OK (sha256 ${r.sha}...) archived ${r.archive}`)
|
|
62
|
+
process.exit(0)
|
|
63
|
+
} else if (cmd === 'harness') {
|
|
64
|
+
// The headless stamp harness (monoforge#23): the same verbs as an
|
|
65
|
+
// in-process, structured surface, so railyard's door drives the stamp loop
|
|
66
|
+
// and reads typed refusals (registered in spec/refusals.json) instead of
|
|
67
|
+
// prose. --grant kind:scope echoes the grant row for the audit ledger.
|
|
68
|
+
const { run } = await import('../src/harness.mjs')
|
|
69
|
+
const verb = process.argv[3] || 'doctor'
|
|
70
|
+
const target = resolve(process.argv[4] || '.')
|
|
71
|
+
const gi = process.argv.indexOf('--grant')
|
|
72
|
+
let grant = null
|
|
73
|
+
if (gi >= 0 && process.argv[gi + 1]) {
|
|
74
|
+
const [kind, ...rest] = process.argv[gi + 1].split(':')
|
|
75
|
+
grant = { kind, scope: rest.join(':') }
|
|
76
|
+
}
|
|
77
|
+
const r = await run(verb, target, { grant })
|
|
78
|
+
console.log(JSON.stringify(r, null, 2))
|
|
79
|
+
process.exit(r.ok ? 0 : 1)
|
|
80
|
+
} else if (cmd === 'packs') {
|
|
81
|
+
// The factory's own pack lane (monoforge#3): load packs/public, arm each with
|
|
82
|
+
// a read-only view of the tree, run it, print verdict rows. EXPLOITED fails.
|
|
83
|
+
const { spawnSync } = await import('node:child_process')
|
|
84
|
+
const r = spawnSync(process.execPath, [resolve(import.meta.dirname, '../scripts/run-packs.mjs'), ...process.argv.slice(3)], { stdio: 'inherit' })
|
|
85
|
+
process.exit(r.status ?? 1)
|
|
86
|
+
} else if (cmd === 'loader') {
|
|
87
|
+
const { runLoader } = await import('../src/packs.mjs')
|
|
88
|
+
process.exit(await runLoader(process.argv.slice(3)))
|
|
89
|
+
} else if (cmd === 'lint-packs') {
|
|
90
|
+
// The pack lint lane as a discoverable verb (mirrors crashtest's
|
|
91
|
+
// lint-packs, issue #32): ready now, honest exit 2 until the factory's
|
|
92
|
+
// own packs + packstruct devDep land - never a silent skip.
|
|
93
|
+
const { runLintPacks } = await import('../src/lint-packs.mjs')
|
|
94
|
+
process.exit(runLintPacks({ argv: process.argv.slice(3), cwd: process.cwd(), json: process.argv.includes('--json') }))
|
|
95
|
+
} else {
|
|
96
|
+
console.log(Help)
|
|
97
|
+
process.exit(2)
|
|
98
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monoforge",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The struct-family factory: stamps a new fleet repo from proven template blocks, doctors it for truth, and locks it. Generated green is never shipped: the doctor refuses placeholder text and unverified gates.\n",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"monoforge": "bin/forge.mjs"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.mjs",
|
|
11
|
+
"./workers": "./src/workers.mjs",
|
|
12
|
+
"./harness": "./src/harness.mjs",
|
|
13
|
+
"./packs": "./src/packs.mjs"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"bin/",
|
|
17
|
+
"src/",
|
|
18
|
+
"templates/",
|
|
19
|
+
"spec/",
|
|
20
|
+
"packs/"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "node test/run.mjs && node test/version-truth.mjs && node test/distribution-run.mjs && node --test test/templates.test.cjs test/workers-compat.test.mjs test/harness.test.mjs test/packs.test.mjs test/ship-from-download.test.cjs test/release-verify.test.cjs test/docs-frontmatter.test.cjs test/web-imports.test.cjs test/status.test.mjs",
|
|
24
|
+
"lint:packs": "node bin/forge.mjs lint-packs --deep",
|
|
25
|
+
"conform:packs": "packstruct audit-conformance . --loader \"node src/packs.mjs {packs}\"",
|
|
26
|
+
"packs": "node scripts/run-packs.mjs",
|
|
27
|
+
"lint:docs": "node scripts/check-docs-frontmatter.cjs && node scripts/check-docs-links.cjs && node scripts/check-docs-style.cjs && node scripts/check-fiction-signatures.cjs && node scripts/check-jekyll-filters.cjs",
|
|
28
|
+
"lint:language": "node scripts/check-language.cjs",
|
|
29
|
+
"check": "npm test && npm run lint:docs && npm run lint:language && npm run lint:packs && npm run conform:packs && npm run packs",
|
|
30
|
+
"prepublishOnly": "npm run check",
|
|
31
|
+
"icons:adopt": "node scripts/adopt-icons.mjs"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"eyestruct": "1.0.0",
|
|
35
|
+
"packstruct": "1.0.0",
|
|
36
|
+
"crashtest": "1.1.0"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"scaffold",
|
|
43
|
+
"generator",
|
|
44
|
+
"factory",
|
|
45
|
+
"ci",
|
|
46
|
+
"struct-family",
|
|
47
|
+
"creadev"
|
|
48
|
+
],
|
|
49
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/dhaupin/monoforge.git"
|
|
53
|
+
},
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/dhaupin/monoforge/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/dhaupin/monoforge#readme"
|
|
58
|
+
}
|
package/packs/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# packs/ - the factory's own check packs
|
|
2
|
+
|
|
3
|
+
This directory is monoforge's home for [**packstruct**](https://packstruct.creadev.org)
|
|
4
|
+
packs, in the family's two-seam split:
|
|
5
|
+
|
|
6
|
+
- **files** travel as an **artifact** (our `lock`: a `.tar.gz` + sha256 with a
|
|
7
|
+
manifest inside)
|
|
8
|
+
- **judgment** travels as a **pack** (packstruct SPEC v1, `check` profile:
|
|
9
|
+
`{ checks: [...] }`, pure reading over a tree)
|
|
10
|
+
|
|
11
|
+
A pack is a `pack.json` manifest plus the entry module it names. SPEC v1 has no
|
|
12
|
+
field for files to write, so a pack can only ever READ a tree - which is exactly
|
|
13
|
+
the doctor's lane. That is why the factory's portable judgment lives here and its
|
|
14
|
+
file-copying lives in `templates/`.
|
|
15
|
+
|
|
16
|
+
## The two visibility folders
|
|
17
|
+
|
|
18
|
+
- `packs/public/` - tracked, reusable across targets. A pack that names its
|
|
19
|
+
target's vocabulary takes it through `ctx`, so another repo can adopt the pack
|
|
20
|
+
without editing it.
|
|
21
|
+
- `packs/local/` - gitignored, machine-private. Not used here.
|
|
22
|
+
|
|
23
|
+
## Run it
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run lint:packs # packstruct lint packs --deep (manifest + entry shape)
|
|
27
|
+
npm run conform:packs # the spec's own loader harness (8/8 required)
|
|
28
|
+
npm run packs # run every pack over THIS repo, print the verdict rows
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
All three ride `npm run check`. `npm run packs` fails on a NEW `EXPLOITED`
|
|
32
|
+
verdict; a `BOUNDED` row never reads as green but does not fail the lane.
|
|
33
|
+
|
|
34
|
+
## The pack(s) in this repo
|
|
35
|
+
|
|
36
|
+
### `forge-shapes` - the stamped-tree checks
|
|
37
|
+
|
|
38
|
+
Six pure-reading checks over a tree the factory stamped:
|
|
39
|
+
|
|
40
|
+
| Check | What it proves |
|
|
41
|
+
|---|---|
|
|
42
|
+
| `forge/receipt-present` | the receipt ships and parses (identity + file list) |
|
|
43
|
+
| `forge/receipt-files-exist` | every file the receipt claims is on disk |
|
|
44
|
+
| `forge/truth-slot-clean` | no `FORGE-TODO` truth slot survived the stamp |
|
|
45
|
+
| `forge/stamp-token-clean` | no raw `__TOKEN__` survived the stamp |
|
|
46
|
+
| `forge/package-paths` | every `package.json` bin/exports/files entry resolves |
|
|
47
|
+
| `forge/publish-gate` | `publish.yml` refuses 0.x and carries no publish token |
|
|
48
|
+
|
|
49
|
+
Verdict taxonomy (family): `PASSED` / `BOUNDED` / `EXPLOITED`. The pack ships
|
|
50
|
+
`test/fixtures/` proving each verdict both ways (SPEC section 4); its self-audit
|
|
51
|
+
runs in `test/packs.test.mjs`.
|
|
52
|
+
|
|
53
|
+
## The loader
|
|
54
|
+
|
|
55
|
+
`src/packs.mjs` is the loader the spec's own harness grades:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx packstruct audit-conformance . --loader "node src/packs.mjs {packs}"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Every refusal is instant, one-line, and names the pack (SPEC section 5). Exit 0
|
|
62
|
+
conforming / 1 violations / 2 usage.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// forge-shapes - the check-profile pack over a monoforge-stamped tree
|
|
2
|
+
// (monoforge#3). Pure reads: it opens the receipt and the files the receipt
|
|
3
|
+
// names, and reports what it finds. Zero network, zero writes.
|
|
4
|
+
//
|
|
5
|
+
// Why a pack when the doctor already checks this: the doctor is monoforge's
|
|
6
|
+
// own inline catalog, hard-wired to the factory. A pack is the PORTABLE
|
|
7
|
+
// judgment - the same claims, re-runnable by any host that loads it, against
|
|
8
|
+
// any stamped tree. The two are twins on purpose; the pack is the one that
|
|
9
|
+
// travels.
|
|
10
|
+
//
|
|
11
|
+
// THE CONTRACT with the target (ctx.forgeTree):
|
|
12
|
+
// root -> absolute path to the stamped tree, or null (the
|
|
13
|
+
// pack then dockets one BOUNDED row and audits
|
|
14
|
+
// nothing - an absent target is never a pass)
|
|
15
|
+
// exists(rel) -> boolean
|
|
16
|
+
// text(rel) -> string | null
|
|
17
|
+
//
|
|
18
|
+
// Verdict taxonomy (family): PASSED / BOUNDED / EXPLOITED. BOUNDED never
|
|
19
|
+
// reads as green.
|
|
20
|
+
|
|
21
|
+
export const PKG = 'packs/public/forge-shapes'
|
|
22
|
+
export const REQUIRED_KEYS = ['forgeTree']
|
|
23
|
+
|
|
24
|
+
const PACK = 'forge-shapes'
|
|
25
|
+
const TODO_MARK = 'FORGE-TODO'
|
|
26
|
+
|
|
27
|
+
class Verdicts {
|
|
28
|
+
constructor() { this.rows = [] }
|
|
29
|
+
passed(id, detail) { this.rows.push({ pack: PACK, id, verdict: 'PASSED', detail: String(detail || '').slice(0, 220) }) }
|
|
30
|
+
bounded(id, bound, detail) { this.rows.push({ pack: PACK, id, verdict: 'BOUNDED', bound, detail: String(detail || '').slice(0, 220) }) }
|
|
31
|
+
failed(id, fault) { this.rows.push({ pack: PACK, id, verdict: 'EXPLOITED', detail: String(fault.problem || JSON.stringify(fault)).slice(0, 220), fault }) }
|
|
32
|
+
get ok() { return !this.rows.some((r) => r.verdict === 'EXPLOITED') }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function take(ctx, key) {
|
|
36
|
+
const value = ctx?.[key]
|
|
37
|
+
if (value === undefined) throw new TypeError(`${PKG}: ctx[${JSON.stringify(key)}] is missing - the runner did not arm the ${key} contract`)
|
|
38
|
+
return value
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// The check ids this pack declares (SPEC section 7 census; the check profile's
|
|
42
|
+
// `checks[]`). Kept in sync with the run() bodies below - a drift here is a
|
|
43
|
+
// missing id, caught by the pack's own fixtures.
|
|
44
|
+
export const checks = [
|
|
45
|
+
{ id: 'forge/receipt-present' },
|
|
46
|
+
{ id: 'forge/receipt-files-exist' },
|
|
47
|
+
{ id: 'forge/truth-slot-clean' },
|
|
48
|
+
{ id: 'forge/stamp-token-clean' },
|
|
49
|
+
{ id: 'forge/package-paths' },
|
|
50
|
+
{ id: 'forge/publish-gate' },
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
export function run(ctx) {
|
|
54
|
+
for (const key of REQUIRED_KEYS) take(ctx, key)
|
|
55
|
+
const v = new Verdicts()
|
|
56
|
+
const tree = ctx.forgeTree
|
|
57
|
+
|
|
58
|
+
if (!tree || tree.root == null) {
|
|
59
|
+
v.bounded('forge/receipt-present', 'target-tree-absent', 'no stamped tree armed (set FORGE_TREE) - nothing was audited, nothing was passed')
|
|
60
|
+
return { ok: v.ok, rows: v.rows }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// --- receipt-present: the receipt ships and parses ---
|
|
64
|
+
const raw = tree.text('.monoforge-stamp.json')
|
|
65
|
+
if (raw == null) {
|
|
66
|
+
v.failed('forge/receipt-present', { problem: 'no .monoforge-stamp.json - the tree carries no stamp receipt, so nothing here proves it was minted by the factory' })
|
|
67
|
+
return { ok: v.ok, rows: v.rows }
|
|
68
|
+
}
|
|
69
|
+
let receipt
|
|
70
|
+
try {
|
|
71
|
+
receipt = JSON.parse(raw)
|
|
72
|
+
} catch (err) {
|
|
73
|
+
v.failed('forge/receipt-present', { problem: `.monoforge-stamp.json is unparseable: ${err.message}` })
|
|
74
|
+
return { ok: v.ok, rows: v.rows }
|
|
75
|
+
}
|
|
76
|
+
const files = Array.isArray(receipt.files) ? receipt.files : []
|
|
77
|
+
if (!receipt.name || !files.length) {
|
|
78
|
+
v.failed('forge/receipt-present', { problem: `receipt is missing its identity or file list (name=${JSON.stringify(receipt.name)}, files=${files.length})` })
|
|
79
|
+
return { ok: v.ok, rows: v.rows }
|
|
80
|
+
}
|
|
81
|
+
v.passed('forge/receipt-present', `receipt for "${receipt.name}" lists ${files.length} file(s)`)
|
|
82
|
+
|
|
83
|
+
// --- receipt-files-exist: every file the receipt claims is on disk ---
|
|
84
|
+
const missing = files.filter((f) => !tree.exists(f))
|
|
85
|
+
if (missing.length) {
|
|
86
|
+
v.failed('forge/receipt-files-exist', { problem: 'the receipt claims files that do not ship - a receipt is a promise about bytes', missing })
|
|
87
|
+
} else {
|
|
88
|
+
v.passed('forge/receipt-files-exist', `all ${files.length} receipted file(s) exist`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// --- truth-slot-clean / stamp-token-clean: the shipped-placeholder law ---
|
|
92
|
+
const todoFiles = []
|
|
93
|
+
const tokenFiles = []
|
|
94
|
+
for (const rel of files) {
|
|
95
|
+
const text = tree.text(rel)
|
|
96
|
+
if (text == null) continue
|
|
97
|
+
const n = (text.match(new RegExp(TODO_MARK, 'g')) || []).length
|
|
98
|
+
if (n) todoFiles.push({ file: rel, count: n })
|
|
99
|
+
const rawTokens = text.match(/__[A-Z][A-Z0-9_]*__/g) || []
|
|
100
|
+
if (rawTokens.length) tokenFiles.push({ file: rel, tokens: [...new Set(rawTokens)] })
|
|
101
|
+
}
|
|
102
|
+
if (todoFiles.length) {
|
|
103
|
+
v.failed('forge/truth-slot-clean', { problem: 'a receipted file still carries a FORGE-TODO truth slot - a shipped placeholder is a shipped lie', files: todoFiles })
|
|
104
|
+
} else {
|
|
105
|
+
v.passed('forge/truth-slot-clean', `${files.length} receipted file(s): no unfilled FORGE-TODO slot`)
|
|
106
|
+
}
|
|
107
|
+
if (tokenFiles.length) {
|
|
108
|
+
v.failed('forge/stamp-token-clean', { problem: 'a receipted file still carries a raw __TOKEN__ - the stamp never finished', files: tokenFiles })
|
|
109
|
+
} else {
|
|
110
|
+
v.passed('forge/stamp-token-clean', `${files.length} receipted file(s): no raw stamp token survived`)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// --- package-paths: bin / exports / files entries all resolve ---
|
|
114
|
+
const pkgRaw = tree.text('package.json')
|
|
115
|
+
if (pkgRaw == null) {
|
|
116
|
+
v.bounded('forge/package-paths', 'package-json-absent', 'no package.json in the tree - this check cannot fire, so it does not pass')
|
|
117
|
+
} else {
|
|
118
|
+
let pkg
|
|
119
|
+
try { pkg = JSON.parse(pkgRaw) } catch (err) {
|
|
120
|
+
v.failed('forge/package-paths', { problem: `package.json is unparseable: ${err.message}` })
|
|
121
|
+
pkg = null
|
|
122
|
+
}
|
|
123
|
+
if (pkg) {
|
|
124
|
+
const broken = []
|
|
125
|
+
for (const [name, b] of Object.entries(pkg.bin || {})) if (!tree.exists(b)) broken.push({ key: `bin.${name}`, path: b })
|
|
126
|
+
for (const [key, val] of Object.entries(pkg.exports || {})) {
|
|
127
|
+
const p = typeof val === 'string' ? val : val?.import
|
|
128
|
+
if (p && !p.includes('*') && !tree.exists(p)) broken.push({ key: `exports.${key}`, path: p })
|
|
129
|
+
}
|
|
130
|
+
for (const f of pkg.files || []) {
|
|
131
|
+
if (f.startsWith('!') || f.includes('*')) continue
|
|
132
|
+
if (!tree.exists(f)) broken.push({ key: 'files', path: f })
|
|
133
|
+
}
|
|
134
|
+
if (broken.length) v.failed('forge/package-paths', { problem: 'a package.json bin/exports/files entry does not resolve (the crashtest#16 class)', broken })
|
|
135
|
+
else v.passed('forge/package-paths', 'every bin/exports/files entry resolves')
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// --- publish-gate: 0.x refusal present, no publish token ---
|
|
140
|
+
const pub = tree.text('.github/workflows/publish.yml')
|
|
141
|
+
if (pub == null) {
|
|
142
|
+
v.bounded('forge/publish-gate', 'publish-workflow-absent', 'no .github/workflows/publish.yml - a tree without a publish lane has no gate to grade')
|
|
143
|
+
} else {
|
|
144
|
+
const refusesZero = /startsWith\(['"]v0\.|0\.\*\)/.test(pub)
|
|
145
|
+
const codeLines = pub.split('\n').filter((l) => !/^\s*#/.test(l)).join('\n')
|
|
146
|
+
const hasToken = /secrets\.NPM_TOKEN|NODE_AUTH_TOKEN/.test(codeLines)
|
|
147
|
+
if (!refusesZero || hasToken) {
|
|
148
|
+
v.failed('forge/publish-gate', {
|
|
149
|
+
problem: 'the publish workflow does not refuse 0.x refs, or references a publish token (the family law is OIDC trusted publishing only)',
|
|
150
|
+
refusesZero,
|
|
151
|
+
hasToken,
|
|
152
|
+
})
|
|
153
|
+
} else {
|
|
154
|
+
v.passed('forge/publish-gate', 'publish.yml refuses 0.x refs and carries no publish token')
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return { ok: v.ok, rows: v.rows }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export default { checks, run, PKG, REQUIRED_KEYS }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"name": "forge-shapes",
|
|
4
|
+
"description": "File checks over a monoforge-stamped tree: the receipt ships and parses, every file the receipt claims exists, the truth-slot law holds (no FORGE-TODO, no raw __TOKEN__ survives), the package.json bin/exports/files entries all resolve, the publish workflow refuses 0.x refs and carries no publish token, and the docs gates the tree ships actually pass. Pure reads over a tree - zero network, zero writes.",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"entry": "index.mjs",
|
|
7
|
+
"env": {
|
|
8
|
+
"fs": {
|
|
9
|
+
"targets": [".monoforge-stamp.json", "package.json", ".github/workflows/publish.yml", "docs/**/*.md"]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"implements": "packstruct@1"
|
|
13
|
+
}
|