Repository navigation
Conversation
Add the `persistent_state` allowlist primitive so a later reset-preserve-state operation can name which workspace files must survive a template-level reset. `template.yaml` is read only at agent creation (cached 10 min), so runtime sync/reset paths can't re-read it — the list is materialized into `.trinity/persistent-state.yaml` at creation time and read from disk thereafter. Same split as `.env` / `.env.example`. Scope: - Reader + materializer in `services/git_service.py` (`DEFAULT_PERSISTENT_STATE`, `materialize_persistent_state`, `_persistent_state_for`). - Matching reader in `agent_server/routers/files.py` for in-container use. - Default defined once; template can override via `template_service._build_template`. - Single non-fatal call site in `agent_service/crud.py` after container start and git-config registration. - Documented default block in the root `template.yaml`. Deliberately out of scope (owned by follow-up PRs): - Reset-preserve-state subroutine / API endpoint (→ Abilityai#384 / S3). - Snapshot / restore endpoints (→ S3). - `.trinity/last-remote-sha/<branch>` storage (→ S7). - `PROTECTED_PATHS` / `EDIT_PROTECTED_PATHS` semantics — a snapshot test (`test_protected_paths_lists_unchanged`) pins the two lists byte-exact so a future change to delete/edit protection has to be its own PR. Tests: 14 new unit tests cover the default constant, template-override path, three reader fallback cases (missing file, invalid YAML, missing key), the five agent-server reader behaviours, and the mirror/source and protected-paths invariants. All pass on Python 3.12, together with the pre-existing 13 git unit tests. Refs Abilityai#381 Closes Abilityai#383 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 18, 2026
vybe
approved these changes
Apr 18, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Clean infrastructure primitive with comprehensive test coverage (14 tests). Explicitly scoped to add reader/writer only without changing existing protection semantics.
3 tasks done
This was referenced Apr 19, 2026
vybe
pushed a commit
that referenced
this pull request
Apr 22, 2026
…ents/index (follow-up to #394) (#404) * docs(feature-flows): add persistent-state-allowlist flow (S4, #383) New vertical-slice document covering the allowlist primitive: - Why it materializes at agent creation (template.yaml cached 10 min) - Flow 1: creation-time materialization (crud.py + git_service) - Flow 2: runtime read (backend + agent-server helpers) - Default list, fallback rules, test coverage - Explicit out-of-scope list (reset subroutine → #384) Index: added to Recent Updates and GitHub Integration sections (one row each, descriptions kept to one line). * docs: record persistent-state allowlist in architecture / requirements / index (S4, #383) - architecture.md: note the primitive in the git_service.py one-liner and call out `.trinity/persistent-state.yaml` in the agent file-structure tree. - requirements.md: add §11.3 under GitHub Integration with status, description, and scope boundary (reset consumer is #384). - project_index.json: bump `last_updated` and add `persistent_state_allowlist` to `features.implemented`. No new endpoints / schema / integrations; minimal touch per update-docs principle. --------- Co-authored-by: Andrii Pasternak <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the persistent-state allowlist primitive from proposal §S4 so a
later reset-preserve-state operation can name which workspace files must
survive a template-level reset.
The default list (matching the verified
s3_fix_verified.shharness):Why it works this way
template.yamlis read only at agent creation (template_service.pycaches it for 10 minutes), so sync/reset paths can't re-read it at
runtime. The list is therefore materialized into
.trinity/persistent-state.yamlat creation time and read from diskthereafter — same split as
.env/.env.example. Operators can editthe on-disk file per-agent.
What this PR changes
src/backend/services/git_service.py—
DEFAULT_PERSISTENT_STATEconstant—
materialize_persistent_state(agent_name, patterns)(heredoc writerexecuted inside the container, preserves glob characters)
—
_persistent_state_for(agent_name)(reader with default fallback)docker/base-image/agent_server/routers/files.py—
_read_persistent_state()for in-container consumerssrc/backend/services/template_service.py—
_build_template()now surfacespersistent_state(falls back toDEFAULT_PERSISTENT_STATEwhen the template omits the key)src/backend/services/agent_service/crud.py— single non-fatal call site after container start and git-config
registration
template.yaml(root) — documented default block162 insertions across 5 modified files, plus two new unit-test files
(14 tests).
Deliberately out of scope
Named here so reviewers don't have to ask:
.trinity/last-remote-sha/<branch>storage → S7PROTECTED_PATHS/EDIT_PROTECTED_PATHSsemantics are unchanged inthis PR. A snapshot test (`test_protected_paths_lists_unchanged`)
pins both lists byte-exact so any future change to delete/edit
protection has to land in its own PR.
Test plan
and `tests/unit/test_persistent_state_reader.py`): default
constant, template-override path, three reader fallback cases
(missing file, invalid YAML, missing key), the five agent-server
reader behaviours, the mirror-matches-source drift guard, and the
PROTECTED_PATHS snapshot.
`test_git_pull_branch.py`) still pass (13/13) — confirms the
module changes don't regress existing git-service flows.
`cat /home/developer/.trinity/persistent-state.yaml` → expect
default list; edit file in container → reader returns the edit.
Refs #381
Closes #383
🤖 Generated with Claude Code