Add stable machine-parseable receipt schema to top-level CLI (publish / fetch-metrics)#7
Open
AlyciaBHZ wants to merge 2 commits into
Open
Add stable machine-parseable receipt schema to top-level CLI (publish / fetch-metrics)#7AlyciaBHZ wants to merge 2 commits into
AlyciaBHZ wants to merge 2 commits into
Conversation
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.
Why
broadcast-kit is increasingly consumed as the egress executor behind other systems (the FKST
redditpackage already shells out to it; more FKST marketing packages — social-metrics, douyin/xhs publishers — will follow). Today those consumers must scrape inconsistent JSON: URL fields differ per platform (post_url/note_url/video_url),statusvalues vary (success/ok/failed), and per-publisher CLIs print human text. Every consumer ends up writing brittle parsing.This PR gives the top-level
broadcast-kit publishandbroadcast-kit fetch-metricsa stable, versioned receipt contract so any caller can depend on fixed field names/types instead of reverse-engineering output.What
broadcast_kit/receipts.pynormalizes only the top-level command result just before print.broadcast.publish.receipt.v0— always-present:platform,status(ok|dry_run|blocked|error),account_label,dry_run,post_uri(unified from post_url/note_url/video_url/url),evidence_path,reason.broadcast.metrics.fetch_receipt.v0— always-present:platform,status(ok|dry_run|stub|error),account_label,dry_run,metrics_path(incl. legacysource.raw_pathfallback),records,preview,reason.raw_statuswhen remapped; forfetch-metrics --platform allthe nestedrecordsitems are left untouched (top-level-only normalization).status: "stub"(no faked collector).error(safe default for a contract).contracts/receipts.md— including the rule that automation should parse only the top-levelpublish/fetch-metricsJSON, never the per-publisher CLIs (which are non-contract).tests/test_cli_receipts.py— 28 tests pass, covering key presence,recordspreservation for--platform all,raw_statusretention, URL/evidence normalization, and thesource.raw_pathfallback.Non-goals
No changes to publisher/collector behavior, per-publisher CLIs, or any live-publish path. Purely additive output normalization.
🤖 Generated with Claude Code