466-b: an insight keeps the supersedes and changes links (rule insight-links)

Builds: design 55 §4, §5; lead answer L-466-3 (issue 466 note 18); 466/AC4
This commit is contained in:
2026-11-25 16:47:05 +01:00
parent 84f1e5b93b
commit 7da6ee61aa
5 changed files with 52 additions and 8 deletions
@@ -1030,7 +1030,7 @@ func verbTools(k *KB, caller func(map[string]any) string) []stdio.Tool {
"clauses, each opening with a bold lead (\"**What is decided.** …\"), and its reasoning in sections (Context, " +
"Considered Options, Consequences, How it is checked, References); for a research effort its status and documents; its " +
"links (supersedes, changes \"0276 §4\", extends, became, cites), and whether it needs the operator, with the brief its ask shows. Refused, naming " +
"every reason at once and writing nothing, when it breaks one of the 31 rules that judge one record or its prose — a " +
"every reason at once and writing nothing, when it breaks one of the 32 rules that judge one record or its prose — a " +
"link to nothing, a clause without a bold lead, a superseded record cited alone, an unknown topic, a retired word. A " +
"proposal is revised by proposing it again; an accepted record (an active research effort or an idea excepted, which take new versions; at most as many research efforts are active as the setting research-active-at-most allows, three by default) changes only by a progressive insight (insight: what " +
"stood before). A research effort's new version may leave out its sections, and its title, date and deciders: it then " +
@@ -2,7 +2,7 @@ package main
// The rules a record is held to (novox/hq ADR 0290 rule 4, to-be 55 §4 and §5).
//
// **31 rules judge one record or its prose**, and `propose` refuses a record that breaks any of them, naming every
// **32 rules judge one record or its prose**, and `propose` refuses a record that breaks any of them, naming every
// one it breaks at once. They are hq's checks (00-META/checks/records.py, cycle.py, index.py, words.py) as they
// judge one record, moved to the write: 25 on its structure, 4 on its prose; and the brief a record that needs
// the operator is asked with (novox/hq issue 639). Each has an id, said in the refusal,
@@ -28,7 +28,7 @@ type Rule struct {
From string
}
// PerRecordRules are the 31, in the order they are judged.
// PerRecordRules are the 32, in the order they are judged.
var PerRecordRules = []Rule{
{"kind", "a record is a decision or a research effort", "cycle.py"},
{"reserved", "its number was reserved for its kind and holds no other record", "cycle.py (duplicate numbers)"},
@@ -61,6 +61,7 @@ var PerRecordRules = []Rule{
{"insight-form", "a progressive insight its text mentions is in the dated, marked form", "records.py insights"},
{"brief", "a record that needs the operator carries a brief its ask reads at a glance: a headline, a summary, at most three points, each fit for the phone", "novox/hq issue 639"},
{"section-form", "a section is a part with a plain title, once in the record, and its text holds no local path, no file and line, and no link to a file", "to-be 55 §2.2"},
{"insight-links", "a progressive insight keeps exactly the accepted record's supersedes and changes links (it may add cites): changing which records a decision supersedes or changes is a new record", "novox/hq issue 466"},
}
// Refusal is one rule a record breaks, and how.
@@ -121,7 +122,7 @@ func allText(r *Record) string {
return b.String()
}
// JudgeRecord holds a proposed record to the 31 rules. held is the entry its number holds (a reservation, the
// JudgeRecord holds a proposed record to the 32 rules. held is the entry its number holds (a reservation, the
// proposal being revised, or the accepted record an insight corrects); lookup reads every other record.
func JudgeRecord(r *Record, held *Entry, lookup Lookup, ref *Reference) []Refusal {
return JudgeRecordOn(r, held, lookup, ref, r.Date)
@@ -295,6 +296,23 @@ func JudgeRecordOn(r *Record, held *Entry, lookup Lookup, ref *Reference, day st
}
}
}
if held != nil && held.Current.Accepted() && r.IsInsight() {
var changed []string
for _, l := range r.Links {
if (l.Kind == LinkSupersedes || l.Kind == LinkChanges) && !hasLink(held.Current, l) {
changed = append(changed, fmt.Sprintf("added %s", l))
}
}
for _, l := range held.Current.Links {
if (l.Kind == LinkSupersedes || l.Kind == LinkChanges) && !hasLink(r, l) {
changed = append(changed, fmt.Sprintf("dropped %s", l))
}
}
if len(changed) > 0 {
refuse("insight-links", "a progressive insight corrects a fact and leaves the decision standing, so it keeps the supersedes and changes links of the accepted record (%s); "+
"changing what a record supersedes or changes is a new record: write one", strings.Join(changed, ", "))
}
}
if r.Kind == KindResearch && r.Effort == StatusGraduated {
became := false
for _, l := range r.Links {
@@ -96,6 +96,18 @@ func TestEveryPerRecordRuleRefusesAProposal(t *testing.T) {
{"brief", func(p *ProposeAsk, w *world, t *testing.T) {
p.Date, p.NeedsOperator = "2026-10-13", true
}},
{"insight-links", func(p *ProposeAsk, w *world, t *testing.T) {
// 466/AC4: an insight that drops the changes link of the accepted record is refused, and one that adds a
// cites link is taken.
w.accepted(t, "author@test", valid(p.Number))
p.Insight = "it said the clause stood"
cites := *p
cites.Links = append(append([]LinkAsk(nil), p.Links...), LinkAsk{Kind: LinkCites, To: "0011"})
if _, err := w.k.Propose("author@test", cites); err != nil {
t.Fatalf("an insight adding a cites link was refused: %v", err)
}
p.Links = p.Links[:1]
}},
{"section-form", func(p *ProposeAsk, w *world, t *testing.T) {
p.Date, p.Sections[0].Name = "2026-11-04", "00-context.md"
}},
@@ -109,8 +121,8 @@ func TestEveryPerRecordRuleRefusesAProposal(t *testing.T) {
t.Errorf("the rule %s has no case", r.ID)
}
}
if len(PerRecordRules) != 31 {
t.Errorf("%d per-record rules; ADR 0290 counts 29, issue 639 adds the brief and to-be 55 §2.2 the form of a section", len(PerRecordRules))
if len(PerRecordRules) != 32 {
t.Errorf("%d per-record rules; ADR 0290 counts 29, issue 639 adds the brief, to-be 55 §2.2 the form of a section and issue 466 the links of an insight", len(PerRecordRules))
}
for _, c := range cases {
t.Run(c.rule, func(t *testing.T) {
@@ -5,6 +5,7 @@ import (
"errors"
"strings"
"testing"
"time"
)
// A decision nothing would cite is not accepted: its review asks changes itself, without a judgement, naming the
@@ -130,7 +131,20 @@ func TestACorrectionThatDropsAChangesLinkWithdrawsTheClausesMark(t *testing.T) {
}
a.Links = a.Links[:1] // only extends 0276 now
a.Insight = "it no longer changes 0276 §1"
w.accepted(t, "author@g14", a)
// 466/AC4: an insight no longer drops a changes link; a version that did (made before the rule) is written
// directly, and its mark is withdrawn.
if _, err := w.k.Propose("author@g14", a); err == nil || !strings.Contains(err.Error(), "- insight-links:") {
t.Fatalf("an insight dropping a changes link was taken: %v", err)
}
e := mustGet(t, s, Key{KindDecision, n})
r := e.Current.Clone()
r.Links = r.Links[:1]
if err := s.Save(context.Background(), Version{By: "test", At: time.Now(), Why: "an older insight", Record: r}, true, true, e.Revision); err != nil {
t.Fatal(err)
}
if _, err := w.k.RecomputeMarks(context.Background()); err != nil {
t.Fatal(err)
}
c := mustGet(t, s, Key{KindDecision, 276}).Current.Clause(1)
if c.Status != ClauseInForce || len(c.ChangedBy) != 0 {
t.Fatalf("0276 §1 keeps a mark no accepted link makes: %+v", c)