File size: 15,178 Bytes
f74bce1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74ee21a
f74bce1
 
 
 
 
0bf36ea
f74bce1
0bf36ea
 
 
f74bce1
 
 
74ee21a
f74bce1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74ee21a
 
 
 
f74bce1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74ee21a
f74bce1
 
74ee21a
f74bce1
 
 
 
 
 
 
 
 
 
 
347a4d6
f74bce1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74ee21a
 
f74bce1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74ee21a
 
 
 
 
f74bce1
 
74ee21a
 
 
f74bce1
 
74ee21a
 
 
 
 
f74bce1
 
 
 
 
 
 
 
 
 
 
74ee21a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f74bce1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74ee21a
f74bce1
 
 
74ee21a
 
 
f74bce1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#!/usr/bin/env python3
"""Build copy-ready Devpost submission packets from the current safe draft."""

from __future__ import annotations

import argparse
import json
from pathlib import Path
from typing import Any


ROOT = Path(__file__).resolve().parents[1]
DEFAULT_JSON = ROOT / "docs" / "assets" / "devpost-submission-packet.json"
DEFAULT_MD = ROOT / "docs" / "assets" / "devpost-submission-packet.md"
DEFAULT_TASKS = ROOT / "tasks.json"
DEFAULT_FINAL_EVIDENCE = ROOT / "docs" / "assets" / "final-live-proof-evidence.json"


BASE_PACKET = {
    "schema": "proofframe.devpost_packet.v1",
    "project_name": "ProofFrame",
    "tagline": "B2-ready provenance desk for GenAI media.",
    "one_liner": (
        "ProofFrame turns generated media into approved evidence packets with B2-ready "
        "manifests, Genblaze-gated provider metadata, checksums, review status, and an "
        "exportable proof bundle."
    ),
    "repository_url": "https://github.com/adjcjh777/backblaze-proofframe",
    "demo_url": "https://adjcjh-backblaze-proofframe.hf.space/?judge=1",
    "video_url": "TBD after final public video upload.",
    "inspiration": (
        "Generated media is easy to make and hard to govern. Teams often lose the prompt, "
        "model, provider, approval status, and durable storage evidence for the files that "
        "eventually ship. ProofFrame treats provenance as the product, not a footer."
    ),
    "what_it_does": [
        "Create a campaign brief.",
        "Generate candidate media assets.",
        "Review, approve, or reject assets.",
        "Search and filter evidence by prompt, model, storage key, checksum, and status.",
        "Track decision coverage across approved, draft, and rejected assets.",
        "Inspect prompt, provider, model, storage backend, storage key, checksum, and risk note.",
        "Copy a safe evidence summary without credentials, cookies, signed URLs, or raw secrets.",
        "Export a manifest.",
        "Download an evidence ZIP containing the manifest, README, and available media.",
        "Use Judge Demo to create a complete local packet instantly.",
    ],
    "how_we_built_it": (
        "ProofFrame uses FastAPI for the API, a single-file browser UI for the proof ledger, "
        "local storage for credential-free demos, a Backblaze B2-compatible S3 storage "
        "backend, and Genblaze provider adapters for GMICloud, OpenAI, and a credential-free "
        "local Pipeline provider built around the official Genblaze Pipeline API. The public "
        "mock demo is deployed as a Hugging Face Space for judge-friendly product inspection "
        "while final reports separate live proof, video, audit, and Devpost receipt gates."
    ),
    "challenges": (
        "The biggest challenge is avoiding shallow sponsor integration. ProofFrame has to "
        "make storage and provenance central: B2 should be the durable evidence layer, and "
        "Genblaze should be the generation orchestration path. Another challenge is public "
        "claim hygiene, so the repo separates local demo behavior from final live sponsor proof."
    ),
    "what_we_learned": (
        "The useful unit for generated media teams is not a single image. It is a packet: "
        "asset, prompt, provider, model, storage object, checksum, approval state, and risk note."
    ),
    "accomplishments": [
        "Built a working local product, not just a pitch.",
        "Deployed a credential-free public mock demo.",
        "Added a one-click Judge Demo path.",
        "Added a review console with evidence search, status filtering, decision coverage, and safe summary copy.",
        "Added downloadable evidence ZIPs.",
        "Added B2-compatible storage and Genblaze provider code paths for GMICloud, OpenAI, and a credential-free local Pipeline provider.",
        "Added CI that runs readiness checks, lint, tests, API smoke, and secret scan.",
        "Added fail-closed gates for evidence JSON exports and final submission audits.",
        "Kept public claims gated by reports, task status, and secret-scan artifacts.",
    ],
    "whats_next": [
        "Live B2 proof with a dedicated bucket and least-privilege key.",
        "Live Genblaze proof with provider/model/run metadata.",
        "Demo video under the event limit.",
        "Final Devpost submission.",
    ],
    "current_providers_and_models": [
        {"provider": "mock", "model": "mock-svg-v1", "status": "current public mock demo"},
    ],
    "final_provider_and_model": {
        "provider": "genblaze/<verified-provider>-image",
        "model": "GENBLAZE_IMAGE_MODEL value used for the verified run",
        "status": "final gate after T021",
    },
}


SAFE_BEFORE_LIVE = {
    "mode": "pre_live_safe",
    "short_description": (
        "ProofFrame is a review desk for generated media. The local demo creates a campaign, "
        "generates mock variants, approves or rejects assets, exports a manifest, and downloads "
        "an evidence ZIP with prompts, provider/model fields, storage references, hashes, and "
        "approval status. The final hackathon submission gate is to verify the same flow with "
        "Genblaze-backed generation and Backblaze B2-backed storage."
    ),
    "b2_usage": (
        "ProofFrame treats Backblaze B2 as the final durable evidence layer, not as a late "
        "file-upload checkbox. The public demo currently runs in local/mock mode, but every "
        "asset packet already carries the B2-ready object model: storage backend, storage key, "
        "checksum, byte size, prompt, provider/model metadata, approval state, and risk note. "
        "The repo includes a dedicated B2 S3-compatible storage adapter, a recorded private B2 "
        "bucket setup, and a one-command B2 proof runner that will upload one generated asset "
        "and one manifest with environment-only credentials. That live upload remains the final "
        "submission gate before any public claim is upgraded to completed B2 storage."
    ),
    "genblaze_usage": (
        "ProofFrame includes Genblaze provider adapters for GMICloud, OpenAI, and a credential-free "
        "local Pipeline provider built around the official Genblaze Pipeline API. In the public mock demo, deterministic generation keeps the "
        "workflow inspectable without secrets; the same manifest fields are reserved for the "
        "final provider, model, request/run metadata, prompt, and asset checksum. The final "
        "submission gate is a live Genblaze-compatible run that proves the provider path and "
        "then carries the resulting asset into the ProofFrame review and storage packet."
    ),
    "claim_warning": "Safe for public mock demo only. Do not submit as final sponsor proof.",
}


SAFE_AFTER_LIVE = {
    "mode": "post_live_verified",
    "short_description": (
        "ProofFrame turns Genblaze-generated media into Backblaze B2-backed evidence packets. "
        "Each packet includes prompt history, provider/model metadata, B2 storage references, "
        "checksums, approval state, and a downloadable manifest bundle so teams can trust, reuse, "
        "or retire generated media."
    ),
    "b2_usage": (
        "ProofFrame stores generated media and exported manifests in Backblaze B2 using "
        "environment-only credentials. The final proof evidence records sanitized B2 storage keys, "
        "byte sizes, and checksums without exposing credentials or signed URLs. B2 is the durable "
        "evidence layer: the media asset and manifest are separate objects under the ProofFrame "
        "campaign prefix, and the app uses those hashes to make later review, export, and audit "
        "steps reproducible."
    ),
    "genblaze_usage": (
        "ProofFrame generates media through Genblaze's official Pipeline. The final proof uses "
        "the credential-free local image provider, records provider/model metadata, and carries "
        "the resulting asset through Genblaze's B2 sink into the ProofFrame storage and approval manifest."
    ),
    "claim_warning": "Use only after T020 and T021 are verified by live proof evidence.",
    "whats_next": [
        "Upload the final demo video under the event limit.",
        "Run the final secret scan and submission audit after video artifacts are ready.",
        "Submit the Devpost project and preserve the receipt URL.",
    ],
}


def load_task_statuses(tasks_path: Path = DEFAULT_TASKS) -> dict[str, str]:
    try:
        tasks = json.loads(tasks_path.read_text(encoding="utf-8"))["tasks"]
    except (FileNotFoundError, KeyError, json.JSONDecodeError):
        return {}
    return {str(task.get("id", "")).upper(): str(task.get("status", "missing")) for task in tasks}


def load_json(path: Path) -> dict[str, Any]:
    try:
        data = json.loads(path.read_text(encoding="utf-8"))
    except (FileNotFoundError, json.JSONDecodeError):
        return {}
    return data if isinstance(data, dict) else {}


def apply_final_evidence(packet: dict[str, Any], evidence_path: Path) -> None:
    evidence = load_json(evidence_path)
    if evidence.get("ok") is not True:
        return
    provider = str(evidence.get("asset_provider") or "").strip()
    model = str(evidence.get("asset_model") or "").strip()
    if not (provider and model):
        return
    packet["final_provider_and_model"] = {
        "provider": provider,
        "model": model,
        "status": "verified by docs/assets/final-live-proof-evidence.json",
    }
    packet["current_providers_and_models"] = [
        {"provider": "mock", "model": "mock-svg-v1", "status": "current public mock demo"},
        {"provider": provider, "model": model, "status": "final B2-backed Genblaze proof"},
    ]


def checklist_item(
    task_statuses: dict[str, str], task: str, label: str, *, required_for_final: bool = True
) -> dict[str, Any]:
    task = task.upper()
    return {
        "task": task,
        "label": label,
        "status": task_statuses.get(task, "missing"),
        "required_for_final": required_for_final,
    }


def usable_video_url(value: str) -> bool:
    text = value.strip()
    return text.startswith(("https://", "http://")) and not text.lower().startswith("tbd")


def build_packet(
    *,
    live: bool = False,
    tasks_path: Path = DEFAULT_TASKS,
    video_url: str | None = None,
    final_evidence_path: Path = DEFAULT_FINAL_EVIDENCE,
) -> dict[str, Any]:
    packet = dict(BASE_PACKET)
    packet.update(SAFE_AFTER_LIVE if live else SAFE_BEFORE_LIVE)
    if live:
        packet["video_url"] = "TBD after final public video upload."
        apply_final_evidence(packet, final_evidence_path)
    if video_url is not None:
        if not usable_video_url(video_url):
            raise ValueError("video_url must be an http(s) URL, not a placeholder.")
        packet["video_url"] = video_url.strip()
    task_statuses = load_task_statuses(tasks_path)
    packet["submission_checklist"] = [
        checklist_item(task_statuses, "T020", "B2 live proof complete"),
        checklist_item(task_statuses, "T021", "Genblaze live proof complete"),
        checklist_item(task_statuses, "T040", "Devpost registration complete"),
        checklist_item(task_statuses, "T041", "Final submission audit complete"),
        checklist_item(task_statuses, "T041A", "Final secret scan complete"),
        checklist_item(task_statuses, "T042", "Devpost project submitted"),
    ]
    return packet


def markdown_section(title: str, body: str | list[str]) -> str:
    if isinstance(body, list):
        content = "\n".join(f"- {item}" for item in body)
    else:
        content = body
    return f"## {title}\n\n{content}\n"


def render_markdown(packet: dict[str, Any]) -> str:
    lines = [
        "# Devpost Submission Packet",
        "",
        f"Mode: `{packet['mode']}`",
        f"Claim warning: {packet['claim_warning']}",
        "",
        markdown_section("Project Name", packet["project_name"]),
        markdown_section("Tagline", packet["tagline"]),
        markdown_section("One-Liner", packet["one_liner"]),
        markdown_section("Repository", packet["repository_url"]),
        markdown_section("Demo URL", packet["demo_url"]),
        markdown_section("Demo Video URL", packet["video_url"]),
        markdown_section("Short Description", packet["short_description"]),
        markdown_section("Inspiration", packet["inspiration"]),
        markdown_section("What It Does", packet["what_it_does"]),
        markdown_section("How We Built It", packet["how_we_built_it"]),
        markdown_section("Backblaze B2 Usage", packet["b2_usage"]),
        markdown_section("Genblaze Usage", packet["genblaze_usage"]),
        markdown_section("Challenges", packet["challenges"]),
        markdown_section("Accomplishments", packet["accomplishments"]),
        markdown_section("What We Learned", packet["what_we_learned"]),
        markdown_section("What's Next", packet["whats_next"]),
        markdown_section(
            "Submission Checklist",
            [
                f"{item['task']} [{item['status']}] {item['label']}"
                for item in packet["submission_checklist"]
            ],
        ),
    ]
    return "\n".join(lines).strip() + "\n"


def write_packet(packet: dict[str, Any], json_path: Path, markdown_path: Path) -> None:
    json_path.parent.mkdir(parents=True, exist_ok=True)
    markdown_path.parent.mkdir(parents=True, exist_ok=True)
    json_path.write_text(json.dumps(packet, indent=2) + "\n", encoding="utf-8")
    markdown_path.write_text(render_markdown(packet), encoding="utf-8")


def build_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(description="Build copy-ready Devpost submission packets.")
    parser.add_argument("--live", action="store_true", help="Use post-live verified sponsor copy.")
    parser.add_argument(
        "--post-live",
        action="store_true",
        help="Alias for --live; useful in final operator runbooks.",
    )
    parser.add_argument(
        "--video-url",
        help="Final public demo video URL. Must be an http(s) URL when provided.",
    )
    parser.add_argument("--tasks", type=Path, default=DEFAULT_TASKS)
    parser.add_argument("--json-out", type=Path, default=DEFAULT_JSON)
    parser.add_argument("--markdown-out", type=Path, default=DEFAULT_MD)
    return parser


def main() -> None:
    args = build_parser().parse_args()
    try:
        packet = build_packet(
            live=args.live or args.post_live,
            tasks_path=args.tasks,
            video_url=args.video_url,
        )
    except ValueError as exc:
        print(json.dumps({"ok": False, "error": str(exc)}, indent=2))
        raise SystemExit(2) from exc
    write_packet(packet, args.json_out, args.markdown_out)
    print(
        json.dumps(
            {
                "ok": True,
                "mode": packet["mode"],
                "video_url": packet["video_url"],
                "json": str(args.json_out),
                "markdown": str(args.markdown_out),
            },
            indent=2,
        )
    )


if __name__ == "__main__":
    main()