Make the repo key escape injective
Soul F1. `/` -> `_` is not injective: `GameCult_Epiphany/thing` and `GameCult/Epiphany_thing` both key to `yggdrasil:stewardship:GameCult_Epiphany_thing`, so an instance stewarding both silently loses one document. Keys are identity, not convenience. `_` is now escaped too, and both codes are two bytes starting with `_`: `_` becomes `__` and `/` becomes `_-`. Every other byte passes through and is never `_`, so a reader going left to right takes each `_` with the byte after it and never has a choice to make. The encoding is reversible, therefore injective. That is the smallest change that buys the property: nothing else moves, and the segment stays inside the `Label` byte class. The test claimed the property and checked one half of the colliding pair, which asserts nothing about collision. It now keys both halves and asserts they differ. M12 is re-anchored on the new spelling, and M13 is new: it puts the shipped `/` -> `_` back, which the pair kills. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
08c1c9d907
commit
eb55efe9c9
2 changed files with 52 additions and 21 deletions
|
|
@ -19,7 +19,7 @@
|
|||
# `epiphany-core/src/pipeline_documents.rs` to `epiphany-pipeline/src/lib.rs`,
|
||||
# so every entry names its own package as well as its own file. M10 still
|
||||
# mutates the spine, which kept its rule and its test. M11 and M12 are new with
|
||||
# the three kinds this cut added.
|
||||
# the three kinds this cut added, and M13-M15 came out of Soul's pass on them.
|
||||
#
|
||||
# A stale anchor is a hard failure, not a skipped entry: the check below asserts
|
||||
# each anchor matches exactly once, since `.Replace` hits every match and a
|
||||
|
|
@ -173,10 +173,22 @@ fn runtime_spine_schema_cache() -> Result<CultCache> {
|
|||
Id = 'M12'
|
||||
Package = $pipeline
|
||||
File = $documents
|
||||
Rule = 'A repo inside a key is escaped to Org_Repo.'
|
||||
Rule = 'A repo inside a key is escaped.'
|
||||
Test = 'tests::stewardship_key_escapes_the_repo_slash'
|
||||
Old = ' Ok(repo.0.replace(''/'', "_"))'
|
||||
Old = ' Ok(repo.0.replace(''_'', "__").replace(''/'', "_-"))'
|
||||
New = ' Ok(repo.0.clone())'
|
||||
},
|
||||
# Soul F1. Escaping is not enough on its own: the escape has to be
|
||||
# injective, or two repos claim one key and a mind stewarding both silently
|
||||
# loses a document. This is the escape the cut shipped, which is not.
|
||||
@{
|
||||
Id = 'M13'
|
||||
Package = $pipeline
|
||||
File = $documents
|
||||
Rule = 'The repo escape is injective, so two repos cannot claim one key.'
|
||||
Test = 'tests::stewardship_key_escapes_the_repo_slash'
|
||||
Old = ' Ok(repo.0.replace(''_'', "__").replace(''/'', "_-"))'
|
||||
New = ' Ok(repo.0.replace(''/'', "_"))'
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
Reference in a new issue