From 7da6ee61aa93bbffc744bdf82470229be75d261f Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 16:46:58 +0100 Subject: [PATCH] 466-b: an insight keeps the supersedes and changes links (rule insight-links) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 55 §4, §5; lead answer L-466-3 (issue 466 note 18); 466/AC4 --- modules/mesh-knowledge/README.md | 2 +- .../mesh-knowledge/cmd/mesh-knowledge/main.go | 2 +- .../cmd/mesh-knowledge/rules.go | 24 ++++++++++++++++--- .../cmd/mesh-knowledge/rules_test.go | 16 +++++++++++-- .../cmd/mesh-knowledge/wholeset_test.go | 16 ++++++++++++- 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/modules/mesh-knowledge/README.md b/modules/mesh-knowledge/README.md index 64b72285d..5954743a8 100644 --- a/modules/mesh-knowledge/README.md +++ b/modules/mesh-knowledge/README.md @@ -78,7 +78,7 @@ as text. `get` serves each, and any other field a record of hq wrote under `fiel ## Writing a record 1. `reserve` a number for its kind. -2. `propose` the record whole. It is refused, naming every reason at once, when it breaks one of the **31 rules +2. `propose` the record whole. It is refused, naming every reason at once, when it breaks one of the **32 rules that judge one record or its prose**. They are hq's checks moved to the write; `PerRecordRules` in `rules.go` lists each one with the check it comes from: - 25 on the structure: kind, reserved number, title, topic, date, deciders, research status, at least one diff --git a/modules/mesh-knowledge/cmd/mesh-knowledge/main.go b/modules/mesh-knowledge/cmd/mesh-knowledge/main.go index ba7bebc84..66305c916 100644 --- a/modules/mesh-knowledge/cmd/mesh-knowledge/main.go +++ b/modules/mesh-knowledge/cmd/mesh-knowledge/main.go @@ -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 " + diff --git a/modules/mesh-knowledge/cmd/mesh-knowledge/rules.go b/modules/mesh-knowledge/cmd/mesh-knowledge/rules.go index a893c47c2..2fd0e0005 100644 --- a/modules/mesh-knowledge/cmd/mesh-knowledge/rules.go +++ b/modules/mesh-knowledge/cmd/mesh-knowledge/rules.go @@ -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 { diff --git a/modules/mesh-knowledge/cmd/mesh-knowledge/rules_test.go b/modules/mesh-knowledge/cmd/mesh-knowledge/rules_test.go index 2e724cf38..e22fe666b 100644 --- a/modules/mesh-knowledge/cmd/mesh-knowledge/rules_test.go +++ b/modules/mesh-knowledge/cmd/mesh-knowledge/rules_test.go @@ -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) { diff --git a/modules/mesh-knowledge/cmd/mesh-knowledge/wholeset_test.go b/modules/mesh-knowledge/cmd/mesh-knowledge/wholeset_test.go index 733566767..07eb0b5da 100644 --- a/modules/mesh-knowledge/cmd/mesh-knowledge/wholeset_test.go +++ b/modules/mesh-knowledge/cmd/mesh-knowledge/wholeset_test.go @@ -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)