Repository navigation
test(k9): make M6's mirror guard real; fix(ci): give the debt measurement provenance #1329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,17 @@ | |
| CORE_CAPABILITIES="fs.read fs.write net.fetch process.spawn container.run secret.read deploy.apply rollback.apply" | ||
| EXTENSION_PREFIX="x-" | ||
|
|
||
| # The same two closed lists are also written down in the host-side files | ||
| # leash.ncl and capabilities.ncl, which this validator never loads — they carry | ||
| # `detect_level`, `check_level` and the handshake records a contract file has no | ||
| # business holding. MIGRATION-1058 M6 states that "--self-test asserts the | ||
| # mirrors agree, so it cannot drift silently". That was true of the bash | ||
| # constants above and false of these two files: nothing read them. --self-test | ||
| # now does. | ||
| K9_DIR="$(cd -- "$SPEC_DIR/.." && pwd)" | ||
| LEASH_NCL="$K9_DIR/leash.ncl" | ||
| CAPABILITIES_NCL="$K9_DIR/capabilities.ncl" | ||
|
|
||
| LAYER="all" | ||
| STRICT=0 | ||
| JSON=0 | ||
|
|
@@ -745,6 +756,27 @@ | |
| t "schema_major mirrors k9_contract.ncl" "$SCHEMA_MAJOR" \ | ||
| "$(grep -oE 'schema_major = "[^"]+"' "$CONTRACT" | sed 's/.*"\(.*\)"/\1/')" | ||
|
|
||
| echo "== the host-side .ncl mirrors cannot drift either (M6) ==" | ||
| # Every value below is extracted as DATA — the enum literal and the array | ||
| # literal — and never from a comment, so rewriting the prose that documents | ||
| # a list cannot satisfy the assertion that checks it. | ||
| local cn hp | ||
| t "leash.ncl SecurityLevel mirrors k9_contract.ncl" \ | ||
| "$(grep -oE "leash_levels = \[[^]]*\]" "$CONTRACT" | grep -oE "'[A-Za-z]+" | tr '\n' ' ' | sed 's/ $//')" \ | ||
| "$(grep -oE "let SecurityLevel = \[\|[^]]*\|\]" "$LEASH_NCL" | grep -oE "'[A-Za-z]+" | tr '\n' ' ' | sed 's/ $//')" | ||
| cn="$(awk '/core_capabilities = \[/,/^ \]/' "$CONTRACT" | grep -oE '"[a-z]+\.[a-z]+"' | tr -d '"' | tr '\n' ' ' | sed 's/ $//')" | ||
| t "capabilities.ncl core mirrors k9_contract.ncl" "$cn" \ | ||
| "$(awk '/^ core = \[/,/^ \]/' "$CAPABILITIES_NCL" | grep -oE '"[a-z]+\.[a-z]+"' | tr -d '"' | tr '\n' ' ' | sed 's/ $//')" | ||
| # §9.2 — Hunt needs all five, always. This is a closed set: a precondition | ||
| # removed from the contract must fail here rather than quietly weaken Hunt. | ||
| hp="$(awk '/hunt_preconditions = \[/,/^ \]/' "$CONTRACT" | grep -oE '"[a-z_]+"' | tr -d '"' | tr '\n' ' ' | sed 's/ $//')" | ||
|
Comment on lines
+769
to
+772
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If a list entry is commented out rather than deleted, these extractors still count its quoted value, allowing the new drift guards to pass despite different actual lists. In a temporary copy, commenting out Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis
Exclude comments from Hunt precondition extraction. The current contract has no quoted lowercase words in comments inside the array. However, a commented-out 🤖 Prompt for AI Agents
|
||
| t "hunt_preconditions is exactly the five, closed (§9.2)" \ | ||
| "signature policy sandbox dry_run capability_grant" "$hp" | ||
| # §7 — the leash taxonomy is likewise closed, in both directions. | ||
| t "the leash taxonomy is exactly three, closed (§7)" \ | ||
| "'Kennel 'Yard 'Hunt" \ | ||
| "$(grep -oE "leash_levels = \[[^]]*\]" "$CONTRACT" | grep -oE "'[A-Za-z]+" | tr '\n' ' ' | sed 's/ $//')" | ||
|
Check warning on line 778 in 1-formats/k9/tools/k9-validate.sh
|
||
|
|
||
| echo "== capability arithmetic (§8) ==" | ||
| expect_ok capability_ok "fs.read" | ||
| expect_ok capability_ok "rollback.apply" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n 70,92p 1-formats/k9/tools/k9-validate.sh sed -n 750,785p 1-formats/k9/tools/k9-validate.sh grep -n "SecurityLevel" 1-formats/k9/leash.nclRepository: hyperpolymath/standards
Length of output: 3678
Keep complete Nickel enum tags in the leash mirror checks.
The tag pattern
'[A-Za-z]+stops at the first digit or underscore. Nickel allows both in enum tags, so'Yard2is read as'Yard. Ifleash.nclchanges'Yardto'Yard2, theSecurityLevelmirror assertion still passes. The contract side uses the same pattern, so a contract tag that gains a digit or underscore is also truncated. The §7 closed-set assertion then cannot detect that change.This is a gap in a self-test guard. The current taxonomy has no digits or underscores, so no current check fails.
🐛 Suggested fix
Host-side
SecurityLevelextraction:Contract-side extraction in the
SecurityLevelmirror assertion:Contract-side extraction in the §7 taxonomy assertion:
🤖 Prompt for AI Agents