Skip to content

fix(procore): gate live write-back behind explicit flag - #26

Merged
mcxl merged 1 commit into
mainfrom
fix/procore-writeback-gate
Jun 17, 2026
Merged

fix(procore): gate live write-back behind explicit flag#26
mcxl merged 1 commit into
mainfrom
fix/procore-writeback-gate

Conversation

@mcxl

@mcxl mcxl commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

Resolves Codex review BLOCKER #1 — live Procore write-back was not actually gated.

  • Adds fail-safe PROCORE_LIVE_WRITEBACK_ENABLED gate, default false.
  • Prevents /v1 Procore webhook from posting comments to the unverified/deprecated write-back endpoint unless explicitly enabled.
  • Adds tests for unset, false, and true flag behavior.
  • Leaves endpoint/resource unchanged pending Procore confirmation.

Detail

The write-back at api/main.py (_process_procore_v1_webhook) previously posted a comment whenever is_live_configured() and retrieval_mode == "live_api" — with no flag — to the deprecated/unverified submittal_logs/.../comments path (core/procore/api_client.py:88). The documented default-off flag was never implemented. This adds the gate immediately before post_submittal_comment.

TestWriteBackGate drives the pipeline through the real live_api path (patched live creds + fetch + extract) and asserts retrieval_mode == "live_api" in the negative cases — proving it's the gate blocking the post, not absent live conditions:

  1. unset flag → no comment, comment_posted False
  2. false → no comment
  3. true + live conditions → comment posted, comment_posted True

Tests

pytest tests/test_procore_webhook.py → 74 passed. flake8 clean. No endpoint/resource change, no migrations applied.

🤖 Generated with Claude Code

Adds a fail-safe PROCORE_LIVE_WRITEBACK_ENABLED gate (default false) before
post_submittal_comment in the /v1 background pipeline. Even with live
credentials and a successful live_api retrieval, no Procore comment is posted
unless the flag is explicitly true. The write-back resource is UNVERIFIED
(deprecated submittal_logs path) pending Procore confirmation; the endpoint
and resource are left unchanged.

Tests: TestWriteBackGate proves unset -> no post, false -> no post, true +
live conditions -> post occurs (retrieval_mode=live_api asserted in the
negative cases so it is the gate, not absent live conditions, that blocks).

Resolves Codex review BLOCKER #1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mcxl
mcxl merged commit bacac45 into main Jun 17, 2026
1 check passed
@mcxl
mcxl deleted the fix/procore-writeback-gate branch June 17, 2026 21:53
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.

1 participant