Skip to content

feat(systems): unassign a held skill when its declared gate cannot be written - #4182

Merged
vybe merged 4 commits into
devfrom
feature/ent1068-unassign-on-failed-gate
Nov 2, 2026
Merged

vybe merged 4 commits into
devfrom
feature/ent1068-unassign-on-failed-gate

Conversation

@vybe

@vybe vybe commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes abilityai/trinity-enterprise#1068. When a manifest declares a gate on a held skill and the write fails, apply now unassigns the skill, so a declared gate is never silently absent. Follows #4154, which only reported it.

What

  • On a failed gate write for a held skill with no gate in force, apply re-reads the gate row. If it was stored after all, nothing changes and the reason says so. Otherwise the skill is unassigned and its package removed, in the same apply.
  • The result says so: the failure reason, a skill_unassigned_gate_failed change, a warning line and summary.skills.write. A deferred package removal is named. A refused unassign gets its own failed[] row.
  • The dry run states the same consequence, from one switch read per apply.
  • The switch: apply_unassign_on_failed_gate, an ops setting, default on, admin only, with a toggle in Settings → Access (ApplyUnassignOnFailedGateSetting.vue).
  • skill_assignment_service.unassign_and_remove is now shared with the unassign route, whose behaviour is unchanged.

Rulings carried (orchestrator, on the operator's behalf)

  • A stored previous gate stays report-only: the gate is not absent.
  • A skill held only through a skill set stays report-only (skill_held_via_set). It keeps running with no approval gate when its gate write fails, even with the switch on. Unassigning the set would take its siblings and clear their explicit gates, which the gates module promises never to do. This leaves part of the operator's ruling open, for the operator's eye.
  • A run in flight is not cancelled; a turn that loaded the skill finishes with it.
  • Several failing gates: each unassigns its own skill.
  • Debt: system_service.py carries open refactor Refactor: split the apply engine out of system_service.py #4134; this change adds one plan field there and defers the rest.

Review + security

/review (Fable, report-only): MERGEABLE, every rider check verified. /cso --diff: no findings. Recorded: a failed gate-row re-read skips the unassign without saying why in the result; three low-confidence items in the review's appendix.

Tests

test_ent1068_unassign_on_failed_gate.py 19, with the three clearing writers pinned to raise. 179 backend across neighbours; 545 frontend across 30 specs; 15 shuffled suites green. Not run here: full island and full frontend suite (CI), live tiers.

Before merge

Behaviour change on live installs, default on: it needs a release-note line. Known and pre-existing: test_ent236_skills_lifecycle::test_real_repo_still_pulls.

🤖 Generated with Claude Code

Release notes (added at merge-train, 2026-11-02)

  • Config keys whose behaviour changed: apply_unassign_on_failed_gate (new ops setting, default on, admin only; toggle in Settings → Access). A held skill whose declared gate cannot be written during a manifest apply is now unassigned instead of left running ungated. Set it off to keep the previous report-only behaviour. A skill held only through a skill set stays report-only (skill_held_via_set) either way.

Trinity Agent (trinity) and others added 4 commits November 2, 2026 03:34
… written (abilityai/trinity-enterprise#1068)

A system apply whose gate write fails on a skill the member already holds,
with no gate in force, now unassigns that skill (no gate, no skill) through
the unassign route's own sequence, lifted into
skill_assignment_service.unassign_and_remove. Per-install switch
apply_unassign_on_failed_gate (ops settings, default true), read once per
apply in the snapshot. A stored previous gate and a set-held skill stay
report-only (skill_held_via_set). The dry run's gate change says the
consequence ahead of time; the summary counts a landed unassign.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…itch modes (abilityai/trinity-enterprise#1068)

Real apply route, real database: switch on x {service refusal, DB fault}
unassigns and names it; switch off keeps the ent#1043 report; lost lease,
deferred removal, a gate row stored despite the raise, previous_gate_stands
and a set-held skill each stay as stated; several failing gates; the dry
run's note in both modes; the unassign route keeps its 409. The ent#1030
never-clear pin is installed throughout.

Mutation: with the unassign hand-off in gates.run removed, 9 tests go red;
with the switch read pinned to true, the 3 switch-off tests go red.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…toggle (abilityai/trinity-enterprise#1068)

An admin can turn the failed-gate unassign off under Settings -> Access,
through the ops-config endpoint. Its own component on the BaseToggle
primitive, so Settings.vue's raw-colour count does not move. The setting
defaults ON, so readOpsBool gains a fallback used only when the key holds
no string: an absent key reads as the server default, not as report-only.
A failed read leaves the switch disabled and says so.

Mutation: with the fallback replaced by false, 2 tests go red (the reader
case and the mounted absent-key case).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tays report-only (abilityai/trinity-enterprise#1068)

Requirements approval-map line, the feature flow's Gates paragraph, the
user doc's gates row and its "absent key is never a revoke" line now name
the one switch-gated exception, and state that a skill held through a
skill set (skill_held_via_set) and one a stored gate still covers
(previous_gate_stands) stay report-only. test_ent1030_skills' docstring no
longer says apply never unassigns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@trinity-ability trinity-ability left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Validation Report — /validate-pr

PR: #4182 — feat(systems): unassign a held skill when its declared gate cannot be written
Branch: feature/ent1068-unassign-on-failed-gate → dev · head 6c3d7f797
Files changed: 20 (+1037/−140) · Lane B (no lane-C path; no schema; tests/ carries deletions, so Lane A is withheld)

Summary

Category Status Notes
Commit messages ✅ 4 conventional commits (feat ×2, test, docs)
Base branch ✅ dev
PR size ✅ 20 files
Status auto-promotion ⚠️ Fixes abilityai/trinity-enterprise#1068 is cross-tracker, so the promotion workflow skips it. Set status-in-dev on the issue by hand after merge (it currently reads status-ready)
Requirements ✅ requirements/roadmap.md approval-map line updated
Architecture ➖ no endpoint, schema or topology change
Feature flows ✅ feature-flows/system-manifest.md: Gates paragraph extended
Security check ✅ §4.1–4.10 clean: no keys, emails, IPs, env files, secrets, credential files, mode flips or host paths; docs-guard pattern does not match
Infrastructure / build / config packaging ➖ no Dockerfile, compose or new os.getenv
Structural review ✅ /review and /cso --diff ran report-only before this pass, and the PR body summarises both: no critical findings, no security findings at the daily gate. I re-checked its two central claims (below)
Merge gate (Tier 1) ✅ All required contexts green, plus pytest (head, seed 12345), regression diff, build, prod-image-smoke, gitleaks. dev tip c8f67cb85 is the last green (dev-ci: success), with no open dev-ci red issue
Test adequacy ✅ Non-happy paths covered: switch off, lost lease, deferred removal, row stored despite the raise, previous gate, set-held, several gates, refused unassign
Code quality ✅ Focused. The unassign route now delegates to skill_assignment_service.unassign_and_remove with unchanged behaviour (409 skill_set_unresolved kept, pinned by a real route call)
Requirements trace ✅ Every acceptance criterion maps to code and tests, except the set-held case (warning below)
Product fit ✅ / ⚠️ Issue approved (status-ready, not incubating). Tier not on record in the open-core split file
Product bar 7–11 ✅ / ⚠️ Bar 10, minor: see Suggestions

Execution coverage (§5.4)

changed symbol executed by live consumer verdict
gates._unassign_held_skill / _gate_row_stored test_ent1068 (through POST /api/systems/apply) gates.run → _run_op gate_set ✅
switch read in read_apply_snapshot → ApplyPlan → gates.plan op field TestSwitchOffReports (stored "false"), test_the_switch_is_on_by_default system_service._plan_gates ✅
skill_assignment_service.unassign_and_remove TestTheUnassignRouteIsUnchanged + every switch-on case routers/skills.py::unassign_skill, gates.py ✅
summary.build(extra_changes=) summary.skills.write asserted at 0, 1 and 2 system_service._apply_report ✅
ApplyUnassignOnFailedGateSetting.vue + readOpsBool fallback mounted spec (jsdom); SSH reading pinned unchanged Settings.vue access tab ✅
test_ent753 census AST guard CI 🛡 guard

Mutation, run here in the PR's own worktree: I made _unassign_held_skill return False up front. test_ent1068 went 9 failed / 10 passed, and I reverted the change afterwards. The review's own mutations (unassign hand-off removed; switch ignored) also went red in both modes.

Re-run on the head: test_ent1068 19, test_ent1043 11, test_ent753 27, test_297 41, test_ent1030_skills 24, test_ent1030_gates 57 (the never-clear guard). All passed. On the frontend, the spec and the raw-colour, source-text and loading-gate ratchets were 4 files, 35 passed. test_ent236_skills_lifecycle did not finish inside my timeout; the PR body already lists it as failing on base too.

Issues found

Critical (block merge)

None.

Warnings (review required)

  • A skill held only through a skill set stays report-only (skill_held_via_set), even with the switch on. It keeps running with no approval gate when its gate write fails. The issue's first acceptance criterion reads as unconditional, so this partly leaves the operator's ruling open. It is recorded in the PR body as a deliberate ruling (unassigning the set would take its siblings and their explicit gates). Flagged for the operator; not blocking.
  • The silent branch from the review (I1): if the gate row cannot be re-read after the failed write, the unassign is skipped. The result then reads exactly like switch-off (skill_runs_ungated) and never says the re-read failed. It is safe in direction, since nothing is unassigned, and it needs two faults in a row. A one-clause reason suffix plus a test would close it.
  • Open-core tier not on record for the manifest gates surface. This is not a finding.

Suggestions (optional)

  • Bar 10: the dry-run consequence note shows the raw setting key (… is unassigned (apply_unassign_on_failed_gate)). Consider the Settings label, "Unassign a skill whose gate cannot be written", instead.
  • From the review's appendix, if anyone has time: the audit row for an apply-driven package removal reads trigger: "unassign", the same as a hand unassign. Only the endpoint tells them apart.

Before merge

  • Release-note line required. This changes behaviour on live installs and is on by default: a failed gate on a held skill now unassigns it. Name the apply_unassign_on_failed_gate ops setting under "Config keys whose behaviour changed".

Recommendation

APPROVE. Tier 1 is green and dev is green. Tests execute the changed path, and the core branch goes red when mutated. The scope matches the issue, with the one set-held exception recorded as a ruling for the operator. After merge: confirm a dev-ci success on the merged SHA, and bump the linked issue to status-in-dev by hand.

🤖 Generated with Claude Code

@vybe
vybe marked this pull request as ready for review November 2, 2026 18:01
@vybe
vybe merged commit fb2bfd6 into dev Nov 2, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants