Fork card: a closed card may name no ruling (withdrawn or superseded question)

Step 6 reads status, and the mind closes a question on any resolution, not
only a ruling (Heimdall's file, step 6: "resolved or withdrawn: fork_closed";
Huginn PR #29 desk.rs:161). The rule "a closed card names its ruling" made a
withdrawn question an invalid card. Now only an open card may not name a
ruling, and ruled_from needs a ruling. Vectors: a valid withdrawn card, and
negatives for an open card with a ruling and ruled_from without one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-10 16:18:14 +00:00
commit acb4757f38
5 changed files with 91 additions and 9 deletions

View file

@ -418,6 +418,44 @@
"options_hash": "f856edce121db4121b5f1af400b1c471ebbfa6579a042aca9a34ae31c15f5c86"
},
"messagePackHex": "DE0010AD736368656D6156657273696F6EB567616D6563756C742E666F726B2E636172642E7630A7666F726B5F6964D92867616D6563756C742D636861743A7175657374696F6E3A736C6F742D6D61726B2D636F6E73656E74A57469746C65B1536C6F74206D61726B20636F6E73656E74A7636F6E74657874BD53686F756C64206120736C6F74206D61726B206265207368617265643FA76F7074696F6E739282A26964A3796573A474657874A953686172652069742E82A26964A26E6FA474657874AE4B656570206974206C6F63616C2EAE7265636F6D6D656E646174696F6EA26E6FA7646570656E647390A56C65616E73A3796573A4666C6167D92670726F766973696F6E616C3A2053656C662065787065637473207468697320746F206D6F7665A97261697365645F696EC0A8646563696465727392D92465306431633262332D613439352D343638372D383837392D366135623463336432653166D92439663865376436632D356234612D343339322D383137302D306631653264336334623561A6737461747573A6636C6F736564A672756C696E67AE783A7265736F6C7574696F6E3A79AA72756C65645F66726F6D91A26E31A56F7264657200AC6F7074696F6E735F68617368D94066383536656463653132316462343132316235663161663430306231633437316562626661363537396130343261636139613334616533316331356635633836"
},
{
"name": "closed_without_a_ruling_the_question_was_withdrawn",
"message": {
"schemaVersion": "gamecult.fork.card.v0",
"fork_id": "gamecult-chat:question:slot-mark-consent",
"title": "Slot mark consent",
"context": "Should a slot mark be shared?",
"options": [
{
"id": "yes",
"text": "Share it."
},
{
"id": "no",
"text": "Keep it local."
}
],
"recommendation": "no",
"depends": [
"gamecult-chat:question:file-zone-audience"
],
"leans": null,
"flag": null,
"raised_in": {
"kind": "CutSpec",
"id": "cultlib-gaps:cut_spec:cut-slot-tolerance.r4"
},
"deciders": [
"e0d1c2b3-a495-4687-8879-6a5b4c3d2e1f"
],
"status": "closed",
"ruling": null,
"ruled_from": [],
"order": 3,
"options_hash": "7d95fc87d532420611fe415c1def27a3447617bb68235f46e3af130aea361c48"
},
"messagePackHex": "DE0010AD736368656D6156657273696F6EB567616D6563756C742E666F726B2E636172642E7630A7666F726B5F6964D92867616D6563756C742D636861743A7175657374696F6E3A736C6F742D6D61726B2D636F6E73656E74A57469746C65B1536C6F74206D61726B20636F6E73656E74A7636F6E74657874BD53686F756C64206120736C6F74206D61726B206265207368617265643FA76F7074696F6E739282A26964A3796573A474657874A953686172652069742E82A26964A26E6FA474657874AE4B656570206974206C6F63616C2EAE7265636F6D6D656E646174696F6EA26E6FA7646570656E647391D92967616D6563756C742D636861743A7175657374696F6E3A66696C652D7A6F6E652D61756469656E6365A56C65616E73C0A4666C6167C0A97261697365645F696E82A46B696E64A743757453706563A26964D92B63756C746C69622D676170733A6375745F737065633A6375742D736C6F742D746F6C6572616E63652E7234A8646563696465727391D92465306431633262332D613439352D343638372D383837392D366135623463336432653166A6737461747573A6636C6F736564A672756C696E67C0AA72756C65645F66726F6D90A56F7264657203AC6F7074696F6E735F68617368D94037643935666338376435333234323036313166653431356331646566323761333434373631376262363832333566343665336166313330616561333631633438"
}
],
"invalid": [
@ -877,8 +915,46 @@
}
},
{
"name": "closed_without_ruling",
"why": "rule: a closed card names its ruling (not expressible in the schema)",
"name": "open_card_names_a_ruling",
"why": "rule: only a closed card names a ruling (not expressible in the schema)",
"message": {
"schemaVersion": "gamecult.fork.card.v0",
"fork_id": "gamecult-chat:question:slot-mark-consent",
"title": "Slot mark consent",
"context": "Should a slot mark be shared?",
"options": [
{
"id": "yes",
"text": "Share it."
},
{
"id": "no",
"text": "Keep it local."
}
],
"recommendation": "no",
"depends": [
"gamecult-chat:question:file-zone-audience"
],
"leans": null,
"flag": null,
"raised_in": {
"kind": "CutSpec",
"id": "cultlib-gaps:cut_spec:cut-slot-tolerance.r4"
},
"deciders": [
"e0d1c2b3-a495-4687-8879-6a5b4c3d2e1f"
],
"status": "open",
"ruling": "cultlib-gaps:resolution:question.slot-mark-consent.n1",
"ruled_from": [],
"order": 3,
"options_hash": "7d95fc87d532420611fe415c1def27a3447617bb68235f46e3af130aea361c48"
}
},
{
"name": "ruled_from_without_a_ruling",
"why": "rule: ruled_from lists answers a ruling was admitted from, so it needs the ruling (not expressible in the schema)",
"message": {
"schemaVersion": "gamecult.fork.card.v0",
"fork_id": "gamecult-chat:question:slot-mark-consent",
@ -909,7 +985,9 @@
],
"status": "closed",
"ruling": null,
"ruled_from": [],
"ruled_from": [
"n1"
],
"order": 3,
"options_hash": "7d95fc87d532420611fe415c1def27a3447617bb68235f46e3af130aea361c48"
}

View file

@ -30,9 +30,9 @@ All documents are CultNet map-mode: every key written, nil where absent, closed
- `fork_id`: the mind's `question` key, `<campaign>:question:<label>`.
- **Hashed (the shown members):** `title`, `context`, `options` (each `{id, text}`, in shown order), `recommendation` (an option id, **never nil**: the stored `question` requires `recommended`), `depends` (strings, each the `campaign:kind:label` rendering of a stored reference, in shown order, empty when none).
- **Not hashed:** `fork_id` (bound beside the hash), `leans` (an option id or nil), `flag`, `raised_in`, `deciders`, `status` (`open` or `closed`), `ruling` (the ruling id when closed), `ruled_from` (answer ids a ruling has been admitted from; non-empty only on a closed card), `order`, and `options_hash` itself.
- **Not hashed:** `fork_id` (bound beside the hash), `leans` (an option id or nil), `flag`, `raised_in`, `deciders`, `status` (`open` or `closed`), `ruling` (the ruling id when a ruling closed the fork; nil when the card is open, and nil on a closed card whose question was withdrawn or otherwise resolved with no ruling), `ruled_from` (answer ids a ruling has been admitted from; non-empty only on a closed card), `order`, and `options_hash` itself.
- **`deciders` is read-only data.** The list is set outside the Mind, through Bifrost's admin path; the Mind reads it and the card projection copies it. A question's own `audience` may only narrow it. A Mind never writes it, so a Mind cannot add itself and answer its own fork.
- Rules a schema cannot say, each with a negative vector: option ids are unique; `recommendation` and `leans` name an option; deciders are unique; a closed card names its `ruling`; an open card's `ruled_from` is empty (a ruling that answers a fork closes it); `options_hash` equals the hash of the shown members.
- Rules a schema cannot say, each with a negative vector: option ids are unique; `recommendation` and `leans` name an option; deciders are unique; an open card names no `ruling` and its `ruled_from` is empty (a ruling that answers a fork closes it); `ruled_from` is non-empty only when `ruling` is set; a closed card may name no ruling (the question was withdrawn, superseded or deferred: step 6 reads `status`, not the ruling); `options_hash` equals the hash of the shown members.
### Options hash (canonical bytes)

View file

@ -104,7 +104,8 @@ const cardRuleErrors = (c: Card): string[] => {
if (!ids.includes(c.recommendation)) errors.push("recommendation is not an option");
if (c.leans !== null && !ids.includes(c.leans)) errors.push("leans is not an option");
if (new Set(c.deciders).size !== c.deciders.length) errors.push("duplicate deciders");
if (c.status === "closed" && c.ruling === null) errors.push("closed without a ruling");
if (c.status === "open" && c.ruling !== null) errors.push("an open card names a ruling");
if (c.ruling === null && c.ruled_from.length > 0) errors.push("ruled_from without a ruling");
if (c.status === "open" && c.ruled_from.length > 0) errors.push("an open card cites an answer in ruled_from");
if (c.options_hash !== optionsHash(c)) errors.push("options_hash is not the hash of the shown members");
return errors;

View file

@ -409,7 +409,8 @@ fork = {
"optionsHash": hashes,
"card": {"valid": [{"name": "operator_fork", "message": CARD, "messagePackHex": hx(CARD)},
{"name": "leans_flag_closed_two_deciders", "message": card(leans="yes", flag="provisional: Self expects this to move", deciders=[OP, HM], depends=[], raised_in=None, status="closed", ruling="x:resolution:y", ruled_from=["n1"], order=0),
"messagePackHex": hx(card(leans="yes", flag="provisional: Self expects this to move", deciders=[OP, HM], depends=[], raised_in=None, status="closed", ruling="x:resolution:y", ruled_from=["n1"], order=0))}],
"messagePackHex": hx(card(leans="yes", flag="provisional: Self expects this to move", deciders=[OP, HM], depends=[], raised_in=None, status="closed", ruling="x:resolution:y", ruled_from=["n1"], order=0))},
{"name": "closed_without_a_ruling_the_question_was_withdrawn", "message": card(status="closed"), "messagePackHex": hx(card(status="closed"))}],
"invalid": [bad(n, w, m) for n, w, m in [
("one_option", "two or more options", card(options=[OPT[0]], recommendation="yes")),
("no_deciders", "a fork with no decider cannot be answered", card(deciders=[])),
@ -423,7 +424,8 @@ fork = {
("leans_not_an_option", "rule: leans is nil or an option id (not expressible in the schema)", card(leans="maybe")),
("duplicate_deciders", "rule: deciders are unique (not expressible in the schema)", card(deciders=[OP, OP])),
("ruled_from_on_an_open_card", "rule: a ruling that answers a fork closes it, so an open card cites no answer in ruled_from (not expressible in the schema)", card(ruled_from=["n1"])),
("closed_without_ruling", "rule: a closed card names its ruling (not expressible in the schema)", card(status="closed")),
("open_card_names_a_ruling", "rule: only a closed card names a ruling (not expressible in the schema)", card(ruling="cultlib-gaps:resolution:question.slot-mark-consent.n1")),
("ruled_from_without_a_ruling", "rule: ruled_from lists answers a ruling was admitted from, so it needs the ruling (not expressible in the schema)", card(status="closed", ruled_from=["n1"])),
("options_hash_of_another_card", "rule: options_hash equals the hash of the shown members (not expressible in the schema)", dict(card(), options_hash=STALE_H)),
]]},
"request": {"valid": [{"name": n, "message": m, "messagePackHex": hx(m)} for n, m in

View file

@ -178,7 +178,8 @@ namespace GameCult.Networking.Tests
if (c["leans"] is not null && !ids.Contains(S(c["leans"]))) yield return "leans is not an option";
var deciders = c["deciders"]!.AsArray().Select(S).ToList();
if (deciders.Distinct().Count() != deciders.Count) yield return "duplicate deciders";
if (S(c["status"]) == "closed" && c["ruling"] is null) yield return "closed without a ruling";
if (S(c["status"]) == "open" && c["ruling"] is not null) yield return "an open card names a ruling";
if (c["ruling"] is null && c["ruled_from"]!.AsArray().Count > 0) yield return "ruled_from without a ruling";
if (S(c["status"]) == "open" && c["ruled_from"]!.AsArray().Count > 0) yield return "an open card cites an answer in ruled_from";
if (S(c["options_hash"]) != HashOf(c)) yield return "options_hash is not the hash of the shown members";
}