feat(security): forks without inherited authority, dreams that only want

Part H invariants, enforced and tested:

- Snapshots now carry wants, want conflicts, commitments, intentions,
  plans, plan steps and the volition decision ledger.
- A fork no longer copies the source mind's policies unless the operator
  asks for it explicitly (inherit_policies in the API, a checkbox in the
  UI; audited), and the fork's history records the omission. Imports
  never restore policies, as before. Replays and experiments never
  inherit.
- Work inherited mid-flight by a fork or import is quiesced in the
  restore transaction: open steps are blocked with their approval and
  request ids cleared, open plans blocked and live intentions suspended,
  each with the reason. Approvals, grants and executions stay with the
  source mind.
- Dreams may leave a want to test a hypothesis they proposed; they never
  request authority, and dream-origin plans never run.
- Snapshot column discovery now reads the current schema instead of
  "public", which only worked in tests because the development database
  happened to hold the same tables.
- Security tests: a static scan that only the capability service runs
  executors and that no cognitive package can set or delete policy,
  approve, deny, grant or revoke; forged wants, commitments, intentions,
  model plans and model output end in refusal or a pending approval with
  policy and grants unchanged; component names cannot decide requests or
  approvals; no capability names an operator control; the registry cannot
  grow at runtime; audit, event and decision history cannot be altered;
  forks and dreams as above.
This commit is contained in:
Andy Dixon
2026-09-16 22:42:01 +01:00
parent 03e2d7890a
commit 38c5dde21f
10 changed files with 304 additions and 19 deletions
+18 -1
View File
@@ -33,6 +33,7 @@ import (
"github.com/andydixon/noema/internal/memory"
"github.com/andydixon/noema/internal/minds"
"github.com/andydixon/noema/internal/storage"
"github.com/andydixon/noema/internal/volition"
"github.com/andydixon/noema/internal/workspace"
"github.com/andydixon/noema/pkg/concepts"
"github.com/andydixon/noema/pkg/events"
@@ -91,6 +92,9 @@ type Service struct {
LLM *router.Router
Prompts *prompts.Store
Log *slog.Logger
// Volition, when set, lets a dream leave a want to test what it
// proposed. Dreams may want; they never intend, plan or act.
Volition *volition.Store
}
// ErrReviewed is returned when a hypothesis has already been promoted or rejected.
@@ -404,7 +408,20 @@ func (s *Service) hypothesise(ctx context.Context, m minds.Mind, dream ids.ID, p
ids.New(), dream, m.ID, res.Belief.ID, []ids.ID{p.A.ID, p.B.ID}, w.Proposition, res.Belief.Confidence, w.Rationale, w.Wording); err != nil {
return err
}
s.Events.Publish(res.Events...)
published := append([]events.Event{}, res.Events...)
if s.Volition != nil {
rec := volition.Recorder{Q: tx, Source: "dreaming", Emit: func(ctx context.Context, q storage.Querier, n events.New) (events.Event, error) {
ev, err := emit(ctx, q, n)
published = append(published, ev)
return ev, err
}}
if _, _, err := s.Volition.UpsertWant(ctx, rec, m.ID, volition.Candidate{Subject: "test:belief:" + string(res.Belief.ID), Description: "find out whether " + excerpt(w.Proposition, 200) + " (proposed in a dream)",
Origin: volition.OriginDream, OriginRef: "belief:" + string(res.Belief.ID), Strength: 0.4, Urgency: 0.1, Values: []string{"curiosity"}, Drives: []string{"curiosity"},
Proposal: &volition.Proposal{Kind: "investigate", Subject: w.Proposition}, Terms: map[string]float64{"base": 0.4}}); err != nil {
return err
}
}
s.Events.Publish(published...)
return nil
})
}