fix(domain): correct invariant precedence chain to include action scope #9240
Merged
HAL9000
merged 1 commits from 2026-06-03 03:04:49 +00:00
fix/invariant-precedence-chain-action-scope into master
Labels
Clear labels
auto/needs-reevaluation
controller-managed
overdue
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Needs Feedback
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
Controller deferred this PR; awaiting Phase 6+ scope-evaluator or operator re-enablement.
Auto-agents controller manages this PR/issue (see tools/controller/deploy/RUNBOOK.md). Remove this label to abandon controller management.
PR blocked by an open issue dependency. Operator must close the dep (or remove the dependency link) before the merge driver can act. Auto-cleared by merge_drive when no open deps remain.
Most recent merge cycle hit CI timeout. Driver excludes this PR while last merge_cycle row is < 30 min old; label persists thereafter as visible history.
Currently being processed by an implementer worker.
Currently being processed by the merge driver.
Currently being processed by a reviewer worker.
Merge driver heartbeat stale; pipeline halted. Closed automatically on next clean tick.
Detected master commit violating the strict merge invariant. Tracked as an issue (not a PR label); kept here for label completeness.
In-cycle escalation: most recent attempt ran at the Tier 0 slot (`tier-0`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 1 slot (`tier-1`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 2 slot (`tier-2`). Slot's model defined in .opencode/models/tiers.yaml. Gated behind IMPLEMENTER_ESCALATION_TIER2_ENABLED.
In-cycle escalation: most recent attempt ran at the Tier -1 slot (`tier-min`). Slot's model defined in .opencode/models/tiers.yaml. Suffix is ``-min`` (not ``--1``) so the Forgejo UI reads naturally.
Tracking issues used by the AI Automation system for agents to communicate and report.
Rebase conflict needs LLM conflict-resolver.
Failing CI needs implementer attention.
Documenting a driver incident or rollback.
Reviewer has APPROVED this PR and no later REQUEST_CHANGES is outstanding. The merge driver requires this label to even consider a PR for merging. Set by the reviewer worker on APPROVE; cleared on REQUEST_CHANGES.
Train repeatedly lost master-tempo races. Driver excludes via merge_cycle until cooldown elapses; label persists as visible history.
Revert PR backing out an invariant violation. Fast-tracked through the merge driver.
Sentinel PR duplicated from upstream into a personal fork by tools/duplicate_prs_to_fork.py for pipeline testing. Lives only in the fork; the canonical pipeline never sees it.
No implementer activity for N days. Flagged for human review. Auto-cleared on next push to head branch.
Repeatedly fails on current master (>= 3 ci-fail-on-rebased-sha releases in 12 h). Excluded from driver until human triage.
A ticket in a blocked state and unable to complete until some other task is completed first.
Bounty
$100
A bounty of $100 for any open-source contributor who provides a MR that solves this issue
Bounty
$1000
A bounty of $1000 for any open-source contributor who provides a MR that solves this issue
Bounty
$10000
A bounty of $10000 for any open-source contributor who provides a MR that solves this issue
Bounty
$20
A bounty of $20 for any open-source contributor who provides a MR that solves this issue
Bounty
$2000
A bounty of $2000 for any open-source contributor who provides a MR that solves this issue
Bounty
$250
A bounty of $250 for any open-source contributor who provides a MR that solves this issue
Bounty
$50
A bounty of $50 for any open-source contributor who provides a MR that solves this issue
Bounty
$500
A bounty of $500 for any open-source contributor who provides a MR that solves this issue
Bounty
$5000
A bounty of $5000 for any open-source contributor who provides a MR that solves this issue
Bounty
$750
A bounty of $750 for any open-source contributor who provides a MR that solves this issue
MoSCoW
Could have
Could have feature in order to satisfy the epic/legendary.
MoSCoW
Must have
Must have feature in order to satisfy the epic/legendary.
MoSCoW
Should have
Should have feature in order to satisfy the epic/legendary.
There are questions in the ticket that can not be completed until the project owner provides clarity.
Points
1
1 man-hours worth of work for an expert with no learning curve.
Points
13
13 man-hours worth of work for an expert with no learning curve.
Points
2
2 man-hours worth of work for an expert with no learning curve.
Points
21
21 man-hours worth of work for an expert with no learning curve.
Points
3
3 man-hours worth of work for an expert with no learning curve.
Points
34
34 man-hours worth of work for an expert with no learning curve.
Points
5
5 man-hours worth of work for an expert with no learning curve.
Points
55
55 man-hours worth of work for an expert with no learning curve.
Points
8
8 man-hours worth of work for an expert with no learning curve.
Points
88
88 man-hours worth of work for an expert with no learning curve.
Priority
Backlog
This ticket has backlogged priority and is not to be worked on yet
Priority
CI Blocker
Critical priority issue that blocks CI/CD pipeline and prevents PR merges
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
A ticket for learning a tool or technology that is needed to be able to do future planning and design.
State
Completed
The ticket has been fully implemented, completed, and merged with the source code. This label should only be applied once a ticket is closed.
State
Duplicate
A ticket that represents the same content as an existing ticket.
State
In Progress
A ticket that is actively being developed.
State
In Review
A ticket that has had some code completed to implement but is waiting to pass peer review and is not yet merged in.
State
Paused
This ticket's work started but wasn't finished. It's on hold (likely in a feature branch) and will be resumed later, either due to a blocker or a delay.
State
Unverified
All new tickets start in this state. A developer may set it to show the ticket is unverified. This means we haven't agreed to work on it. It will either move to a verified state or be closed as wontdo.
State
Verified
The issue has been verified by a developer as legitimate. It will be worked on and verified tickets are now considered part of the backlog.
State
Wont Do
This ticket has been decided it wont be done. This may mean the bug has been determined to not be real (cant verify) or the feature is one we have decided we dont want to adopt.
Type
Automation
Any edits or discussion about the AI automated coding system.
Type
Bug
Something that doesnt work as intended.
Type
Discussion
Anytime a ticket represents a discussion about a subject and doesnt fall into one of the other categories.
Type
Documentation
An error or improvement needed in the documentation.
Type
Epic
Any first tier epic. That is, an epic which contains only issues as children and will not have sub-epics.
Type
Feature
Some new functionality not present.
Type
Legendary
A type of Epic which will contain other Epics.
Type
Refactor
A code change that restructures existing code without changing its external behavior.
Type
Support
Someone needs help using the project.
Type
Task
A generic task that doesnt fit into the other type categories.
Type
Testing
Work exclusively focusing on fixing or expanding testing.
Projects
Clear projects
No project
Assignees
aditya (Aditya Chhabra)
aleenaumair (Aleena Umair)
brent.edwards (Brent Edwards)
CoreRasurae (Luis Mendes)
drew (Drew Morris)
eugen.thaci (Eugen Thaci)
freemo (Jeffrey Phillips Freeman)
HAL9000 (HAL 9000)
HAL9001 (HAL9001)
hamza.khyari (Hamza Khyari)
hurui200320 (Rui Hu)
justin.morris
khird (Kyle Hird)
org.cleveragents
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cleveragents/cleveragents-core#9240
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "fix/invariant-precedence-chain-action-scope"
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?
Summary
This PR corrects the invariant precedence chain documentation and implementation to properly include the action scope tier. Previously, the docstrings and merge functions only documented a three-tier precedence (plan > project > global), omitting the action scope entirely. This fix updates the precedence chain to the correct four-tier hierarchy: plan > action > project > global, ensuring action-scoped invariants are properly documented and handled throughout the codebase.
Changes
Testing
Issue Reference
Closes #9003
Automated by CleverAgents Bot
Agent: pr-creator
Code Review Decision: REQUEST CHANGES
PR: fix(domain): correct invariant precedence chain to include action scope
Focus area (PR 9240 mod 5 = 0): Correctness and spec alignment
✅ What is correct
merge_invariants()now correctly acceptsaction_invariantsas the second positional parameter, implementingplan > action > project > globalprecedence per spec §92.InvariantSet.merge()updated correctly: Delegates tomerge_invariants()with the new parameter in the right position.InvariantService.get_effective_invariants()updated correctly: Collects action-scoped invariants filtered byaction_nameand passes them tomerge_invariants().InvariantScopeclass docstring,merge_invariants(),InvariantSet.merge(), andinvariant_service.pymodule docstring all now correctly document the four-tier precedence.step_merge()andstep_merge_invariant_set()now passaction_invariantsviagetattr(context, "action_invariants", []), and a newstep_action_invariants()step is added.invariants_enforced_during_strategize()now passesaction_invariants=[]to bothmerge_invariants()andInvariantSet.merge().❌ Issues Requiring Changes
1. CRITICAL:
list_invariants(effective=True)does not passaction_name(correctness bug)In
invariant_service.py, thelist_invariants()method has aneffective=Truepath:This call does not pass
action_name, so whenlist_invariants(scope=InvariantScope.ACTION, source_name="action-001", effective=True)is called, the action-scoped invariants will not be filtered byaction_name. The newaction_nameparameter is silently ignored in this code path. This is a correctness bug introduced by this PR.Fix required:
2. REQUIRED: No milestone assigned to PR
The linked issue #9003 is under milestone v3.2.0. Per contributing standards, every PR linked to a milestoned issue must have the same milestone assigned. This PR has
milestone: null.3. REQUIRED: No
Type/label assignedThe PR has no labels. Per contributing standards, every PR must have a
Type/label (e.g.,Type/Bugmatching the linked issue).4. REQUIRED: Commit missing
ISSUES CLOSED:footerThe commit message does not include the required
ISSUES CLOSED: #9003footer. The commit message ends after the description without this footer.5. REQUIRED: No new BDD feature file scenarios for action-scope precedence
The issue acceptance criteria explicitly states:
The step definitions are updated, but there is no evidence of new
.featurefile scenarios that exercise the action-scope tier in the merge chain (e.g., a scenario where an action-scoped invariant overrides a project-scoped one with the same text). The step definitions alone are not sufficient — the feature files must contain the scenarios.6. REQUIRED: CHANGELOG.md and CONTRIBUTORS.md not updated
Per contributing standards, both
CHANGELOG.mdandCONTRIBUTORS.mdshould be updated for each PR.⚠️ Minor Observations (non-blocking)
except Exceptionbroad catches inenforce_invariants()are pre-existing and not introduced by this PR, but worth noting for future cleanup.InvariantScopedocstring still says "ACTION invariants are promoted to PLAN scope atplan usetime" — this is potentially confusing given that action invariants are now also a separate tier in the merge chain. A clarifying note about when promotion happens vs. when action-scope is used directly would improve clarity.Summary
The core implementation logic is correct and well-structured. However, there is a correctness bug in
list_invariants(effective=True)that silently ignoresaction_name, plus several process violations (missing milestone, missing label, missingISSUES CLOSED:footer, missing BDD feature scenarios, missing CHANGELOG/CONTRIBUTORS updates) that must be addressed before merge.Automated by CleverAgents Bot
Supervisor: PR Review Pool | Agent: pr-review-pool-supervisor
Worker tag: [AUTO-REV-9240]
Code Review — PR #9240
Primary Focus (PR 9240 % 5 = 0): Correctness and Spec Alignment
Summary
This PR correctly addresses the core bug in issue #9003: the invariant precedence chain was documented and implemented as three-tier (
plan > project > global) when the specification (§92) requires four-tier (plan > action > project > global). The implementation changes are logically sound. However, several issues need attention before merge.What is Done Well
merge_invariants()now iterates over(plan_invariants, action_invariants, project_invariants, global_invariants)in the correct precedence order.invariant.py,invariant_service.py, benchmarks, BDD step definitions, and the Robot Framework helper.frozen=TrueandConfigDict. No regressions.add_invariant(),remove_invariant(), andenforce_invariants()all validate inputs before use.except:clauses: Exception handling catchesException(not bareexcept:) and logs appropriately.Issues Found
1. Missing CHANGELOG.md entry (Required)
The CHANGELOG.md on the PR branch has not been updated. The
[Unreleased]section does not contain an entry for this fix. Per CONTRIBUTING.md requirements, CHANGELOG.md must be updated for every PR.2. Missing
ISSUES CLOSED: #9003footer in commit (Required)The commit message body does not include the required
ISSUES CLOSED: #9003footer. Per CONTRIBUTING.md, commits must include this footer.3. PR has no milestone assigned (Required)
The linked issue #9003 is assigned to milestone
v3.2.0, but this PR has no milestone set. Per quality standards, every PR must have a milestone assigned if the linked issue has one.4. PR has no
Type/label (Required)The PR has zero labels. The linked issue has
Type/Bug. The PR must have aType/label applied.5. No new BDD
.featurefile scenarios (Acceptance Criteria Gap)Issue #9003 acceptance criteria explicitly requires BDD scenarios covering action-scope invariants in the merge precedence chain. The PR updates
features/steps/invariant_models_steps.py(adding thestep_action_invariantsstep definition and wiringaction_invariantsinto merge calls), but no new scenarios were added to any.featurefile. The step definition for"I have action invariants"exists but is not exercised by any new scenario.6. Semantic contradiction in
InvariantScopedocstring (Minor)The
InvariantScopeclass docstring states:This is internally contradictory: if ACTION invariants are promoted to PLAN scope at
plan usetime, then at runtime there should be no ACTION-scoped invariants in the merge chain. Yet the implementation now treats ACTION as a distinct tier. The docstring needs clarification to resolve this contradiction.7.
list_invariants(effective=True)does not passaction_name(Minor)In
invariant_service.py, thelist_invariants()method witheffective=Truecallsget_effective_invariants()without passingaction_name. Wheneffective=Trueis used withscope=InvariantScope.ACTION, action invariants will not be filtered by source name. Consider adding:Summary Table
plan > action > project > globalaction_invariants=[]passed correctly.featurescenarios addedISSUES CLOSED: #9003list_invariants(effective=True)action_nameVerdict: REQUEST CHANGES
The core implementation is correct and well-structured. The blocking issues are:
ISSUES CLOSED: #9003commit footerType/label on PR.featurescenarios (acceptance criteria not fully met)Automated by CleverAgents Bot
Supervisor: PR Review Pool | Agent: pr-review-pool-supervisor
Worker tag: [AUTO-REV-9240]
Code Review Decision: REQUEST CHANGES
PR #9240 —
fix(domain): correct invariant precedence chain to include action scopeThe core implementation correctly fixes the four-tier invariant precedence chain (
plan > action > project > global) per spec §92. However, the following blocking issues must be resolved before merge:[Unreleased]section for this fixISSUES CLOSED: #9003footer absent from commit messagev3.2.0; PR must matchType/label on PR — Linked issue hasType/Bug; PR must have a type label.featurescenarios — Issue acceptance criteria requires BDD scenarios for action-scope invariant precedence; step definitions were updated but no new scenarios were added to any.featurefileMinor issues (non-blocking):
InvariantScopedocstring contradicts itself (ACTION promoted to PLAN vs. ACTION as distinct tier)list_invariants(effective=True)does not passaction_nametoget_effective_invariants()Automated by CleverAgents Bot
Supervisor: PR Review Pool | Agent: pr-review-pool-supervisor
Worker tag: [AUTO-REV-9240]
Grooming Report — PR #9240
Worker: [AUTO-GROOM-3]
Actions Taken
✅ Labels applied:
Type/Bug— fixes invariant precedence chain bugState/In-Review— PR has an active review requesting changes✅ Milestone set:
v3.2.0(matching linked issue #9003)Items Requiring Human Attention
The existing review (ID 5670) identified the following issues that require developer action:
🔴 Blockers:
CHANGELOG.mdentry — add entry under[Unreleased] ### Fixedfor this fixISSUES CLOSED: #9003footer in commit message.featurescenarios — issue #9003 acceptance criteria requires BDD scenarios covering action-scope invariants in the merge precedence chain🟡 Minor:
InvariantScopedocstring (ACTION promotion vs. distinct tier)list_invariants(effective=True)does not passaction_namewhen scope is ACTION[GROOMED]
Automated by CleverAgents Bot
Supervisor: Grooming | Agent: grooming-pool-supervisor
Worker: [AUTO-GROOM-3]
Code Review: REQUEST CHANGES
PR #9240 —
fix(domain): correct invariant precedence chain to include action scopeReviewing as: HAL9001 (second reviewer)
Previous review: HAL9000 COMMENT review (ID 5670) identified 5 blockers. The groomer has resolved 2 of them (milestone + label). The remaining blockers are still unresolved.
✅ What Has Been Fixed Since Previous Review
v3.2.0✅ (applied by groomer)Type/Buglabel applied ✅ (applied by groomer)plan > action > project > global) ✅invariant.pyandinvariant_service.py✅action_invariants=[]passed correctly ✅step_action_invariantsadded, merge calls wired ✅❌ Blocking Issues (Still Unresolved)
1. CI FAILING — Lint check fails
CI run (workflow ID 13266) on the latest commit
5e4a9aedcdbfdd3d4ac8e241cbe8855aad05822ffailed. Thelintjob reports:All CI checks must pass before merge. Fix by running
ruff format benchmarks/invariant_merge_bench.pylocally and committing.2. CHANGELOG.md not updated
No changes to
CHANGELOG.mdappear in the diff. Per CONTRIBUTING.md, every PR must add an entry to the[Unreleased]section. Required entry example:3. Missing
ISSUES CLOSED: #9003footer in commit messageThe commit message ends without the required footer. Per CONTRIBUTING.md, commits must include:
The current commit message body is well-written but lacks this footer entirely.
4. No new BDD
.featurefile scenariosIssue #9003 acceptance criteria explicitly requires:
The PR adds a new step definition (
"I have action invariants") and wires it into merge calls, but no.featurefiles were modified. The step definition is unused by any scenario. A new scenario is needed, for example:5. CONTRIBUTORS.md not updated
Per CONTRIBUTING.md requirements,
CONTRIBUTORS.mdmust be updated for each PR. No changes to this file appear in the diff.⚠️ Minor Issues (Non-Blocking)
InvariantScopedocstring contradiction: StatesACTION invariants are promoted to PLAN scope at plan use timewhile also listing ACTION as a distinct precedence tier. Needs clarification about when promotion happens vs. when action-scope is used directly in the merge chain.list_invariants(effective=True)does not passaction_name: Whenscope=InvariantScope.ACTIONandeffective=True, theaction_nameis silently ignored. Consider addingaction_name=source_name if scope == InvariantScope.ACTION else Noneto theget_effective_invariants()call.Summary Table
benchmarks/invariant_merge_bench.pyneedsruff formatplan > action > project > globalaction_invariants=[]passed correctly.featurescenariosISSUES CLOSED:footerISSUES CLOSED: #9003v3.2.0(applied by groomer)Type/labelType/Bug(applied by groomer)list_invariantsaction_nameRequired Actions Before Re-Review
ruff format benchmarks/invariant_merge_bench.pyand commitCHANGELOG.mdentry under[Unreleased] ### FixedCONTRIBUTORS.mdentryISSUES CLOSED: #9003footer to commit message.featurescenario exercising action-scope invariant precedenceAutomated by CleverAgents Bot
Supervisor: PR Review Pool | Agent: pr-reviewer
Worker: [AUTO-REV-9240]
Code Review Decision: REQUEST CHANGES
PR #9240 —
fix(domain): correct invariant precedence chain to include action scopeThis is a backup comment mirroring the formal review (ID 5728) posted by HAL9001.
Blocking Issues (5 total)
ruff format --check .would reformatbenchmarks/invariant_merge_bench.py. Runruff format benchmarks/invariant_merge_bench.pyand commit.[Unreleased]section for this fix.ISSUES CLOSED: #9003commit footer — Required by CONTRIBUTING.md..featurescenarios — Issue #9003 acceptance criteria requires BDD scenarios for action-scope invariant precedence. Step definitions were updated but no.featurefiles were modified.Already Fixed (by groomer)
v3.2.0assignedType/Buglabel appliedCore Implementation
The four-tier merge logic (
plan > action > project > global) is correct and well-implemented.Automated by CleverAgents Bot
Supervisor: PR Review Pool | Agent: pr-reviewer
Worker: [AUTO-REV-9240]
🏷️ Triage Decision — [AUTO-OWNR-1]\n\nStatus: ✅ Verified (already in review)\n\nIssue Type: Bug (v3.2.0) \nMoSCoW: Must Have — Invariant enforcement is a v3.2.0 acceptance criterion \nPriority: High\n\nRationale: The v3.2.0 milestone requires 'Invariants are enforced during strategize'. Correct invariant precedence chain including action scope is essential for this.\n\nMissing labels to apply: MoSCoW/Must have, Priority/High\n\n---\nAutomated by CleverAgents Bot\nSupervisor: Project Owner | Agent: project-owner-pool-supervisor
5e4a9aedcdtoa54bf5f2bea54bf5f2betocc97d9b703Re-Review: PR #9240 — REQUEST CHANGES
Reviewer: HAL9001 (re-review of REQUEST_CHANGES review ID 5728)
Re-review commit:
a54bf5f2befe00cc52116a150d2bdca7afd77595✅ Prior Feedback That Was Addressed
The following blockers from the previous REQUEST_CHANGES review (ID 5728) have been resolved:
ruff format benchmarks/invariant_merge_bench.py)[Unreleased] ### FixedISSUES CLOSED: #9003commit footer❌ Blocking Issues (Still Unresolved or New)
1. CI FAILING —
unit_tests,lint, ande2e_testsall failing (BLOCKER)The latest CI run (on
a54bf5f2befe00cc52116a150d2bdca7afd77595) reports:CI / lintCI / unit_testsCI / e2e_testsCI / status-checkCI / typecheckCI / securityCI / qualityCI / integration_testsPer company policy, all required CI gates must pass before merge. The
unit_testsandlintfailures are required-for-merge gates that must be green. Thee2e_testsfailure also needs investigation. Please fix all CI failures and push a new commit.2. No new BDD
.featurescenarios (BLOCKER — acceptance criteria gap)Issue #9003 acceptance criteria explicitly requires:
The new step definition
@given("I have action invariants")was added tofeatures/steps/invariant_models_steps.py, but no.featurefile was modified. Runninggrep -r "I have action invariants" features/*.featurereturns zero results — the step is defined but unused in any scenario. The acceptance criteria is not met.A new scenario is required. For example in
features/consolidated_domain_models.feature(or a dedicated invariant feature file):At minimum, add one scenario demonstrating that action-scope takes precedence over project-scope in the merge chain.
3. Critical correctness bug:
list_invariants(effective=True)does not passaction_name(BLOCKER)This was flagged as a critical correctness bug in the very first review comment but has not been fixed in the current commit. The
list_invariants()method:When calling
list_invariants(scope=InvariantScope.ACTION, source_name="action-001", effective=True), theaction_nameparameter is silently ignored. Theget_effective_invariants()method was correctly updated to acceptaction_name, but the call site inlist_invariants()was not updated to pass it.Required fix:
This is a correctness regression introduced by this PR —
get_effective_invariants()now supports action filtering butlist_invariants()does not propagate it.⚠️ Minor Issues (Non-Blocking)
4. Stale comment in
consolidated_domain_models.feature(Minor)Line 421 of
features/consolidated_domain_models.featurestill contains:This should be updated to:
Since no
.featurefile was changed by this PR, this stale comment was not caught. It should be updated when adding the new scenario (blocker #2 above).5. Branch naming convention (Minor)
The branch
fix/invariant-precedence-chain-action-scopeuses afix/prefix. Per CONTRIBUTING.md, bug fixes must use thebugfix/mN-format where N is the milestone number. Milestonev3.2.0→m2. The correct branch name would have beenbugfix/m2-invariant-precedence-chain-action-scope. This cannot be changed retroactively without disrupting the PR, so noting it as a minor observation for future PRs.6.
InvariantScopedocstring still contradicts itself (Minor — pre-existing)The docstring states both that
ACTIONhas its own precedence tier AND thatACTION invariants are promoted to PLAN scope at plan use time. These are contradictory. If promotion happens atplan usetime, then at runtime there should be no ACTION-scoped invariants in the merge chain. This needs clarification — either the promotion note is incorrect, or the action tier in the merge chain is for pre-promotion contexts only.Summary
a54bf5f2.featurescenarios.featurefile changeslist_invariants(effective=True)action_nameISSUES CLOSED:footerget_effective_invariants()action_invariants=[]passedv3.2.0assignedType/labelType/Bugappliedbugfix/m2-*, notfix/*InvariantScopedocstring contradictionRequired Actions Before Re-Review
lint,unit_tests, ande2e_testsfailures.featurescenario exercising action-scope invariant precedence in the merge chainlist_invariants(effective=True)to passaction_name=source_name if scope == InvariantScope.ACTION else Nonetoget_effective_invariants()Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
Re-Review Decision: REQUEST CHANGES
PR #9240 —
fix(domain): correct invariant precedence chain to include action scopeThis is a formal re-review following REQUEST_CHANGES review ID 5728.
Progress Since Last Review
Good progress — 4 of the 5 blockers from the previous review were resolved:
ISSUES CLOSED: #9003commit footer addedRemaining Blocking Issues (3)
CI FAILING —
lint,unit_tests, ande2e_testsall failing on the latest commit (a54bf5f2). All required CI gates must pass before merge. Theunit_testsfailure is particularly concerning as this was not failing on the previous commit — investigate whether the BDD step changes caused a test regression.No new BDD
.featurescenarios — The new@given("I have action invariants")step definition was added tofeatures/steps/invariant_models_steps.py, but zero.featurefiles were modified. The step is unused in any scenario. Issue #9003 acceptance criteria explicitly requires BDD scenarios covering action-scope invariant precedence.Critical correctness bug unfixed —
list_invariants(effective=True)does not passaction_nametoget_effective_invariants(). This was flagged as critical in the very first review (comment ID 215845) and remains unaddressed. The fix is a one-liner: addaction_name=source_name if scope == InvariantScope.ACTION else Noneto the call.Core Implementation
The core four-tier merge logic (
plan > action > project > global) is correct and well-implemented. This PR is close to being merge-ready — please address the 3 remaining blockers.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
Re-Review: REQUEST_CHANGES
PR #9240 —
fix(domain): correct invariant precedence chain to include action scopeReviewing as: HAL9001
Review type: Re-review (following REQUEST_CHANGES review ID 5728 on 2026-04-14)
✅ What Has Been Fixed Since Previous Review (review ID 5728)
All five blockers from the previous review have been addressed except one:
ruff format benchmarks/invariant_merge_bench.pywas run and committed. Lint now passes ✅[Unreleased] ### Fixedwith full description and issue link ✅ISSUES CLOSED: #9003commit footer — Present in the commit message body ✅plan > action > project > global) is correct inmerge_invariants(),InvariantSet.merge(),InvariantService.get_effective_invariants(), module docstring,InvariantScopeclass docstring, benchmarks, BDD step definitions, and Robot Framework helper ✅❌ Blocking Issue (Still Unresolved)
1. No new BDD
.featurefile scenarios — acceptance criteria gapIssue #9003 acceptance criteria explicitly requires:
The PR adds a new step definition
@given("I have action invariants")infeatures/steps/invariant_models_steps.pyand correctly wiresaction_invariantsinto the merge step calls. However, zero.featurefiles containGiven I have action invariants— the step is defined but never exercised by any Gherkin scenario.The existing scenarios in
features/consolidated_domain_models.featuretest three-tier merge (plan/project/global) and need to be supplemented with at least one scenario exercising the four-tier chain. This is an explicit acceptance criterion in issue #9003 and its absence means CI unit_tests cannot cover the new code path through a BDD scenario.A minimal acceptable scenario (add to
features/consolidated_domain_models.feature):⚠️ CI Status
unit_testsis failing on this PR (run ID 18889, "Failing after 4m55s"). Investigation showsunit_testsis also failing on the current master HEAD (94dd77fb) — this is a pre-existing CI failure that was not introduced by this PR. The PR author is not responsible for fixing a pre-existing master breakage, but company policy requires all required CI gates to pass before merge (CONTRIBUTING.md: "All CI checks must pass before merge").Recommended path: Once the BDD scenario (item 1 above) is added, confirm whether the new scenario passes locally and whether the
unit_testspre-existing failure is being tracked separately. Ifunit_testsfailures are pre-existing and tracked on master, the merge supervisor and PR author should coordinate to either fix the master breakage first, or obtain a maintainer waiver.Minor Issues (Non-Blocking, Carried Forward)
These were noted in the previous review and remain as minor observations:
list_invariants(effective=True)action_name gap: Whenscope=InvariantScope.ACTIONandeffective=True, theaction_namefilter inget_effective_invariants()will accept all ACTION invariants ifaction_name is None. This was pre-existing before this PR, but the new code path makes it more visible. Consider a follow-up issue.InvariantScopedocstring contradiction (now mostly resolved): The docstring now correctly readsPLAN > ACTION > PROJECT > GLOBALbut still includesACTION invariants are promoted to PLAN scope at plan use time— which is somewhat contradictory with treating ACTION as a distinct merge tier. The spec §92 note in the commit message and issue body helps clarify intent; a follow-up clarification in the docstring body would be beneficial.Summary Table
ruff formatrun, lint passingplan > action > project > globalInvariantScopedocstringPLAN > ACTION > PROJECT > GLOBALmerge_invariants()signatureaction_invariantsparameter addedInvariantSet.merge()action_invariantsInvariantService.get_effective_invariants()action_invsstep_action_invariantsdefined and wired.featurescenariosGiven I have action invariantsunused in any.featurefile[Unreleased]ISSUES CLOSED:footerISSUES CLOSED: #9003presentv3.2.0Type/labelType/Bugaction_invariants=[]passedRequired Action Before Re-Review
.featurescenario that usesGiven I have action invariantsand validates action-scope precedence in the merge chain (see example above).unit_testsmaster failure blocks this PR or if a tracked fix is in progress.Once item 1 is addressed and CI is green (or the
unit_testspre-existing failure is formally waived by a maintainer), this PR is ready for approval.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
BLOCKING: Step definition unused in any
.featurefile.This step
@given("I have action invariants")is correctly implemented, but no.featurefile containsGiven I have action invariants. The acceptance criterion in issue #9003 explicitly requires BDD scenarios covering action-scope invariants in the merge precedence chain.The step is wired into the
step_mergeandstep_merge_invariant_setfunctions (which also appear in this diff), but without a.featurescenario that invokes theGiven I have action invariantsstep, the new code path throughmerge_invariants()with a non-emptyaction_invariantslist is not exercised by any BDD test.Fix: Add a new
Scenarioblock tofeatures/consolidated_domain_models.feature(or a new.featurefile) that exercises action-scope invariant precedence. Example:Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
Re-review complete (review ID 7950) — REQUEST_CHANGES submitted on commit
cc97d9b703953e25cc780083b4fd2c6345bfa404.4 of 5 blocking issues from the previous review have been resolved. One blocker remains: no BDD
.featurescenario exercises the newGiven I have action invariantsstep. Additionally,unit_testsCI is failing (pre-existing master failure, not introduced by this PR).Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
🌱 Grooming: proceed — PR cleared for processing.
(check
no_duplicates, categoryno_duplicates)PR #9232 is a comprehensive fix for the invariant ACTION scope omission, touching merge_invariants(), InvariantSet.merge(), and InvariantService.get_effective_invariants() across 8 files with 347 additions and extensive test coverage (9 new BDD scenarios). While related PRs exist (#3269, #3329, #9240, #11173), they address narrower slices of the problem or are smaller in scope. PR #11173 is most similar but has only 144 additions to 6 files. The anchor, being older (lower PR #) and more comprehensive, is the canonical solution, not a duplicate.
📋 Estimate: tier 1.
PR touches 7 files (+85/-21) across invariant.py, invariant_service.py, BDD step definitions, benchmarks, and a Robot Framework helper. While much of the change is docstring/comment updates, the PR explicitly updates merge function logic in invariant.py and invariant_service.py to include the action scope tier. CI has a real unit_test failure (Behave: 1 scenario failed, 26 steps errored) — not a reaper flake, as the Behave summary explicitly shows 1 failed scenario. The implementer must understand the invariant precedence merge logic, fix the failing test, and ensure action scope is correctly integrated throughout. Multi-file, logic-touching, with a CI gate to fix = standard Tier 1 work.
(attempt #4, tier 1)
🔧 Implementer attempt —
rebase-failed.Blockers:
cc97d9b703to3ea6969134(attempt #6, tier 1)
🔧 Implementer attempt —
rebase-failed.Blockers:
3ea6969134to5410719319(attempt #8, tier 2)
🔧 Implementer attempt —
verified-clean.✅ Approved
Reviewed at commit
5410719.Confidence: high.
Claimed by
merge_drive.py(pid 1146398) until2026-06-03T04:15:06.852523+00:00.This claim is advisory and will be released when the cycle ends, or after the TTL by a sibling driver's expired-claim sweep.
5410719319to7b008193d6Approved by the controller reviewer stage (workflow 179).