[P1] Add backend-neutral durable scoped state and policy APIs #433
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/prolog-rlm#433
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #74
Goal
Add the generic
prolog-rlmcore substrate for durable scoped trusted state: host/user/project/session scope identity, backend-neutral storage, validated values/rules, provenance, revocation/supersession, and deterministic resolution of ordinary settings.This is the storage/policy substrate required by persistent project authorization and by downstream Prolog-native project configuration. It is not itself a coding-agent configuration product and it is not an arbitrary model-writable Prolog database.
Problem / motivation
Current core state deliberately serves different purposes:
rlm_authorityholds mutable runtime/session authority and pending operations;rlm_artifactholds immutable/versioned durable task knowledge and fresh-root handoff;rlm_contextexposes bounded opaque epistemic context;rlm_graphpersists resumable graph checkpoints/events;No current API means:
That semantic class deserves its own closed contract rather than being aliased to artifacts, graph state, MCP facts, or authority history.
Architectural boundary
Core owns:
Downstream packages own:
This issue must not create a
.claudeclone or a giantfact/7bucket.Required scope model
Define closed scope forms equivalent in semantics to:
Exact terms may follow repository conventions.
Project identity contract
Project identity is security-relevant because persistent authorization will depend on it. Do not key durable state by raw
cwd.The design/implementation must explicitly define behavior for:
Do not overbuild distributed project identity in the first slice. The required invariant is that project identity is a first-class structured concept distinct from current filesystem location.
The implementation should document whether relocation/worktrees/clones preserve or intentionally create distinct identities and provide an explicit migration/rebinding path if identities can become stale. Ambiguity at a security boundary must fail closed rather than silently choosing another project.
State record semantics
Define a closed, ground, schema-validated record capable of representing ordinary trusted settings and policy records without executing them.
It should carry the repository-convention equivalent of:
Do not store arbitrary executable closures/callables as values.
A later value may supersede an older one while preserving enough provenance/history to explain what changed. Revocation must be a first-class semantic operation, not “write magic false into the same key.”
Following #64, active executable/effective policy state and retained audit/history must remain separable. History must not retain trusted continuation callables or become the live registry merely because append-only storage is convenient.
Public API direction
Follow existing structured-outcome naming/style. Exact predicate names are intentionally left to implementation, but the public surface should provide semantics equivalent to:
Names/arity may differ. The important contract is explicit store/scope identity, trusted mutation, inspectability, revocation, effective resolution, and backend independence.
Trusted mutation boundary
Mutation predicates are trusted host/library APIs, analogous to authority setters. They must not be registered as unrestricted model tools.
A model can produce a request or candidate setting/policy as ordinary data. Converting that request into durable trusted state requires a mediated host/operator action.
The API should make origin/trust explicit enough that loading arbitrary project/model data cannot masquerade as a host/operator mutation.
Backend contract
Provide at least:
The public semantics must not depend on SWI
library(persistency)even if the first persistent implementation reuses that mechanism, asrlm_artifactandrlm_graphcurrently do.Backend requirements:
If a future remote/latency-bearing backend is added, follow #54: canonical execute semantics -> async Future -> synchronous facade awaiting the same Future. Do not add fake async variants to pure/in-memory operations merely for visual symmetry.
Precedence semantics
This issue owns deterministic precedence for ordinary non-security settings.
Define and test a documented scope overlay order. A likely shape is narrower scope overriding broader scope where eligible, but implementation must decide exact host/user/project/session ordering and how “unset”, revoked, invalid, and explicit values behave.
Do not reuse ordinary overlay logic as the security-authority algorithm.
Authority-affecting persisted rules are resolved by #76 through the #53 authority boundary and remain capped by current hard/host policy. This substrate stores and queries them but does not decide that they authorize execution.
Security invariants
call/1.dangerousor makeallow_sessionpersistent.Interaction with existing modules/issues
#16 /
rlm_artifactReuse persistence/versioning lessons where useful, not artifact semantics. Artifacts are model/task knowledge and can be published by reasoning workflows; that must never imply permission mutation.
rlm_graph/ agent stateGraph checkpoints and agent runtime state remain execution state. They may carry references to scoped state but are not the durable settings database.
#53 /
rlm_authorityThis issue does not persist authority modes and does not implement authorization decisions. #76 composes scoped policy with #53.
#52 /
rlm_mcp_policyMCP profile/config-reference facts are hard trusted lifecycle configuration. They remain separate from user/project preferences and remembered permissions.
#68-#71
#70 may resolve effective operator/project policy as a context source, but its
rlm_artifactsnapshots remain epistemic resolved-context records. Preserve provenance classes rather than flattening the stores.#48/#49/#50
The core abstraction must be generic enough for external tool libraries and downstream agents without importing their concrete catalogs or UX.
Acceptance criteria
cwd.allow_sessionto persistent state.fact/7API collapses artifacts, repository context, MCP declarations, and trusted operator state into one semantic class.Non-goals
rlm_artifact,rlm_context, orrlm_graphstorage with this substrate.Dependencies / references
research/RLM-RESEARCH-003-typed-symbolic-execution.orgresearch/RLM-RESEARCH-005-swi-agent-runtime.orgresearch/RLM-RESEARCH-007-langchain-langgraph-port.orgresearch/RLM-RESEARCH-009-durable-artifact-context.orgBlocks #76 and #77.
Duplicate of #75 (pre-existing Forgejo mirror with GitHub number parity). Closing this accidental duplicate created by today's open-state sync; #75 stays canonical on Forgejo.