An active research effort takes new versions, reviewed as proposals (hq issue 844)

This commit is contained in:
2026-10-15 21:22:17 +02:00
parent a95b3fa053
commit 24d05701d3
8 changed files with 110 additions and 13 deletions
@@ -335,7 +335,10 @@ func (k *KB) Propose(caller string, a ProposeAsk) (*Proposed, error) {
return nil, fmt.Errorf("%s has a progressive insight by %s waiting for its review: only its author, proven by the "+
"runtime, revises it (this call is by %s). Nothing was proposed", key, held.Pending.Author, caller)
}
if strings.TrimSpace(a.Insight) == "" {
// An active research effort is still being researched: it takes new versions freely, each reviewed as a
// proposal while the served version stays (novox/hq issue 844). Every other accepted record needs an insight.
revision := a.Kind == KindResearch && held.Current.Status == StatusActive && strings.TrimSpace(a.Insight) == ""
if strings.TrimSpace(a.Insight) == "" && !revision {
return nil, fmt.Errorf("%s is %s: it changes only by a new record, or by a progressive insight, a correction of fact "+
"that leaves the decision standing (give insight: what stood before). Nothing was proposed", key, held.Current.Status)
}
@@ -349,8 +352,14 @@ func (k *KB) Propose(caller string, a ProposeAsk) (*Proposed, error) {
r.Pending = &PendingState{Insight: Insight{Date: k.now().Format("2006-01-02"), Before: strings.TrimSpace(a.Insight), By: caller}}
r.Date = held.Current.Date
r.Effort = a.Status
if revision {
r.Pending = &PendingState{}
}
if why == "" {
why = "a progressive insight proposed"
if revision {
why = "a new version proposed"
}
}
default:
return nil, fmt.Errorf("%s is %s and takes no proposal; nothing was proposed", key, held.Working().Status)
@@ -381,7 +390,7 @@ func (k *KB) Propose(caller string, a ProposeAsk) (*Proposed, error) {
}
return nil, fmt.Errorf("%s is refused by %d rule(s), and nothing was written:\n- %s", key, len(refusals), strings.Join(lines, "\n- "))
}
v := Version{By: caller, At: k.now(), Why: why, Record: r, Insight: !current}
v := Version{By: caller, At: k.now(), Why: why, Record: r, Insight: r.IsInsight()}
if err := k.Store.Save(ctx, v, current, false, held.Revision); err != nil {
return nil, fmt.Errorf("%s could not be written (%v); nothing was proposed", key, err)
}
@@ -397,7 +406,10 @@ func (k *KB) Propose(caller string, a ProposeAsk) (*Proposed, error) {
if r.NeedsOperator {
says += ", and then the operator's Approve"
}
if !current {
if !current && !r.IsInsight() {
says = fmt.Sprintf("A new version of %s is proposed as version %d. The knowledge base reviews it now; the served version stays "+
"until that review approves it", key, n)
} else if !current {
says = fmt.Sprintf("A progressive insight to %s is proposed as version %d. The knowledge base reviews it now; the accepted "+
"version is served until that review approves it", key, n)
}
@@ -416,8 +428,11 @@ func (k *KB) accept(ctx context.Context, held *Entry, w *Record, by, why, warran
at := k.now()
if insight {
in := r.Pending.Insight
isInsight := r.IsInsight()
r.Pending = nil
r.Insights = append(r.Insights, in)
if isInsight {
r.Insights = append(r.Insights, in)
}
r.Status = held.Current.Status
if r.Kind == KindResearch && contains(ResearchStatuses, r.Effort) && held.Current.Status != StatusSuperseded {
r.Status = r.Effort
@@ -442,7 +457,7 @@ func (k *KB) accept(ctx context.Context, held *Entry, w *Record, by, why, warran
if warrant != "" {
why += "; " + warrant
}
if err := k.Store.Save(ctx, Version{By: by, At: at, Why: why, Record: r, Insight: insight}, true, true, held.Revision); err != nil {
if err := k.Store.Save(ctx, Version{By: by, At: at, Why: why, Record: r, Insight: insight && w.IsInsight()}, true, true, held.Revision); err != nil {
return nil, fmt.Errorf("%s could not be accepted (%v); it stays proposed", r.Key(), err)
}
k.emit(EventAccepted, r, by, why, held.Versions+1)