@mago-foundation/mago-ski 0.4.0 → 0.5.0-beta.1

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.
Files changed (59) hide show
  1. package/README.md +5 -3
  2. package/action.yml +21 -2
  3. package/dist/hosts/github/check.d.ts +21 -0
  4. package/dist/hosts/github/check.js +124 -0
  5. package/dist/hosts/github/publish.d.ts +7 -0
  6. package/dist/hosts/github/publish.js +52 -0
  7. package/dist/hosts/github/run.d.ts +12 -0
  8. package/dist/hosts/github/run.js +32 -18
  9. package/dist/hosts/pi/index.js +40 -18
  10. package/dist/src/admin.d.ts +2 -1
  11. package/dist/src/admin.js +3 -2
  12. package/dist/src/admission-evidence.d.ts +15 -0
  13. package/dist/src/admission-evidence.js +48 -0
  14. package/dist/src/admission.d.ts +102 -0
  15. package/dist/src/admission.js +316 -0
  16. package/dist/src/canonical-json.d.ts +6 -0
  17. package/dist/src/canonical-json.js +11 -0
  18. package/dist/src/cli.d.ts +2 -0
  19. package/dist/src/cli.js +229 -5
  20. package/dist/src/diff.d.ts +9 -0
  21. package/dist/src/diff.js +3 -2
  22. package/dist/src/dsse.js +2 -2
  23. package/dist/src/experimental/sigstore.d.ts +30 -0
  24. package/dist/src/experimental/sigstore.js +35 -5
  25. package/dist/src/fs-safe.d.ts +15 -2
  26. package/dist/src/fs-safe.js +68 -50
  27. package/dist/src/gate/adapters/claude-code.js +8 -5
  28. package/dist/src/gate/adapters/codex.js +5 -6
  29. package/dist/src/gate/generations.js +2 -0
  30. package/dist/src/gate/instance.js +7 -7
  31. package/dist/src/gate/proc.d.ts +6 -0
  32. package/dist/src/gate/proc.js +14 -3
  33. package/dist/src/gate/service.js +3 -0
  34. package/dist/src/gate/setup.d.ts +5 -5
  35. package/dist/src/gate/setup.js +128 -88
  36. package/dist/src/policy.d.ts +7 -0
  37. package/dist/src/policy.js +19 -2
  38. package/dist/src/profile.d.ts +34 -0
  39. package/dist/src/profile.js +182 -0
  40. package/dist/src/published-by.d.ts +64 -0
  41. package/dist/src/published-by.js +227 -0
  42. package/dist/src/recovery-admin.js +7 -4
  43. package/dist/src/root-events.d.ts +2 -0
  44. package/dist/src/root-events.js +61 -4
  45. package/dist/src/tree-digest.d.ts +6 -0
  46. package/dist/src/tree-digest.js +8 -0
  47. package/dist/src/usf-check.d.ts +28 -0
  48. package/dist/src/usf-check.js +128 -0
  49. package/dist/src/usf.d.ts +48 -0
  50. package/dist/src/usf.js +238 -0
  51. package/docs/hosts/publish.md +65 -0
  52. package/docs/hosts/skill-check.md +91 -0
  53. package/docs/spec/admission-v0.md +84 -0
  54. package/docs/spec/gui-admin-rack-v1.md +1 -1
  55. package/docs/spec/observed-profile-v1.md +51 -0
  56. package/docs/spec/root-recovery-v1.md +3 -2
  57. package/docs/spec/trust-documents-v1.md +1 -1
  58. package/docs/threat-model.md +12 -0
  59. package/package.json +5 -1
@@ -0,0 +1,48 @@
1
+ export declare const USF_FORMAT = "owasp.usf/v1.0";
2
+ /** Frontmatter larger than this is not read. */
3
+ export declare const MAX_FRONTMATTER_BYTES: number;
4
+ export interface UsfManifest {
5
+ files: {
6
+ read: string[];
7
+ write: string[];
8
+ deny_write: string[];
9
+ };
10
+ network: {
11
+ allow: string[];
12
+ deny: string | null;
13
+ };
14
+ shell: boolean | null;
15
+ tools: string[];
16
+ requires: {
17
+ binaries: string[];
18
+ min_runtime_version: string | null;
19
+ };
20
+ /** Keys this reader does not know; they are listed, not enforced. */
21
+ unknownKeys: string[];
22
+ }
23
+ export interface UsfReading {
24
+ /** The declaration, when the frontmatter has a `permissions` block that reads the same under YAML 1.1 and 1.2. */
25
+ manifest: UsfManifest | null;
26
+ /** Whether the frontmatter has a `permissions` key at all. */
27
+ declared: boolean;
28
+ /** Why the frontmatter or the declaration could not be read; null when it could. */
29
+ error: string | null;
30
+ /** Fields whose YAML 1.1 and YAML 1.2 readings differ. */
31
+ ambiguous: string[];
32
+ }
33
+ export declare class UsfError extends Error {
34
+ }
35
+ /**
36
+ * The frontmatter text between the opening and the closing `---`, or null when SKILL.md has none.
37
+ * Lines end at LF or CRLF, as in the Markdown frontmatter convention hosts follow.
38
+ */
39
+ export declare function frontmatter(skillMd: string): string | null;
40
+ /** A `network.allow` entry: a host name, `*.` plus a host name (its subdomains), a bracketed IPv6 address, or `*` (any host). */
41
+ export declare function normalizeHostEntry(entry: string): string;
42
+ /**
43
+ * Reads the USF declaration from SKILL.md. Never throws on Skill content: a Skill without frontmatter, with
44
+ * frontmatter that is not YAML, or without a `permissions` block simply has no declaration, and `error` says why.
45
+ */
46
+ export declare function readUsf(skillMd: string): UsfReading;
47
+ /** Whether a declared `network.allow` list covers a host found in the Skill's files. */
48
+ export declare function hostAllowed(allow: readonly string[], host: string): boolean;
@@ -0,0 +1,238 @@
1
+ // OWASP Universal Skill Format (USF) v1.0: the optional `permissions` and `requires` blocks of a SKILL.md frontmatter.
2
+ // Real Skills write ordinary YAML, so the frontmatter is read with a full YAML parser. Readers disagree on some plain
3
+ // values (YAML 1.1, used by PyYAML, reads `yes`, `on` and dates as non-text; YAML 1.2 does not), so the declaration is
4
+ // read under both rules, and a field whose two readings differ is reported as ambiguous instead of being guessed.
5
+ import { CST, Lexer, parseDocument } from 'yaml';
6
+ export const USF_FORMAT = 'owasp.usf/v1.0';
7
+ /** Frontmatter larger than this is not read. */
8
+ export const MAX_FRONTMATTER_BYTES = 64 * 1024;
9
+ const MAX_ALIASES = 50;
10
+ /** Real frontmatter has tens of keys; the YAML parser's cost grows faster than linearly with thousands. */
11
+ const MAX_KEYS = 2_000;
12
+ const MAX_HOST_CHARS = 253;
13
+ export class UsfError extends Error {
14
+ }
15
+ const hostPattern = /^(?:\*\.)?[a-z0-9-]+(?:\.[a-z0-9-]+)*\.?$/u;
16
+ const ipv6Pattern = /^\[[0-9a-f:.]+\]$/u;
17
+ /**
18
+ * The frontmatter text between the opening and the closing `---`, or null when SKILL.md has none.
19
+ * Lines end at LF or CRLF, as in the Markdown frontmatter convention hosts follow.
20
+ */
21
+ export function frontmatter(skillMd) {
22
+ const text = skillMd.startsWith('') ? skillMd.slice(1) : skillMd;
23
+ const lines = text.split(/\r?\n/u);
24
+ if (lines.length < 2 || !/^---[ \t]*$/u.test(lines[0]))
25
+ return null;
26
+ const close = lines.findIndex((line, index) => index > 0 && /^---[ \t]*$/u.test(line));
27
+ if (close < 0)
28
+ throw new UsfError('SKILL.md frontmatter has no closing --- line');
29
+ const body = lines.slice(1, close).join('\n');
30
+ if (Buffer.byteLength(body) > MAX_FRONTMATTER_BYTES)
31
+ throw new UsfError(`SKILL.md frontmatter is larger than ${MAX_FRONTMATTER_BYTES} bytes`);
32
+ return body;
33
+ }
34
+ /**
35
+ * A token pass before parsing. It refuses the YAML forms where the readers in use disagree, or where this
36
+ * parser accepts what PyYAML rejects: directives and document markers (`%YAML 1.1` would override the version a
37
+ * reading asks for), tags, `?` keys, collections as keys and a tab before `:`. It also bounds the work.
38
+ */
39
+ function requireSimpleYaml(text) {
40
+ let keys = 0;
41
+ let anchors = 0;
42
+ let previousSolid = 'start';
43
+ const history = [];
44
+ // Controls and the characters YAML 1.1 (PyYAML) reads as line breaks but YAML 1.2 does not. Tabs are checked below.
45
+ if (/[\u0000-\u0008\u000b-\u001f\u007f\u0085\u2028\u2029]/u.test(text))
46
+ throw new UsfError('the frontmatter holds a control character or a Unicode line break (U+0085, U+2028, U+2029)');
47
+ for (const source of new Lexer().lex(text)) {
48
+ const type = CST.tokenType(source) ?? '';
49
+ // A | or > block's text arrives as one token after its header; tabs are fine there and refused everywhere else.
50
+ const blockText = history.length >= 3 && history[history.length - 3] === 'block-scalar-header' && history[history.length - 2] === 'newline' && history[history.length - 1] === 'scalar';
51
+ if (type === 'space' && source.includes('\t') && !blockText)
52
+ throw new UsfError('the frontmatter has a tab outside quoted or | > text; PyYAML refuses it');
53
+ // A plain value or key (the lexer gives it no type) with a tab: PyYAML refuses it; quoted text may hold tabs.
54
+ if (type === '' && source.includes('\t') && !/^["']/u.test(source))
55
+ throw new UsfError('the frontmatter has a tab in an unquoted value or key; PyYAML refuses it');
56
+ history.push(type);
57
+ if (history.length > 3)
58
+ history.shift();
59
+ if (type === 'directive-line' || type === 'doc-start' || type === 'doc-end')
60
+ throw new UsfError('the frontmatter holds a YAML directive or a document marker (%, --- or ...); remove it');
61
+ if (type === 'tag')
62
+ throw new UsfError(`the frontmatter uses the YAML tag ${source.slice(0, 40)}; tags are not accepted, because YAML readers resolve them differently`);
63
+ if (type === 'explicit-key-ind')
64
+ throw new UsfError('the frontmatter uses a "?" key; write keys as plain text');
65
+ if (type === 'map-value-ind') {
66
+ if (previousSolid !== '' && previousSolid !== 'flow-seq-end' && previousSolid !== 'flow-map-end')
67
+ throw new UsfError('the frontmatter has a ":" without a key');
68
+ if (previousSolid === 'flow-seq-end' || previousSolid === 'flow-map-end')
69
+ throw new UsfError('the frontmatter uses a list or map as a key; write keys as plain text');
70
+ keys += 1;
71
+ if (keys > MAX_KEYS)
72
+ throw new UsfError(`the frontmatter has more than ${MAX_KEYS} keys`);
73
+ }
74
+ if (type === 'anchor' || type === 'alias') {
75
+ anchors += 1;
76
+ if (anchors > MAX_ALIASES)
77
+ throw new UsfError(`the frontmatter has more than ${MAX_ALIASES} anchors and aliases`);
78
+ }
79
+ if (type !== 'space')
80
+ previousSolid = type;
81
+ }
82
+ }
83
+ function readYaml(text, version) {
84
+ // Duplicate keys are an error: readers keep different copies (PyYAML the last, others the first or none).
85
+ const doc = parseDocument(text, { version, uniqueKeys: true, prettyErrors: false });
86
+ const error = doc.errors[0];
87
+ if (error)
88
+ throw new UsfError(`the frontmatter is not valid YAML ${version}: ${error.message.split('\n')[0]}`);
89
+ try {
90
+ // Alias expansion is capped, so a few lines cannot expand into a huge value.
91
+ return doc.toJS({ maxAliasCount: MAX_ALIASES });
92
+ }
93
+ catch (error) {
94
+ throw new UsfError(`the frontmatter could not be read as YAML ${version}: ${error.message}`);
95
+ }
96
+ }
97
+ const isMap = (value) => typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Date);
98
+ function stringList(value, label) {
99
+ if (value === undefined || value === null)
100
+ return [];
101
+ if (!Array.isArray(value) || !value.every((item) => typeof item === 'string'))
102
+ throw new UsfError(`${label} must be a list of text values`);
103
+ return value;
104
+ }
105
+ function section(value, label, known, unknownKeys) {
106
+ if (value === undefined || value === null)
107
+ return {};
108
+ if (!isMap(value))
109
+ throw new UsfError(`${label} must be a block of keys`);
110
+ for (const key of Object.keys(value))
111
+ if (!known.includes(key))
112
+ unknownKeys.push(`${label}.${key}`);
113
+ return value;
114
+ }
115
+ /** A `network.allow` entry: a host name, `*.` plus a host name (its subdomains), a bracketed IPv6 address, or `*` (any host). */
116
+ export function normalizeHostEntry(entry) {
117
+ const trimmed = entry.trim();
118
+ // ASCII only before case folding: toLowerCase() turns some non-ASCII letters (the Kelvin sign) into ASCII ones.
119
+ const host = /^[\x21-\x7e]+$/u.test(trimmed) ? trimmed.toLowerCase() : '';
120
+ if (host === '*')
121
+ return host;
122
+ if (host.length > MAX_HOST_CHARS || !(hostPattern.test(host) || ipv6Pattern.test(host)))
123
+ throw new UsfError(`permissions.network.allow entry "${entry.slice(0, 80)}" is not a host name (write api.example.com, not a URL)`);
124
+ if (ipv6Pattern.test(host)) {
125
+ // The same normal form the profile's URL parser gives (it rewrites, for example, IPv4-mapped addresses).
126
+ try {
127
+ return new URL(`http://${host}/`).hostname;
128
+ }
129
+ catch {
130
+ throw new UsfError(`permissions.network.allow entry "${entry.slice(0, 80)}" is not an IPv6 address`);
131
+ }
132
+ }
133
+ return host.endsWith('.') ? host.slice(0, -1) : host;
134
+ }
135
+ /** The declaration in one YAML reading of the frontmatter. */
136
+ function declaration(document) {
137
+ const unknownKeys = [];
138
+ const permissions = section(document.permissions, 'permissions', ['files', 'network', 'shell', 'tools'], unknownKeys);
139
+ const files = section(permissions.files, 'permissions.files', ['read', 'write', 'deny_write'], unknownKeys);
140
+ const network = section(permissions.network, 'permissions.network', ['allow', 'deny'], unknownKeys);
141
+ const requires = section(document.requires, 'requires', ['binaries', 'min_runtime_version'], unknownKeys);
142
+ const shell = permissions.shell ?? null;
143
+ if (shell !== null && typeof shell !== 'boolean')
144
+ throw new UsfError('permissions.shell must be true or false');
145
+ const deny = network.deny ?? null;
146
+ if (deny !== null && typeof deny !== 'string')
147
+ throw new UsfError('permissions.network.deny must be a text value such as "*"');
148
+ const minRuntime = requires.min_runtime_version ?? null;
149
+ if (minRuntime !== null && typeof minRuntime !== 'string')
150
+ throw new UsfError('requires.min_runtime_version must be a text value');
151
+ return {
152
+ files: {
153
+ read: stringList(files.read, 'permissions.files.read'),
154
+ write: stringList(files.write, 'permissions.files.write'),
155
+ deny_write: stringList(files.deny_write, 'permissions.files.deny_write'),
156
+ },
157
+ network: { allow: [...new Set(stringList(network.allow, 'permissions.network.allow').map(normalizeHostEntry))].sort(), deny },
158
+ shell,
159
+ tools: stringList(permissions.tools, 'permissions.tools'),
160
+ requires: { binaries: stringList(requires.binaries, 'requires.binaries'), min_runtime_version: minRuntime },
161
+ unknownKeys: unknownKeys.sort(),
162
+ };
163
+ }
164
+ function attempt(read) {
165
+ try {
166
+ return { manifest: read() };
167
+ }
168
+ catch (error) {
169
+ if (error instanceof UsfError)
170
+ return { error: error.message };
171
+ throw error;
172
+ }
173
+ }
174
+ const FIELDS = [
175
+ ['permissions.shell', (m) => m.shell],
176
+ ['permissions.network.allow', (m) => m.network.allow],
177
+ ['permissions.network.deny', (m) => m.network.deny],
178
+ ['permissions.files.read', (m) => m.files.read],
179
+ ['permissions.files.write', (m) => m.files.write],
180
+ ['permissions.files.deny_write', (m) => m.files.deny_write],
181
+ ['permissions.tools', (m) => m.tools],
182
+ ['requires.binaries', (m) => m.requires.binaries],
183
+ ['requires.min_runtime_version', (m) => m.requires.min_runtime_version],
184
+ ];
185
+ /**
186
+ * Reads the USF declaration from SKILL.md. Never throws on Skill content: a Skill without frontmatter, with
187
+ * frontmatter that is not YAML, or without a `permissions` block simply has no declaration, and `error` says why.
188
+ */
189
+ export function readUsf(skillMd) {
190
+ const none = (error, declared = false) => ({ manifest: null, declared, error, ambiguous: [] });
191
+ let text;
192
+ try {
193
+ text = frontmatter(skillMd);
194
+ }
195
+ catch (error) {
196
+ if (error instanceof UsfError)
197
+ return none(error.message);
198
+ throw error;
199
+ }
200
+ if (text === null)
201
+ return none(null);
202
+ let modern;
203
+ let legacy;
204
+ try {
205
+ requireSimpleYaml(text);
206
+ modern = readYaml(text, '1.2');
207
+ legacy = readYaml(text, '1.1');
208
+ }
209
+ catch (error) {
210
+ if (!(error instanceof UsfError))
211
+ throw error;
212
+ // Unreadable: count it as declared whenever a permissions key may be there, so it cannot pass as "no declaration".
213
+ return none(error.message, /permissions["']?[ \t]*:/u.test(text));
214
+ }
215
+ if (modern === null || modern === undefined)
216
+ return none(null);
217
+ if (!isMap(modern) || !isMap(legacy))
218
+ return none('the frontmatter is not a block of keys');
219
+ if (!Object.hasOwn(modern, 'permissions') && !Object.hasOwn(legacy, 'permissions'))
220
+ return none(null);
221
+ const a = attempt(() => declaration(modern));
222
+ const b = attempt(() => declaration(legacy));
223
+ if ('error' in a && 'error' in b)
224
+ return none(a.error, true);
225
+ if ('error' in a || 'error' in b) {
226
+ const failed = 'error' in a ? `in YAML 1.2, ${a.error}` : `in YAML 1.1 (PyYAML), ${b.error}`;
227
+ return { manifest: null, declared: true, error: `the declaration reads differently in YAML 1.1 and 1.2 (${failed}); quote text values and write true or false`, ambiguous: ['permissions'] };
228
+ }
229
+ const ambiguous = FIELDS.filter(([, get]) => JSON.stringify(get(a.manifest)) !== JSON.stringify(get(b.manifest))).map(([name]) => name);
230
+ if (ambiguous.length > 0)
231
+ return { manifest: null, declared: true, error: `these fields read differently in YAML 1.1 (PyYAML) and YAML 1.2: ${ambiguous.join(', ')}; quote text values and write true or false`, ambiguous };
232
+ return { manifest: a.manifest, declared: true, error: null, ambiguous: [] };
233
+ }
234
+ /** Whether a declared `network.allow` list covers a host found in the Skill's files. */
235
+ export function hostAllowed(allow, host) {
236
+ const name = host.toLowerCase().replace(/\.$/u, '');
237
+ return allow.some((entry) => entry === '*' || entry === name || (entry.startsWith('*.') && name.endsWith(entry.slice(1))));
238
+ }
@@ -0,0 +1,65 @@
1
+ # Publish Action: keyless published-by attestations
2
+
3
+ A Skill author's release workflow can state, with the repository's own GitHub identity, which exact Skill bytes it published. Nobody has to create or keep a key. On public repositories the statement is recorded in the public Sigstore transparency log, which nobody, including the Mago Foundation, can edit. The statement is verified against public Sigstore infrastructure, not against a Mago server.
4
+
5
+ A published-by attestation says who published these bytes, from which repository, workflow and commit. It does not say that the Skill is safe.
6
+
7
+ ## Set up
8
+
9
+ ```yaml
10
+ # .github/workflows/publish-skills.yml
11
+ name: publish skills
12
+ on:
13
+ release:
14
+ types: [published]
15
+ permissions:
16
+ contents: read
17
+ id-token: write # lets actions/attest request a short-lived signing certificate
18
+ attestations: write # lets it store the attestation on GitHub
19
+ jobs:
20
+ publish:
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v7
24
+ with:
25
+ persist-credentials: false
26
+ - uses: mago-foundation/mago-ski/publish@v0.5.0-beta.1
27
+ ```
28
+
29
+ Inputs: `path` and `require-manifest`, as in the [Skill check Action](skill-check.md). Outputs: `bundle-path` (the Sigstore bundle) and `attestation-url`.
30
+
31
+ What it does:
32
+
33
+ 1. It runs the Skill check on every Skill. If any Skill fails, nothing is signed.
34
+ 2. It writes one in-toto statement. Its subjects are the Skills' tree digests ([skill-tree v2](../spec/skill-tree-v2.md)), and its predicate (`https://magofoundation.dev/attestation/published-by/v1`) records each Skill's path, the SHA-256 of its `SKILL.md`, its USF declaration as read (or why there is none), and its [observed profile](../spec/observed-profile-v1.md).
35
+ 3. It signs the statement with GitHub's [`actions/attest`](https://github.com/actions/attest) (pinned by commit). On public repositories this uses the public-good Sigstore instance; on private repositories it uses GitHub's own instance (GitHub Enterprise Cloud).
36
+
37
+ Run it on release, or on pushes to a protected branch, so that the signing workflow cannot be changed by an unreviewed pull request. The Action refuses to run on `pull_request`, `pull_request_target` and `workflow_run` events. Pin it to a full commit SHA rather than a tag.
38
+
39
+ ## Verifying
40
+
41
+ Anyone can check an attestation for the bytes they have, offline:
42
+
43
+ ```sh
44
+ cosign trusted-root create --with-default-services --out trusted_root.json # once; this step uses the network
45
+ mago-ski attestation verify ./skills/release-notes \
46
+ --bundle release-notes.sigstore.json --trusted-root trusted_root.json --cosign ./cosign \
47
+ --repo acme/skills --workflow .github/workflows/publish-skills.yml --repo-id 123456789
48
+ ```
49
+
50
+ The bundle comes from the Action's `bundle-path` output, or from GitHub (`gh attestation download`, or the `/repos/OWNER/NAME/attestations/sha256:DIGEST` API, where DIGEST is the Skill's tree digest from `mago-ski digest`).
51
+
52
+ The command:
53
+
54
+ - recomputes the Skill's tree digest from the bytes;
55
+ - runs Cosign v3.1.3 (its SHA-256 must match the official release) against the trusted root, with no network access needed. Cosign checks the signature, the certificate chain, the transparency-log proof, that the signer is a GitHub Actions workflow of `--repo` (and `--workflow`), that the statement is a published-by statement, and that it names this digest;
56
+ - reads the signer's identity from the certificate: repository, numeric repository id, owner id, workflow, commit, ref, trigger and runner. `--repo` must match both the signing workflow's repository and the repository whose code ran (with a reusable workflow from another repository they differ, and the attestation is refused), and `--workflow` the top-level workflow. `--repo-id` pins the numeric id. The id survives renames, and a fork or a new repository with the same name cannot have it;
57
+ - recomputes the observed profile and the declaration, and reports any difference from what the publisher recorded.
58
+
59
+ Result: `PUBLISHED_BY` (exit 0) with the facts, `RECORD_MISMATCH` (exit 1) when the record does not match the bytes, or `NOT_VERIFIED` (exit 1) with the reason.
60
+
61
+ ## Limits
62
+
63
+ - `--repo` is compared with the workflow identity as GitHub spells it, case included. Prefer `--repo-id`.
64
+ - A compromised publisher account or workflow can still publish. Reviews, revocation and the organisation's rules (next step of 0.5.0) limit how far that reaches.
65
+ - The statement records what the files contained; it says nothing about whether the Skill is safe.
@@ -0,0 +1,91 @@
1
+ # Skill check Action (free, no keys)
2
+
3
+ A GitHub Action for any repository that publishes Skills. It works on the Skills that exist today: it needs no keys, no accounts, no mago-ski setup and no new file from the author.
4
+
5
+ For every Skill (a folder with a `SKILL.md`) it does two things:
6
+
7
+ 1. **Shows what the Skill's files contain**: the websites they name, the files that are code (scripts, executables, shell code blocks) and the programs that shell code calls. This is the Skill's [observed profile](../spec/observed-profile-v1.md). It is computed from the bytes alone and never from what the Skill says about itself.
8
+ 2. **Checks a declaration, if the Skill has one.** A Skill may declare its needs in the `permissions` block of the [OWASP Universal Skill Format](https://github.com/OWASP/www-project-agentic-skills-top-10/blob/main/universal-skill-format.md) (USF) v1.0, in its `SKILL.md` frontmatter. If it does, the check fails when the declaration does not cover what the files contain.
9
+
10
+ The check does not say that a Skill is safe. It states what the files contain and whether the Skill's own declaration covers it.
11
+
12
+ ## Set up
13
+
14
+ ```yaml
15
+ # .github/workflows/skill-check.yml
16
+ name: skill check
17
+ on: [pull_request, push]
18
+ permissions:
19
+ contents: read
20
+ jobs:
21
+ check:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v7
25
+ with:
26
+ persist-credentials: false
27
+ - uses: mago-foundation/mago-ski/check@v0.5.0-beta.1
28
+ ```
29
+
30
+ Pin the Action to a full commit SHA if your repository pins its Actions. Use `pull_request`, not `pull_request_target`: the check needs no secrets and no write access. The Action installs its single dependency (`yaml`) from mago-ski's lockfile, with install scripts turned off.
31
+
32
+ Inputs:
33
+
34
+ - `path` (default `.`): the folder to search for Skills. `.git` and `node_modules` folders are skipped.
35
+ - `require-manifest` (default `false`): when `true`, a Skill without a readable USF declaration fails.
36
+
37
+ Run the same check locally with `mago-ski check SKILL_DIR [--require-manifest]`.
38
+
39
+ ## Results
40
+
41
+ | Situation | Result |
42
+ |---|---|
43
+ | No `permissions` block | **Pass**, with the profile shown and a block to paste. Fails only with `require-manifest: true`. |
44
+ | The declaration covers the profile | **Pass.** |
45
+ | A web address (`http://` or `https://`) in any file has a host that `permissions.network.allow` does not cover | **Fail** |
46
+ | Scripts or shell code exist and `permissions.shell` is not `true` | **Fail** |
47
+ | A `permissions` block exists but cannot be read one way only (see below) | **Fail** |
48
+ | A `permissions` block exists and some files could not be searched (binary, not UTF-8, over 2 MiB, or left out by `.skilldigestignore`; images, fonts and media are fine) | **Fail**: the declaration cannot be checked against them |
49
+ | The frontmatter is not valid YAML and declares nothing | **Pass**, with a note that hosts may not read the Skill's name and description |
50
+
51
+ `network.allow` entries are host names: `api.example.com` covers only that host; `*.example.com` covers its subdomains but not `example.com` itself; `"*"` covers every host, and the summary says so. `files`, `tools` and `requires.binaries` are shown but not checked against the files, because a tool cannot reliably tell them from ordinary text.
52
+
53
+ ## Declaring what a Skill needs
54
+
55
+ ```yaml
56
+ ---
57
+ name: release-notes
58
+ description: Writes release notes from merged pull requests.
59
+ permissions:
60
+ network:
61
+ allow: [api.github.com]
62
+ deny: "*"
63
+ shell: true
64
+ files:
65
+ read: [CHANGELOG.md]
66
+ tools: [web_fetch]
67
+ requires:
68
+ binaries: [gh]
69
+ ---
70
+ ```
71
+
72
+ The job summary shows a block filled in from the profile. Read it before you paste it: it lists what the files contain, not what the Skill should be allowed to do.
73
+
74
+ ## How the frontmatter is read
75
+
76
+ The frontmatter is ordinary YAML and is read with a full YAML parser, so anything a YAML reader accepts is accepted: multi-line and quoted descriptions, folded and literal blocks, anchors, Unicode.
77
+
78
+ YAML readers disagree on some unquoted values. YAML 1.1 (used by PyYAML and others) reads `yes`, `no`, `on`, `off`, some numbers and dates as non-text; YAML 1.2 reads them as text. The declaration is therefore read under both rules. If a declared field reads differently, the check reports it instead of guessing which reader a host uses. Write `shell: true` or `false`, and quote values such as `"on"`.
79
+
80
+ A few YAML forms make readers disagree, or are accepted by some readers and refused by PyYAML. A frontmatter that uses them cannot carry a declaration: directives and document markers inside it (`%YAML`, `---`, `...`), tags (`!!str`, `!x`), `?` keys, lists or maps used as keys, tabs outside quoted or `|`/`>` text (in unquoted values and keys too), a `:` without a key, control characters and the Unicode line breaks U+0085, U+2028 and U+2029, duplicate keys, more than 2,000 keys or 50 anchors and aliases, or more than 64 KiB. A Skill that uses them and has a `permissions` key fails; one without a `permissions` key passes with a note.
81
+
82
+ ## On pull requests
83
+
84
+ The summary also lists what the change adds compared with the base branch, in plain words: new websites used or declared, a switch to `shell: true`, new scripts, new programs in shell code, new files to read or write, files no longer protected from writes, and new tools. This list is for the reviewer and does not affect the result: pass or fail depends only on the pull request's own files. The base revision is checked out to the runner's temporary folder, outside the workspace. A repository that contains a `.mago-ski-check-base` path is refused, because the check reserves that path.
85
+
86
+ ## Limits
87
+
88
+ - Written instructions cannot be fully checked by a tool. A Skill can tell the model, in ordinary words, to visit a site or run a command. The check sees it only when the address or code is written out. Review by a person stays in the picture.
89
+ - Web addresses are found only when written with `http://` or `https://` (not `ws://`, `ftp://`, `ssh://`, `git@…` or a bare host name). Shell code is found in fenced Markdown code blocks only: not in indented code blocks, HTML `<pre><code>`, other languages' code that starts a process (Python's `os.system`, `awk`'s `system()`), or non-Markdown text files; there, scripts count by type, `#!` or the executable bit.
90
+ - USF v1.0 is a proposal and may change; this check follows it. `content_hash` and `signature` are not checked: USF does not yet define what they cover. Keyless signing of releases comes in the next step of 0.5.0.
91
+ - Linux and macOS runners only.
@@ -0,0 +1,84 @@
1
+ # Admission rules v0 (`mago.admission/v0`)
2
+
3
+ Status: preview in mago-ski 0.5.0-beta.1; the format may change before 0.5.0.
4
+
5
+ An admission rule file is an organisation's short, readable statement of which evidence is enough to admit a Skill. It is the admission language only: it decides whether an exact Skill version may be loaded, and never describes what an agent may do while it works. That belongs to a separate runtime language under a different name.
6
+
7
+ ## Determinism
8
+
9
+ A decision is a pure function of (facts, rules, time):
10
+
11
+ - No model, classifier, score or threshold anywhere in the decision.
12
+ - No network during the decision. Facts come from the Skill's bytes and from documents verified offline (a review certificate against the organisation's trust root; a published-by bundle against a local Sigstore trusted root).
13
+ - The same facts, rules and time give the same decision on any computer. `mago-ski admit --log` records the facts with each decision, so `mago-ski admission diff` can replay them.
14
+
15
+ ## Facts
16
+
17
+ | Fact | Source |
18
+ |---|---|
19
+ | `profile` | the [observed profile](observed-profile-v1.md), computed from the bytes |
20
+ | `declaration` | the OWASP USF `permissions`/`requires` block as read (see [skill check](../hosts/skill-check.md)), or none |
21
+ | `reviewed_by` | a certificate that the organisation's trust root vouches for, for these exact bytes (`VERIFIED`), with its dates |
22
+ | `published_by` | a [published-by](../hosts/publish.md) bundle that verifies for these exact bytes and whose record matches them: numeric repository id, owner id, workflow path, commit |
23
+ | `base` | the same facts for the reviewed version this one updates, from its own bytes |
24
+
25
+ ## File
26
+
27
+ ```yaml
28
+ admission_version: mago.admission/v0
29
+ default: REQUIRE_REVIEW # the action when no rule matches
30
+ rules:
31
+ - id: our-own-skills # lower-case letters, digits, dashes; unique
32
+ when:
33
+ publisher: { repository_id: "123456789", workflow: .github/workflows/publish.yml }
34
+ action: ALLOW
35
+ - id: reviewed
36
+ when: { reviewed: true }
37
+ action: ALLOW
38
+ - id: plain-updates
39
+ when:
40
+ update: { same_publisher: true, max_days_since_review: 90 }
41
+ action: ALLOW
42
+ - id: shell-gets-a-flag
43
+ when:
44
+ capabilities: { shell: true }
45
+ action: FLAG
46
+ - id: blocked-site
47
+ when:
48
+ capabilities: { websites: [paste.example] }
49
+ action: BLOCK
50
+ reason: "This site is not allowed in our Skills"
51
+ ```
52
+
53
+ The file is YAML 1.2 with unique keys and no aliases. Keys outside this schema are errors.
54
+
55
+ **Actions**, from least to most strict: `ALLOW`, `LOG_ONLY`, `FLAG`, `REQUIRE_REVIEW`, `BLOCK`. The first three admit the Skill.
56
+
57
+ **How a decision is made.** Rules with a `capabilities` condition are *tighteners*; all others are *basis* rules. The base decision is the strictest action among the matching basis rules, or `default` when none matches. The decision is the stricter of that and the strictest matching tightener. So deny wins, and a tightener can raise a decision but never admit a Skill the basis would stop: `capabilities: {shell: true}` with `FLAG` flags reviewed Skills that run code and leaves unreviewed ones at `REQUIRE_REVIEW`. Among rules with the same action, the first in the file names the decision.
58
+
59
+ **Conditions** (all given conditions must hold):
60
+
61
+ - `publisher`: `repository_id`, `owner_id` (numeric ids, quoted), `workflow` (a `.github/workflows/…` path, only together with `repository_id`), `branch` (the ref was `refs/heads/<branch>`) and `trigger` (a list of GitHub event names, such as `[release, push]`). It matches the verified published-by identity. Names and tags cannot be written: a rename or a moved tag cannot change a decision, and a fork or a new repository with the same name has another id.
62
+ - `reviewed`: `true` or `false`, whether `reviewed_by` exists.
63
+ - `capabilities`: `shell: true` (scripts or shell code are present, or the declaration asks for a shell); `websites: [hosts]` (it names or declares one of these hosts; `*.example.com` covers subdomains); `any_website: true`; `undeclared: true` (a declaration exists and does not cover the profile); `no_declaration: true`; `incomplete: true` (the profile is incomplete).
64
+ - `update`: `same_publisher: true` (required) and `max_days_since_review`. It matches when a base is supplied whose `reviewed_by` exists, the base is another digest of the same Skill name, both have the same publisher (repository id and workflow), the version does not escalate, and the base's review is at most that many days old. **Escalation** compares what the Skill can reach, declared and observed together: it escalates when it runs code or asks for a shell and the base did not, when it names or declares a host the base did not cover, when it declares `network.allow: "*"` and the base did not, when its profile is incomplete, when its declaration asks to read or write files, or for tools or programs, that the base's did not, when it stops protecting a file the base's `deny_write` listed, when it drops `network.deny: "*"`, when its declaration adds keys mago-ski does not know, when its shell code names programs the base's did not, when the base had a declaration and this version has none, or when this version's declaration cannot be read one way only. Changes to the instructions alone are not an escalation; a person's review of the base covers only the base.
65
+
66
+ **Checks at load time** (the linter): unknown keys, duplicate ids, `BLOCK`/`REQUIRE_REVIEW` without a `reason`, `ALLOW` with `capabilities` (no effect: tighteners cannot admit), and basis rules that admit (`ALLOW`, `LOG_ONLY`, `FLAG`) with `reviewed: false` or with no publisher, review or update condition (they would admit every Skill).
67
+
68
+ Replay refuses a log record with a missing or mistyped field rather than reading a missing review as present.
69
+
70
+ ## Decision
71
+
72
+ ```json
73
+ { "action": "REQUIRE_REVIEW", "admitted": false, "rule_id": "default", "matched": [], "reason": null,
74
+ "missing": "a review of this exact version (reviewed-by); it is not a plain update because it reaches new websites: new.example" }
75
+ ```
76
+
77
+ `rule_id` names the rule behind the decision, so every decision can be explained.
78
+
79
+ ## Not in v0
80
+
81
+ - Hosts (Pi, the company gate for Claude Code and Codex, the verify Action) do not read admission rules yet. In 0.5.0, decisions are made with `mago-ski admit` in CI or by an administrator.
82
+ - Rule files are plain files, not signed trust documents.
83
+ - Chains of automatic updates: an update is admitted only directly from a reviewed base (one hop).
84
+ - A bound on how many SKILL.md lines changed, layered packs (`extends`), and witnessed-by records.
@@ -274,7 +274,7 @@ The renderer cannot name a file, a key or a directory in any of them. A compromi
274
274
  - **The user-namespace check is a hurdle**, not a boundary (see [Organisation pin](#organisation-pin)); Flatpak, rootless containers and user-namespace CI runners are unsupported.
275
275
  - **A copy or hard link of the key inside a Skill is not detected.** A moved key fails the stored-path check at signing. The private-key scan at signing covers the files the digest covers, as in the CLI.
276
276
  - **The memory does not protect against the user** (see above).
277
- - **Retired keys are known only from walked events.** A key retired before `root_events_after` is not known to a host or to the GUI. The host check refuses a trust root that lists a key retired in the events the host walked (`trust root lists approver <id>, which has held the root or timestamp role; a key that left those roles never takes another`); the gate's trust store (`src/gate/trust-store.ts`) calls `loadTrustContext` directly and does not check this.
277
+ - **Retired keys come from the whole log.** A key retired in a walked event, or shown leaving a role in an event before `root_events_after` (read without checking its signatures, and used only to refuse), is retired. The host check refuses a trust root that lists such a key (`trust root lists approver <id>, which has held the root or timestamp role; a key that left those roles never takes another`); the gate's trust store (`src/gate/trust-store.ts`) calls `loadTrustContext` directly and does not check this.
278
278
  - **Former recovery keys.** The GUI and `root add-approver --policy` refuse a key that left a recovery set in the walked events as an approver; hosts do not check this. For former recovery keys, no host refuses a document it accepted before. While a former recovery key is listed as an approver, the GUI marks it and allows only removing it, hosts keep accepting the trust root, and `root renew` and `root remove-approver` in the CLI do not check it.
279
279
  - **Upgrade note for retired keys.** The host check for retired root and timestamp keys is the one deliberate exception to "no host refuses a document it accepted before":
280
280
 
@@ -0,0 +1,51 @@
1
+ # Observed profile v1 (`mago.observed-profile/v1`)
2
+
3
+ Status: draft, part of mago-ski 0.5.0.
4
+
5
+ An observed profile states what a Skill's own files show: the websites they name, the files that are code, and the programs that shell code calls. It is computed from the bytes alone, deterministically and offline. It never reads the Skill's frontmatter, so what a Skill says about itself cannot change it. A declaration (such as an OWASP Universal Skill Format manifest) can be compared with a profile, and a `published-by` attestation (0.5.0 step 2) records one.
6
+
7
+ A profile is a list of facts about the content. It does not say a Skill is safe, and it is not complete: instructions written in ordinary words are not extracted.
8
+
9
+ ## Input
10
+
11
+ The files of the Skill tree as defined by [skill-tree v2](skill-tree-v2.md): the same file set, the same bytes and the same executable bits that the tree digest covers. Files that skill-tree v2 leaves out are not profiled; `.skilldigestignore` entries are listed as `not_searched.ignored`.
12
+
13
+ ## Output
14
+
15
+ ```json
16
+ {
17
+ "profile": "mago.observed-profile/v1",
18
+ "digest": "sha256:<tree digest of the same bytes>",
19
+ "web_hosts": ["api.example.com"],
20
+ "scripts": [{ "path": "scripts/run.sh", "reason": ".sh file" }],
21
+ "programs": ["curl", "jq"],
22
+ "not_searched": { "media": [], "unreadable": [], "ignored": [] },
23
+ "complete": true
24
+ }
25
+ ```
26
+
27
+ Lists are sorted by code point, except `scripts`, which follows the tree's file order.
28
+
29
+ ## Rules
30
+
31
+ **Searchable file.** A file is searchable when it is at most 2 MiB, contains no NUL byte, and is valid UTF-8. A file that is not searchable goes into `not_searched.media` if its extension is one of `.png .jpg .jpeg .gif .webp .avif .bmp .ico .tif .tiff .heic .woff .woff2 .ttf .otf .eot .mp3 .wav .ogg .flac .m4a .mp4 .webm .mov`, and into `not_searched.unreadable` otherwise. Extensions are compared in lower case.
32
+
33
+ **web_hosts.** In every searchable file, each match of `https?://[^\s"'`<>()[\]{}]+` (case-insensitive), with trailing `.,;:!?` removed, is parsed as a WHATWG URL. If the scheme is `http` or `https`, the URL's host name is added. A match that does not parse adds nothing. Limits: 128 distinct origins, 100,000 matches per tree, and 262 characters per origin. Reaching a limit sets `complete` to false. These are the same rules as the network-origin scan in `mago-ski diff` (`mago.network-origin-scan/v1`). In addition, each match of `https?://\[[0-9A-Fa-f:.]{2,45}\](?::[0-9]{1,5})?` (a bracketed IPv6 address, which the first pattern does not match) is parsed the same way and its host name added in the URL parser's normal form (for example `[::ffff:a9fe:a9fe]`), up to 128 more hosts. For a match that contains `\`, the host another URL parser reads is added too: the text after `://` up to the first `/`, `?` or `#`, after its last `@`, without a port and percent-decoded, if it is a plain host name or a bracketed IPv6 address (in the URL parser's normal form). Brackets are kept in this candidate. (WHATWG treats `\` as `/`, so `https://a.example\@b.example/` is `a.example` there and `b.example` in Python's `urlparse`.)
34
+
35
+ **scripts.** A file is listed, with the first reason that applies:
36
+
37
+ 1. `executable file`: its executable bit is set.
38
+ 2. `starts with #!`: its first two bytes are `#!`.
39
+ 3. `<ext> file`: its extension is one of `.sh .bash .zsh .fish .ksh .py .js .mjs .cjs .ts .mts .cts .rb .pl .php .lua .ps1 .psm1 .bat .cmd .go .rs .java .kt .kts .swift .c .cc .cpp .cs .vbs .awk .tcl .r .jl .ex .exs .groovy .scala .applescript .scpt .jar .wasm .exe .dll .so .dylib`.
40
+ 4. `build or task file`: its base name, in lower case, is `makefile`, `gnumakefile`, `justfile`, `rakefile`, `dockerfile` or `containerfile`.
41
+ 5. `N shell code block(s)`: it is a searchable `.md`, `.markdown` or `.mdx` file, and N ≥ 1 of its lines match `^(?:[ \t>]|[-*+][ \t]|[0-9]{1,9}[.)][ \t])*(`{3,}|~{3,})[ \t]*\{?\.?([A-Za-z0-9_+.:-]*)` (indentation, blockquote and list markers before the fence), where the second group, in lower case and cut at the first `-`, `_`, `+`, `.` or `:`, is one of: `sh bash shell zsh fish ksh csh tcsh dash ash console shellsession shellscript terminal powershell ps1 pwsh cmd bat batch nushell nu`. So `bash-session`, `shell-script` and `sh+x` count.
42
+
43
+ Rule 5 counts opening lines without pairing fences, on purpose: no arrangement of fences can hide a shell block. A fence that a Markdown reader treats as plain text can still be counted. That errs towards listing.
44
+
45
+ **programs.** Inside shell code blocks of searchable Markdown files (a fence opens a block; a line with the same fence character, at least as long, and no info string closes it), each line is read as follows. Leading indentation, blockquote and list markers (as in rule 5) and a prompt (`$`, `PS>`, `>`, `%` followed by blanks) are removed. The line is split on blanks. Leading words that are `sudo doas env exec time nohup command builtin then do else !` or `NAME=value` assignments are skipped. Lines whose first remaining word starts with `#` are skipped. The base name of the first remaining word is added if it matches `^[A-Za-z0-9._+-]{1,64}$`. The list holds at most 200 names. It is a hint, not a complete inventory: programs called from scripts are not listed.
46
+
47
+ **complete.** `false` when `not_searched.unreadable` or `not_searched.ignored` is not empty, or when a web_hosts limit was reached. Media files do not make a profile incomplete.
48
+
49
+ ## Versioning
50
+
51
+ Any change to which files, hosts, scripts or programs are reported is a new profile version. Verifiers recompute the profile themselves with the version named in the document, and never trust a profile they did not compute.
@@ -171,7 +171,7 @@ Let *current set* be the recovery set in force just before the event.
171
171
  - `new_root.key_id` must not be any key that an earlier event revoked or replaced. A key that has left the root role never returns.
172
172
  - `new_root.key_id` may equal `root_key_id` only if that key is not revoked. This changes the recovery set or the timestamp key without changing the root (for example, when a trustee leaves or the timestamp key leaks).
173
173
  - `new_timestamp.key_id` must not be the current or new root key, must not be in the current or new recovery set, and must not be a timestamp key that an earlier event replaced.
174
- - `new_root.key_id` must not be the current or new timestamp key, and `new_recovery` must not contain the current root key, the current timestamp key, or any key that an earlier event revoked or replaced. **A key that has left the root or timestamp role never takes any role again**, so a leaked key cannot come back as a recovery key. Hosts only know the keys replaced by events they walk (after `root_events_after`).
174
+ - `new_root.key_id` must not be the current or new timestamp key, and `new_recovery` must not contain the current root key, the current timestamp key, or any key that an earlier event revoked or replaced. **A key that has left the root or timestamp role never takes any role again**, so a leaked key cannot come back as a recovery key. Events before `root_events_after` are not checked, but hosts still read which keys they show leaving a role and treat those keys as retired (see [Host processing](#host-processing)).
175
175
 
176
176
  ### Rules for a revoke
177
177
 
@@ -245,6 +245,7 @@ At every trust check, before reading the trust root, a host with a v2 recovery p
245
245
 
246
246
  1. Starts from the policy: *active root* = `root_fingerprint`, *recovery set* = `recovery`, *timestamp key* = `freshness.key_id`, *revoked* = false.
247
247
  2. Reads `root_events`. A missing, malformed or oversized log is `UNVERIFIABLE`.
248
+ - **Events before `root_events_after` are read, not checked.** The policy pins the state after them, not the keys that signed them, so their signatures and rules are not checked and nothing is ever accepted because of them. The host reads only which keys they show leaving a role, and uses that only to refuse: the root key a revoke names, the root key a rotate replaces with another key, a timestamp key that a later event replaces, and a recovery key that a rotate leaves out of `new_recovery` count as retired or former recovery keys for the rest of the walk and for the trust root check. Someone who can change these events can only make a host refuse more, which they can already do by deleting the log; with `freshness`, the timestamp covers the whole file. An event there with the wrong payload type, a payload that does not parse, or the wrong `sequence`, and an event there that retires a key the policy pins (`the events before root_events_after show key <id> leaving the root or timestamp role, but the policy pins it as the <role> key`), make the log `UNVERIFIABLE`.
248
249
  3. For each event after the first `root_events_after`, in order, checks every rule above against the current state, then applies it:
249
250
  - revoke: *revoked* = true.
250
251
  - rotate: *active root* = `new_root.key_id`, *recovery set* = `new_recovery`, *timestamp key* = `new_timestamp.key_id` if present, *revoked* = false.
@@ -258,7 +259,7 @@ Walking the full log keeps hosts without state correct, but hosts load trust doc
258
259
  2. Check rollback and forks against the host state. Otherwise `UNVERIFIABLE`.
259
260
  3. If the active root is revoked, every Skill is blocked: see [Revoked root](#revoked-root-blocked-in-every-mode). Nothing else is read.
260
261
  4. With `freshness`, check the timestamp against the files. Otherwise `UNVERIFIABLE`.
261
- 5. Check the trust root and the revocation list as in v1, except that they must be signed by the **active root** instead of `root_fingerprint`. The trust root is also `UNVERIFIABLE` if any approver's key is in the active recovery set, is the active timestamp key, or is a key that has held the root or timestamp role in the walked events (`trust root lists approver <id>, which has held the root or timestamp role; a key that left those roles never takes another`). Only events after `root_events_after` are walked, so only keys retired in them are known. Hosts do not refuse a former recovery key listed as an approver; the GUI and `root add-approver --policy` refuse it as a new approver. The gate trust store (`src/gate/trust-store.ts`) does not run this check.
262
+ 5. Check the trust root and the revocation list as in v1, except that they must be signed by the **active root** instead of `root_fingerprint`. The trust root is also `UNVERIFIABLE` if any approver's key is in the active recovery set, is the active timestamp key, or is a key that has held the root or timestamp role in the walked events (`trust root lists approver <id>, which has held the root or timestamp role; a key that left those roles never takes another`). Keys shown leaving a role in the events before `root_events_after` count too (see [Walking the log](#walking-the-log)). Hosts do not refuse a former recovery key listed as an approver; the GUI and `root add-approver --policy` refuse it as a new approver. The gate trust store (`src/gate/trust-store.ts`) does not run this check.
262
263
 
263
264
  Before upgrading hosts, an organisation removes such approvers; see the upgrade note in the CHANGELOG.
264
265
  6. Record the new state.