Repository navigation
fix(git): UI Push no longer commits runtime state (#462) - #510
Closed
AndriiPasternak31 wants to merge 3 commits into
Closed
AndriiPasternak31 wants to merge 3 commits into
AndriiPasternak31 wants to merge 3 commits into
Conversation
…i#462) The platform-injected `.gitignore` only excluded 11 entries (shell init/history + a few cache dirs + `.env*`/`.mcp.json`), so a single UI Push staged 1,599 runtime files in one observed instance — `.cache/`, `.claude/sessions/`, `.claude/shell-snapshots/`, `.claude.json`, `.sudo_as_admin_successful`, `.local/lib/python3.11/site-packages/` — all paths that `docs/TRINITY_COMPATIBLE_AGENT_GUIDE.md:126-169` already required Trinity-compatible agents to exclude. Three coordinated changes: 1. Widen `_GITIGNORE_PATTERNS` in `git_service.py` to the full canonical list (30 entries), grouped by category. Single source of truth — the doc block now mirrors the constant and a unit test (`test_doc_and_constant_in_sync`) keeps them aligned in CI. 2. Migrate existing agents on every Push. New helper `_migrate_workspace_gitignore` runs `_build_gitignore_merge_command` (idempotent, was init-only) plus a new `git rm --cached` step for files now matching an ignore rule — both via `execute_command_in_container` so the migration works regardless of the agent server code version inside the container. Errors are logged and swallowed so a transient migration failure can't break Push. Also extracts the workspace-vs-home detection into a shared `_detect_git_dir` helper used by both init and the new migration. 3. Sync `docs/TRINITY_COMPATIBLE_AGENT_GUIDE.md` to the constant: add `.claude/sessions/`, `.claude/shell-snapshots/`, `.local/`, the four shell init files, `.sudo_as_admin_successful`, and a SoT note pointing to `_GITIGNORE_PATTERNS`. Policy decision on `git add -A` (acceptance criterion #3): kept. With the canonical list widened and migrated onto every Push, `-A` is safe — it stages exactly the agent-value files. Switching to an explicit allow-list would require enumerating every legitimate path (skills, commands, agent configs, code, docs, `workspace/**`) and would silently drop new file types as features are added. Tracking that as a separate hardening if more "forgot to ignore X" bugs surface. Tests: `tests/unit/test_github_init_gitignore.py` extended with 4 new cases — full canonical list present, idempotent on double run, doc / constant parity, and `git rm --cached` of force-tracked runtime files (working-tree files preserved). All 6 tests pass. Closes Abilityai#462 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds the 4 new tests from PR Abilityai#510 (`test_full_documented_exclusion_list_present`, `test_idempotent_double_run`, `test_doc_and_constant_in_sync`, `test_rm_cached_for_newly_ignored_files`) under a new "Recent Test Additions (2026-04-25)" section so the test-runner agent's catalog stays current. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…Abilityai#462 PR Abilityai#510 widened `_GITIGNORE_PATTERNS` and added a per-Push migration. Bring the two affected flow docs up to date: - github-sync.md: add per-Push gitignore migration step to the Sync sequence diagram and a paragraph explaining `_migrate_workspace_gitignore`, `_build_rm_cached_ignored_command`, and the best-effort error policy. - github-repo-initialization.md: replace the now-stale 11-pattern enumeration with a pointer to the canonical `_GITIGNORE_PATTERNS` constant (which is itself the SoT — see TRINITY_COMPATIBLE_AGENT_GUIDE.md mirror + parity test). Note that the same merge re-runs on every Push for existing-agent migration and that `_detect_git_dir` is now a shared helper. No new flow needed; no index entry needed (behavior tightening, not new feature). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
vybe
approved these changes
Apr 27, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Validation passed. Fix is correct and well-tested — 30 gitignore patterns, idempotent migration on Push, backward-compatible with legacy workspace-path agents. Four meaningful unit tests added. Feature flow docs updated within the PR. Two cosmetic gaps: (1) PR has no labels — please mirror issue #462's priority-p1/type-bug labels; (2) feature-flows.md index is missing a #462 entry for consistency with #458. Neither blocks merge. ✅ Merging.
Contributor
|
git fetch origin
git rebase origin/dev
# resolve any conflicts
git push --force-with-leaseOnce rebased the PR is approved and ready to merge immediately. |
Contributor
vybe
pushed a commit
that referenced
this pull request
Sep 22, 2026
…roved, deferred or killed, as a platform primitive (Abilityai/trinity-enterprise#638) Operator ruling R25: the approve / defer / kill judgments a role companion and its human make every week live nowhere — they evaporate with the chat. This gives a seat (agent × person, the ent#637 memory scope) a lintable record of its judgment, recorded by the companion over MCP or the person in Agent details, expiring unless reconfirmed, corrected by supersession, and read back into every turn so the criterion is reused. It is the evidence base for the autonomy dial (tandem-06 §2.2, #641). The record (tandem-07 §7a): outcome (approved | deferred | killed) · what was decided · the alternatives that were live · the criterion that discriminated · who decided (role + person) · decided_at + review_by · what would reverse it · notes (the only prose) · ask_class · cites · request_id (the #611 gate). - Grammar with receipts (services/seat_decision_service.py): prose where a field belongs → 422 decision_prose_only naming every failing field; no alternatives → 422 decision_is_a_note; a citation outside the seat's own records → 422 unknown_citation; a request_id that is not this agent's queue item → 422 unknown_request. Nothing is stored on refusal. - Direction is not a seat decision (R C3): the caller declares scope; a direction record is kept as `routed` — visible, expiring, outside the evidence — with the canon-proposal hint, so it neither evaporates nor pollutes the record. - Expiry is computed on read (review_by before today; equal is not expired), never written; correction inserts a new row chained by supersedes_id and flips the old one in one CAS transaction; close / reverse are status flips (reverse needs a reason — the evidence); reconfirm moves review_by. A non-active target is a named 409. Nothing is deleted. - Evidence: reused = records cited by a LATER record (a superseding record does not implicitly cite); per ask_class the distinct criteria, reversals, expired and `stable` (≥3, one criterion, no reversal) — #641's input. - Two surfaces, one seat rule. MCP `record_decision` / `list_seat_decisions` (src/mcp-server/src/tools/decisions.ts → POST/GET /api/agents/{name}/ decisions, routers/seat_decisions.py): the seat is resolved from execution_id exactly as write_user_memory does, never supplied; Idempotency-Key honoured (the tool derives one over the arguments); decided_by_role from assignment_provider.resolve_assignment or the caller, never a container read; NO email in the answer (decider = seat | owner); enforce:{param:"agent_name"} policy rows. The person records, corrects, reconfirms, closes and reverses in Agent details (client_portal/ seat_decisions.py, PortalAgentDecisions.vue, clientPortal store slice). - Readers: own seat always; the agent OWNER (role_card._is_owner) every seat writable; a stakeholder the assignment provider recognises through the optional seam method kinds_for(agent, reader) every seat read-only; no provider → own seat only. Writes: own seat, or the owner on a named seat. - Read into context: the seat's active decisions ride the shared memory block (platform_prompt_service.format_user_memory_block) on every caller, bounded and email-free — what makes a criterion reusable. - Storage: seat_decisions on both tracks (SQLite seat_decisions_table + Alembic 0068 ← 0067, has_table guard + IF NOT EXISTS indexes), cleanup CASCADE, JSON lists in TEXT, stats in Python, bounded reads. Tests: tests/unit/test_ent638_seat_decisions.py (45 — grammar table, lifecycle over a real SQLite file, evidence, readers, both routers, both tracks, facade parity), src/frontend/tests/unit/portalAgentDecisions.spec.js (8, mounted), src/mcp-server/src/tools/decisions.test.ts (5). Mutation checks: the expiry boundary and the email-free agent shape each turn tests red. Deferred (trinity-dev DEBT_INBOX 2026-09-22): readers per role rather than per agent; auto-record from an answered decision request (#611); the canon-folder export (the role pack's record-decision, #510 — field names already match). Refs Abilityai/trinity-enterprise#638 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vybe
pushed a commit
that referenced
this pull request
Sep 22, 2026
…roved, deferred or killed (Abilityai/trinity-enterprise#638) (#2949) * feat(workspace): the seat-level decision record — why a thing was approved, deferred or killed, as a platform primitive (Abilityai/trinity-enterprise#638) Operator ruling R25: the approve / defer / kill judgments a role companion and its human make every week live nowhere — they evaporate with the chat. This gives a seat (agent × person, the ent#637 memory scope) a lintable record of its judgment, recorded by the companion over MCP or the person in Agent details, expiring unless reconfirmed, corrected by supersession, and read back into every turn so the criterion is reused. It is the evidence base for the autonomy dial (tandem-06 §2.2, #641). The record (tandem-07 §7a): outcome (approved | deferred | killed) · what was decided · the alternatives that were live · the criterion that discriminated · who decided (role + person) · decided_at + review_by · what would reverse it · notes (the only prose) · ask_class · cites · request_id (the #611 gate). - Grammar with receipts (services/seat_decision_service.py): prose where a field belongs → 422 decision_prose_only naming every failing field; no alternatives → 422 decision_is_a_note; a citation outside the seat's own records → 422 unknown_citation; a request_id that is not this agent's queue item → 422 unknown_request. Nothing is stored on refusal. - Direction is not a seat decision (R C3): the caller declares scope; a direction record is kept as `routed` — visible, expiring, outside the evidence — with the canon-proposal hint, so it neither evaporates nor pollutes the record. - Expiry is computed on read (review_by before today; equal is not expired), never written; correction inserts a new row chained by supersedes_id and flips the old one in one CAS transaction; close / reverse are status flips (reverse needs a reason — the evidence); reconfirm moves review_by. A non-active target is a named 409. Nothing is deleted. - Evidence: reused = records cited by a LATER record (a superseding record does not implicitly cite); per ask_class the distinct criteria, reversals, expired and `stable` (≥3, one criterion, no reversal) — #641's input. - Two surfaces, one seat rule. MCP `record_decision` / `list_seat_decisions` (src/mcp-server/src/tools/decisions.ts → POST/GET /api/agents/{name}/ decisions, routers/seat_decisions.py): the seat is resolved from execution_id exactly as write_user_memory does, never supplied; Idempotency-Key honoured (the tool derives one over the arguments); decided_by_role from assignment_provider.resolve_assignment or the caller, never a container read; NO email in the answer (decider = seat | owner); enforce:{param:"agent_name"} policy rows. The person records, corrects, reconfirms, closes and reverses in Agent details (client_portal/ seat_decisions.py, PortalAgentDecisions.vue, clientPortal store slice). - Readers: own seat always; the agent OWNER (role_card._is_owner) every seat writable; a stakeholder the assignment provider recognises through the optional seam method kinds_for(agent, reader) every seat read-only; no provider → own seat only. Writes: own seat, or the owner on a named seat. - Read into context: the seat's active decisions ride the shared memory block (platform_prompt_service.format_user_memory_block) on every caller, bounded and email-free — what makes a criterion reusable. - Storage: seat_decisions on both tracks (SQLite seat_decisions_table + Alembic 0068 ← 0067, has_table guard + IF NOT EXISTS indexes), cleanup CASCADE, JSON lists in TEXT, stats in Python, bounded reads. Tests: tests/unit/test_ent638_seat_decisions.py (45 — grammar table, lifecycle over a real SQLite file, evidence, readers, both routers, both tracks, facade parity), src/frontend/tests/unit/portalAgentDecisions.spec.js (8, mounted), src/mcp-server/src/tools/decisions.test.ts (5). Mutation checks: the expiry boundary and the email-free agent shape each turn tests red. Deferred (trinity-dev DEBT_INBOX 2026-09-22): readers per role rather than per agent; auto-record from an answered decision request (#611); the canon-folder export (the role pack's record-decision, #510 — field names already match). Refs Abilityai/trinity-enterprise#638 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(workspace): a routed decision expires like an active one; the status vocabulary is checked at the sink; the portal routes are executed by a test (Abilityai/trinity-enterprise#638) Review findings on PR #2949: `effective_status` returned `routed` verbatim, so a direction record kept to avoid evaporation accreted forever — it now expires at `review_by` like an active one (the doc already said so). `DECISION_STATUSES` was declared and never read; `insert_seat_decision` now refuses a status outside it. Three tests execute the portal route layer (roster gate first, receipt → HTTP detail, action body forwarded). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * merge-train: re-parent the seat_decisions Alembic revision onto 0070_metric_points as 0071 (Abilityai/trinity-enterprise#638) — mechanical, per the merge-train note on the PR dev gained 0068–0070 after this branch forked, so 0068_seat_decisions off 0067 was a second head (#2068 class): upgrade head would have applied zero revisions. Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: sim <[email protected]>
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
_GITIGNORE_PATTERNSingit_service.pyfrom 11 to 30 entries to cover the full canonical list documented indocs/TRINITY_COMPATIBLE_AGENT_GUIDE.md(adds.claude/sessions/,.claude/shell-snapshots/,.claude.json[.backup],.sudo_as_admin_successful,.trinity/,content/,*.pem,*.key,credentials.json,*.log,*.tmp,.DS_Store,*.local.{md,json}, plus the existing.claude/{projects,statsig,todos,debug}/)._migrate_workspace_gitignorehelper runs the (already-idempotent) gitignore merge plusgit rm --cachedfor files now matching an ignore rule, viaexecute_command_in_container. Works regardless of agent server code version inside the container — no rebuild required.docs/TRINITY_COMPATIBLE_AGENT_GUIDE.mdto the Python constant and add a single-source-of-truth note + parity test.Closes #462. Related: #458 (#461) added the idempotent merge primitive this PR re-uses.
Policy decision: keep
git add -AAcceptance criterion #3 asked us to pick option (a) keep
-Aor (b) switch to an allow-list. Picked (a) with rationale: with the canonical list widened and migrated onto every Push,-Ais safe — it stages exactly the agent-value files. Switching to an explicit allow-list would require enumerating every legitimate path (skills, commands, agent configs, code, docs,workspace/**) and would silently drop new file types as features are added. Worth revisiting as a separate hardening if more "forgot to ignore X" bugs surface.Files
src/backend/services/git_service.py— widened constant, new_build_rm_cached_ignored_command/_detect_git_dir/_migrate_workspace_gitignorehelpers, migration call wired intosync_to_githubimmediately before the HTTP forward to the agent's/api/git/sync.docs/TRINITY_COMPATIBLE_AGENT_GUIDE.md— gitignore code block + Claude-Code runtime list synced to constant; SoT note added.tests/unit/test_github_init_gitignore.py— 4 new tests covering full-list presence, idempotency, doc/constant parity, andgit rm --cachedof force-tracked runtime files (working-tree files preserved).Test plan
pytest tests/unit/test_github_init_gitignore.py -v— all 6 pass (2 existing bug: initialize_github_sync commits .env and .mcp.json despite .gitignore #458 regression tests + 4 new bug: UI Push commits runtime state (.cache, .claude/sessions, .claude.json, .sudo_as_admin_successful, etc.) — git add -A against too-narrow .gitignore #462 tests).touch ~/.cache/test-leak ~/.claude/sessions/test-leak ~/.claude.json, click Push, verify the GitHub commit contains zero of those paths and that/home/developer/.gitignorecontains the new entries..cache/x(git add -f), commit, then click Push — confirm the resulting commit contains aD .cache/xline and the gitignore diff.Files NOT modified (deliberately)
docker/base-image/agent_server/routers/git.py— kept thegit add -Aat line 693 and the auto-sync heartbeat at line 163. Platform-side migration handles correctness; touching agent-side would require base-image rebuild + agent re-creation, which isn't automatic in Trinity's ops model. Once the first post-upgrade Push migrates the workspace.gitignore, every subsequent in-containergit add -A(Push or 15-min heartbeat) operates against the now-correct list.🤖 Generated with Claude Code