Skip to content

fix(audit): bump SCHEMA_VERSION to 2 for scorer-stamped records (#315) - #324

Merged
Birfy merged 3 commits into
mainfrom
fix/issue-315-audit-schema-version
Oct 16, 2026
Merged

Birfy merged 3 commits into
mainfrom
fix/issue-315-audit-schema-version

Conversation

@Birfy

@Birfy Birfy commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Closes #315

Problem

#312 added optional AuditRecord.scorer_version while leaving SCHEMA_VERSION at 1. An older v0.6.0 reader accepts schema version 1 but has no scorer_version constructor parameter; from_dict forwards the new field → TypeError → AuditStore counts the line corrupt and silently skips pending work.

Fix

Tests

  • tests/test_audit_store_durability.py: unstamped/stamped v2 round-trips, v1 migration (pending/resolved/buggy stamp), mixed v1+v2 load without rewriting bytes, simulated old-reader contract.
  • Broader local smoke: durability, sparse, attach, cheap-layer, verifier_boost, diagnose_script — green.

Changelog

changelog.d/315-audit-schema-version.md

Records with the post-#312 scorer_version shape now persist
schema_version=2 so older v1-only readers hit their explicit
unsupported-version raise instead of TypeError→corrupt-skip on
pending work. New reader migrates v1 lines (including the mistaken
early stamp under schema_version=1). Scorer-identity behaviour from
#304/#312 is unchanged.
@Birfy
Birfy enabled auto-merge (squash) October 16, 2026 16:23
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T16:26:16.697735Z e17070e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (posted as COMMENT; self-approve is blocked on own PRs).

Summary

Closes #315: SCHEMA_VERSION → 2 for the scorer-stamped audit shape; new reader migrates v1 (including the mistaken early stamp); old v1-only readers hit explicit unsupported-version rejection instead of TypeError→corrupt-skip on pending work. #304/#312 scorer-identity behaviour preserved.

Verification

  • Local: test_audit_store_durability, sparse, attach, cheap-layer, test_verifier_boost, diagnose_script — green.
  • Changelog fragment present; squash auto-merge enabled.

No blocking changes. CI matrix still pending at review time.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e17070e9f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agentdescent/audit/records.py Outdated
d = dict(d)
version = d.get("schema_version")
if version != SCHEMA_VERSION:
if version not in _SUPPORTED_SCHEMA_VERSIONS:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep malformed v1 records inside the corrupt-line path

When an existing v1 line contains valid JSON but cannot construct an AuditRecord (for example, it is missing purpose or has an invalid inclusion probability), accepting v1 here makes AuditStore._load_line call from_dict in its preflight outside the guarded construction block. The resulting KeyError/TypeError/ValueError aborts opening the entire store instead of counting and skipping that one corrupt line as documented; distinguish supported versions before construction or move migration construction under the existing exception handler.

Useful? React with 👍 / 👎.

Comment thread agentdescent/audit/records.py Outdated
Comment on lines +178 to +179
known = set(cls.__dataclass_fields__)
return cls(**{k: v for k, v in d.items() if k in known})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject unknown fields instead of silently defaulting them

Filtering to dataclass fields silently accepts malformed v1 and v2 records with unknown keys. For example, a persisted record that misspells optional stratum as strtaum is now loaded under the default "all" stratum, changing the resulting audit statistics; previously the unexpected keyword caused the line to be counted as corrupt. Since scorer_version is already a known dataclass field, migration does not require dropping every other unknown key.

Useful? React with 👍 / 👎.

Birfy added 2 commits October 17, 2026 04:13
…ields (#315)

Addresses Codex review on #324:
- P1: AuditStore._load_line preflight now only raises on versions outside
  SUPPORTED_SCHEMA_VERSIONS, so a malformed v1 line goes through the guarded
  construction and is counted corrupt instead of aborting the whole store.
- P2: AuditRecord.from_dict no longer filters unknown keys; a misspelt field
  (e.g. strtaum) raises TypeError and is counted corrupt rather than loading
  under default values.
Also regenerates docs/api.md (SCHEMA_VERSION=2), which failed the test matrix.

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed 3e7f6ad addressing both Codex findings and the red test matrix:

  • P1 (malformed v1 aborts the store): AuditStore._load_line now only takes the raising preflight for versions outside SUPPORTED_SCHEMA_VERSIONS; v1 and v2 both go through the guarded construction, so a v1 line missing purpose/task_id/verifier_score or with inclusion_prob=0 is one corrupt line, not an unopenable store.
  • P2 (unknown keys silently defaulted): AuditRecord.from_dict no longer filters to dataclass fields; a misspelt strtaum raises TypeError and is counted corrupt instead of landing in stratum all.
  • CI: all five test (3.x) jobs failed only on test_api_reference (docs/api.md still showed schema_version: int = 1); regenerated. Also merged current main.

New tests: malformed-v1 (3 params), invalid inclusion prob under v1, unknown field under v1 and v2, and unknown schema_version=3 still raises. The 6 corrupt-path tests fail without the fix; tests/test_audit_store_durability.py passes in full. Changelog fragment updated. LGTM once the matrix is green.

@Birfy
Birfy merged commit 0702791 into main Oct 16, 2026
7 checks passed
@Birfy
Birfy deleted the fix/issue-315-audit-schema-version branch October 16, 2026 20:46
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.

audit: version scorer-stamped records so older readers do not silently skip pending work

1 participant