@mago-foundation/mago-ski 0.1.0 → 0.3.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.
Files changed (91) hide show
  1. package/README.md +54 -9
  2. package/action.yml +2 -2
  3. package/dist/hosts/github/run.d.ts +9 -1
  4. package/dist/hosts/github/run.js +64 -11
  5. package/dist/hosts/pi/index.d.ts +5 -3
  6. package/dist/hosts/pi/index.js +219 -14
  7. package/dist/src/admin.d.ts +140 -1
  8. package/dist/src/admin.js +328 -63
  9. package/dist/src/canonical-json.js +73 -28
  10. package/dist/src/certificate.js +23 -15
  11. package/dist/src/cli.js +590 -89
  12. package/dist/src/diff.d.ts +0 -4
  13. package/dist/src/diff.js +326 -70
  14. package/dist/src/dsse.d.ts +6 -4
  15. package/dist/src/dsse.js +22 -6
  16. package/dist/src/fs-safe.d.ts +32 -3
  17. package/dist/src/fs-safe.js +193 -31
  18. package/dist/src/gate/adapters/claude-code-hook.d.ts +1 -0
  19. package/dist/src/gate/adapters/claude-code-hook.js +4 -0
  20. package/dist/src/gate/adapters/claude-code-settings.d.ts +13 -0
  21. package/dist/src/gate/adapters/claude-code-settings.js +49 -0
  22. package/dist/src/gate/adapters/claude-code.d.ts +33 -0
  23. package/dist/src/gate/adapters/claude-code.js +193 -0
  24. package/dist/src/gate/adapters/client.d.ts +13 -0
  25. package/dist/src/gate/adapters/client.js +57 -0
  26. package/dist/src/gate/adapters/codex-hook.d.ts +1 -0
  27. package/dist/src/gate/adapters/codex-hook.js +5 -0
  28. package/dist/src/gate/adapters/codex-requirements.d.ts +19 -0
  29. package/dist/src/gate/adapters/codex-requirements.js +56 -0
  30. package/dist/src/gate/adapters/codex.d.ts +16 -0
  31. package/dist/src/gate/adapters/codex.js +574 -0
  32. package/dist/src/gate/adapters/hook-main.d.ts +7 -0
  33. package/dist/src/gate/adapters/hook-main.js +35 -0
  34. package/dist/src/gate/adapters/host-pid.d.ts +1 -0
  35. package/dist/src/gate/adapters/host-pid.js +20 -0
  36. package/dist/src/gate/admission.d.ts +54 -0
  37. package/dist/src/gate/admission.js +490 -0
  38. package/dist/src/gate/contract.d.ts +51 -0
  39. package/dist/src/gate/contract.js +94 -0
  40. package/dist/src/gate/decision-log.d.ts +38 -0
  41. package/dist/src/gate/decision-log.js +251 -0
  42. package/dist/src/gate/generations.d.ts +67 -0
  43. package/dist/src/gate/generations.js +518 -0
  44. package/dist/src/gate/proc.d.ts +31 -0
  45. package/dist/src/gate/proc.js +79 -0
  46. package/dist/src/gate/refresh.d.ts +11 -0
  47. package/dist/src/gate/refresh.js +30 -0
  48. package/dist/src/gate/run-verifier.d.ts +23 -0
  49. package/dist/src/gate/run-verifier.js +89 -0
  50. package/dist/src/gate/service.d.ts +80 -0
  51. package/dist/src/gate/service.js +722 -0
  52. package/dist/src/gate/strict-json.d.ts +11 -0
  53. package/dist/src/gate/strict-json.js +190 -0
  54. package/dist/src/gate/trust-store.d.ts +36 -0
  55. package/dist/src/gate/trust-store.js +251 -0
  56. package/dist/src/gate/verifier-worker.d.ts +8 -0
  57. package/dist/src/gate/verifier-worker.js +66 -0
  58. package/dist/src/index.d.ts +2 -0
  59. package/dist/src/index.js +2 -0
  60. package/dist/src/keys.d.ts +4 -0
  61. package/dist/src/keys.js +85 -30
  62. package/dist/src/main-module.js +1 -1
  63. package/dist/src/names.js +2 -4
  64. package/dist/src/policy.d.ts +173 -6
  65. package/dist/src/policy.js +685 -54
  66. package/dist/src/recovery-admin.d.ts +173 -0
  67. package/dist/src/recovery-admin.js +400 -0
  68. package/dist/src/revocations.js +3 -1
  69. package/dist/src/root-events.d.ts +107 -0
  70. package/dist/src/root-events.js +376 -0
  71. package/dist/src/time.d.ts +19 -3
  72. package/dist/src/time.js +50 -8
  73. package/dist/src/timestamp.d.ts +61 -0
  74. package/dist/src/timestamp.js +107 -0
  75. package/dist/src/tree-digest.d.ts +4 -0
  76. package/dist/src/tree-digest.js +41 -16
  77. package/dist/src/trust-root.d.ts +5 -0
  78. package/dist/src/trust-root.js +34 -13
  79. package/dist/src/verify.d.ts +69 -13
  80. package/dist/src/verify.js +309 -61
  81. package/docs/hosts/adapter-interface.md +8 -2
  82. package/docs/hosts/github-action.md +3 -3
  83. package/docs/hosts/pi.md +10 -3
  84. package/docs/spec/gui-admin-rack-v1.md +289 -0
  85. package/docs/spec/root-recovery-v1.md +451 -0
  86. package/docs/spec/skill-certificate-v1.md +1 -1
  87. package/docs/spec/skill-tree-v2.md +2 -2
  88. package/docs/spec/trust-documents-v1.md +12 -6
  89. package/docs/spec/verification.md +20 -3
  90. package/docs/threat-model.md +9 -6
  91. package/package.json +49 -44
@@ -16,29 +16,32 @@ mago-ski answers one question: **is the Skill this agent is about to use the exa
16
16
  | **Hiding the instructions from the digest**: `.skilldigestignore` listing `SKILL.md` | Rejected. `SKILL.md` is always covered, and certificates without it are `UNVERIFIABLE` |
17
17
  | **Exposing uncovered files**: `.git`, ignored files, or an unused in-tree certificate file in a verified Skill | The Pi host refuses `read` of any file not in the certificate and refuses `grep` over Skills that have excluded files. The in-tree certificate counts as safe only when it is the certificate that verified the Skill |
18
18
  | **Symlinks**: a linked Skill directory, a linked `SKILL.md`, or a link inside a Skill pointing elsewhere | Digests reject symlinks. Discovery (CLI, GitHub Action) reports linked Skills as `UNVERIFIABLE` instead of skipping them, and fails rather than skipping Skills deeper than its search limit. The Pi host matches tool paths both before and after resolving links |
19
+ | **Names outside the digest**: a contributor renames a verified Skill's directory, or names files inside an unverified Skill, so that the text reaches the model | The directory path is not covered by the certificate. The Pi host shows a Skill's path to the model only if it is plainly spelled (see the [Pi host](hosts/pi.md)), and removes entries of unverified Skills from `find` and `ls` results |
19
20
  | **Path aliases**: `@/path`, `file://` URLs, Unicode spaces or filename variants that Pi's tools resolve to a Skill file | The Pi host resolves tool paths the same way Pi's tools do before matching them |
20
21
  | **Verification errors** | The Pi host fails closed in enforce mode: a Skill that cannot be checked is `UNVERIFIABLE`, and if checking crashes outright, file and shell tools that touch any Skill path are blocked |
21
22
  | **Pull request trusting itself**: a PR adds its own root or approver | The GitHub Action reads policy, trust root and revocation list from the protected base revision |
23
+ | **Compromised root key** (with a v2 policy and a recovery set) | Any `revoke_threshold` recovery keys revoke the root by a signed root event: hosts that read it block every Skill, in shadow mode too. `rotate_threshold` recovery keys and the new root then replace it, without editing host policies. The thief cannot undo or forge either event. Limits: [What each leak allows](spec/root-recovery-v1.md#what-each-leak-allows) |
24
+ | **Frozen host** (fed old documents to hide a revoke, with `freshness` on) | A short-lived timestamp names the exact current files; once the newest one expires (24 hours by default), the host trusts nothing until it gets current files |
22
25
  | **Tampered documents** | Canonical JSON with exact fields and Ed25519 signatures over DSSE: a changed document fails verification. Malformed documents and invalid signatures are `UNVERIFIABLE`; a change caught by an earlier check (for example a different Skill name or signer) reports that check's verdict instead |
23
26
 
24
27
  ## What it does not protect against
25
28
 
26
29
  - **Malicious first versions and fooled reviewers.** A certificate records a decision; it does not make the decision correct. Review quality is the organization's job.
27
30
  - **Prompt injection at runtime.** A verified Skill can still be steered by untrusted data it reads (the confused-deputy problem). Runtime evaluation of tool calls against the approved contract is a separate layer (Mago's CLEAR), not part of mago-ski.
28
- - **Shell commands that reach Skill files indirectly.** In Pi, `bash` and `powershell` are checked by matching Skill paths in the command text. Relative paths after `cd`, globs, variables or encoded paths can evade it. In enforce mode, the guarantees that hold are: unverified Skills are not advertised, `/skill:` cannot load them, and the structured file tools (`read`, `grep`, `edit`, `write`, `find`, `ls`) refuse their files. `find` and `ls` may still list file names inside verified Skills.
31
+ - **Shell commands that reach Skill files indirectly.** In Pi, `bash` and `powershell` are checked by matching Skill paths in the command text. Relative paths after `cd`, globs, variables or encoded paths can evade it. In enforce mode, the guarantees that hold are: unverified Skills are not advertised, `/skill:` cannot load them, and the structured file tools (`read`, `grep`, `edit`, `write`, `find`, `ls`) refuse their files. `find` and `ls` may still list file names inside verified Skills; in an unverified Skill they are removed from the results (a `bash` `ls` or `find` is not filtered). Names of files a verified Skill excludes from its certificate can still appear.
29
32
  - **Other code in the agent process.** A hostile Pi extension, MCP server or custom tool runs with the same permissions as mago-ski and can read files directly or change the Skill list after mago-ski filters it. Load mago-ski last and only trusted extensions.
30
33
  - **A compromised host.** Root or same-user malware can change files, the policy, the state file or the extension itself. This includes racing directory replacement between path resolution and reading; the digest re-checks file identity, but a same-user attacker controls the file system.
31
- - **A compromised root key.** Everything chains to it. Keep it offline. Root key rotation is designed but not implemented in v1.
34
+ - **A compromised root key without a recovery set.** With a v1 policy (or a v2 policy without `recovery`), everything chains to the root key, and recovering from a leak means editing every host's policy. Set up [root recovery](spec/root-recovery-v1.md). With it, `rotate_threshold` leaked recovery keys can still take over, and without `freshness` a thief who holds the root key and controls delivery to a host can keep it on an old log.
32
35
  - **Files excluded from the digest** (`.skilldigestignore`, root `.git`) are not approved. The Pi host refuses to read them from a verified Skill, but other tools may still use them.
33
- - **Windows.** Not supported in 0.1. Windows has no POSIX executable bit, so it cannot reproduce Linux and macOS digests; see the [digest spec](spec/skill-tree-v2.md).
36
+ - **Windows.** Not supported yet. Windows has no POSIX executable bit, so it cannot reproduce Linux and macOS digests; see the [digest spec](spec/skill-tree-v2.md).
34
37
 
35
38
  ## Revocation timing
36
39
 
37
- Revocation is not instant everywhere. A host acts on a revocation once it reads the updated list. Until then it accepts its current list for as long as that list is unexpired, so the list's lifetime (30 days by default, set with `--expires`) is the longest a revoked certificate can still pass. Shorten it for high-risk organizations and republish often (`revoke refresh`). The host state file stops a host from being moved back to an older list. In CI there is no state file; the Action reads the list from the protected base revision, so a revocation applies to pull requests once it is merged there.
40
+ Revocation is not instant everywhere. A host acts on a revocation once it reads the updated list. Until then it accepts its current list for as long as that list is unexpired, so the list's lifetime (30 days by default, set with `--expires`) is the longest a revoked certificate can still pass. Shorten it for high-risk organizations and republish often (`revoke refresh`). The host state file stops a host from being moved back to an older list. In CI there is no state file; the Action reads the list from the protected base revision, so a revocation applies to pull requests once it is merged there. With `freshness` in a v2 policy, the bound drops to the timestamp's `max_lifetime` (24 hours by default): a host that is not given the new list stops trusting the old one when its timestamp expires.
38
41
 
39
42
  ## Assumptions
40
43
 
41
44
  - The root private key is offline and only its holder can sign trust documents.
42
- - Approver private keys are kept by the people they name; `approve` refuses a key stored inside the Skill directory.
43
- - The host policy, trust documents and state file are writable only by the user or administrator, not by the code under review. The Pi host never reads policy from the project directory.
45
+ - Approver private keys are kept by the people they name; `approve` refuses a key stored inside the Skill directory, and refuses a Skill that contains private-key material in a recognizable format (PEM, PKCS#8, OpenSSH and SSH2 private keys, PGP private key blocks, PuTTY `.ppk` files and age secret keys). This is a best-effort check for accidents, not a general secret scanner.
46
+ - The host policy, trust documents and state file are writable only by the user or administrator, not by the code under review. Neither the Pi host nor the CLI reads policy from the project directory (the CLI uses `--policy`, `MAGO_SKI_POLICY` or `~/.mago-ski/policy.json`). The policy may place `decision_log` and `state_file` only inside its own directory.
44
47
  - Clocks are roughly correct (5 minutes of skew is tolerated for issue times).
package/package.json CHANGED
@@ -1,69 +1,45 @@
1
1
  {
2
2
  "name": "@mago-foundation/mago-ski",
3
- "version": "0.1.0",
4
- "author": "The Mago Foundation",
3
+ "version": "0.3.0",
5
4
  "description": "Skills PKI: organization-approved, exact-version Skill certificates enforced on the agent host",
5
+ "license": "Apache-2.0",
6
+ "author": "The Mago Foundation",
7
+ "homepage": "https://magofoundation.dev",
6
8
  "repository": {
7
9
  "type": "git",
8
10
  "url": "https://github.com/mago-foundation/mago-ski.git"
9
11
  },
10
- "homepage": "https://magofoundation.dev",
11
12
  "bugs": {
12
13
  "url": "https://github.com/mago-foundation/mago-ski/issues"
13
14
  },
14
- "keywords": [
15
- "pi-package",
16
- "agent-skills",
17
- "skills",
18
- "pki",
19
- "supply-chain",
20
- "signing"
21
- ],
22
- "license": "Apache-2.0",
23
15
  "type": "module",
24
- "engines": {
25
- "node": ">=22.0.0"
26
- },
27
- "os": [
28
- "linux",
29
- "darwin"
30
- ],
31
- "bin": {
32
- "mago-ski": "dist/src/cli.js"
33
- },
34
16
  "exports": {
35
17
  ".": {
36
18
  "types": "./dist/src/index.d.ts",
37
19
  "import": "./dist/src/index.js"
38
20
  }
39
21
  },
40
- "pi": {
41
- "extensions": [
42
- "./dist/hosts/pi/index.js"
43
- ]
44
- },
45
- "scripts": {
46
- "build": "tsc -p tsconfig.build.json",
47
- "typecheck": "tsc -p tsconfig.json --noEmit",
48
- "test": "node --test --test-concurrency=1 \"tests/**/*.test.ts\"",
49
- "check": "npm run typecheck && npm test",
50
- "prepublishOnly": "npm run check && npm run build"
22
+ "bin": {
23
+ "mago-ski": "dist/src/cli.js"
51
24
  },
52
25
  "files": [
53
- "dist",
26
+ "docs/hosts/",
54
27
  "action.yml",
55
- "README.md",
56
- "LICENSE",
57
- "NOTICE",
28
+ "dist",
58
29
  "docs/spec",
59
- "docs/hosts/",
60
- "docs/threat-model.md"
30
+ "docs/threat-model.md",
31
+ "LICENSE",
32
+ "README.md",
33
+ "NOTICE"
61
34
  ],
62
- "devDependencies": {
63
- "@earendil-works/pi-ai": "1.1.0",
64
- "@earendil-works/pi-coding-agent": "1.1.0",
65
- "@types/node": "22.20.4",
66
- "typescript": "5.8.3"
35
+ "scripts": {
36
+ "build": "tsc -p tsconfig.build.json",
37
+ "check": "npm run typecheck && npm test",
38
+ "prepublishOnly": "npm run check && npm run build",
39
+ "test": "node --test --test-concurrency=1 \"tests/**/*.test.ts\"",
40
+ "test:live:claude-code": "node tests/live/claude-code-gate.live.ts",
41
+ "test:live:codex": "node tests/live/codex-gate.live.ts",
42
+ "typecheck": "tsc -p tsconfig.json --noEmit"
67
43
  },
68
44
  "peerDependencies": {
69
45
  "@earendil-works/pi-coding-agent": ">=1.0.4"
@@ -72,5 +48,34 @@
72
48
  "@earendil-works/pi-coding-agent": {
73
49
  "optional": true
74
50
  }
51
+ },
52
+ "devDependencies": {
53
+ "@earendil-works/pi-ai": "1.1.0",
54
+ "@earendil-works/pi-coding-agent": "1.1.0",
55
+ "@types/node": "22.20.4",
56
+ "typescript": "5.8.3"
57
+ },
58
+ "keywords": [
59
+ "agent-skills",
60
+ "pi-package",
61
+ "pki",
62
+ "signing",
63
+ "skills",
64
+ "supply-chain"
65
+ ],
66
+ "engines": {
67
+ "node": "^22.23.4 || ^24.22.1 || >=26.12.1"
68
+ },
69
+ "os": [
70
+ "darwin",
71
+ "linux"
72
+ ],
73
+ "imports": {
74
+ "#package.json": "./package.json"
75
+ },
76
+ "pi": {
77
+ "extensions": [
78
+ "./dist/hosts/pi/index.js"
79
+ ]
75
80
  }
76
81
  }