Repository navigation
feat(prompt): "Your environment" block in the platform prompt (trinity-enterprise#945) - #3800
Conversation
…trinity-enterprise#945) States the container facts an agent cannot infer from tool signatures: the user and durable workspace volume, the noexec RAM /tmp and $TMPDIR, UTC, what a reset to main keeps, the folders the platform creates or reads, the memory/ convention, when template.yaml is re-read, and the agent image's guardrail path_deny list. - The block renders at every prompt tier (always class). - The protected-paths sentence depends on the runtime: Claude Code is told its Write/Edit tools refuse these paths and shell commands do not; Codex, Gemini and any other runtime are told nothing blocks them. - _GUARDRAIL_PATH_DENY is a backend copy of guardrails-baseline.json path_deny (the backend image does not ship the hooks). - The Codex orientation now names refresh_metric_definitions. - The user-memory warning now names Claude Code's auto-memory (under ~/.claude/projects/) instead of a path that does not exist. - capabilities.py: a stale "100 MB cap" comment now says the tmpfs size cap (the default is 512m and AGENT_TMP_SIZE changes it). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-enterprise#945) test_ent945_environment_block.py (T1-T10): the block renders at every tier through get_platform_system_prompt, directly before Package Persistence; no marker ships unfilled on any runtime; the backend path_deny copy equals guardrails-baseline.json exactly; each reserved folder matches its owning constant (read by AST, never skipped); the protected-paths sentence never claims a hook a runtime lacks; budget 2600 chars; no /tmp size number; the Codex orientation names refresh_metric_definitions. Written first and seen red (53 failed: section missing) before the service change. test_ent243_prompt_tier.py: test_minimal_keeps_the_user_memory_leak_warning re-pinned from the old ~/.claude/projects/memory/ literal to the new "Claude Code's auto-memory (under ~/.claude/projects/)" wording. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…erprise#945) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing (trinity-enterprise#945) - The reset sentence now names the default keep-set that applies when `.trinity/persistent-state.yaml` is absent (the agent server's `_DEFAULT_PERSISTENT_STATE`). New owner-match test `test_reset_default_set_matches_the_agent_server` parses that constant out of files.py; it was red before the sentence changed. - `write_user_memory` description no longer names `~/.claude/projects/memory/`, which does not exist: it names Claude Code's auto-memory under `~/.claude/projects/` and the repo's `memory/` directory, matching the prompt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#945) - system-wide-trinity-prompt.md: bullet for the always-tier "Your environment" section and what pins it. - write-user-memory.md: drop the nonexistent `~/.claude/projects/memory/` literal for Claude Code's auto-memory under `~/.claude/projects/`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trinity-ability
left a comment
There was a problem hiding this comment.
PR Validation Report — #3800 (/validate-pr, Lane B, tip af6f25854)
Recommendation: REQUEST CHANGES — one factual error in the new always-on block. It is a one-clause fix. Everything else passes.
Summary
| Category | Status | Notes |
|---|---|---|
| Commit messages | ✅ | 5 conventional commits |
| Base branch | ✅ | dev |
| PR size | ✅ | 8 files, +368/−10 |
| Status auto-promotion | "Implements trinity-enterprise#945" has no closing keyword. It is cross-tracker, so the private issue needs a manual status-in-dev bump after merge either way |
|
| Architecture / feature flows | ✅ | agent-runtime.md, system-wide-trinity-prompt.md, write-user-memory.md updated |
| Security (§4.1–4.10) | ✅ | No keys, emails, IPs, mode flips or env files. /home/developer/ appears only as the in-container path. Enterprise-docs guard pattern: 0 hits |
| Infra / build / config packaging | ➖ | No Dockerfile, compose or new env var |
| Structural review | ✅ | The independent reading review and /cso --diff are cited in the body |
| Merge gate (Tier 1) | ✅ | All checks on af6f25854 are green. regression diff, pytest (head) and journey-smoke pass. dev-ci is success and no dev-ci red issue is open |
| Test adequacy | ✅ | Each fact is pinned to its owning constant, not to the block's own text |
| Code quality | ✅ / |
See W1 |
Execution coverage (§5.4)
| changed symbol / test | executed by | live consumer | verdict |
|---|---|---|---|
### Your environment + __PATH_DENY_SENTENCE__ fill |
TestPresence::test_live_prompt_carries_the_block through get_platform_system_prompt(runtime=…) |
routers/chat.py, task_execution_service.py → get_platform_system_prompt |
✅ |
_adapt_instructions_for_runtime hooked/unhooked swap |
TestRuntimeHonesty |
same composition root | ✅ Mutation: replacing the runtime_key not in _GUARDRAIL_HOOK_RUNTIMES guard with False turns 3 tests red. Restored afterwards |
_GUARDRAIL_PATH_DENY |
TestPathDeny (exact list equality with guardrails-baseline.json) |
the rendered prompt | ✅ guard |
| Reset default keep-set | test_reset_default_set_matches_the_agent_server (AST read of _DEFAULT_PERSISTENT_STATE) |
the rendered prompt | ✅ guard |
Local runs on af6f25854: test_ent945_environment_block.py 64 passed, test_ent243_prompt_tier.py 39 passed, test_platform_prompt_unit.py 41 passed.
Critical (block merge)
C1. src/backend/services/platform_prompt_service.py:242: "a reset to the template's main … never touches untracked ones" is false for one of the two reset paths.
- The statement holds for
reset_to_main_preserve_state_impl(docker/base-image/agent_server/routers/git.py:2731), which runsgit reset --hard origin/mainand overlays the snapshot, with no clean step. - The
force_resetpull strategy (docker/base-image/agent_server/routers/git.py:2553-2573) is also a reset to the template's main. On atrinity/*working branch,_get_pull_branch(git.py:1549) resolves tomain, so it runsgit reset --hard origin/mainand thengit clean -fd. It also ignores.trinity/persistent-state.yamlentirely. - People reach
force_resetthrough the UI ("Force Replace Local" inGitConflictModal.vue:56) and through the MCPgit_pulltool (src/mcp-server/src/tools/git.ts:264).
An agent that trusts the always-on sentence and keeps work untracked but not gitignored loses it on that path. Gitignored files such as data/ do survive, because clean -fd has no -x.
Suggested fix, one clause: scope the existing sentence to the preserve-state reset, and add that a force-reset pull ("Force Replace Local" / git_pull force_reset) discards local changes and deletes untracked, non-gitignored files, with no keep-set. The test file has no owner pin for this fact. Consider pinning it to git.py, for example by asserting that reset_to_main_preserve_state_impl contains no clean.
Companion #3801 carries the same claim. It appears in the submodule paragraph, in "(An ordinary pull merges and does not reset.)", and in the FAQ and agent-data lines ("neither wipes untracked files"). The two PRs do not contradict each other, but both contradict the code. Correct them together so the two surfaces stay identical.
Warnings
- W1.
platform_prompt_service.py:512:_GUARDRAIL_HOOK_RUNTIMES = {"claude-code", ""}leaves out"claude". BothCLAUDE_RUNTIME_NAMES(agent_service/helpers.py:41) and the agent-side_CLAUDE_RUNTIMES(runtime_adapter.py:195) treatclaudeas Claude Code, which runs the hook. An agent labelledclaudewould be told "Nothing in your runtime blocks these writes". That fails in the safe direction but is still untrue. Add"claude", or mirror the set in a pinned test. - W2. PR body inaccuracies.
- It calls #3797 the "sibling guide PR", but #3797 is the issue and the PR is #3801.
- It says the block covers "
$TMPDIR… never cleared wholesale" and "An ordinary pull merges". Neither sentence is in the block. - #3801 says "merges or rebases". This is body-only, but it is the one place where the two descriptions differ.
Suggestions
platform_prompt_service.py:252: "Your own memory directory ismemory/…" is a convention rather than a platform fact, and it has no owner pin. The wording is fine per the #3797 ruling; it is noted only because the rest of the block is owner-pinned.
Report-only validation: no commits or pushes were made to this branch.
🤖 Generated with Claude Code
…me alias (trinity-enterprise#945) Validation round 1 follow-ups on the `### Your environment` block: - Name the force-replace pull (pull-conflict "Force Replace Local" and `git_pull`) as the exception to "never touches untracked ones": it resets to the remote and runs `git clean -fd`, deleting untracked files that are not gitignored. - `data/` is gitignored only once the agent declares `data_paths`; it is not in the base gitignore patterns, so the block no longer says it always is. - `_GUARDRAIL_HOOK_RUNTIMES` gains `claude`, which the agent server treats as Claude Code (runtime_adapter, execution_env), so that alias is no longer told nothing blocks the protected paths. Red first: test_force_replace_pull_is_named_as_the_exception, test_data_folder_ignore_is_conditional and test_claude_alias_gets_the_hooked_sentence all failed before the change. The feature-flow summary is updated to match. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#3797) A force-replace pull (strategy=force_reset) runs git reset --hard then git clean -fd, so it deletes untracked files that are not gitignored; the default pull is git pull --rebase; data/ is gitignored only once data_paths is declared. Wording matches the companion PR #3800. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trinity-ability
left a comment
There was a problem hiding this comment.
PR Validation Report — round 2 (head 8fd08e2b5)
Lane B (prompt service, MCP tool description, tests, docs; no schema). Round 1 was review 5567799045 on af6f25854.
Round-1 items
| Item | Status | Evidence |
|---|---|---|
| C1: force-replace pull vs "never touches untracked" | ✅ fixed | Block now says a force-replace pull "resets to the remote and deletes untracked files that are not gitignored". That matches agent_server/routers/git.py force_reset (git reset --hard origin/<branch> then git clean -fd, no -x, so ignored files survive). "Offered when a pull conflicts" matches GitConflictModal.vue:56. "Through git_pull" matches src/mcp-server/src/tools/git.ts (strategy: force_reset). |
W1: _GUARDRAIL_HOOK_RUNTIMES lacked "claude" |
✅ fixed | Now {"claude-code", "claude", ""}, the same set as runtime_adapter.py:195 and execution_env.py:138. |
| W2: PR-body errors | ✅ fixed | Body names sibling #3801. The cross-tracker / no-closing-keyword note is under Before merge. Claims match the block text. Test counts reproduce (72 in the new file). |
R3: data/ ignore condition |
✅ | "gitignored once you declare data_paths" is accurate: data/ is not in _GITIGNORE_PATTERNS; it is added by trinity_files._data_paths_gitignore_entries (DP-002). |
Execution coverage (§5.4)
| changed symbol | executed by | live consumer | verdict |
|---|---|---|---|
_GUARDRAIL_HOOK_RUNTIMES += claude |
T13 + TestRuntimeHonesty[claude] |
platform_prompt_service runtime adapter |
✅ |
| force-replace sentence | T11 (rendered block) | the platform prompt render | ✅ |
data/ conditional |
T12 (rendered block) | the platform prompt render | ✅ |
Mutations (run in an isolated worktree):
- Removing
"claude"from the set turns 2 tests red (T13 andtest_claude_code_names_its_hook_and_its_gap[claude]). - Reverting both sentences turns 2 tests red (T11, T12).
Local runs: test_ent945_environment_block.py, test_ent243_prompt_tier.py and test_platform_prompt_runtime.py give 118 passed.
Agreement with #3801 (a178c5efc)
The two PRs agree on all five points:
- Reset keep-set: the default set is named identically.
- Force-replace pull sentence: same wording. #3801 says "the MCP
git_pulltool". data/ignore condition: the same in both.memory/: committed at the repo root in both..trinity/: both say people cannot edit it from the Files tab and the agent can.
Other checks
- Security greps: no keys, real emails, symlinks or mode changes. The only
/home/hit is the in-container/home/developer/path, which is documented and not a host path. - CI: terminal and green: 20 pass, 6 skipped, 0 failing.
dev-ci: success, and there is no opendev-ci redissue.
Not blocking
- Cross-tracker issue: no closing keyword reaches trinity-enterprise#945, so after merge set
status-in-devon it by hand. The body already says this. - Merge order: merge together with #3801.
Recommendation: APPROVE. No new findings.
…ts (#3797) (#3801) * docs(guide): recommended workspace layout in Directory Structure (#3797) Restates ## Directory Structure as three zones (platform-owned, committed, volume-only) with three rules, project_files/<slug>/, $TMPDIR scratch, gitignored side clones vs submodules (#2366), the .gitignore read as a consequence of the zones, and source links. Drops the stale .claude/skills-library/ mount line. Wording kept consistent with the platform prompt's environment block (trinity-enterprise#945). Refs #3797 Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(guide): FAQ pointer to the recommended workspace layout (#3797) Refs #3797 Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(guide): consistent committed folder, reset default, pull vs reset (#3797) - Content Folder Convention, Best Practices and the commit_paths example name reports/<kind>/ as the committed work folder, matching the new Directory Structure tree; outputs/ is kept as a legacy name that still works. - The reset-to-main sentence states the default persistent set used when .trinity/persistent-state.yaml is absent, and that untracked files are never touched. - The FAQ, agent-data.md, the guide's data_paths section and the agent-data-volumes flow no longer call an ordinary template pull a reset. - Memory Management points at the repo-level memory/ and keeps per-person facts out of it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(agents): force-replace pull, pull rebases, data/ ignore condition (#3797) A force-replace pull (strategy=force_reset) runs git reset --hard then git clean -fd, so it deletes untracked files that are not gitignored; the default pull is git pull --rebase; data/ is gitignored only once data_paths is declared. Wording matches the companion PR #3800. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Trinity Agent (trinity) <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Fixes abilityai/trinity-enterprise#945 (platform prompt "Your environment" block).
What
Adds a facts-only
### Your environmentblock to the platform prompt (platform_prompt_service.py), rendered at every prompt tier. It tells the agent where it lives:/tmp(a small RAM-backednoexectmpfs) and$TMPDIR(~/.tmp, on the volume)data/is gitignored oncedata_pathsis declared), and that.trinity/is written by the agent but people cannot edit it from the Files tabtemplate.yamledits take effect.trinity/persistent-state.yaml, or a default set without that file (workspace/,.trinity/,.mcp.json,.claude.json,.claude/.credentials.json). It never touches untracked files. A force-replace pull (offered on a pull conflict, and throughgit_pull) is the exception: it resets to the remote and deletes untracked files that are not gitignored.guardrails-baseline.jsonpath_deny. On Claude Code (runtime labelclaude-code,claudeor empty), Write/Edit refuse them and shell commands do not. On Codex/Gemini nothing in the runtime blocks them."Remembering Things About Users" now calls auto-memory "Claude Code's auto-memory (under
~/.claude/projects/)" instead of a path that does not exist (~/.claude/projects/memory/). It also says the repo'smemory/directory is shared across all users.write_user_memory's MCP description uses the same wording. The stale "100 MB"/tmpcomment incapabilities.pyis corrected.Commits:
c4f2f7e07block ·3016feae2tests ·d9d2e2f20architecture note ·bef530b53review fixes (reset default,write_user_memorywording) ·af6f25854feature flows ·8fd08e2b5validation round 1 fixes (force-replace pull,data/ignore condition,clauderuntime alias).Rulings carried
/tmpgets no size, becauseAGENT_TMP_SIZEsets it (default 512m).guardrails-baseline.jsonpath_deny. No Dockerfile change..trinity/clause is kept: "People cannot edit it from the Files tab; you can."~/.claude/projects/memory/._DEFAULT_PERSISTENT_STATEfromagent_server/routers/files.pywithast.routers/git.pyforce_resetrunsgit clean -fd);data/is gitignored only oncedata_pathsis declared (it is not in_GITIGNORE_PATTERNS);_GUARDRAIL_HOOK_RUNTIMESgains"claude", matchingruntime_adapter.pyandexecution_env.py. docs(guide): recommended workspace layout for Trinity-compatible agents (#3797) #3801 carries the same wording, plus "an ordinary pull rebases" (R2), which this block does not state.Review + security
write_user_memorydescription and doc hits, F2 reset default, F3 feature-flow bullet), all fixed inbef530b53/af6f25854./cso --difffound nothing..claudeandsrc/backend/enterpriseare untouched in the range./validate-prround 1 (review 5567799045): REQUEST CHANGES on C1 (force-replace pull) and W1 (claudealias); both fixed in8fd08e2b5.claude/ empty, 2,290 on Gemini, 2,276 on Codex (cap 2,600).write_user_memorydescription: 1,238 chars (cap 2,048).Tests
tests/unit/test_ent945_environment_block.py: 72 passed on8fd08e2b5. The F2 owner-match test and the three round-2 tests (force-replace sentence, conditionaldata/ignore,claudealias) were shown red before the prompt changed.test_ent243_prompt_tier.py39,test_platform_prompt_unit.py41,test_platform_prompt_runtime.py7, all passing.d9d2e2f20. Five mutations turned 7 tests red.services/services.platform_prompt_service: 170 passed.Before merge
status-in-devon it by hand.devondocs/memory/architecture/agent-runtime.md. This branch adds no new conflict there. fix(agent-server): price turns run through OpenRouter at OpenRouter prices #3490 and fix(agent-runtime): drop the startup credentials auto-import that called a route that never existed (#3510) #3758 test-merge clean.Handoffs
.claude/DEBT_INBOX.md: a reverse drift guard for the### Your environmentblock. Todaytests/unit/test_ent945_environment_block.pyonly checks that every folder the block names still matches its owning constant. Nothing fails when a new folder is reserved (a newstartup.shmkdir or.trinity/file) and the block does not mention it. When the injection registry lands, add a scan ofstartup.shmkdirs and.trinity/literals against a shrink-only exempt list. This chain does not stage the.claudesubmodule, so the entry is recorded here for the debt-inbox owner.Built by trinity-pm's build-chain run
chain-agent-env(plan → rulings → implement → review → fix) through the fleet engineer.🤖 Generated with Claude Code