Skip to content

Commit 1a186f6

Browse files
authored
fix: distinguish CLI checksums from signed skill provenance (#11)
1 parent b348f9b commit 1a186f6

7 files changed

Lines changed: 148 additions & 22 deletions

File tree

‎docs/distribution.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,14 @@ Kilo archive provenance. The existing remote Skills service, released Continue
146146
grep transport and Rust KG MCP are distinct optional integrations. Actual Kilo
147147
installation, OAuth/provider methods and catalog admission remain unqualified
148148
until their individual output checks pass. No current Kilo listing is claimed.
149+
150+
### Skill signatures and CLI download checksums
151+
152+
The TSM signature verifies the original signed skill files. It does not authenticate
153+
separately installed `terraphim-grep` or `terraphim-agent` binaries. The Clients
154+
v1.21.20 download evidence establishes checksums; no archive-signature claim is
155+
made here. The Kilo imports of grep, memory and learn 1.0.3 correct the inherited
156+
phrase “signed, checksummed release archives” to “checksummed release archives”.
157+
Their provenance records the exact old/new text and source version/commit, and
158+
the verifier permits only that reviewed correction. Original signed source files
159+
and existing release assets remain unchanged.

‎integrations/kilo/release-inputs.json‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
"files": {
3232
"LICENSE": "bd6930ed220ef9feae8be4721c84e845318b060bcd08e19007d4d10171dd45f2",
3333
"NOTICE": "52f3456ba8b6e845956338bd08bc2fadadbcf1263a052dc968f1524521367115",
34-
"SKILL.md": "dd2f32d2a627014b66e74f9610643b8138fd64fddfb55f3319472c2a28a12746",
35-
"local.patch": "da385469b27e450e3e9b72e73da56346fa414fcb633e55a3a0ba3a1c2d53d091",
34+
"SKILL.md": "fee56aa6c00d781b13defe6b195b77d870d72ee15eed24490ace98b348e6245a",
35+
"local.patch": "b0be529f02cbf7d0d344a8925d68d3900600701f95ecd5697124f9f396c453e9",
3636
"local.remove": "b6d386395a64b4912c766a87e22759691237c477a58643cb7d62c1c248545436",
3737
"references/command-guide.md": "79b5993fd6087dc104b5270d16abd4beddbecbd5f038f1eb1f711326645aa97b",
38-
"references/kilo-provenance.json": "a2d2d01dab9b414874d3cab956bc8b0f87759d05630be749c67b60df5585ba63",
38+
"references/kilo-provenance.json": "d7b60f52720585d83aa8cd2f99d0b830c0218d153626ee9b48aa1133d4961984",
3939
"references/risk-concern.knowledge-graph.json": "f8648b16470e764bdff5c95064078419d71e8d41d2ca30d4b1508017c166a45d",
4040
"references/workflows.md": "77d840f59c99c502413161985be10eedb09162a6e3dd337caa2a24aceccc0fad"
4141
},
@@ -70,11 +70,11 @@
7070
"files": {
7171
"LICENSE": "bd6930ed220ef9feae8be4721c84e845318b060bcd08e19007d4d10171dd45f2",
7272
"NOTICE": "52f3456ba8b6e845956338bd08bc2fadadbcf1263a052dc968f1524521367115",
73-
"SKILL.md": "bd5eb837483548e4666ea9569d76473c7f0c6e8f04da2a7e1a645797f0ab7ede",
74-
"local.patch": "834514919748b7783d8e1a21381515497c5aa4a647ea848464529f71a628737c",
73+
"SKILL.md": "738eaf7fd3896d091c58a6a060166d67e240f919bbe40d9b2eeb8b3826252ea4",
74+
"local.patch": "b2116ea9d1a2d15f1fe4ffc4d5f37f44e969a221f66236bcd84dd954802568f9",
7575
"local.remove": "b6d386395a64b4912c766a87e22759691237c477a58643cb7d62c1c248545436",
7676
"references/command-guide.md": "fd9af409bae86ec3b77495fad94694af021c1fc1d42081fd0ce13cdeab99bc89",
77-
"references/kilo-provenance.json": "0cec09d5fa2c0b88aea47b9e462115b43d248bfe95243263c7d3421f39fc4a17",
77+
"references/kilo-provenance.json": "75368221c945f004c13e4a5cd6c820c89a203d609eac90aeacd8e5766f721c07",
7878
"references/risk-concern.knowledge-graph.json": "f8648b16470e764bdff5c95064078419d71e8d41d2ca30d4b1508017c166a45d",
7979
"references/workflows.md": "77d840f59c99c502413161985be10eedb09162a6e3dd337caa2a24aceccc0fad"
8080
},
@@ -109,11 +109,11 @@
109109
"files": {
110110
"LICENSE": "bd6930ed220ef9feae8be4721c84e845318b060bcd08e19007d4d10171dd45f2",
111111
"NOTICE": "52f3456ba8b6e845956338bd08bc2fadadbcf1263a052dc968f1524521367115",
112-
"SKILL.md": "cc798f22c6e3901b8ef41bb20f08eef13dea09f7352a2509c239ba4a89d5c643",
113-
"local.patch": "d0794fd7c59143022ea5c60010f07306606a6425a7240e17cb93ac675cf53ef9",
112+
"SKILL.md": "2672a6200c2e0210d6403faab86880b3e9f0104324875d8212d21d1c23039dca",
113+
"local.patch": "f526f46f135182875cfcb8674539376bcc2fcfe8b577e37b2752634a757b13df",
114114
"local.remove": "b6d386395a64b4912c766a87e22759691237c477a58643cb7d62c1c248545436",
115115
"references/command-guide.md": "d076dfb8ad82fc2db1296549fa2c2cab606b28836a42a43e20e4f91b056529b2",
116-
"references/kilo-provenance.json": "0952086ea703ca400e8f62ecf6096984ce0bee36facd87f2f3bcdab710644014",
116+
"references/kilo-provenance.json": "c7478a3be9a331dd9a5d93525fba5b0e3541dd295204d41657e861aa6c3bd82d",
117117
"references/risk-concern.knowledge-graph.json": "f8648b16470e764bdff5c95064078419d71e8d41d2ca30d4b1508017c166a45d",
118118
"references/workflows.md": "77d840f59c99c502413161985be10eedb09162a6e3dd337caa2a24aceccc0fad"
119119
},

‎scripts/verify_kilo_distribution.py‎

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,39 @@ def _body(data: bytes) -> bytes:
225225
return sections[1]
226226

227227

228+
def wording_corrections(row: dict, entry_id: str) -> list[dict]:
229+
"""Return the single reviewed factual correction for the original 1.0.3 skills."""
230+
if (
231+
entry_id
232+
not in {"terraphim-grep", "terraphim-agent-memory", "terraphim-agent-learn"}
233+
or row.get("version") != "1.0.3"
234+
or row.get("sourceCommit") != "391c7e4ebc103f1770b9dca589fcce7ccd211d5f"
235+
):
236+
return []
237+
return [
238+
{
239+
"sourceVersion": "1.0.3",
240+
"sourceCommit": "391c7e4ebc103f1770b9dca589fcce7ccd211d5f",
241+
"oldText": "For signed,\nchecksummed release archives",
242+
"newText": "For checksummed release archives",
243+
"reason": "The verified skill signature does not authenticate separate CLI archives; only CLI release checksums were verified.",
244+
}
245+
]
246+
247+
248+
def expected_instruction_body(data: bytes, row: dict, entry_id: str) -> bytes:
249+
"""Preserve original instructions except an exact admitted factual correction."""
250+
body = _body(data).rstrip(b"\n")
251+
for correction in wording_corrections(row, entry_id):
252+
old = correction["oldText"].encode()
253+
if body.count(old) != 1:
254+
raise VerificationError(
255+
"reviewed wording correction is not uniquely applicable"
256+
)
257+
body = body.replace(old, correction["newText"].encode())
258+
return body + b"\n" + FOOTER.encode()
259+
260+
228261
def _archive_files(row: dict) -> dict:
229262
imported = row.get("import")
230263
if not imported:
@@ -255,11 +288,8 @@ def verify_import(source: Path, imported: Path, inputs: dict, entry_id: str) ->
255288
)
256289
if (imported / "local.remove").read_bytes() != b"skill.toml\n":
257290
raise VerificationError("root signature removal is not exact")
258-
if (
259-
_body((imported / "SKILL.md").read_bytes())
260-
!= _body((source / "SKILL.md").read_bytes()).rstrip(b"\n")
261-
+ b"\n"
262-
+ FOOTER.encode()
291+
if _body((imported / "SKILL.md").read_bytes()) != expected_instruction_body(
292+
(source / "SKILL.md").read_bytes(), row, entry_id
263293
):
264294
raise VerificationError("imported instruction body changed")
265295
for name in row["sourceBlake3"]:
@@ -271,6 +301,8 @@ def verify_import(source: Path, imported: Path, inputs: dict, entry_id: str) ->
271301
if actual.get(name) != expected:
272302
raise VerificationError(f"license/notice changed: {name}")
273303
provenance = json.loads((imported / PROVENANCE_PATH).read_text(encoding="utf-8"))
304+
if provenance.get("wordingCorrections", []) != wording_corrections(row, entry_id):
305+
raise VerificationError("wording provenance differs from reviewed correction")
274306
original = provenance["source"]
275307
if (
276308
provenance.get("schemaVersion") != 1

‎tests/fixtures/kilo/terraphim-grep/SKILL.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ terraphim-grep --help
3131
```
3232

3333
The examples target released **Clients 1.21.20**. Homebrew may install a different
34-
version; inspect the installed help before using a command. For signed,
35-
checksummed release archives, follow the
34+
version; inspect the installed help before using a command. For checksummed release archives, follow the
3635
[installation guide](https://terraphim-skills.md/docs/non-technical/).
3736
The skill does not install software automatically.
3837

‎tests/fixtures/kilo/terraphim-grep/local.patch‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
diff --git a/terraphim-grep/SKILL.md b/terraphim-grep/SKILL.md
22
--- a/terraphim-grep/SKILL.md
33
+++ b/terraphim-grep/SKILL.md
4-
@@ -81,3 +81,11 @@
4+
@@ -31,8 +31,7 @@
5+
```
6+
7+
The examples target released **Clients 1.21.20**. Homebrew may install a different
8+
-version; inspect the installed help before using a command. For signed,
9+
-checksummed release archives, follow the
10+
+version; inspect the installed help before using a command. For checksummed release archives, follow the
11+
[installation guide](https://terraphim-skills.md/docs/non-technical/).
12+
The skill does not install software automatically.
13+
14+
@@ -81,3 +80,11 @@
515

616
Browse the [Community, Core, and Premium skill catalogue](https://terraphim-skills.md/skills/).
717
Discovering a related skill never starts checkout or changes an entitlement.
@@ -27,7 +37,7 @@ diff --git a/terraphim-grep/references/kilo-provenance.json b/terraphim-grep/ref
2737
new file mode 100644
2838
--- /dev/null
2939
+++ b/terraphim-grep/references/kilo-provenance.json
30-
@@ -0,0 +1,42 @@
40+
@@ -0,0 +1,52 @@
3141
+{
3242
+ "schemaVersion": 1,
3343
+ "entryId": "terraphim-grep",
@@ -66,7 +76,17 @@ new file mode 100644
6676
+ "upstream text whitespace normalization",
6777
+ "root LICENSE via metadata.source.license_path",
6878
+ "root skill.toml removed via local.remove",
69-
+ "NOTICE, provenance and explanation added via local.patch"
79+
+ "NOTICE, provenance and explanation added via local.patch",
80+
+ "exact CLI archive wording correction recorded in wordingCorrections"
7081
+ ],
71-
+ "signatureScope": "The original signature verifies the immutable source skill, not this transformed Kilo copy."
82+
+ "signatureScope": "The original signature verifies the immutable source skill, not this transformed Kilo copy.",
83+
+ "wordingCorrections": [
84+
+ {
85+
+ "sourceVersion": "1.0.3",
86+
+ "sourceCommit": "391c7e4ebc103f1770b9dca589fcce7ccd211d5f",
87+
+ "oldText": "For signed,\nchecksummed release archives",
88+
+ "newText": "For checksummed release archives",
89+
+ "reason": "The verified skill signature does not authenticate separate CLI archives; only CLI release checksums were verified."
90+
+ }
91+
+ ]
7292
+}

‎tests/fixtures/kilo/terraphim-grep/references/kilo-provenance.json‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@
3636
"upstream text whitespace normalization",
3737
"root LICENSE via metadata.source.license_path",
3838
"root skill.toml removed via local.remove",
39-
"NOTICE, provenance and explanation added via local.patch"
39+
"NOTICE, provenance and explanation added via local.patch",
40+
"exact CLI archive wording correction recorded in wordingCorrections"
4041
],
41-
"signatureScope": "The original signature verifies the immutable source skill, not this transformed Kilo copy."
42+
"signatureScope": "The original signature verifies the immutable source skill, not this transformed Kilo copy.",
43+
"wordingCorrections": [
44+
{
45+
"sourceVersion": "1.0.3",
46+
"sourceCommit": "391c7e4ebc103f1770b9dca589fcce7ccd211d5f",
47+
"oldText": "For signed,\nchecksummed release archives",
48+
"newText": "For checksummed release archives",
49+
"reason": "The verified skill signature does not authenticate separate CLI archives; only CLI release checksums were verified."
50+
}
51+
]
4252
}

‎tests/test_kilo_distribution.py‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,60 @@ def test_actual_official_import_matches_pinned_tree_and_original_body(self):
6060
self.assertIn("NOTICE", receipt["archiveFiles"])
6161
self.assertIn("references/kilo-provenance.json", receipt["archiveFiles"])
6262

63+
def test_exact_cli_checksum_wording_correction_is_accepted(self):
64+
skill = self.imported / "SKILL.md"
65+
skill.write_text(
66+
skill.read_text().replace(
67+
"For signed,\nchecksummed release archives",
68+
"For checksummed release archives",
69+
)
70+
)
71+
inputs = json.loads(json.dumps(INPUTS))
72+
inputs["skills"][ID]["import"]["files"] = V.read_tree(self.imported)
73+
receipt = V.verify_import(ROOT / "skills" / ID, self.imported, inputs, ID)
74+
self.assertEqual("PASS", receipt["status"])
75+
self.assertIn("For checksummed release archives", skill.read_text())
76+
77+
def test_cli_wording_transform_is_limited_to_admitted_version_and_commit(self):
78+
for name in (
79+
"terraphim-grep",
80+
"terraphim-agent-memory",
81+
"terraphim-agent-learn",
82+
):
83+
data = (ROOT / "skills" / name / "SKILL.md").read_bytes()
84+
row = INPUTS["skills"][name]
85+
expected = V.expected_instruction_body(data, row, name)
86+
self.assertNotIn(b"For signed,\nchecksummed release archives", expected)
87+
self.assertIn(b"For checksummed release archives", expected)
88+
for field, changed in (("version", "1.0.4"), ("sourceCommit", "0" * 40)):
89+
unsupported = dict(row, **{field: changed})
90+
unchanged = V.expected_instruction_body(data, unsupported, name)
91+
self.assertIn(b"For signed,\nchecksummed release archives", unchanged)
92+
self.assertNotIn(b"For checksummed release archives", unchanged)
93+
94+
def test_original_cli_signature_claim_refused_even_if_hash_is_recomputed(self):
95+
skill = self.imported / "SKILL.md"
96+
skill.write_text(
97+
skill.read_text().replace(
98+
"For checksummed release archives",
99+
"For signed,\nchecksummed release archives",
100+
)
101+
)
102+
inputs = json.loads(json.dumps(INPUTS))
103+
inputs["skills"][ID]["import"]["files"] = V.read_tree(self.imported)
104+
with self.assertRaisesRegex(V.VerificationError, "body"):
105+
V.verify_import(ROOT / "skills" / ID, self.imported, inputs, ID)
106+
107+
def test_wording_provenance_refused_even_if_hash_is_recomputed(self):
108+
path = self.imported / "references/kilo-provenance.json"
109+
provenance = json.loads(path.read_text())
110+
provenance["wordingCorrections"] = []
111+
path.write_text(json.dumps(provenance, indent=2) + "\n")
112+
inputs = json.loads(json.dumps(INPUTS))
113+
inputs["skills"][ID]["import"]["files"] = V.read_tree(self.imported)
114+
with self.assertRaisesRegex(V.VerificationError, "wording provenance"):
115+
V.verify_import(ROOT / "skills" / ID, self.imported, inputs, ID)
116+
63117
def test_all_original_skills_have_exact_admitted_file_hashes(self):
64118
for name in INPUTS["skills"]:
65119
self.assertEqual(

0 commit comments

Comments
 (0)