Skip to content

fix(validator): reject structurally invalid PAT stores - #1658

Open
taooutsider wants to merge 1 commit into
entrius:testfrom
taooutsider:codex/sn74-pat-store-schema-public
Open

fix(validator): reject structurally invalid PAT stores#1658
taooutsider wants to merge 1 commit into
entrius:testfrom
taooutsider:codex/sn74-pat-store-schema-public

Conversation

@taooutsider

Copy link
Copy Markdown

Summary

  • Validate that miner_pats.json decodes to the declared list[dict] contract.
  • Keep load_all_pats() tolerant for scoring snapshots while making writes fail closed.
  • Make PAT broadcast/check handlers report an unavailable store instead of surfacing raw type errors.
  • Add regression coverage for invalid JSON roots and non-object list entries.

Problem

The PAT store already handled malformed JSON and I/O errors, but syntactically valid JSON with the wrong structure was accepted. Values such as null, {}, or ["not an entry"] caused load_all_pats() to return the wrong type and could raise TypeError or AttributeError in scoring and write paths.

The fix introduces a specific PatStoreFormatError, preserves the tolerant read-only scoring behavior, and prevents invalid stores from being overwritten.

This is separate from #1481 / #1486, which addressed malformed or unreadable store data rather than valid JSON with an invalid schema.

Related Issues

No new issue. Public issue creation is currently restricted for this repository.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  • Tests added/updated
  • Manually tested

Validation completed:

  • 55 passed in focused PAT storage/handler tests
  • 971 passed in the full test suite
  • Ruff lint and format passed
  • Pyright passed with zero errors
  • Vulture passed
  • Pre-commit and pre-push hooks passed
  • git diff --check passed

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented where applicable

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant