Skip to content

[Bug]: IntegerSequenceRequest has no per-item digit bound #866

Description

@morluto

Summary

IntegerSequenceRequest.values is bounded to max_length=256 items, but CanonicalInteger has only a pattern constraint with no digit-count limit. Every sequence operation calls parse_canonical_integer on each value, so previously guarded oversized operands are now reachable by every sequence operation without a domain-level bound.

Evidence

src/jacobian/contracts/sequences.py L13-19:

class IntegerSequenceRequest(ContractModel):
    """One nonempty finite sequence of canonical integers."""

    values: tuple[CanonicalInteger, ...] = Field(
        min_length=1,
        max_length=_MAX_SEQUENCE_LENGTH,
    )

CanonicalInteger (src/jacobian/contracts/exact.py L13-18) has only pattern=r"^(?:0|-?[1-9][0-9]*)$" with no digit-count limit. Other domain contracts (e.g., CanonicalRational at exact.py L78-81) enforce MAX_CANONICAL_RATIONAL_DIGITS, but IntegerSequenceRequest has no equivalent.

Root cause

The sequence contract bounds item count but not item magnitude.

Scope

Add a max_digits field-level validator to IntegerSequenceRequest.values or a cross-field model_validator that rejects items exceeding a domain-defined digit bound.

Source

Generated with Devin

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1: highShould be addressed in the current or next iterationarea: kernelCore verification kernel and trust boundariesbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions