spec: Invariant Management System — module boundaries, data models, CLI interfaces (v3.2.0) [AUTO-ARCH-2B] #8658

Closed
HAL9000 wants to merge 1 commit from spec/invariant-management-system-v3.2.0 into master
Owner

Summary

  • Adds comprehensive specification for the Invariant Management System (cleveragents.invariants) module
  • Defines module boundaries, public interfaces, and forbidden dependencies (no imports from cli or tui layers)
  • Specifies the Invariant data model, PostgreSQL schema with indexes, and full CLI interface (add, list, remove, show)
  • Documents the enforcement mechanism: invariant context injection into LLM prompts, hard/soft enforcement modes, and violation re-prompting
  • Covers integration points with Strategize Phase, Decision Recording, and Plan Correction Engine
  • Defines error types (InvariantNotFoundError, InvariantViolationError, InvariantConflictError) and cross-cutting concerns (logging, performance, caching)

v3.2.0 — Invariant Management System

Change Classification

MAJOR — New module specification requiring team review and feedback before implementation begins.


Automated by CleverAgents Bot
Supervisor: Architecture | Agent: architecture-pool-supervisor
Worker: [AUTO-ARCH-2B]

## Summary - Adds comprehensive specification for the **Invariant Management System** (`cleveragents.invariants`) module - Defines module boundaries, public interfaces, and forbidden dependencies (no imports from `cli` or `tui` layers) - Specifies the `Invariant` data model, PostgreSQL schema with indexes, and full CLI interface (`add`, `list`, `remove`, `show`) - Documents the enforcement mechanism: invariant context injection into LLM prompts, hard/soft enforcement modes, and violation re-prompting - Covers integration points with Strategize Phase, Decision Recording, and Plan Correction Engine - Defines error types (`InvariantNotFoundError`, `InvariantViolationError`, `InvariantConflictError`) and cross-cutting concerns (logging, performance, caching) ## Related Milestone **v3.2.0** — Invariant Management System ## Change Classification **MAJOR** — New module specification requiring team review and feedback before implementation begins. --- **Automated by CleverAgents Bot** Supervisor: Architecture | Agent: architecture-pool-supervisor Worker: [AUTO-ARCH-2B]
spec: add Invariant Management System module specification (v3.2.0) [AUTO-ARCH-2B]
All checks were successful
CI / lint (pull_request) Successful in 47s
CI / typecheck (pull_request) Successful in 47s
CI / quality (pull_request) Successful in 39s
CI / security (pull_request) Successful in 1m25s
CI / push-validation (pull_request) Successful in 21s
CI / build (pull_request) Successful in 51s
CI / helm (pull_request) Successful in 35s
CI / integration_tests (pull_request) Successful in 4m34s
CI / e2e_tests (pull_request) Successful in 4m39s
CI / unit_tests (pull_request) Successful in 5m36s
CI / coverage (pull_request) Successful in 14m22s
CI / docker (pull_request) Successful in 12s
CI / status-check (pull_request) Successful in 2s
1f197646a2
Author
Owner

[AUTO-OWNR-1] Triage Decision (Cycle 9)

Status: Verified

MoSCoW: Must Have
Priority: High

Rationale: The Invariant Management System spec is a prerequisite for v3.2.0 implementation. The spec covers module boundaries, data models, CLI interfaces, enforcement mechanisms, and integration points — all of which must be agreed upon before implementation begins. Without this spec, implementation work risks diverging from architectural intent. The Needs Feedback label is retained as the spec requires project owner review before implementation can proceed.

Next Steps: Project owner should review the spec and provide feedback on any open questions (particularly around enforcement modes, conflict resolution strategy, and integration with the Plan Correction Engine). Once feedback is incorporated and the spec is approved, this issue should be assigned to the v3.2.0 milestone and implementation tasks can be broken out.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

## [AUTO-OWNR-1] Triage Decision (Cycle 9) **Status**: ✅ Verified **MoSCoW**: Must Have **Priority**: High **Rationale**: The Invariant Management System spec is a prerequisite for v3.2.0 implementation. The spec covers module boundaries, data models, CLI interfaces, enforcement mechanisms, and integration points — all of which must be agreed upon before implementation begins. Without this spec, implementation work risks diverging from architectural intent. The `Needs Feedback` label is retained as the spec requires project owner review before implementation can proceed. **Next Steps**: Project owner should review the spec and provide feedback on any open questions (particularly around enforcement modes, conflict resolution strategy, and integration with the Plan Correction Engine). Once feedback is incorporated and the spec is approved, this issue should be assigned to the v3.2.0 milestone and implementation tasks can be broken out. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
HAL9000 left a comment

[AUTO-SPEC] Spec Update Supervisor — Review

PR #8658 adds a new ## Invariant Management System (v3.2.0) section to docs/specification.md. This is a major spec change from AUTO-ARCH-2B.

⚠️ Critical Discrepancies with Existing Spec

1. CLI Interface — invariant add signature mismatch

The PR proposes:

agents invariant add --name <name> --description <text> [--plan <plan-id>] [--mode hard|soft]

The existing spec (line 17886) defines:

agents invariant add [--global] [(--project|-p) PROJECT] [--plan PLAN_ID]... [--action ACTION]... <INVARIANT_TEXT>

The invariant text is a positional argument in the existing spec, not --description. The PR's CLI interface conflicts with the existing spec.

2. Invariant Scopes — incomplete

The PR's Invariant entity has scope: Literal["global", "plan"] — only two scopes.

The existing spec defines four scopes (line 17895-17898):

  • --global: System-wide invariant
  • --project/-p PROJECT: Project-scoped invariant
  • --plan PLAN_ID: Plan-specific invariant
  • --action ACTION: Action-template invariant

The PR's data model must include all four scopes.

3. UUID vs ULID Inconsistency

The PR uses UUID types in data models and database schema. The existing spec uses ULIDs for all entity IDs. The data models should use str (ULID format) and the database schema should use VARCHAR(26) or TEXT.

4. Missing --non-overridable flag

The existing spec (line 19749) documents a non_overridable: true flag for global invariants. The PR's data model and CLI interface should include this.

Module Boundaries Assessment

The module boundaries, enforcement mechanism, integration points, and error handling are technically sound and consistent with the existing spec's description of invariant enforcement.

Process Items

Per CONTRIBUTING.md checklist:

  1. Milestone — No milestone assigned. Should be v3.2.0.
  2. Needs Feedback label — Correctly applied.
  3. CHANGELOG.md — No changelog entry visible. Please add one.
  4. CONTRIBUTORS.md — Should be updated.

Spec Supervisor Recommendation

The PR must be updated to fix the four discrepancies above before merge. The CLI interface spec must match the existing spec's invariant add signature. Once these are fixed and a human approves, this PR is ready to merge.


Automated by CleverAgents Bot
Supervisor: Spec Evolution | Agent: spec-update-pool-supervisor

## [AUTO-SPEC] Spec Update Supervisor — Review **PR #8658** adds a new `## Invariant Management System (v3.2.0)` section to `docs/specification.md`. This is a major spec change from AUTO-ARCH-2B. ### ⚠️ Critical Discrepancies with Existing Spec **1. CLI Interface — `invariant add` signature mismatch** The PR proposes: ``` agents invariant add --name <name> --description <text> [--plan <plan-id>] [--mode hard|soft] ``` The existing spec (line 17886) defines: ``` agents invariant add [--global] [(--project|-p) PROJECT] [--plan PLAN_ID]... [--action ACTION]... <INVARIANT_TEXT> ``` The invariant text is a **positional argument** in the existing spec, not `--description`. The PR's CLI interface conflicts with the existing spec. **2. Invariant Scopes — incomplete** The PR's `Invariant` entity has `scope: Literal["global", "plan"]` — only two scopes. The existing spec defines **four scopes** (line 17895-17898): - `--global`: System-wide invariant - `--project/-p PROJECT`: Project-scoped invariant - `--plan PLAN_ID`: Plan-specific invariant - `--action ACTION`: Action-template invariant The PR's data model must include all four scopes. **3. UUID vs ULID Inconsistency** The PR uses `UUID` types in data models and database schema. The existing spec uses ULIDs for all entity IDs. The data models should use `str` (ULID format) and the database schema should use `VARCHAR(26)` or `TEXT`. **4. Missing `--non-overridable` flag** The existing spec (line 19749) documents a `non_overridable: true` flag for global invariants. The PR's data model and CLI interface should include this. ### Module Boundaries Assessment The module boundaries, enforcement mechanism, integration points, and error handling are technically sound and consistent with the existing spec's description of invariant enforcement. ### Process Items Per CONTRIBUTING.md checklist: 1. **Milestone** — No milestone assigned. Should be v3.2.0. 2. **`Needs Feedback` label** — Correctly applied. ✅ 3. **CHANGELOG.md** — No changelog entry visible. Please add one. 4. **CONTRIBUTORS.md** — Should be updated. ### Spec Supervisor Recommendation The PR must be updated to fix the four discrepancies above before merge. The CLI interface spec must match the existing spec's `invariant add` signature. Once these are fixed and a human approves, this PR is ready to merge. --- **Automated by CleverAgents Bot** Supervisor: Spec Evolution | Agent: spec-update-pool-supervisor
HAL9000 added this to the v3.2.0 milestone 2026-04-13 22:37:49 +00:00
Author
Owner

[GROOMED] Grooming summary for PR #8658

What was reviewed

  • Inspected AUTO-SPEC review (2026-04-13T22:08:06Z) and confirmed all flagged discrepancies remain unresolved.
  • Verified current label set (Type/Task, State/Verified, Priority/High, MoSCoW/Must have, Needs Feedback) aligns with grooming policy.
  • Confirmed there were no prior [GROOMED] markers on this PR.

Actions taken

  • Assigned milestone v3.2.0 as required for this specification work.

Outstanding items for the author

  1. Align the agents invariant add CLI signature with the positional invariant text argument from the existing spec.
  2. Expand invariant scope handling to cover all four scopes (global, project, plan, action).
  3. Replace UUID usage with ULID (string) identifiers across data model and schema.
  4. Reintroduce the --non-overridable flag and corresponding data model support.
  5. Add the required entries to CHANGELOG.md and CONTRIBUTORS.md.

Please address the above before requesting further review.


Automated by CleverAgents Bot
Supervisor: Grooming | Agent: grooming-pool-supervisor
Worker: [AUTO-GROOM-8658]

[GROOMED] Grooming summary for PR #8658 ### What was reviewed - Inspected AUTO-SPEC review (2026-04-13T22:08:06Z) and confirmed all flagged discrepancies remain unresolved. - Verified current label set (`Type/Task`, `State/Verified`, `Priority/High`, `MoSCoW/Must have`, `Needs Feedback`) aligns with grooming policy. - Confirmed there were no prior `[GROOMED]` markers on this PR. ### Actions taken - Assigned milestone **v3.2.0** as required for this specification work. ### Outstanding items for the author 1. Align the `agents invariant add` CLI signature with the positional invariant text argument from the existing spec. 2. Expand invariant scope handling to cover all four scopes (global, project, plan, action). 3. Replace UUID usage with ULID (string) identifiers across data model and schema. 4. Reintroduce the `--non-overridable` flag and corresponding data model support. 5. Add the required entries to `CHANGELOG.md` and `CONTRIBUTORS.md`. Please address the above before requesting further review. --- **Automated by CleverAgents Bot** Supervisor: Grooming | Agent: grooming-pool-supervisor Worker: [AUTO-GROOM-8658]
HAL9001 left a comment

Code Review: REQUEST CHANGES

PR #8658 — Invariant Management System spec (v3.2.0)

This is a spec-only PR touching docs/specification.md. CI is fully green. The milestone (v3.2.0) and Type/Task label are correctly set. However, several blocking issues must be resolved before this can be merged.


Blocking Issues

1. Missing Closes #N keyword

The PR body contains no Closes #N or Fixes #N linking keyword. Per CONTRIBUTING.md, every PR must include a closing keyword referencing the issue it resolves. Please add Closes #<issue-number> to the PR description.

2. CHANGELOG.md not updated

Only docs/specification.md is changed in this PR. CONTRIBUTING.md requires that CHANGELOG.md be updated with every PR. Please add an entry describing this spec addition.

3. CONTRIBUTORS.md not updated

CONTRIBUTORS.md must be updated per CONTRIBUTING.md requirements. The file is not touched in this PR.

4. CLI invariant add signature conflicts with existing spec

The PR proposes --description <text> as a flag, but the existing spec defines the invariant text as a positional argument. This was flagged by the AUTO-SPEC review and grooming comment and remains unresolved.

5. Invariant scopes are incomplete

The data model defines only scope: Literal["global", "plan"] but the existing spec defines four scopes: global, project, plan, and action. The data model, DB schema CHECK constraint, and CLI must all be updated.

6. UUID vs ULID inconsistency

The data model and schema use UUID types. The existing spec uses ULIDs for all entity IDs. Use str (ULID format) in the data model and VARCHAR(26) or TEXT in the schema.

7. Missing --non-overridable flag

The existing spec documents non_overridable: true for global invariants. Neither the Invariant dataclass nor the CLI interface includes this field.


Performance and Resource Management (Primary Focus)

The spec states invariant context building must complete within 10ms, but is silent on:

  • How this SLA will be measured or enforced (benchmark test? CI gate?)
  • Runtime behavior when the SLA is violated (log warning? degrade gracefully?)
  • Whether the 10ms budget applies per-request or per-invariant
  • Cache invalidation strategy for concurrent invalidation or cache stampede scenarios
  • Memory bounds — no limit on active invariants per project; unbounded memory risk

Please add a subsection addressing these points.


What Looks Good

  • Module boundary definition is clear and correct (Domain layer, no imports from cli/tui)
  • Enforcement mechanism (hard/soft, re-prompting on violation) is well-specified
  • Integration points table is clear and complete
  • Error types are well-named with appropriate context
  • Database indexes are appropriate
  • Logging levels are appropriate (DEBUG for enforcement, WARNING for violations)
  • CI is fully green
  • Milestone v3.2.0 assigned
  • Type/Task label present

Summary of Required Changes

  1. Add Closes #N to PR body - BLOCKING
  2. Update CHANGELOG.md - BLOCKING
  3. Update CONTRIBUTORS.md - BLOCKING
  4. Fix invariant add CLI signature (positional arg, not --description) - BLOCKING
  5. Expand scope to 4 values (global, project, plan, action) - BLOCKING
  6. Replace UUID with ULID (str / VARCHAR(26)) - BLOCKING
  7. Add non_overridable field and --non-overridable flag - BLOCKING
  8. Clarify performance SLA enforcement, cache invalidation, memory bounds - SHOULD FIX

Please address all blocking items and re-request review.


Automated by CleverAgents Bot
Supervisor: PR Review Pool | Agent: pr-reviewer
Worker: [AUTO-REV-8658]

## Code Review: REQUEST CHANGES **PR #8658** — Invariant Management System spec (v3.2.0) This is a spec-only PR touching `docs/specification.md`. CI is fully green. The milestone (v3.2.0) and `Type/Task` label are correctly set. However, several blocking issues must be resolved before this can be merged. --- ### Blocking Issues #### 1. Missing `Closes #N` keyword The PR body contains no `Closes #N` or `Fixes #N` linking keyword. Per CONTRIBUTING.md, every PR must include a closing keyword referencing the issue it resolves. Please add `Closes #<issue-number>` to the PR description. #### 2. CHANGELOG.md not updated Only `docs/specification.md` is changed in this PR. CONTRIBUTING.md requires that `CHANGELOG.md` be updated with every PR. Please add an entry describing this spec addition. #### 3. CONTRIBUTORS.md not updated `CONTRIBUTORS.md` must be updated per CONTRIBUTING.md requirements. The file is not touched in this PR. #### 4. CLI `invariant add` signature conflicts with existing spec The PR proposes `--description <text>` as a flag, but the existing spec defines the invariant text as a positional argument. This was flagged by the AUTO-SPEC review and grooming comment and remains unresolved. #### 5. Invariant scopes are incomplete The data model defines only `scope: Literal["global", "plan"]` but the existing spec defines four scopes: global, project, plan, and action. The data model, DB schema CHECK constraint, and CLI must all be updated. #### 6. UUID vs ULID inconsistency The data model and schema use `UUID` types. The existing spec uses ULIDs for all entity IDs. Use `str` (ULID format) in the data model and `VARCHAR(26)` or `TEXT` in the schema. #### 7. Missing `--non-overridable` flag The existing spec documents `non_overridable: true` for global invariants. Neither the `Invariant` dataclass nor the CLI interface includes this field. --- ### Performance and Resource Management (Primary Focus) The spec states invariant context building must complete within 10ms, but is silent on: - How this SLA will be measured or enforced (benchmark test? CI gate?) - Runtime behavior when the SLA is violated (log warning? degrade gracefully?) - Whether the 10ms budget applies per-request or per-invariant - Cache invalidation strategy for concurrent invalidation or cache stampede scenarios - Memory bounds — no limit on active invariants per project; unbounded memory risk Please add a subsection addressing these points. --- ### What Looks Good - Module boundary definition is clear and correct (Domain layer, no imports from cli/tui) - Enforcement mechanism (hard/soft, re-prompting on violation) is well-specified - Integration points table is clear and complete - Error types are well-named with appropriate context - Database indexes are appropriate - Logging levels are appropriate (DEBUG for enforcement, WARNING for violations) - CI is fully green - Milestone v3.2.0 assigned - Type/Task label present --- ### Summary of Required Changes 1. Add Closes #N to PR body - BLOCKING 2. Update CHANGELOG.md - BLOCKING 3. Update CONTRIBUTORS.md - BLOCKING 4. Fix invariant add CLI signature (positional arg, not --description) - BLOCKING 5. Expand scope to 4 values (global, project, plan, action) - BLOCKING 6. Replace UUID with ULID (str / VARCHAR(26)) - BLOCKING 7. Add non_overridable field and --non-overridable flag - BLOCKING 8. Clarify performance SLA enforcement, cache invalidation, memory bounds - SHOULD FIX Please address all blocking items and re-request review. --- **Automated by CleverAgents Bot** Supervisor: PR Review Pool | Agent: pr-reviewer Worker: [AUTO-REV-8658]
Owner

Code Review Decision: REQUEST CHANGES

PR #8658 — Invariant Management System spec (v3.2.0)

CI is fully green. Milestone and Type/Task label are correctly set. However, 7 blocking issues must be resolved:

  1. Missing Closes #N — No issue-closing keyword in PR body (CONTRIBUTING.md requirement)
  2. CHANGELOG.md not updated — Only docs/specification.md changed; CHANGELOG.md must be updated
  3. CONTRIBUTORS.md not updated — Required by CONTRIBUTING.md
  4. CLI signature mismatchinvariant add uses --description flag but existing spec requires positional argument for invariant text
  5. Incomplete scopes — Data model has only global/plan; existing spec requires 4 scopes: global, project, plan, action
  6. UUID vs ULID — Data model and schema use UUID; existing spec uses ULIDs (str / VARCHAR(26))
  7. Missing --non-overridable flag — Documented in existing spec but absent from data model and CLI

Additionally (should fix): The 10ms performance SLA for invariant context building lacks enforcement details, runtime degradation behavior, memory bounds, and cache stampede handling.

All blocking items were previously flagged by the AUTO-SPEC review (2026-04-13T22:08:06Z) and the grooming comment (2026-04-13T22:37:56Z) and remain unresolved in the current commit.


Automated by CleverAgents Bot
Supervisor: PR Review Pool | Agent: pr-reviewer
Worker: [AUTO-REV-8658]

**Code Review Decision: REQUEST CHANGES** PR #8658 — Invariant Management System spec (v3.2.0) CI is fully green. Milestone and Type/Task label are correctly set. However, 7 blocking issues must be resolved: 1. **Missing `Closes #N`** — No issue-closing keyword in PR body (CONTRIBUTING.md requirement) 2. **CHANGELOG.md not updated** — Only `docs/specification.md` changed; CHANGELOG.md must be updated 3. **CONTRIBUTORS.md not updated** — Required by CONTRIBUTING.md 4. **CLI signature mismatch** — `invariant add` uses `--description` flag but existing spec requires positional argument for invariant text 5. **Incomplete scopes** — Data model has only `global`/`plan`; existing spec requires 4 scopes: global, project, plan, action 6. **UUID vs ULID** — Data model and schema use `UUID`; existing spec uses ULIDs (`str` / `VARCHAR(26)`) 7. **Missing `--non-overridable` flag** — Documented in existing spec but absent from data model and CLI Additionally (should fix): The 10ms performance SLA for invariant context building lacks enforcement details, runtime degradation behavior, memory bounds, and cache stampede handling. All blocking items were previously flagged by the AUTO-SPEC review (2026-04-13T22:08:06Z) and the grooming comment (2026-04-13T22:37:56Z) and remain unresolved in the current commit. --- **Automated by CleverAgents Bot** Supervisor: PR Review Pool | Agent: pr-reviewer Worker: [AUTO-REV-8658]
Author
Owner

[GROOMED] Grooming summary for PR #8658 (2026-04-14)

What was inspected

  • Reviewed AUTO-SPEC supervisor feedback (2026-04-13) and AUTO-REV review (2026-04-14) to confirm unresolved blockers.
  • Verified milestone assignment (v3.2.0) and noted the PR body still lacks a closing keyword.

Actions taken

  • Updated label set to required categories: State/In Review, Type/Documentation, Priority/High, MoSCoW/Must have; kept Needs Feedback for open questions.

Outstanding items for the author

  1. Add the required Closes #… or Fixes #… issue reference in the PR description.
  2. Append entries to CHANGELOG.md and CONTRIBUTORS.md per CONTRIBUTING.md.
  3. Align agents invariant add CLI signature with the existing spec (positional invariant text).
  4. Expand invariant scope handling to cover global, project, plan, and action scopes across the data model, schema, and CLI.
  5. Replace UUID usage with ULIDs (string IDs) in the models and schema.
  6. Restore the non_overridable flag/field in both CLI and data model.
  7. Elaborate on performance SLA enforcement (measurement approach, over-budget behavior, cache invalidation, memory bounds).

Please address the above before re-requesting review.


Automated by CleverAgents Bot
Supervisor: Grooming | Agent: grooming-pool-supervisor

[GROOMED] Grooming summary for PR #8658 (2026-04-14) ### What was inspected - Reviewed AUTO-SPEC supervisor feedback (2026-04-13) and AUTO-REV review (2026-04-14) to confirm unresolved blockers. - Verified milestone assignment (v3.2.0) and noted the PR body still lacks a closing keyword. ### Actions taken - Updated label set to required categories: State/In Review, Type/Documentation, Priority/High, MoSCoW/Must have; kept Needs Feedback for open questions. ### Outstanding items for the author 1. Add the required `Closes #…` or `Fixes #…` issue reference in the PR description. 2. Append entries to `CHANGELOG.md` and `CONTRIBUTORS.md` per CONTRIBUTING.md. 3. Align `agents invariant add` CLI signature with the existing spec (positional invariant text). 4. Expand invariant scope handling to cover global, project, plan, and action scopes across the data model, schema, and CLI. 5. Replace UUID usage with ULIDs (string IDs) in the models and schema. 6. Restore the `non_overridable` flag/field in both CLI and data model. 7. Elaborate on performance SLA enforcement (measurement approach, over-budget behavior, cache invalidation, memory bounds). Please address the above before re-requesting review. --- **Automated by CleverAgents Bot** Supervisor: Grooming | Agent: grooming-pool-supervisor ---
freemo closed this pull request 2026-04-15 15:46:17 +00:00
All checks were successful
CI / lint (pull_request) Successful in 47s
Required
Details
CI / typecheck (pull_request) Successful in 47s
Required
Details
CI / quality (pull_request) Successful in 39s
Required
Details
CI / security (pull_request) Successful in 1m25s
Required
Details
CI / push-validation (pull_request) Successful in 21s
CI / build (pull_request) Successful in 51s
Required
Details
CI / helm (pull_request) Successful in 35s
CI / integration_tests (pull_request) Successful in 4m34s
Required
Details
CI / e2e_tests (pull_request) Successful in 4m39s
CI / unit_tests (pull_request) Successful in 5m36s
Required
Details
CI / coverage (pull_request) Successful in 14m22s
Required
Details
CI / docker (pull_request) Successful in 12s
Required
Details
CI / status-check (pull_request) Successful in 2s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!8658
No description provided.