Repository navigation
fix: wire schema staleness check into audit workflow (#800) - #904
Conversation
Add check_schema_staleness that verifies x-polylogue-generated-at timestamp is present, parseable, and within 90 days. Wired into audit_provider workflow alongside existing checks. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79c614ecaa
ℹ️ 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".
| gen_time = datetime.fromisoformat(generated_at.replace("Z", "+00:00")) | ||
| age_days = (datetime.now(UTC) - gen_time).days | ||
| except ValueError: |
There was a problem hiding this comment.
Guard naive generated-at timestamps before age arithmetic
If x-polylogue-generated-at is a valid ISO string without timezone info (for example 2026-03-16T12:23:13), datetime.fromisoformat(...) returns a naive datetime, and subtracting it from datetime.now(UTC) raises TypeError. Because only ValueError is handled here, check_schema_staleness can raise and abort the audit workflow instead of returning a warning for malformed/ambiguous timestamps.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Wires a new schema “staleness” audit check into the schema audit workflow so provider audits can warn when committed schemas are old or missing a generated-at timestamp.
Changes:
- Adds
check_schema_staleness()audit check based onx-polylogue-generated-at. - Runs the staleness check as part of
audit_provider().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| polylogue/schemas/audit/workflow.py | Adds the staleness check into the per-provider audit sequence. |
| polylogue/schemas/audit/checks.py | Implements check_schema_staleness() and updates module exports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "check_annotation_coverage", | ||
| "check_cross_provider_consistency", | ||
| "check_privacy_guards", | ||
| "check_schema_drift", |
| def check_schema_staleness(schema: Mapping[str, object] | SchemaNode) -> CheckResult: | ||
| """Check whether the committed schema is stale via its generated-at timestamp.""" | ||
| from datetime import UTC, datetime | ||
|
|
||
| root = json_document(schema) | ||
| generated_at = root.get("x-polylogue-generated-at") | ||
| if not generated_at or not isinstance(generated_at, str): | ||
| return CheckResult( | ||
| name="schema_staleness", | ||
| status=OutcomeStatus.WARNING, | ||
| summary="Schema has no x-polylogue-generated-at timestamp", | ||
| ) | ||
| try: | ||
| gen_time = datetime.fromisoformat(generated_at.replace("Z", "+00:00")) | ||
| age_days = (datetime.now(UTC) - gen_time).days | ||
| except ValueError: | ||
| return CheckResult( |
Closes the remaining schema-audit gap from #800. PR #921 landed the structural-role exemption and `detect_drift()` wiring; the staleness check still had no audit-side caller. - `polylogue/schemas/audit/checks.py`: adds `check_schema_staleness()` reading the committed package manifest dates against the live archive observations. - `polylogue/schemas/audit/workflow.py`: `audit_provider()` invokes the new check inline so `devtools schema-audit` surfaces stale schemas as part of its normal report. Refs #800
Closes the remaining schema-audit gap from #800. PR #921 landed the structural-role exemption and `detect_drift()` wiring; the staleness check still had no audit-side caller. - `polylogue/schemas/audit/checks.py`: adds `check_schema_staleness()` reading the committed package manifest dates against the live archive observations. - `polylogue/schemas/audit/workflow.py`: `audit_provider()` invokes the new check inline so `devtools schema-audit` surfaces stale schemas as part of its normal report. Refs #800
Add check_schema_staleness wired into audit_provider. 2 files +38.