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:
+12
-7
@@ -117,13 +117,17 @@ func (s *Server) snapshotArchive(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(a) //nolint:errcheck
|
||||
}
|
||||
|
||||
// ForkSnapshot creates a mind from a snapshot; shared with the UI.
|
||||
func (s *Server) ForkSnapshot(ctx context.Context, sn snapshots.Snapshot, slug, display, by string) (minds.Mind, error) {
|
||||
m, err := s.deps.Snapshots.Fork(ctx, sn.ID, snapshots.ForkOptions{Slug: slug, DisplayName: display, By: by})
|
||||
// ForkSnapshot creates a mind from a snapshot; shared with the UI. The fork
|
||||
// receives no policies unless inheritPolicies is set explicitly.
|
||||
func (s *Server) ForkSnapshot(ctx context.Context, sn snapshots.Snapshot, slug, display, by string, inheritPolicies bool) (minds.Mind, error) {
|
||||
m, err := s.deps.Snapshots.Fork(ctx, sn.ID, snapshots.ForkOptions{Slug: slug, DisplayName: display, By: by, InheritPolicies: inheritPolicies})
|
||||
if err != nil {
|
||||
return m, mindErr(err)
|
||||
}
|
||||
s.deps.Audit.Log(ctx, "mind.fork", "mind", m.ID.String(), map[string]any{"snapshot": sn.ID, "source": sn.MindID, "slug": m.Slug})
|
||||
s.deps.Audit.Log(ctx, "mind.fork", "mind", m.ID.String(), map[string]any{"snapshot": sn.ID, "source": sn.MindID, "slug": m.Slug, "inherit_policies": inheritPolicies})
|
||||
if !inheritPolicies {
|
||||
s.deps.Events.OperatorAction(ctx, m.ID, by, "mind.fork.policies", "Capability policies were not inherited from the source mind; this mind has only global policy until an operator adds rules", map[string]any{"inherit_policies": false})
|
||||
}
|
||||
s.deps.Events.OperatorAction(ctx, m.ID, by, "mind.fork", "Mind forked from snapshot "+sn.Name+" (history before event "+strconv.FormatInt(sn.EventSeq, 10)+" is shared with the source)", map[string]any{"snapshot_id": sn.ID, "source_mind": sn.MindID, "event_seq": sn.EventSeq})
|
||||
s.deps.Events.OperatorAction(ctx, sn.MindID, by, "mind.fork", "Operator "+by+" forked this mind into "+m.Slug+" from snapshot "+sn.Name, map[string]any{"snapshot_id": sn.ID, "fork_mind": m.ID})
|
||||
s.deps.Brain.Reconcile(ctx) //nolint:errcheck
|
||||
@@ -136,14 +140,15 @@ func (s *Server) snapshotFork(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
var in struct {
|
||||
Slug string `json:"slug"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Slug string `json:"slug"`
|
||||
DisplayName string `json:"display_name"`
|
||||
InheritPolicies bool `json:"inherit_policies"`
|
||||
}
|
||||
if err := decode(r, &in); err != nil {
|
||||
fail(w, r, err)
|
||||
return
|
||||
}
|
||||
m, err := s.ForkSnapshot(r.Context(), sn, in.Slug, in.DisplayName, actor(r))
|
||||
m, err := s.ForkSnapshot(r.Context(), sn, in.Slug, in.DisplayName, actor(r), in.InheritPolicies)
|
||||
if err != nil {
|
||||
fail(w, r, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user