Tighten who writes and reviews a record, date the rules, bound history (review of #206)
mesh/merge-gate pass: builds new: modules/mesh-knowledge, sent nowhere; no bus step; every machine composes with the change as it did without (4 of 4 compo…
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate pass: builds new: modules/mesh-knowledge, sent nowhere; no bus step; every machine composes with the change as it did without (4 of 4 compo…
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery superseded: a newer head of the same pull request
A revision came from anyone and a review was refused only to the first author, so a co-writer could approve, and a record proposed before callers are proven would later be reviewable by its own unproven author. Now a revision is taken only from the proven author, a reserved number only from whoever reserved it, and a review is refused from any writer of any version or for any record with an unproven writer. The rules held records from no date, so a correction to an older record was refused by rules hq never held it to; each dated rule now holds from hq's own start date, and a new record cannot be dated before its reservation. history and the question to ask are bounded like the other answers.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// A rule holds a record from the day hq's checks began to hold it (the review of mesh-catalog#206): a dated
|
||||
// correction to an older record is judged by the rules that held it then, never by one that came later.
|
||||
|
||||
// insightTo is a progressive insight to a held record: the record as it stands, resent whole, with what stood
|
||||
// before.
|
||||
func insightTo(t *testing.T, w *world, k Key) ProposeAsk {
|
||||
t.Helper()
|
||||
r := mustGet(t, w.k.Store, k).Current
|
||||
p := ProposeAsk{Kind: k.Kind, Number: k.Number, Title: r.Title, Topic: r.Topic, Date: r.Date, Deciders: r.Deciders,
|
||||
Sections: r.Sections, Homes: r.Homes, Insight: "the count said 12 where 13 stood"}
|
||||
for _, c := range r.Clauses {
|
||||
p.Clauses = append(p.Clauses, c.Text)
|
||||
}
|
||||
for _, l := range r.Links {
|
||||
p.Links = append(p.Links, LinkAsk{Kind: l.Kind, To: l.To.String(), From: l.From})
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// ADR 0011 (2026-04-03) is a real older record: its decision is prose, it has no section saying how it is checked,
|
||||
// and it was written before the words and clause rules held. A correction of fact to it is taken.
|
||||
func TestAnInsightToAnOlderRecordIsJudgedByTheRulesThatHeldIt(t *testing.T) {
|
||||
w := newWorld(t, newMemStore(), hqMain(t))
|
||||
if _, err := w.k.Import("import@test", ImportAsk{}, hqMain(t)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p := insightTo(t, w, Key{KindDecision, 11})
|
||||
p.Sections[0].Text += "\n\nThe control plane wrote them."
|
||||
if _, err := w.k.Propose("corrector@ace", p); err != nil {
|
||||
t.Fatalf("an insight to ADR 0011 was refused by rules that never held it: %v", err)
|
||||
}
|
||||
// The same words in a record of today are refused.
|
||||
n := w.reserved(t, "author@g14")
|
||||
q := valid(n)
|
||||
q.Sections[2].Text = "The control plane wrote them."
|
||||
if _, err := w.k.Propose("author@g14", q); err == nil || !strings.Contains(err.Error(), "- retired-word:") {
|
||||
t.Fatalf("a retired word in a record of today: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEachDatedRuleHoldsFromItsDay(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
rule, before, from string
|
||||
}{
|
||||
{"retired-word", "2026-10-06", "2026-10-07"},
|
||||
{"daemon-line", "2026-10-08", "2026-10-09"},
|
||||
{"deferral", "2026-10-08", "2026-10-09"},
|
||||
{"has-clause", "2026-10-10", "2026-10-11"},
|
||||
{"clause-lead", "2026-10-10", "2026-10-11"},
|
||||
{"checked", "2026-10-10", "2026-10-11"},
|
||||
} {
|
||||
if Holds(c.rule, c.before) || !Holds(c.rule, c.from) {
|
||||
t.Errorf("%s holds a record of %s: %v, of %s: %v", c.rule, c.before, Holds(c.rule, c.before), c.from, Holds(c.rule, c.from))
|
||||
}
|
||||
}
|
||||
if !Holds("title", "2026-01-01") {
|
||||
t.Error("an undated rule does not hold an old record")
|
||||
}
|
||||
}
|
||||
|
||||
// A new record cannot be dated back past the rules: it is of the day its number was reserved, or later.
|
||||
func TestANewRecordIsNotDatedBeforeItsReservation(t *testing.T) {
|
||||
w := imported(t, newMemStore())
|
||||
n := w.reserved(t, "author@g14")
|
||||
p := valid(n)
|
||||
p.Date = "2026-01-01"
|
||||
p.Sections[2].Text = "The control plane wrote them."
|
||||
_, err := w.k.Propose("author@g14", p)
|
||||
if err == nil || !strings.Contains(err.Error(), "- date:") {
|
||||
t.Fatalf("a new record dated before its reservation: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user