@runeditrun/rer 0.2.108 → 0.2.109
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/cli/contract-status.mjs +28 -0
- package/global/CHANGELOG.md +9 -0
- package/package.json +1 -1
package/cli/contract-status.mjs
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
// `rer check` on a seed's CONTRACT.md: the Status table parses, and every
|
|
2
2
|
// evidence path it cites is in the checkout. A seed without CONTRACT.md has
|
|
3
3
|
// nothing to check here.
|
|
4
|
+
//
|
|
5
|
+
// One exception, and only in a managed copy: the platform installs a published
|
|
6
|
+
// release without the publisher's repository automation (everything under
|
|
7
|
+
// `.github/workflows`, plus `.github/dependabot.yml`), so an evidence path in
|
|
8
|
+
// that set cannot be in the copy. A checkout is a managed copy only when it
|
|
9
|
+
// carries the platform's committed release record, `rer-upstream.json`, exactly
|
|
10
|
+
// as the platform writes it (a regular file, schema 1, and exactly the keys
|
|
11
|
+
// repository, tag and commit). Every other path stays a hard check there, and
|
|
12
|
+
// an authoring checkout checks everything.
|
|
4
13
|
import { lstat, readFile } from 'node:fs/promises';
|
|
5
14
|
import { isAbsolute, join, normalize, sep } from 'node:path';
|
|
6
15
|
import { ContractError, parseContract } from '../foundation/runtime/seed-contract.mjs';
|
|
7
16
|
|
|
8
17
|
const file = 'CONTRACT.md';
|
|
18
|
+
const releaseRecord = 'rer-upstream.json';
|
|
19
|
+
const automation = /^\.github\/(?:workflows(?:\/|$)|dependabot\.ya?ml$)/;
|
|
20
|
+
|
|
21
|
+
async function isManagedCopy(root) {
|
|
22
|
+
try {
|
|
23
|
+
const path = join(root, releaseRecord);
|
|
24
|
+
const stat = await lstat(path);
|
|
25
|
+
if (!stat.isFile() || stat.size > 4096) return false;
|
|
26
|
+
const value = JSON.parse(await readFile(path, 'utf8'));
|
|
27
|
+
return !!value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).sort().join(',') === 'commit,repository,schema,tag'
|
|
28
|
+
&& value.schema === 1 && /^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9._-]{1,100}$/.test(value.repository)
|
|
29
|
+
&& /^v?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(value.tag) && /^[a-f0-9]{40}$/i.test(value.commit);
|
|
30
|
+
} catch { return false; }
|
|
31
|
+
}
|
|
9
32
|
|
|
10
33
|
export async function contractStatusClauses(root) {
|
|
11
34
|
let text;
|
|
@@ -16,8 +39,13 @@ export async function contractStatusClauses(root) {
|
|
|
16
39
|
return error.problems.map(problem => ({ id: 'CONTRACT.status', ok: false, message: `${file}:${problem.line}: ${problem.message}` }));
|
|
17
40
|
}
|
|
18
41
|
const clauses = [{ id: 'CONTRACT.status', ok: true }];
|
|
42
|
+
const managed = await isManagedCopy(root);
|
|
19
43
|
for (const clause of contract.clauses) for (const path of clause.evidence) {
|
|
20
44
|
const inside = !isAbsolute(path) && !normalize(path).split(sep).includes('..');
|
|
45
|
+
if (managed && inside && automation.test(normalize(path).split(sep).join('/'))) {
|
|
46
|
+
clauses.push({ id: `CONTRACT.evidence.${clause.id}`, ok: true, message: `${file}:${clause.row}: ${clause.id} evidence ${path} is publisher repository automation, skipped in a managed copy.` });
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
21
49
|
let exists = false;
|
|
22
50
|
if (inside) try { await lstat(join(root, path)); exists = true; } catch {}
|
|
23
51
|
clauses.push({ id: `CONTRACT.evidence.${clause.id}`, ok: exists, ...(!exists ? { message: `${file}:${clause.row}: ${clause.id} is ${clause.status} with evidence ${path}, which ${inside ? 'is not in this checkout' : 'is outside this repository'}.` } : {}) });
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.109
|
|
4
|
+
|
|
5
|
+
### `rer check` in a managed copy
|
|
6
|
+
|
|
7
|
+
- `rer check` no longer fails a managed copy for contract evidence it never carries. A managed copy is installed without the publisher's repository automation, so a `CONTRACT.md` clause citing a file under `.github/workflows/` or `.github/dependabot.yml` failed `CONTRACT.evidence.<ID>` with "is not in this checkout" (a first managed build of an installed seed failed this way on a workflow file). Those evidence paths are now skipped: the clause passes and its message says the path is publisher repository automation, skipped in a managed copy.
|
|
8
|
+
- The skip applies only when the checkout is positively a managed copy: it carries the platform's `rer-upstream.json` release record exactly as written (a regular file of at most 4 KiB, schema 1, with exactly the keys `repository`, `tag` and `commit`, each well-formed). The platform writes that record only when the installed source commit is a published release, so a managed copy installed from an untagged commit has no record and keeps the hard existence check for every evidence path. Every other evidence path in a managed copy, and every path in an authoring checkout (no record), stays a hard check as before.
|
|
9
|
+
- The seed command contract (`SEED-COMMAND-CONTRACT.md`, in the default seed and the export) describes the rule.
|
|
10
|
+
- Code only: no migration is added. A seed gets this by adopting 0.2.109; nothing here is live in any deployed seed until that seed adopts and deploys it.
|
|
11
|
+
|
|
3
12
|
## 0.2.108
|
|
4
13
|
|
|
5
14
|
### Installer PATH step
|