Skip to content

fix(spec-driven): report, not enforce, a minimum on records that need one or more owners - #879

Draft
ArmenSl wants to merge 1 commit into
developmentfrom
fix/agent-circular-minimum
Draft

ArmenSl wants to merge 1 commit into
developmentfrom
fix/agent-circular-minimum

Conversation

@ArmenSl

@ArmenSl ArmenSl commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Why

For a rule like context Library inv books_at_least_1: self.books->size() >= 1, the Spec-Driven Agent decides whether to seed an "Enforce ... HTTP 400" task or a "Report ... never refuse creating" task. deferred_collection_minimum chose "report" only when each Book needs exactly one Library (1). When each Book needs one or more (1..*), it seeded the 400 task.

That makes the app unusable:

  • The generated create only links Books that already exist.
  • No Book can exist before a Library, so the first Library has nothing to link and is refused.
  • So neither class can ever get a record.

This was reproduced live in a generated backend during the review of #877: POST /library/ and POST /book/ were both refused.

What

  • besser/spec_driven_agent/planning/model_rules.py: the gate is now "the opposite end is mandatory" (min >= 1) whatever its upper bound. The docstring is updated to match.
  • besser/spec_driven_agent/pipeline/orchestrator.py: the report task said "Each Book belongs to one Library", which is wrong for 1..*. It now says "Each Book needs a Library first".
  • Nested creations: not considered. The FastAPI and web-app scaffolds the agent uses generate with nested_creations=False, so a create never makes new related records.

Tests

  • tests/spec_driven_agent/test_ocl_rule_seed.py:
    • New test_a_minimum_on_records_that_need_one_or_more_owners_is_not_a_refusal. It fails before the fix and passes after.
    • The (book_needs_library=True, books_in_one_library=False) case is removed from test_every_other_collection_rule_is_still_enforced, because it asserted the deadlocking 400.
  • Local runs:
    • tests/spec_driven_agent: 7208 passed. 2 failed, the same 2 that fail on unchanged development on this machine (ruff not on the test venv's PATH).
    • ruff check besser/ passes.

Overlap with #877

#877 edits the same test file: it adds a generator_used argument and a commit-check test with the same model. Whichever merges second needs a small rebase of that file.

… one or more owners

deferred_collection_minimum only deferred a minimum such as
self.books->size() >= 1 when each Book needs exactly one Library. When
each Book needs one or more (1..*), the agent seeded an "Enforce ... HTTP
400" task. The generated create only links records that already exist, so
the first Library has no Book to link and no Book can exist before a
Library: enforced, neither class can ever get a record. Found in a
generated backend during the review of #877.

The gate is now a mandatory opposite end whatever its upper bound, and the
report task no longer says each Book belongs to one Library.
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.

1 participant