fix(snippets): read the stored provenance before writing the fresh stamp into the response
CI & Build / Python lint (push) Successful in 4s
CI & Build / Plugin hooks (push) Successful in 7s
CI & Build / TypeScript typecheck (push) Successful in 10s
CI & Build / integration (push) Successful in 16s
CI & Build / Python tests (push) Successful in 54s
CI & Build / Build & push image (push) Successful in 26s
CI & Build / Python lint (push) Successful in 4s
CI & Build / Plugin hooks (push) Successful in 7s
CI & Build / TypeScript typecheck (push) Successful in 10s
CI & Build / integration (push) Successful in 16s
CI & Build / Python tests (push) Successful in 54s
CI & Build / Build & push image (push) Successful in 26s
fields aliases data['snippet'], so stamping the response first made the staleness check compare the new stamp to itself — the background persist never fired. Caught by test_current_code_confirms_and_refreshes_provenance on run 3811, which exists for exactly this write. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1049,13 +1049,18 @@ async def attach_live_body(note, data: dict) -> None:
|
||||
data["body_source"] = "forge"
|
||||
data["body_freshness"] = "current"
|
||||
if fetched.commit_sha:
|
||||
# Read the stored stamp BEFORE writing the fresh one into the
|
||||
# response: `fields` aliases data["snippet"], so the other order
|
||||
# makes the staleness check compare the new stamp to itself and
|
||||
# the persist never fires (caught by the unit test, run 3811).
|
||||
stored_prov = fields.get("provenance") or {}
|
||||
stale = stored_prov.get("commit_sha") != fetched.commit_sha
|
||||
prov = compose_provenance(commit_sha=fetched.commit_sha)
|
||||
# Reflected in THIS response as well as persisted — the reader
|
||||
# shouldn't need a second pull to see the stamp they caused.
|
||||
if isinstance(data.get("snippet"), dict):
|
||||
data["snippet"]["provenance"] = prov
|
||||
stored_prov = fields.get("provenance") or {}
|
||||
if stored_prov.get("commit_sha") != fetched.commit_sha:
|
||||
if stale:
|
||||
spawn(
|
||||
_refresh_provenance(note, fetched.commit_sha),
|
||||
site="pull provenance-refresh",
|
||||
|
||||
Reference in New Issue
Block a user