Add checked private storage to reusable conformance rules
Scope attachments and projections by stable rule-application identity; keep lexical names private to each application. Lower ordinary initialization mappings and concrete captured creation targets through existing checking. Preserve stateless forwarding, conflict detection, and the materialization fence. Add tests for multiple same-atom specializations, name isolation, generic edges, factory seeds, and storage evolution. Full protocol Nix build and tests pass.
This commit is contained in:
@@ -87,6 +87,27 @@ test("two factories initialize two independent state owners without constructors
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
test("rule-owned state uses the same checked initialization and creation obligations", () => {
|
||||
const source = text
|
||||
.replace('conform Note as Data id "owner:data"', 'conform Tagged as Data id "rule:data"')
|
||||
.replace("on Note : string", "on Self : string");
|
||||
const result = compile(source);
|
||||
assert.ok(result.ok, JSON.stringify(result.diagnostics));
|
||||
const owner = result.workspace.conformances.find((c) => c.ruleOrigin?.ruleId === "rule:data")!;
|
||||
assert.equal(owner.initialization?.[0]?.binding.kind, "state");
|
||||
assert(owner.privateAttachments[0]!.id.startsWith("rule:sha256:"));
|
||||
for (const [invalid, diagnostic] of [
|
||||
[source.replaceAll("Data from input.data;", ""), "Required state"],
|
||||
[source.replace("initialize { title to state Title; };", ""), "no declared initialization mapping"],
|
||||
[source.replace("title to state Title;", "title to state Tags;"), "rule-private storage"],
|
||||
[source.replaceAll("Data from input.data;", "Data from input.tags;"), "does not match"],
|
||||
]) {
|
||||
const failure = compile(invalid!);
|
||||
assert.equal(failure.ok, false);
|
||||
assert.match(JSON.stringify(failure.diagnostics), new RegExp(diagnostic!));
|
||||
}
|
||||
});
|
||||
test("creation rejects missing seeds, wrong input shapes, and private initialization laundering", () => {
|
||||
for (const [edit, message] of [
|
||||
[text.replaceAll("Tagged from input.tags;", ""), "Required state tags-state"],
|
||||
|
||||
Reference in New Issue
Block a user