fix(procore): gate live write-back behind explicit flag - #26
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves Codex review BLOCKER #1 — live Procore write-back was not actually gated.
PROCORE_LIVE_WRITEBACK_ENABLEDgate, default false./v1Procore webhook from posting comments to the unverified/deprecated write-back endpoint unless explicitly enabled.Detail
The write-back at
api/main.py(_process_procore_v1_webhook) previously posted a comment wheneveris_live_configured() and retrieval_mode == "live_api"— with no flag — to the deprecated/unverifiedsubmittal_logs/.../commentspath (core/procore/api_client.py:88). The documented default-off flag was never implemented. This adds the gate immediately beforepost_submittal_comment.TestWriteBackGatedrives the pipeline through the reallive_apipath (patched live creds + fetch + extract) and assertsretrieval_mode == "live_api"in the negative cases — proving it's the gate blocking the post, not absent live conditions:comment_posted Falsefalse→ no commenttrue+ live conditions → comment posted,comment_posted TrueTests
pytest tests/test_procore_webhook.py→ 74 passed. flake8 clean. No endpoint/resource change, no migrations applied.🤖 Generated with Claude Code