feat(procore): write metadata-only audit records#29
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9eb7f6c13a
ℹ️ 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".
| hard_severities = {"hard_fail", "mandatory", "critical"} | ||
| return sum( | ||
| 1 | ||
| for item in amendments | ||
| if isinstance(item, dict) | ||
| and str(item.get("severity", "")).strip().lower() in hard_severities |
There was a problem hiding this comment.
Include high-severity amendments in hard-fail audits
When the prescreen emits a high-severity amendment, such as the HRCW declaration path that sets severity: "high" and forces escalation, this allow-list records hard_fail_count as 0 because it only counts hard_fail, mandatory, and critical. That under-reports the immutable audit record for the highest-severity reviews even though lower-severity mandatory amendments are counted.
Useful? React with 👍 / 👎.
| amendments = review_artifact.get("required_amendments", []) | ||
| if isinstance(amendments, list): | ||
| return len(amendments) |
There was a problem hiding this comment.
Count the full issue inventory in audit records
For reviews with more than five amendments, run_prescreen_review stores only the top visible items in required_amendments and keeps the rest in _all_amendments/suppressed_issue_count; using len(required_amendments) caps the persisted finding_count at the display limit, so complex submissions get an immutable Supabase audit row that understates the actual findings that drove the recommendation.
Useful? React with 👍 / 👎.
core/procore/audit.pyto build rows matching migration 008 without raw SWMS text, review prose, amendment reasons, comment bodies, or attachment content./v1/procore/webhookbackground processing to attemptrecord_procore_auditafter review/comment metadata is known.Tests:
python -m pytest tests/test_procore_audit.py tests/test_procore_webhook.py-> 79 passedflake8 api/main.py core/procore/audit.py tests/test_procore_audit.py-> cleanRemaining Procore-gated work: T7 OAuth/DMSA and final T8 write-back resource confirmation.