Skip to content

refactor(grounding): three Claim models for one concept — merge, do not rename apart #18086

Open

Description

@mrveiss

Summary

Claim had five definitions. Two were unrelated concepts and are renamed apart in #18082 (WorkClaim for a held work scope, KeyClaim for an idempotency-key result). The remaining three are the same concept at three stages of enrichment — a real fork. Renaming those apart would entrench it, so they are deliberately left alone until they can be merged.

Parent: #12771.

The three

module fields importers
api/knowledge_grounding_models.py:137 claim_text, source, confidence, timestamp, metadata 2
services/knowledge_grounding_models.py:129 claim_text, claim_type, kb_status, confidence, sources, kb_fact, timestamp, metadata 4
services/grounded_agent_models.py:46 claim_id, claim_text, subject, predicate, object, confidence, context, timestamp 6

All three are "an assertion extracted from model output, to be checked against the knowledge base". All three carry claim_text, confidence and timestamp. They diverge in what they add:

  • the api one is the thinnest and records where the claim came from (source);
  • the services/knowledge_grounding_models one adds classification and KB verdict (claim_type, kb_status, sources, kb_fact);
  • the grounded_agent_models one adds an identity and an SPO decomposition (claim_id, subject/predicate/object).

They feed three pipelines that all ultimately do grounding: conflict_resolver, claim_verifier + claim_classifier, and grounded_agent + the knowledge_grounding API.

Why this is not a rename

The fork-detector's advice for a cluster is "merge the others into one", and for the other clusters in #18082 that advice was wrong — they were name collisions. Here it is right, which is exactly why this is split out: a mechanical rename would produce ApiClaim / ClassifiedClaim / AgentClaim and make three models of one concept permanent.

It is also not a mechanical change. It needs decisions that a rename does not:

  • metadata vs context — the same bag under two names.
  • Is source the same thing as sources? Singular provenance versus a list of matching KB facts are probably different fields, not one.
  • Is the SPO triple intrinsic or a later enrichment? If intrinsic, every producer must fill it; if not, it is optional and consumers must handle absence.
  • One model or a small pipeline of stages? A single union dataclass with a dozen optional fields is the failure mode this work is supposed to avoid.

Twelve import sites depend on specific field sets, so a wrong merge changes grounding and verification behaviour silently rather than failing loudly.

A second duplication sitting underneath it

There are two different modules both named knowledge_grounding_models.py — one in api/, one in services/ — each defining its own Claim. The duplication is at module level, not just symbol level, and the fork detector cannot see that at all because it keys on symbol names. Worth checking whether the whole pair should be one module before merging the dataclasses inside them.

Acceptance criteria

  • One Claim for the extracted-claim concept, with a recorded decision for each field question above
  • Claim removed from repo_tests/symbol_fork_baseline.json
  • All 12 import sites migrated, with no optional field added merely to keep a caller compiling
  • A recorded decision on whether api/knowledge_grounding_models.py and services/knowledge_grounding_models.py should remain two modules
  • Grounding and verification behaviour pinned by tests before the merge, so the merge is checkable rather than assumed

Activity

  1. github-actions commented on Oct 7, 2026

    @github-actions
    Contributor

    👋 Auto-triage could not confidently classify this issue (no confident signal). Could a maintainer add the appropriate labels (frontend, backend, infrastructure, docs, testing and good-first-issue, intermediate, advanced)?

  2. mrveiss commented on Oct 7, 2026

    @mrveiss
    OwnerAuthor

    Correction: the "two modules with the same name" claim in this issue is wrong

    The issue body says:

    There are two different modules both named knowledge_grounding_models.py — one in api/, one in services/ — each defining its own Claim. The duplication is at module level, not just symbol level.

    The second sentence is wrong, and I wrote it from the filenames without comparing the contents. Measured:

    api/knowledge_grounding_models.py       341 lines
    services/knowledge_grounding_models.py  218 lines
    diff | wc -l                            510
    

    Their top-level symbols barely overlap:

    api/ services/
    GroundingSourceType, ConflictResolution, ReviewTicketStatus, ReviewTicketPriority, KBFact, Claim, ResearchResult, ResolvedClaim, Conflict, ReviewTicket ClaimType, KBStatus, VerificationMethod, KBSource, Claim, ClaimExtractionResult

    Claim is the only name in both. So this is two different modules that happen to share a filename, not a duplicated module. The module-level duplication claim should be struck; the acceptance criterion "a recorded decision on whether the two modules should remain two modules" is still worth keeping, but as a naming/clarity question, not a deduplication one.

    The Claim finding itself stands unchanged and is still the point of this issue: three definitions of one concept across api/knowledge_grounding_models, services/knowledge_grounding_models and services/grounded_agent_models, sharing claim_text/confidence/timestamp across 12 import sites, differing only in what they add. That was measured field by field, not inferred.

    Why I am flagging my own error rather than quietly editing

    Two other same-filename pairs came up in the same sweep and only one is a real duplicate, which is exactly why the filename is not evidence:

    One of three same-named pairs was a duplicate. Reading duplication off a filename would have been wrong twice out of three times.

  3. mrveiss commented on Oct 10, 2026

    @mrveiss
    OwnerAuthor

    Module-naming decision (2026-10-10), from the merge evidence: the two knowledge_grounding_models.py modules stay two modules. After Claim, VerifiedClaim, Conflict and ConflictResolution were merged onto one canonical definition each (branch issue-18086-claim-models), they hold different content:

    • api/knowledge_grounding_models.py holds the conflict-resolver and review-queue domain: GroundingSourceType, ConflictResolution, ReviewTicket*, KBFact, ResearchedFact, ResolvedClaim, Conflict.
    • services/knowledge_grounding_models.py holds claim classification and verification: ClaimType, KBStatus, VerificationMethod, KBSource, Claim, ClaimStatus, VerificationStatus, VerifiedClaim, ClaimExtractionResult.

    They are not one module under two paths, so no module merge applies. Still open in this area: the vocabularies overlap (pending_review/human_review and inconclusive/unresolved in ConflictResolution; ClaimStatus vs VerificationStatus). Collapsing them changes wire values, so it needs its own decision. services/agents/subagent_task.py's ConflictResolution dataclass is a different concept (consensus between subagent outputs).

  4. added
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Nov 3, 2026
  5. github-actions commented on Nov 3, 2026

    @github-actions
    Contributor

    needs-structure: this issue is missing:

    • a phase:M4.<k> label matching milestone M4 - Deforking and deduplication: found none

    The label clears on the next issue event once all three are present (#19522).

  6. mrveiss commented on Nov 6, 2026

    @mrveiss
    OwnerAuthor

    Local branch issue-18086-claim-models (not on GitHub), inspected 2026-11-06

    Verdict: LANDED (triage said REAL-UNIQUE)

    Intent: Merge the three Claim models into one; one Conflict, ConflictResolution and VerifiedClaim.

    Result: Corrected from REAL-UNIQUE. Both commits are on main (7d59711, c8ca9bd); ReviewTicketPriority follow-up landed too (2524769). Pending hunks are claim_verifier type placement main restructured (claim_verifier_types.py); do NOT revive.

    Commits not on main (2 non-merge, 0 merge):

    Pending hunks (added lines not on main): 9 hunks in 7 files; largest:

    • repo_tests/_reach_policy.py:ALLOWANCE_VERDICTS: dict[str, tuple[str, str, str]] = { (3 lines) — "one-claim-model-scan": (
    • repo_tests/one_claim_model_18086_test.py:(top level) (3 lines) — for n in ast.walk(ast.parse(source)):
    • autobot-backend/services/claim_verifier.py:class ClaimVerifier: (2 lines) — async def _verify_unknown_claim(self, claim: Claim) -> VerifiedClaim:
    • autobot-backend/tests/services/test_claim_verifier.py:class TestBatchVerification: (2 lines) — assert results[0].claim.claim_text == "IN KB claim"
    • autobot-backend/services/claim_verifier.py:class ClaimVerifier: (1 lines) — verified = await self._verify_unknown_claim(claim)
    • autobot-backend/services/knowledge_grounding_models_test.py:def test_the_deliberate_prose_file_still_carries_the_literal (1 lines) — by_id = Conflict(claim_1_id="c1", description="d", severity="high")
    • autobot-backend/tests/services/test_claim_verifier.py:class TestBatchVerification: (1 lines) — assert result.claim.claim_text == f"Claim {i}"
    • repo_tests/python_file_size_ratchet_baseline.py:RATCHET_BASELINE: dict[str, int] = { (1 lines) — "autobot-backend/services/claim_verifier.py": 792,
    • scripts/python_file_size_known_large.py:KNOWN_LARGE: dict[str, int] = { (1 lines) — "autobot-backend/services/claim_verifier.py": 792,

    Milestone change: this issue had no M1-M4 milestone; set to M4 - Deforking and deduplication (code area: grounding models dedup).

  7. mrveiss commented on Nov 20, 2026

    @mrveiss
    OwnerAuthor

    Branch issue-18086-claim-models (PR #21822, head not recorded in the audit log) was deleted as a zero-change branch. None of the five ACs is ticked; I did not verify the single Claim, the baseline entry, the 12 import sites or the pinning tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-structureMissing goal milestone, matching phase label or native parent (#19522)tech-debt

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions