added
This commit is contained in:
commit
4eaec52904
55 files changed
+5044
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
*.vtt text eol=lf
|
||||||
|
*.txt text eol=lf
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
.venv/
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
build/
|
||||||
|
.test-work/
|
||||||
|
private/
|
||||||
|
recordings/
|
||||||
|
*.mp4
|
||||||
|
*.mov
|
||||||
|
*.mkv
|
||||||
|
*.mp3
|
||||||
|
*.wav
|
||||||
|
*.m4a
|
||||||
|
*.flac
|
||||||
|
*.webm
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Agent instructions
|
||||||
|
|
||||||
|
Read `README.md`, `repository.json`, `docs/workflow.md`, and relevant schemas. Default: original media + TXT + VTT in a user folder, metadata interview, local draft build, then human review. Use `skills/media-intake/SKILL.md`, followed by `skills/structure-media/SKILL.md`. Intake and structure-plan JSON are editable inputs; `structured/` is derived. The optional public exporter retains its separate contracts and approval requirements.
|
||||||
|
|
||||||
|
Preserve semantic IDs, unrelated work, all three originals, and prior output. Gather useful missing metadata upfront; accept partial answers and unknowns. Local drafts do not require public URLs or prior human content approval. Never invent timing, identities, consent, rights, or factual verification. Resolve sensitive exclusions before processing affected content. Public export requires clearance. Keep private sources and credentials outside this template repo.
|
||||||
|
|
||||||
|
Validate JSON contracts, source/timing/citation relationships, review fingerprints, output checksums, and representative retrieval behavior. Run `python -m unittest discover -s tests -v` and `git diff --check`. Keep README, schemas, script, examples, skill, interfaces, version, and changelog aligned when contracts change. Existing example review hashes depend on source bytes and builder version.
|
||||||
|
|
||||||
|
Build locally within the requested scope. Obtain authorization for publication, Git pushes, deployment, license selection, or external platform changes. Proposed work in `UPDATES.md` is not authorization. Do not advertise APIs, MCP services, semantic entailment verification, embeddings, or indexing until implemented and verified.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Author and repository identity
|
||||||
|
|
||||||
|
Repository owner: Eddie Soehnel.
|
||||||
|
|
||||||
|
Canonical repository: https://projects.eddiesoehnel.com/adminprojects/structured-media-builder-OPEN
|
||||||
|
|
||||||
|
Initial implementation prepared with AI assistance. Recording creators, speakers, transcription provenance, and publication rights belong in each media manifest and are separate from repository ownership. No template software/documentation license has been selected.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 0.2.0 — 2026-10-17
|
||||||
|
|
||||||
|
- Made the default process folder-first: original recording plus TXT/VTT, upfront metadata intake, in-folder draft build, then human review.
|
||||||
|
- Added the media-intake skill and copyable human checklist; source pages and partial metadata can populate inputs without inventing missing facts.
|
||||||
|
- Added a local draft builder, source-preserving audit, MP3 encoded-duration measurement, explicit unknowns/provenance, local citations, review documents, and retrieval.
|
||||||
|
- Retained the approved public exporter as a separate optional workflow. Missing hosted URLs, rights decisions, or prior human approval no longer block local review drafts.
|
||||||
|
- Added regression coverage for unknown metadata, source preservation, exclusions, source changes, draft status, local retrieval, and ambiguous file sets.
|
||||||
|
|
||||||
|
## 0.1.0 — 2026-10-17
|
||||||
|
|
||||||
|
- Established a media-specific source, review, semantic, publication, and discovery workflow based on the AI Knowledge Structure and Structured Website Builder guides.
|
||||||
|
- Added deterministic reviewed TXT/VTT ingestion, conceptual chunks, source-cited Q&A, chapter export, HTML/JSON-LD, collection discovery, local keyword search, and input/output integrity checks.
|
||||||
|
- Added schemas, blocked-by-default templates, synthetic audio/video examples, repo-local processing skill, regression tests, standards research, and API/MCP design contracts.
|
||||||
|
- Kept STT integrations, hosted services, embeddings, deployment, licensing selection, and search-engine verification explicitly separate.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Use synthetic fixtures for tests. Preserve IDs and source/derivative boundaries. For a new input format, document what is preserved and what needs review; reject unsupported timing instead of silently changing it. Update schema, builder, workflow, examples, and tests together for contract changes.
|
||||||
|
|
||||||
|
Run the test suite and a local example build, verify checksums, inspect a representative retrieval result, and review `git diff --check`. Publishing and service integration require separate authorization. Discuss license selection with the owner; the initial repository has no selected license.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# License not yet selected
|
||||||
|
|
||||||
|
The repository owner has not selected a license for this new template's code or documentation. This file does not grant an open-source or content license. Select and add an explicit license before representing this repository as openly licensed for reuse.
|
||||||
|
|
||||||
|
Do not inherit the related website builder's software or website-content licenses by assumption. Each recording, transcript, thumbnail, and semantic derivative also needs its own verified rights and attribution in the media manifest.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Publication workflow
|
||||||
|
|
||||||
|
Building and reviewing locally is separate from publishing. This repository contains no deploy command and grants no automatic publication authority.
|
||||||
|
|
||||||
|
1. Build the complete approved catalog into a fresh release directory. Run `verify`, search representative terms, inspect HTML and JSON-LD, and review the final export's full file list.
|
||||||
|
2. Inspect TXT, VTT (including NOTE blocks), cue text, names, authorship, rights, synthesized answers, summaries, thumbnails, and outbound URLs. Check speaker/attendee permission and exclude internal discussion, chats, participant lists, credentials, confidential screen content, and unapproved third-party material.
|
||||||
|
3. Obtain publication approval for the specific release and destination. Select an explicit repository license separately before representing this template as openly licensed. Recording and derivative rights are separate facts.
|
||||||
|
4. Upload only the selected release directory's contents to the configured collection site root. Coordinate the external media host and companion-site release. Do not upload source folders, private inputs, tests, `.git`, environments, or the whole repository.
|
||||||
|
5. Verify over HTTPS: collection index, each canonical recording page, media URL/player, caption track, real time seeking, artifact URLs, JSON-LD, sitemap, CORS, MIME types (`text/vtt`, `application/json`, `application/ld+json`), and intended crawler access. Test an initial and a later cue against the actual recording. Run search-engine tools for any claimed search feature. No local check proves indexing or citation by AI.
|
||||||
|
6. Record the release checksum, approver, destination, verification results, and limitations in your operational records. A receipt's `deployment_verified: false` reflects the local builder's evidence; don't edit it to simulate remote verification.
|
||||||
|
|
||||||
|
Updating a collection requires publishing the complete new release so withdrawn items do not linger. Confirm deletion/redirects and invalidate public/CDN/vector caches as appropriate. Keep any rollback copy private when it contains withdrawn content. Authorization to build does not authorize publishing, pushing commits, or changing hosting.
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
# Structured Media Builder
|
||||||
|
|
||||||
|
Put an audio or video recording and its speech-to-text **TXT and VTT files in one folder**. Ask an AI to use this template against that folder. The AI gathers useful metadata, builds structured assets inside that folder, and leaves them for your review.
|
||||||
|
|
||||||
|
Use it for webinars, meetings, interviews, podcasts, lectures, demonstrations, and other recordings. No browser preview or local web server is required. Internet publication, API/MCP hosting, and embeddings are later options.
|
||||||
|
|
||||||
|
Version **0.2.0**, experimental. See [the detailed workflow](docs/workflow.md) and [capabilities](docs/architecture.md).
|
||||||
|
|
||||||
|
## What you prepare
|
||||||
|
|
||||||
|
1. Run your normal speech-to-text process.
|
||||||
|
2. Copy the original media, its `.txt`, and its `.vtt` into a new recording folder. Keep your filenames; the three stems do not have to match.
|
||||||
|
3. Include whatever metadata you know using the checklist below, or provide a published source page. You do not need to create JSON, supply every answer, or review generated chunks in advance.
|
||||||
|
4. Give the AI the template repo path and recording folder path. It inspects the files, interviews you about missing useful facts, builds the assets, and returns review links.
|
||||||
|
|
||||||
|
Your original three files remain unchanged. A local draft can be built when URLs, exact credits, rights, or other optional facts are unknown. Unknowns stay explicit; human review follows the build.
|
||||||
|
|
||||||
|
## Metadata checklist for your prompt
|
||||||
|
|
||||||
|
Use [this copyable checklist](templates/media-intake.md), or ordinary prose. Partial answers and “unknown” are welcome. An official recording page is useful: the AI should extract supported metadata from it before asking you to repeat anything.
|
||||||
|
|
||||||
|
| Information | What helps | If unavailable |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Identity | Official title; recording date/timezone; organizer/publisher; series/part; event type | Use a marked candidate or leave unknown |
|
||||||
|
| People and credits | Hosts, speakers, moderators, affiliations, correct spellings, attribution | Transcript names remain unverified |
|
||||||
|
| Purpose | Description, audience, topics, questions people should find answers to | AI drafts these from the transcript for review |
|
||||||
|
| Links and supporting material | Published session page, future landing page, slides, reports, related sessions | Leave unset; add later |
|
||||||
|
| Rights and scope | Known license/rights, sharing limits, sensitive content or exclusions | Build a local draft; resolve before publication |
|
||||||
|
| Transcript quality | STT tool/model, review status, errors, missing sections, languages | Record limitations and preserve sources |
|
||||||
|
| Processing preferences | Depth, priority topics, terminology, downstream API/MCP/RAG goals | Use coherent chunks and grounded Q&A |
|
||||||
|
|
||||||
|
The AI inspects supplied files, prompt, and authorized source pages before asking. It groups useful missing questions, accepts partial answers, and records the distinction between user answers, file observations, source-page facts, transcript claims, AI interpretations, and unknowns. Source ambiguity and requested sensitive exclusions must be resolved before processing affected content.
|
||||||
|
|
||||||
|
## Example request
|
||||||
|
|
||||||
|
```text
|
||||||
|
Use C:\projects\indx\structured-media-builder-OPEN to structure the media in:
|
||||||
|
C:\path\to\my-recording-folder
|
||||||
|
|
||||||
|
Title / organizer / date: ...
|
||||||
|
Published session page: ...
|
||||||
|
Speakers / affiliations: ...
|
||||||
|
Audience / priority questions: ...
|
||||||
|
Credits / sharing limits / transcript issues: ...
|
||||||
|
|
||||||
|
Ask for missing useful metadata first. Build all assets in the recording
|
||||||
|
folder, leave unknowns explicit, then give me the result to review.
|
||||||
|
```
|
||||||
|
|
||||||
|
## What the AI does
|
||||||
|
|
||||||
|
1. Follow [media-intake](skills/media-intake/SKILL.md): inventory sources, compare TXT/VTT, measure available timing, inspect supplied source pages, and interview you.
|
||||||
|
2. Save `media-intake.json` beside the sources, with provenance and unknowns.
|
||||||
|
3. Follow [structure-media](skills/structure-media/SKILL.md): read the whole transcript, author coherent topic chunks, useful Q&A with exact evidence, and navigation chapters. Save `structure-plan.json` beside the sources.
|
||||||
|
4. Build a new `structured/` subfolder. Validate time ranges, cue coverage, IDs, evidence quotes, output checksums, and original source hashes.
|
||||||
|
5. Return `structured/README.md` and `structured/review.md`. Everything remains **draft** until you review it. Flag missing metadata, suspected STT errors, and unverified figures or identities.
|
||||||
|
6. Incorporate your corrections into a new output such as `structured-002/`, preserving originals and prior results. Publication is separate.
|
||||||
|
|
||||||
|
## Files you receive
|
||||||
|
|
||||||
|
```text
|
||||||
|
my-recording-folder/
|
||||||
|
original-recording.mp3 original media (or video)
|
||||||
|
original-transcript.txt original STT text
|
||||||
|
original-transcript.vtt original timed STT text
|
||||||
|
media-intake.json answers, observations, provenance, unknowns
|
||||||
|
structure-plan.json authored chunks, Q&A, and chapters
|
||||||
|
structured/
|
||||||
|
README.md overview, chapter map, summaries, Q&A
|
||||||
|
review.md review checklist, unknowns, quality notes
|
||||||
|
media.json recording metadata and source audit
|
||||||
|
transcript.md readable timed transcript with cue anchors
|
||||||
|
transcript.json normalized timed cues
|
||||||
|
chunks.json conceptual units and source citations
|
||||||
|
qa.json answers with exact quoted evidence
|
||||||
|
chapters.json navigation without invented hosted URLs
|
||||||
|
schema.jsonld draft AudioObject/VideoObject, known facts
|
||||||
|
ai-index.json local artifact routing
|
||||||
|
llms.txt local reading guide
|
||||||
|
build-receipt.json hashes, counts, and draft status
|
||||||
|
```
|
||||||
|
|
||||||
|
Chunks preserve what was said. Summaries and Q&A interpret it with supporting quotes and time ranges; neither proves a speaker's claims true. Originals are not rewritten or copied into the output. If TXT/VTT differ, the draft uses VTT timing/text and flags the difference.
|
||||||
|
|
||||||
|
## Commands for the AI or operator
|
||||||
|
|
||||||
|
Python 3.11+ and `jsonschema` are required. Run from this template repo. The AI normally handles these steps.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python -m pip install -r requirements.txt
|
||||||
|
python scripts/folder_builder.py inspect --folder "C:\path\to\my-recording-folder"
|
||||||
|
python scripts/folder_builder.py prepare --folder "C:\path\to\my-recording-folder" --output "C:\path\to\my-recording-folder\media-intake.json"
|
||||||
|
# Fill intake from the interview, then seed and author the semantic plan:
|
||||||
|
python scripts/folder_builder.py seed --folder "C:\path\to\my-recording-folder" --intake "C:\path\to\my-recording-folder\media-intake.json" --output "C:\path\to\my-recording-folder\structure-plan.json"
|
||||||
|
python scripts/folder_builder.py build --folder "C:\path\to\my-recording-folder" --intake "C:\path\to\my-recording-folder\media-intake.json" --plan "C:\path\to\my-recording-folder\structure-plan.json" --output "C:\path\to\my-recording-folder\structured"
|
||||||
|
python scripts/folder_builder.py verify --output "C:\path\to\my-recording-folder\structured"
|
||||||
|
python scripts/folder_builder.py search --output "C:\path\to\my-recording-folder\structured" --query "a useful question"
|
||||||
|
```
|
||||||
|
|
||||||
|
`seed` is a starter, not completed semantic analysis. The AI must structure the content before delivery. Existing intake, plans, and outputs are not overwritten. Supported MP3 duration is measured from MPEG frames; otherwise media duration stays unknown and VTT end time is reported separately.
|
||||||
|
|
||||||
|
## Later: publish or serve reviewed content
|
||||||
|
|
||||||
|
After review and collection of publication facts, the optional [approved public export](docs/public-export.md) can generate companion HTML, hosted URLs, and a collection sitemap. It retains stricter review/rights checks and is separate from local draft generation.
|
||||||
|
|
||||||
|
Static JSON and local keyword search work now. [API/MCP contracts](docs/interfaces.md) are future adapter designs. [Research](docs/research.md) covers standards and platform patterns. This adapts [AI Knowledge Structure](https://projects.eddiesoehnel.com/adminprojects/ai-knowledge-structure-OPEN) and [Structured Website Builder](https://projects.eddiesoehnel.com/adminprojects/structured-website-builder-OPEN) to timed media evidence.
|
||||||
|
|
||||||
|
## Repository maintenance
|
||||||
|
|
||||||
|
- [Agent instructions](AGENTS.md), [manifest](repository.json), [identity](repository-variables.json), [author](AUTHOR.md), [changelog](CHANGELOG.md), [skills](skills.md).
|
||||||
|
- [Schemas](schemas/README.md), [templates](templates/README.md), [synthetic tests](examples/README.md), [validation](docs/validation.md).
|
||||||
|
- [Publication](PUBLICATION_WORKFLOW.md), [security](SECURITY.md), [contributing](CONTRIBUTING.md), [license](LICENSE.md), [proposals](UPDATES.md).
|
||||||
|
|
||||||
|
Run `python -m unittest discover -s tests -v` and `python scripts/check_repository.py` after changes. No repository code/documentation license has been selected; recording and derivative rights are separate facts.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Security and privacy
|
||||||
|
|
||||||
|
Use only publication-safe transcripts and metadata in public repositories. Ignore rules are a convenience, not a privacy boundary. Meeting chat, attendee identities, private questions, credentials, and screen-shared information need explicit review before release. VTT NOTE blocks are preserved in exported files.
|
||||||
|
|
||||||
|
The builder makes no network requests, executes no transcript content, escapes HTML output, refuses source path traversal, and requires reviewed inputs for public exports. HTTPS URLs must not carry credentials or common signed-access parameters. These checks do not replace review of every published URL or third-party asset.
|
||||||
|
|
||||||
|
Input hashes and output checksums detect inconsistencies; they are not authenticated signatures. This static public profile supplies no authentication, revocation, PII detection, malware scanning, or private-corpus policy enforcement. Keep service credentials outside source control and generated output. Report sensitive issues privately to the repository owner rather than placing private media or secrets in an issue.
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
# Proposed work
|
||||||
|
|
||||||
|
These are options, not implemented features or authorization.
|
||||||
|
|
||||||
|
1. Pilot the workflow on one owner-approved recording and evaluate retrieval questions, timing, speaker accuracy, and review effort.
|
||||||
|
2. Select the repository's code/documentation license and verify media derivative rights.
|
||||||
|
3. Implement a read-only API and MCP adapter against the same reviewed exports; add access checks before supporting restricted content.
|
||||||
|
4. Add reviewed slide/OCR/frame evidence with separate provenance and timestamps for information absent from speech.
|
||||||
|
5. Add STT/platform adapters only for authorized exports; normalize overlapping/rolling captions while preserving evidence.
|
||||||
|
6. Add persistent identity history, semantic change feeds, redirect/tombstone generation, and retrieval-store invalidation.
|
||||||
|
7. Add embeddings/hybrid retrieval when evaluation demonstrates a need; retain model, dimensions, text hash, source version, and deletion propagation separately from canonical content.
|
||||||
|
8. Add Podcast Namespace RSS snippets, platform-specific seek adapters, video sitemap extensions, translations, and public-site verification once the hosting workflow is chosen.
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# Architecture and data contracts
|
||||||
|
|
||||||
|
## Default local-review profile (0.2.0)
|
||||||
|
|
||||||
|
The primary workflow starts with three files, metadata intake, local generation, then human review. `folder_builder.py` implements `intake.schema.json` and `folder-export.schema.json`, preserving unknowns without requiring invented URLs or prior approval. Originals remain unchanged; TXT/VTT differences become review notes. All output is draft. Intake and structure-plan JSON are editable inputs.
|
||||||
|
|
||||||
|
The remaining sections describe the stricter optional public exporter retained from 0.1.0. Its catalog/manifest contracts and gates do not apply to ordinary local drafts. See [folder workflow](workflow.md) and [later public export](public-export.md).
|
||||||
|
|
||||||
|
## Sources and build direction
|
||||||
|
|
||||||
|
The original recording is the evidence for what happened. A reviewed VTT is the authoritative timed text representation. TXT mirrors its words. `media.json` owns recording facts, rights, publication clearance, and transcription provenance. `plan.json` owns semantic boundaries, stable identities, authored interpretations, citations, chapters, and review metadata. A collection catalog lists the intended release set.
|
||||||
|
|
||||||
|
Generated files are disposable derivatives. Never edit them as source. A build has no wall-clock timestamps: meaningful dates come from authored metadata, so identical inputs produce identical bytes. Exact source hashes detect transcription/metadata changes; exported checksums detect derivative changes.
|
||||||
|
|
||||||
|
| Implemented | Deliberately separate / future |
|
||||||
|
| --- | --- |
|
||||||
|
| Reviewed VTT/TXT ingestion and alignment | STT vendor orchestration and downloads |
|
||||||
|
| Authored semantic plans; deterministic source text | Automatic LLM interpretation and review |
|
||||||
|
| Timed citations, chunks, grounded Q&A, chapters | OCR, slides, scene/frame descriptions, visual evidence |
|
||||||
|
| Static companion pages, JSON-LD, catalog, sitemap | Deployment, search-engine validation, video sitemap extension |
|
||||||
|
| Local keyword search with citations | Hosted API, MCP runtime, authentication, rate limits |
|
||||||
|
| Checksummed input/output and explicit versions | Full CIS envelope, registry, graph, policy service, tombstones |
|
||||||
|
| Portable JSON for downstream retrieval | Vector database, embeddings, hybrid ranking, evaluation corpus |
|
||||||
|
|
||||||
|
## Minimum semantic projection
|
||||||
|
|
||||||
|
This uses the guide repositories' lightweight CIS approach rather than copying the entire advanced envelope. Each chunk has an authored `chunk_id`, conceptual `knowledge_id`, integer version, prior IDs when superseding, label, heading path, summary, tags, order, exact transcript text, cue IDs, start/end seconds, speakers when present, and citations. Document-level rights and the input fingerprint apply to all chunks and Q&A.
|
||||||
|
|
||||||
|
IDs are namespaced by media ID in the examples. They are assigned during authoring and preserved across compatible edits. They are not text hashes or timecodes. The builder enforces uniqueness within a recording; a future cross-corpus registry must reconcile conceptual identity explicitly. `supersedes` is authored lineage, not a validated remote relationship.
|
||||||
|
|
||||||
|
Each citation includes media/cue IDs, start/end seconds, a canonical transcript anchor, and a native player link when available. Transcript cue IDs are revision-sensitive locators, so archive the input hash/version with a citation when exact historical reconstruction matters. Keep old approved releases privately as needed; public permanent version URLs are a future hosting decision.
|
||||||
|
|
||||||
|
## JSON contracts
|
||||||
|
|
||||||
|
The seven public-export schemas plus the two local intake/export [JSON Schemas](../schemas/README.md) use Draft 2020-12 and reject unknown fields. Runtime validation also checks relationships that JSON Schema alone cannot establish: identity alignment, sequential cue coverage, time bounds, exact evidence quotes, chapter ordering, TXT/VTT equality, review hashes, URL safety, output boundaries, and publication clearance.
|
||||||
|
|
||||||
|
`qa.json` may contain zero answers. A claim in a transcript is attributed speech, not independent verification. Q&A can synthesize multiple cues, but each supporting quote must be a literal substring of its referenced cue. The builder cannot mechanically prove entailment; review is required.
|
||||||
|
|
||||||
|
`chapters.json` uses the Podcast Namespace chapter format with `version: 1.2.0` and seconds as numbers. It is separate from our transcript schema and from the namespace's alternative transcript JSON format. Those formats use different field names; do not advertise our `transcript.json` as a Podcast Namespace JSON transcript. Use the exported TXT/VTT for podcast links today.
|
||||||
|
|
||||||
|
## Discovery and playback
|
||||||
|
|
||||||
|
The public URL root is the contents of a build directory. `/media/<id>/` contains the human page and relative alternate links. JSON artifact URLs share that canonical path. `/ai-index.json` routes to all release items and their artifacts. `llms.txt` is optional guidance, while `sitemap.xml` is a standard URL sitemap. Neither is an access-control mechanism or a guarantee that an AI will fetch content.
|
||||||
|
|
||||||
|
Native `content_url` playback uses HTML video/audio and `?t=<seconds>` on the companion page. Its small player script seeks after metadata loads. A source URL's CORS, media availability, MIME, codecs, and range support must be checked at publication. Embed-only media gets an outbound recording link and transcript anchors; it does not claim universal external-platform seeking. Integrate a host's supported player API explicitly if needed.
|
||||||
|
|
||||||
|
Video chapters become Schema.org `Clip` records only for a native player, where the builder actually implements time links. Audio emits `AudioObject`. Generic Schema.org validity is distinct from eligibility for a particular search feature. No `FAQPage`, `SeekToAction`, live API, or MCP capability is advertised just because a Q&A file or interface design exists.
|
||||||
|
|
||||||
|
## Privacy and rights
|
||||||
|
|
||||||
|
Raw source locations never appear in the export. The public `media.json` omits local transcript paths. It still contains reviewed creator/provenance and rights facts; review those for intended publication. VTT is copied intact, including NOTE blocks, so remove private annotations before clearance. No automatic PII redactor is claimed.
|
||||||
|
|
||||||
|
This first profile is for fully public, cleared content. It is not a private meeting vault or multi-tenant permission system. A private or paid corpus needs an access layer that checks policy before any list/search/fetch response, including snippets and Q&A; static obscurity and robots directives are insufficient.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Proposed API and MCP adapters
|
||||||
|
|
||||||
|
The static files and CLI search are implemented. [openapi.json](../interfaces/openapi.json) and [mcp-tools.json](../interfaces/mcp-tools.json) are design contracts only; there is no listening API, MCP transport, service deployment, or service discovery advertisement. Do not register them with clients as available endpoints.
|
||||||
|
|
||||||
|
## Read-only surface
|
||||||
|
|
||||||
|
| Need | Proposed HTTP operation | Proposed MCP tool |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Browse recordings | `GET /media` | `list_media` |
|
||||||
|
| Find a passage or answer | `GET /search?q=...&limit=5` | `search_media` |
|
||||||
|
| Fetch recording context and artifact routes | `GET /media/{media_id}` | `get_media` |
|
||||||
|
| Fetch one source-cited conceptual unit | `GET /media/{media_id}/chunks/{chunk_id}` | `get_media_chunk` |
|
||||||
|
|
||||||
|
Use opaque media/chunk IDs as identifiers; URL-encode IDs containing colons. Return the same IDs, text, time ranges, canonical transcript URLs, rights, and input fingerprint as the approved export. Search returns a bounded `results` array matching the local CLI records. No matches returns an empty array, never an invented answer. Fetching an unknown or withdrawn item returns a clear not-found response.
|
||||||
|
|
||||||
|
An adapter should load only a complete release after checksum/schema verification and use a single release snapshot for each request. Validate parameters, constrain limits, return structured errors, log without private transcripts or credentials, and prevent arbitrary path/URL fetching. Add pagination and deterministic filtering when scale requires them. The initial OpenAPI design is intentionally limited to a small corpus; it is not a deployed production API specification.
|
||||||
|
|
||||||
|
For a restricted corpus, apply access checks before search, snippets, Q&A, list, or fetch; never expose a public index that reveals restricted metadata. This repository's first profile is entirely public. A production adapter also needs authentication decisions, rate limits, CORS, health checks, release refresh, withdrawal handling, and integration tests.
|
||||||
|
|
||||||
|
MCP implementation must support the actual protocol lifecycle, capability negotiation, tool listing/invocation, and error behavior. Tool definitions alone are not a server. No additional network action is implied by a transcript's content.
|
||||||
|
|
||||||
|
## Future embeddings
|
||||||
|
|
||||||
|
Keep vector records downstream of the canonical chunks. Store media/chunk/knowledge IDs, chunk version, source input fingerprint, exact embedded-text hash, embedding model/version and dimensions, language, and rights/access filters. Regenerate when text/model changes; invalidate removed or restricted content. Decide whether to index Q&A separately and preserve its source citations.
|
||||||
|
|
||||||
|
Use a realistic question set to compare keyword, semantic, and hybrid retrieval. Measure retrieval coverage and citation correctness before choosing infrastructure. Never replace source text with an embedding, or use vector similarity as proof that an answer is supported.
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
# Recording-to-discovery workflow
|
||||||
|
|
||||||
|
## 1. Establish source and publication facts
|
||||||
|
|
||||||
|
Create one source folder per stable recording ID, for example `collection/annual-webinar/`. Copy `templates/media.json` into it as `media.json`. Put reviewed, publication-safe `transcript.txt` and `transcript.vtt` alongside it. Store only material you are authorized to expose in a public repository. Keep the original recording and unredacted STT output in private storage, with an operator-side mapping to the media ID.
|
||||||
|
|
||||||
|
Fill in every template field, including the real duration in seconds, language, stable media URL or embed URL, published date, meaningful update date, creators, transcription tool/model when known, and rights statement. Use explicit `null` for unknown optional facts. `recorded_at` and `published_at` are different facts. Do not fabricate an original upload date from a later build date.
|
||||||
|
|
||||||
|
Set a stable collection `site_url`, such as `https://media.your-domain.example`, and a canonical URL exactly matching `<site_url>/media/<media_id>/`. A host URL identifies the bytes or player; the canonical URL identifies the companion page. Mirrors retain the recording's stable ID. Edited recordings with shifted timelines need a distinct media ID and an explicit migration record.
|
||||||
|
|
||||||
|
Set `synthetic` to false for real recordings and `allow_synthetic` to false in real catalogs. The supplied template intentionally blocks public output until rights, privacy, and consent are cleared. Its example URLs, dates, and names must be replaced.
|
||||||
|
|
||||||
|
## 2. Review STT and align text
|
||||||
|
|
||||||
|
Run the STT tool you already use; there is no paid transcription integration here. Preserve its raw output privately. Review public copies against the recording, especially names, numbers, unfamiliar vocabulary, speaker attribution, and low-quality audio.
|
||||||
|
|
||||||
|
VTT supplies the timed source. TXT supplies the portable reading copy and must match the normalized cue words exactly, including any speaker prefixes that appear as literal text. WebVTT `<v Speaker>` markup is extracted as speaker metadata and is not part of TXT. If your TXT has timestamps or speaker prefixes that the VTT does not, reconcile the reviewed copies before building. A multilingual translation is a separate source set and review, not a silent replacement.
|
||||||
|
|
||||||
|
Supported VTT: UTF-8/BOM, LF/CRLF, `HH:MM:SS.mmm` or `MM:SS.mmm`, optional cue identifiers/settings, NOTE blocks, multiline text, voice labels, basic emphasis/class/language tags, and HTML entities. The parser rejects overlapping/out-of-order cues, multiple speakers inside one cue, STYLE/REGION blocks, header metadata, ruby, and inline karaoke timestamps. Normalize these formats with a reviewed adapter rather than discard their meaning. Rolling captions often require deduplication and resegmentation. Cues must fit within the declared duration. Gaps are allowed; they are not inferred speech.
|
||||||
|
|
||||||
|
No cue-level confidence is invented. Missing speaker names remain null. Literal prefixes such as `Speaker 1:` remain source text unless converted to reviewed voice markup. Do not infer real identities from voices.
|
||||||
|
|
||||||
|
## 3. Draft semantic structure
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python scripts/media_builder.py draft --manifest collection/annual-webinar/media.json --plan collection/annual-webinar/plan.json
|
||||||
|
```
|
||||||
|
|
||||||
|
This creates one explicitly unreviewed starter chunk covering all cues. It performs no semantic inference. Ask an AI/editor to split this into coherent topic units using the repo-local skill and recording context. The `cue-000001` IDs refer to cue sequence in the normalized transcript, not permanent knowledge identities. Cue IDs can change after transcript edits, which invalidate the review hash.
|
||||||
|
|
||||||
|
For each chunk, author `chunk_id`, `knowledge_id`, `version`, `supersedes`, title, heading path, summary, a few useful tags, and a contiguous ordered cue list. Every cue must belong to exactly one chunk. This base layer has no overlapping windows. Future RAG adapters can add context windows without changing these canonical chunks. Keep long single-topic chunks when needed; no fixed token count is required.
|
||||||
|
|
||||||
|
Q&A should answer plausible retrieval questions, including what to do, why it matters, and stated limitations. `answer_type` distinguishes a direct extract from synthesis. Each answer needs at least one exact quote with a `chunk_id` and `cue_id`; cross-chunk synthesis cites all supporting chunks. An exact quote is mechanically checked; whether it supports the answer is a human/editorial judgment. Leave Q&A empty when there is no useful grounded answer. Never turn an unanswered meeting question into a claimed answer or invent a to-do owner/date.
|
||||||
|
|
||||||
|
Choose chapters for navigation, independently of chunk count. Each chapter identifies its first and last source cue. Chapters may omit a greeting or other nonessential navigation section; chunks still cover all cues. Chapter labels and summaries are interpretations requiring review.
|
||||||
|
|
||||||
|
## 4. Approve this exact input set
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python scripts/media_builder.py signature --manifest collection/annual-webinar/media.json --plan collection/annual-webinar/plan.json
|
||||||
|
```
|
||||||
|
|
||||||
|
After inspecting the recording and plan, paste the returned `input_sha256` into `plan.json` → `review.input_sha256`. Set `review.status` to `approved`, identify the reviewer, and record an ISO 8601 `reviewed_at` with timezone. Do not use an AI's name to imply a human approved real material. Clear consent/privacy and confirm redistribution rights in `media.json` before computing the final hash.
|
||||||
|
|
||||||
|
The hash covers canonical manifest and plan data (excluding the review block), the exact TXT/VTT bytes, and builder version. Changing any of these invalidates approval. Changing only review metadata does not. This is a workflow integrity check, not authentication or a signature authority. Automated validation cannot determine copyright ownership, consent, factual truth, or semantic entailment.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python scripts/media_builder.py validate --manifest collection/annual-webinar/media.json --plan collection/annual-webinar/plan.json
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. Build and retrieve
|
||||||
|
|
||||||
|
Copy `templates/catalog.json` to `collection/catalog.json`, edit its title/site URL, and list the source manifest and plan paths relative to the catalog. Catalog paths must stay inside the catalog folder; transcript paths stay inside their media source folder. Keep generated output outside those media source folders.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python scripts/media_builder.py build --catalog collection/catalog.json --output build/release-001
|
||||||
|
python scripts/media_builder.py verify --root build/release-001
|
||||||
|
python scripts/media_builder.py search --root build/release-001 --query "equipment maintenance" --limit 5
|
||||||
|
```
|
||||||
|
|
||||||
|
All catalog items must pass before output is written. Files are assembled in a temporary sibling directory and renamed into a new output directory. Existing outputs are never overwritten. Failures preserve sources and prior releases. The output checksum receipt covers every exported file except the receipt itself. It detects accidental changes, not malicious replacement of both files and receipt.
|
||||||
|
|
||||||
|
Search reads only a verified export, matches Unicode word tokens, ranks by distinct query-token matches, and returns chunks or Q&A plus citations and rights. This is a small-corpus keyword baseline, not vector retrieval or a relevance guarantee. No network calls, paid inference, or embeddings occur.
|
||||||
|
|
||||||
|
## 6. Update and retire
|
||||||
|
|
||||||
|
Minor corrections preserve semantic IDs; increment the chunk version when its text or meaning changes. A split or merge gets new chunk/knowledge IDs and records prior IDs in `supersedes`. This version does not maintain an identity registry or automatically audit historical version increments; review continuity against the previous release. Build a new complete catalog release, not an incremental append to old public files.
|
||||||
|
|
||||||
|
For removal, omit the item from the next release, remove all old public copies/hosted captions, purge caches and downstream retrieval stores, and record the decision privately where appropriate. Replacing local output alone does not revoke an already published copy. Redirects, tombstones, and change feeds are proposed additions, not implemented lifecycle services.
|
||||||
|
|
||||||
|
Inspect the generated page and data, then follow [the publication workflow](../PUBLICATION_WORKFLOW.md). Publish only the chosen complete output directory; never upload the repository root.
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Research and adoption decisions
|
||||||
|
|
||||||
|
Researched 2026-10-17 using official specifications and platform documentation. These sources inform the design; they do not show that a specific AI system will index or cite the eventual site. No public media collection or service has been deployed during template creation.
|
||||||
|
|
||||||
|
## Portable media representation
|
||||||
|
|
||||||
|
- **WebVTT:** timed text cues and voice annotations provide a portable source for captions and evidence locators. Keep reviewed TXT alongside VTT for simple consumption. This builder supports a documented subset and rejects formats needing normalization. [W3C WebVTT](https://www.w3.org/TR/webvtt1/).
|
||||||
|
- **Schema.org:** `AudioObject` and `VideoObject` support a transcript property; media identity and metadata belong with the recording. Emit these types on companion pages. [AudioObject](https://schema.org/AudioObject).
|
||||||
|
- **Video discovery:** Google's guidance includes `VideoObject`, chapter `Clip` records, and `SeekToAction`. Adopt recording metadata and chapter clips where actual seeking works. Do not emit `SeekToAction` for unsupported players. Metadata eligibility, crawlability, thumbnails, prominence, and playback still need live checks; schema output alone does not establish a rich result. [Google video structured data](https://developers.google.com/search/docs/appearance/structured-data/video).
|
||||||
|
- **Video sitemaps:** a video extension can describe video assets beyond a basic page sitemap. Keep it as a next step after real hosting and thumbnail URLs are selected; this version emits the ordinary URL sitemap only. [Google video sitemaps](https://developers.google.com/search/docs/crawling-indexing/sitemaps/video-sitemaps).
|
||||||
|
- **Media fragments:** the W3C defines temporal fragment addressing, but arbitrary hosted players cannot be assumed to support it. Use actual companion-player seeking for native sources and transcript anchors for embed-only sources. [W3C Media Fragments](https://www.w3.org/TR/media-frags/).
|
||||||
|
|
||||||
|
## Existing platform patterns
|
||||||
|
|
||||||
|
| Platform or system | Observed pattern | Adopt here |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Podcast Namespace | RSS links to typed transcript files and an external chapter JSON file | Export portable TXT/VTT and chapter JSON; RSS integration remains separate |
|
||||||
|
| YouTube | Caption-track download is an authorized API operation requiring permission to edit the video | Use owner-authorized caption exports; do not build around arbitrary public-caption downloading |
|
||||||
|
| Zoom cloud recordings | Recording APIs distinguish audio/video, VTT transcripts, and other artifacts such as meeting chat | Import only approved transcript/media exports; chat is not a transcript or automatic publication input |
|
||||||
|
| Vimeo | API documentation exposes text-track management and upload | Retain portable caption tracks; a platform sync adapter needs separate implementation and credentials |
|
||||||
|
| Azure AI Video Indexer | Insights span transcript, OCR, and other audio/visual information | Track visual coverage; later add reviewed visual evidence rather than imply STT captures slides or demonstrations |
|
||||||
|
|
||||||
|
Sources: [Podcast Namespace transcript specification](https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/tags/transcript.md), [chapter specification](https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/tags/chapters.md), [chapter JSON format](https://podcasting2.org/docs/podcast-namespace/examples/chapters/jsonChapters), [YouTube caption download](https://developers.google.com/youtube/data/reference/rest/v3/captions/download), [Zoom Meetings API](https://developers.zoom.us/docs/api/meetings/), [Vimeo text-track uploads](https://developer.vimeo.com/api/upload/texttracks), [Azure Video Indexer insights](https://learn.microsoft.com/en-us/azure/azure-video-indexer/insights-overview).
|
||||||
|
|
||||||
|
Vimeo's full documentation body was not extractable in this research session; its official search result supports only the text-track/upload pattern above. No Vimeo behavior or integration was tested. Zoom's compliance archive API has different artifact formats from cloud recording; inspect the exact export route rather than treat every `TRANSCRIPT` type as VTT.
|
||||||
|
|
||||||
|
## AI retrieval and interfaces
|
||||||
|
|
||||||
|
MCP describes tools with names, descriptions, and JSON Schema inputs; a server must implement the protocol and invocation behavior. Our [interface designs](interfaces.md) define proposed read-only adapters over the same reviewed artifacts. A JSON file listing tools is not a functioning MCP server. [MCP tools specification](https://modelcontextprotocol.io/specification/2025-11-25/server/tools).
|
||||||
|
|
||||||
|
`llms.txt` is a proposal for concise agent guidance and linked content, separate from sitemaps and crawler rules. Use it as a small routing guide alongside the machine catalog, without claiming universal adoption or access enforcement. [llms.txt proposal](https://llmstxt.org/).
|
||||||
|
|
||||||
|
Design inference: chunks and cited Q&A can support useful list/search/fetch interfaces before embeddings exist. Start with directly retrievable JSON and measurable keyword search. Add hybrid/vector retrieval when realistic questions expose a demonstrated gap. RAG is a downstream use of the canonical material, not the defining storage format.
|
||||||
|
|
||||||
|
## Alignment with the guide repositories
|
||||||
|
|
||||||
|
The current local AI Knowledge Structure guide defines maturity profiles and separates authoring, semantic artifacts, discovery, runtime policy, and retrieval. The current Structured Website Builder uses authored chunk identities, heading paths, order, lightweight rights, Q&A, HTML alternate links, and generated discovery files. This template preserves those choices and adds media timing and evidence relationships.
|
||||||
|
|
||||||
|
The guide's advanced CIS identity/lineage ideas remain useful design context, but this template implements a small explicit projection. It does not copy site-specific branding, content licenses, hosting settings, Poppy capability declarations, contact APIs, or private operational details. New interfaces are advertised only after implementation and verification.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Initial implementation validation
|
||||||
|
|
||||||
|
Validated 2026-10-17 in the canonical local repository. Version 0.1.0.
|
||||||
|
|
||||||
|
- 27 regression tests passed, covering audio/video builds, source citations, cross-chunk Q&A, deterministic output, review invalidation, TXT/VTT alignment, timing errors, privacy/rights gates, unsupported captions, source path boundaries, output preservation, tamper detection, HTML escaping, and partial-build refusal.
|
||||||
|
- Both synthetic example manifests validated and built together into `build/demo`. Output checksums verified from that directory.
|
||||||
|
- Repository JSON parsed, all seven JSON Schemas checked, local Markdown links and manifest paths resolved, and local OpenAPI schema references resolved.
|
||||||
|
- Repo-local skill passed the skill-creator validator. Source whitespace and a targeted high-confidence credential-pattern scan passed. This scan is not a comprehensive security audit.
|
||||||
|
- Keyword retrieval returned source-cited chunks and a cross-chunk answer with expected timed transcript anchors. Generated HTML and its embedded JSON-LD were parsed and checked against the JSON-LD export.
|
||||||
|
|
||||||
|
No real recording was supplied. Audio recognition quality, human factual review, participant consent, real media playback, hosted caption behavior, external API/MCP service behavior, deployment, and search-engine or AI indexing were not verified. The examples contain placeholder media URLs and synthetic review metadata.
|
||||||
|
|
||||||
|
All source files remain uncommitted. No Git push, remote repository setting change, or publication was performed. Repository licensing remains unselected.
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# Folder-first intake, build, and review
|
||||||
|
|
||||||
|
The primary instructions and metadata checklist are in [README](../README.md). Start with the user's folder containing media, TXT, and VTT. Do not require a site, catalog, canonical URL, or preapproved transcript to create a local review draft.
|
||||||
|
|
||||||
|
## Intake
|
||||||
|
|
||||||
|
Use [media-intake](../skills/media-intake/SKILL.md) before [structure-media](../skills/structure-media/SKILL.md). Read supplied metadata first. Inventory exact files, record hashes, parse cues, compare normalized TXT/VTT, and distinguish media duration from final cue time. Filenames may differ. Ask which files to use when multiple sets create ambiguity.
|
||||||
|
|
||||||
|
Inspect authorized published source pages and extract only supported facts, with provenance. Do not treat a publication date as a recording date or a public embed as reuse permission. Ask remaining useful questions together using [the checklist](../templates/media-intake.md). Accept partial answers. File dates/titles are candidates; transcript names and statistics are attributed, unverified content. Record provenance in `media-intake.json`. Silence never becomes metadata or approval. Optional unknowns do not block a clearly incomplete local draft after a reasonable opportunity to reply.
|
||||||
|
|
||||||
|
Resolve source ambiguity and sensitive exclusions affecting processing first. Set `excluded_cue_ids` only from clear user direction. Excluded cues remain in unchanged originals but are omitted from generated transcript/chunks/Q&A and recorded by ID/count. Keep restricted originals in appropriate private storage.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
VTT supplies exact words and times. TXT is cross-checked; differences become review issues instead of prompting source rewrites or invented timing. Unsupported/overlapping VTT requires explicit normalization in a separate derivative.
|
||||||
|
|
||||||
|
Read the whole transcript. Create coherent topic units useful on their own. Assign stable chunk/knowledge IDs; preserve continuing concepts, increment substantive versions, and record splits/merges with `supersedes`. Every included cue belongs to one chunk. Chapters serve navigation independently.
|
||||||
|
|
||||||
|
Generate useful questions with exact supporting quotes. Cross-chunk answers cite every material supporting section. Substring validation proves a quote occurs, not that it entails the answer. Preserve uncertainty and sampling/measurement caveats beside numbers. Do not assign cue-level speaker identities without a source label or reliable mapping from the user.
|
||||||
|
|
||||||
|
## Build before review
|
||||||
|
|
||||||
|
Use `folder_builder.py build` to write a new immediate subfolder, normally `structured/`. Intake and plan JSON remain editable inputs. The output includes overview, transcript, review checklist, metadata, chunks, Q&A, chapters, draft JSON-LD, routing, and checksum receipt. Everything is draft and not publication ready.
|
||||||
|
|
||||||
|
Known facts appear in JSON-LD; missing public URLs, dates, and licenses are omitted. Local citations use transcript anchors and seconds. Chapter JSON omits unknown hosted URLs. No browser or server is required.
|
||||||
|
|
||||||
|
Validate source hashes/boundaries, cue coverage/order, times, identities, schema fields, exact quotes, and output checksums. Do not invent human approval to enable a draft build.
|
||||||
|
|
||||||
|
Local keyword retrieval weights question/title and summary matches above incidental mentions in a long transcript chunk. Scores are a lexical ranking aid, not confidence or semantic entailment. Inspect representative queries after a real build.
|
||||||
|
|
||||||
|
## Review and refine
|
||||||
|
|
||||||
|
Return direct links to the output README and review checklist. The user reviews identities/numbers, metadata, chunks, summaries, answers, rights, and missing visual evidence. Apply corrections to intake/plan, preserve continuing IDs, and build a fresh directory such as `structured-002/`. Review does not imply publication or Git push authority.
|
||||||
|
|
||||||
|
The [public export workflow](public-export.md) is later and optional, requiring real publication metadata and content/rights clearance. Hosted APIs, MCP, embeddings, publication, and independent fact verification are separate integrations.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Synthetic examples
|
||||||
|
|
||||||
|
[catalog.json](catalog.json) builds an audio field note and a webinar-style video transcript. All dialogue, speakers, timestamps, rights/review metadata, and media URLs are test fixtures. No real recording, attendee information, or playable media is included. These demonstrate reviewed data relationships and pipeline behavior, not a human's approval of real content.
|
||||||
|
|
||||||
|
The webinar includes cross-chunk Q&A synthesis; the audio example includes an explicit content limitation. Output is generated under `build/`, never treated as authoritative source. Production catalogs should use `allow_synthetic: false`.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"schema_version": "1.0",
|
||||||
|
"title": "Structured Media Examples",
|
||||||
|
"site_url": "https://media.example.org",
|
||||||
|
"allow_synthetic": true,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"manifest": "example-webinar/media.json",
|
||||||
|
"plan": "example-webinar/plan.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"manifest": "example-audio/media.json",
|
||||||
|
"plan": "example-audio/plan.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"schema_version": "1.0",
|
||||||
|
"media_id": "example-audio",
|
||||||
|
"kind": "audio",
|
||||||
|
"title": "An audio field note on maintenance",
|
||||||
|
"description": "Synthetic demonstration of timed, source-cited media discovery.",
|
||||||
|
"language": "en",
|
||||||
|
"canonical_url": "https://media.example.org/media/example-audio/",
|
||||||
|
"content_url": "https://cdn.example.org/example-audio.mp3",
|
||||||
|
"embed_url": null,
|
||||||
|
"thumbnail_url": null,
|
||||||
|
"duration_seconds": 40,
|
||||||
|
"recorded_at": null,
|
||||||
|
"published_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"updated_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"synthetic": true,
|
||||||
|
"creators": [
|
||||||
|
{
|
||||||
|
"name": "Example presenter",
|
||||||
|
"role": "speaker"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transcripts": {
|
||||||
|
"txt": "transcript.txt",
|
||||||
|
"vtt": "transcript.vtt"
|
||||||
|
},
|
||||||
|
"transcription": {
|
||||||
|
"method": "synthetic",
|
||||||
|
"engine": "hand-authored fixture",
|
||||||
|
"model": null,
|
||||||
|
"generated_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"reviewed_by": "Fixture review",
|
||||||
|
"visual_coverage": "audio-only"
|
||||||
|
},
|
||||||
|
"rights": {
|
||||||
|
"statement": "Synthetic fixture for template testing. No real participant data.",
|
||||||
|
"license": null,
|
||||||
|
"usage_info": null,
|
||||||
|
"redistribution_allowed": true
|
||||||
|
},
|
||||||
|
"publication": {
|
||||||
|
"consent": "cleared",
|
||||||
|
"privacy_review": "cleared"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"chapter_id": "example-audio:chapter:inspection",
|
||||||
|
"end_cue_id": "cue-000002",
|
||||||
|
"start_cue_id": "cue-000001",
|
||||||
|
"title": "Inspection"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chapter_id": "example-audio:chapter:maintenance-log",
|
||||||
|
"end_cue_id": "cue-000004",
|
||||||
|
"start_cue_id": "cue-000003",
|
||||||
|
"title": "Maintenance Log"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"chunk_id": "example-audio:chunk:inspection",
|
||||||
|
"cue_ids": [
|
||||||
|
"cue-000001",
|
||||||
|
"cue-000002"
|
||||||
|
],
|
||||||
|
"heading_path": [
|
||||||
|
"An audio field note on maintenance",
|
||||||
|
"Inspection"
|
||||||
|
],
|
||||||
|
"knowledge_id": "example-audio:knowledge:inspection",
|
||||||
|
"summary": "Inspect equipment using manufacturer guidance.",
|
||||||
|
"supersedes": [],
|
||||||
|
"tags": [
|
||||||
|
"inspection"
|
||||||
|
],
|
||||||
|
"title": "Inspection",
|
||||||
|
"version": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chunk_id": "example-audio:chunk:maintenance-log",
|
||||||
|
"cue_ids": [
|
||||||
|
"cue-000003",
|
||||||
|
"cue-000004"
|
||||||
|
],
|
||||||
|
"heading_path": [
|
||||||
|
"An audio field note on maintenance",
|
||||||
|
"Maintenance Log"
|
||||||
|
],
|
||||||
|
"knowledge_id": "example-audio:knowledge:maintenance-log",
|
||||||
|
"summary": "Document wear and preserve the limits of this field note.",
|
||||||
|
"supersedes": [],
|
||||||
|
"tags": [
|
||||||
|
"maintenance-log"
|
||||||
|
],
|
||||||
|
"title": "Maintenance Log",
|
||||||
|
"version": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"media_id": "example-audio",
|
||||||
|
"qa": [
|
||||||
|
{
|
||||||
|
"answer": "Inspect the equipment before use and follow the manufacturer instructions.",
|
||||||
|
"answer_type": "extractive",
|
||||||
|
"evidence": [
|
||||||
|
{
|
||||||
|
"chunk_id": "example-audio:chunk:inspection",
|
||||||
|
"cue_id": "cue-000002",
|
||||||
|
"quote": "Inspect the equipment before use and follow the manufacturer instructions."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"qa_id": "example-audio:qa:one",
|
||||||
|
"question": "What does the presenter recommend?"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"review": {
|
||||||
|
"input_sha256": "f07febaba81d031d5818ddeabce1aa7042d2d0c7747e4083d11cae00a8c5d3c4",
|
||||||
|
"reviewed_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"reviewer": "Synthetic fixture review",
|
||||||
|
"status": "approved"
|
||||||
|
},
|
||||||
|
"schema_version": "1.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
This is an audio field note about maintaining equipment.
|
||||||
|
Inspect the equipment before use and follow the manufacturer instructions.
|
||||||
|
Record the date and describe any wear you observe.
|
||||||
|
This note does not include instructions for replacing damaged components.
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
WEBVTT
|
||||||
|
|
||||||
|
source-1
|
||||||
|
00:00:00.000 --> 00:00:10.000
|
||||||
|
<v Narrator>This is an audio field note about maintaining equipment.</v>
|
||||||
|
|
||||||
|
source-2
|
||||||
|
00:00:10.000 --> 00:00:20.000
|
||||||
|
<v Narrator>Inspect the equipment before use and follow the manufacturer instructions.</v>
|
||||||
|
|
||||||
|
source-3
|
||||||
|
00:00:20.000 --> 00:00:30.000
|
||||||
|
<v Narrator>Record the date and describe any wear you observe.</v>
|
||||||
|
|
||||||
|
source-4
|
||||||
|
00:00:30.000 --> 00:00:40.000
|
||||||
|
<v Narrator>This note does not include instructions for replacing damaged components.</v>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"schema_version": "1.0",
|
||||||
|
"media_id": "example-webinar",
|
||||||
|
"kind": "video",
|
||||||
|
"title": "Finding recordings after a webinar",
|
||||||
|
"description": "Synthetic demonstration of timed, source-cited media discovery.",
|
||||||
|
"language": "en",
|
||||||
|
"canonical_url": "https://media.example.org/media/example-webinar/",
|
||||||
|
"content_url": "https://cdn.example.org/example-webinar.mp4",
|
||||||
|
"embed_url": null,
|
||||||
|
"thumbnail_url": "https://cdn.example.org/example-webinar.jpg",
|
||||||
|
"duration_seconds": 60,
|
||||||
|
"recorded_at": null,
|
||||||
|
"published_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"updated_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"synthetic": true,
|
||||||
|
"creators": [
|
||||||
|
{
|
||||||
|
"name": "Example presenter",
|
||||||
|
"role": "speaker"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transcripts": {
|
||||||
|
"txt": "transcript.txt",
|
||||||
|
"vtt": "transcript.vtt"
|
||||||
|
},
|
||||||
|
"transcription": {
|
||||||
|
"method": "synthetic",
|
||||||
|
"engine": "hand-authored fixture",
|
||||||
|
"model": null,
|
||||||
|
"generated_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"reviewed_by": "Fixture review",
|
||||||
|
"visual_coverage": "not-assessed"
|
||||||
|
},
|
||||||
|
"rights": {
|
||||||
|
"statement": "Synthetic fixture for template testing. No real participant data.",
|
||||||
|
"license": null,
|
||||||
|
"usage_info": null,
|
||||||
|
"redistribution_allowed": true
|
||||||
|
},
|
||||||
|
"publication": {
|
||||||
|
"consent": "cleared",
|
||||||
|
"privacy_review": "cleared"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
{
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"chapter_id": "example-webinar:chapter:transcripts",
|
||||||
|
"end_cue_id": "cue-000002",
|
||||||
|
"start_cue_id": "cue-000001",
|
||||||
|
"title": "Transcripts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chapter_id": "example-webinar:chapter:citations",
|
||||||
|
"end_cue_id": "cue-000004",
|
||||||
|
"start_cue_id": "cue-000003",
|
||||||
|
"title": "Citations"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chapter_id": "example-webinar:chapter:distribution",
|
||||||
|
"end_cue_id": "cue-000006",
|
||||||
|
"start_cue_id": "cue-000005",
|
||||||
|
"title": "Distribution"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"chunks": [
|
||||||
|
{
|
||||||
|
"chunk_id": "example-webinar:chunk:transcripts",
|
||||||
|
"cue_ids": [
|
||||||
|
"cue-000001",
|
||||||
|
"cue-000002"
|
||||||
|
],
|
||||||
|
"heading_path": [
|
||||||
|
"Finding recordings after a webinar",
|
||||||
|
"Transcripts"
|
||||||
|
],
|
||||||
|
"knowledge_id": "example-webinar:knowledge:transcripts",
|
||||||
|
"summary": "Keep portable transcript files alongside a recording.",
|
||||||
|
"supersedes": [],
|
||||||
|
"tags": [
|
||||||
|
"transcripts"
|
||||||
|
],
|
||||||
|
"title": "Transcripts",
|
||||||
|
"version": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chunk_id": "example-webinar:chunk:citations",
|
||||||
|
"cue_ids": [
|
||||||
|
"cue-000003",
|
||||||
|
"cue-000004"
|
||||||
|
],
|
||||||
|
"heading_path": [
|
||||||
|
"Finding recordings after a webinar",
|
||||||
|
"Citations"
|
||||||
|
],
|
||||||
|
"knowledge_id": "example-webinar:knowledge:citations",
|
||||||
|
"summary": "Use conceptual chunks and cite timed source cues.",
|
||||||
|
"supersedes": [],
|
||||||
|
"tags": [
|
||||||
|
"citations"
|
||||||
|
],
|
||||||
|
"title": "Citations",
|
||||||
|
"version": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chunk_id": "example-webinar:chunk:distribution",
|
||||||
|
"cue_ids": [
|
||||||
|
"cue-000005",
|
||||||
|
"cue-000006"
|
||||||
|
],
|
||||||
|
"heading_path": [
|
||||||
|
"Finding recordings after a webinar",
|
||||||
|
"Distribution"
|
||||||
|
],
|
||||||
|
"knowledge_id": "example-webinar:knowledge:distribution",
|
||||||
|
"summary": "Review permission and expose data through an optional API.",
|
||||||
|
"supersedes": [],
|
||||||
|
"tags": [
|
||||||
|
"distribution"
|
||||||
|
],
|
||||||
|
"title": "Distribution",
|
||||||
|
"version": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"media_id": "example-webinar",
|
||||||
|
"qa": [
|
||||||
|
{
|
||||||
|
"answer": "Keep the plain text transcript and the timed VTT file together.",
|
||||||
|
"answer_type": "extractive",
|
||||||
|
"evidence": [
|
||||||
|
{
|
||||||
|
"chunk_id": "example-webinar:chunk:transcripts",
|
||||||
|
"cue_id": "cue-000002",
|
||||||
|
"quote": "Keep the plain text transcript and the timed VTT file together."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"qa_id": "example-webinar:qa:one",
|
||||||
|
"question": "What does the presenter recommend?"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"answer": "The presenter recommends keeping TXT and VTT together and adding citations with start and end times.",
|
||||||
|
"answer_type": "synthesis",
|
||||||
|
"evidence": [
|
||||||
|
{
|
||||||
|
"chunk_id": "example-webinar:chunk:transcripts",
|
||||||
|
"cue_id": "cue-000002",
|
||||||
|
"quote": "Keep the plain text transcript and the timed VTT file together."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"chunk_id": "example-webinar:chunk:citations",
|
||||||
|
"cue_id": "cue-000004",
|
||||||
|
"quote": "Each answer needs a transcript citation with start and end times."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"qa_id": "example-webinar:qa:two",
|
||||||
|
"question": "Why keep the original transcript and add time ranges?"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"review": {
|
||||||
|
"input_sha256": "e063a8ec92a57e1c60daddc1e96a4662275d6526c194e2ffc9428d40eb4ac1dc",
|
||||||
|
"reviewed_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"reviewer": "Synthetic fixture review",
|
||||||
|
"status": "approved"
|
||||||
|
},
|
||||||
|
"schema_version": "1.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Today we discuss how people can find a recording after a webinar.
|
||||||
|
Keep the plain text transcript and the timed VTT file together.
|
||||||
|
A conceptual chunk should cover one topic and preserve the words from its source cues.
|
||||||
|
Each answer needs a transcript citation with start and end times.
|
||||||
|
Check participant permission before sharing a meeting recording or its transcript.
|
||||||
|
An API can retrieve the reviewed JSON without creating embeddings first.
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
WEBVTT
|
||||||
|
|
||||||
|
source-1
|
||||||
|
00:00:00.000 --> 00:00:10.000
|
||||||
|
<v Host>Today we discuss how people can find a recording after a webinar.</v>
|
||||||
|
|
||||||
|
source-2
|
||||||
|
00:00:10.000 --> 00:00:20.000
|
||||||
|
<v Host>Keep the plain text transcript and the timed VTT file together.</v>
|
||||||
|
|
||||||
|
source-3
|
||||||
|
00:00:20.000 --> 00:00:30.000
|
||||||
|
<v Guest>A conceptual chunk should cover one topic and preserve the words from its source cues.</v>
|
||||||
|
|
||||||
|
source-4
|
||||||
|
00:00:30.000 --> 00:00:40.000
|
||||||
|
<v Guest>Each answer needs a transcript citation with start and end times.</v>
|
||||||
|
|
||||||
|
source-5
|
||||||
|
00:00:40.000 --> 00:00:50.000
|
||||||
|
<v Host>Check participant permission before sharing a meeting recording or its transcript.</v>
|
||||||
|
|
||||||
|
source-6
|
||||||
|
00:00:50.000 --> 00:01:00.000
|
||||||
|
<v Host>An API can retrieve the reviewed JSON without creating embeddings first.</v>
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
{
|
||||||
|
"status": "design-only",
|
||||||
|
"description": "Tool definitions for a future MCP adapter; not a server or deployed capability.",
|
||||||
|
"tools": [
|
||||||
|
{
|
||||||
|
"name": "list_media",
|
||||||
|
"description": "List approved public media and their artifact routes.",
|
||||||
|
"inputSchema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {},
|
||||||
|
"required": [],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"readOnlyHint": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "search_media",
|
||||||
|
"description": "Search reviewed transcript chunks and Q&A; return bounded source-cited results.",
|
||||||
|
"inputSchema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"query": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"limit": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1,
|
||||||
|
"maximum": 100,
|
||||||
|
"default": 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"query"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"readOnlyHint": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_media",
|
||||||
|
"description": "Fetch one approved public recording metadata record and artifact routes.",
|
||||||
|
"inputSchema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"media_id"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"readOnlyHint": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_media_chunk",
|
||||||
|
"description": "Fetch one exact conceptual unit with timed transcript citations.",
|
||||||
|
"inputSchema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"chunk_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"media_id",
|
||||||
|
"chunk_id"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"readOnlyHint": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"info": {
|
||||||
|
"title": "Structured Media Read API \u00e2\u20ac\u201d Proposed",
|
||||||
|
"version": "0.2.0",
|
||||||
|
"description": "Design contract only. No deployed API. Adapters serve complete validated public releases."
|
||||||
|
},
|
||||||
|
"x-implementation-status": "design-only",
|
||||||
|
"paths": {
|
||||||
|
"/media": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "list_media",
|
||||||
|
"summary": "List recording metadata and artifact routes",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Approved export data",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "../schemas/ai-index.schema.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Invalid request"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Unknown or withdrawn resource"
|
||||||
|
},
|
||||||
|
"503": {
|
||||||
|
"description": "No validated release available"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/search": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "search_media",
|
||||||
|
"summary": "Search reviewed chunks and Q&A",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "q",
|
||||||
|
"in": "query",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "limit",
|
||||||
|
"in": "query",
|
||||||
|
"required": false,
|
||||||
|
"schema": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1,
|
||||||
|
"maximum": 100,
|
||||||
|
"default": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Approved export data",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"results"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"results": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"media_id",
|
||||||
|
"type",
|
||||||
|
"id",
|
||||||
|
"score",
|
||||||
|
"text",
|
||||||
|
"rights",
|
||||||
|
"citations"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"chunks",
|
||||||
|
"qa"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"score": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"rights": {
|
||||||
|
"$ref": "../schemas/media.schema.json#/properties/rights"
|
||||||
|
},
|
||||||
|
"citations": {
|
||||||
|
"type": "array",
|
||||||
|
"minItems": 1,
|
||||||
|
"items": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"$ref": "../schemas/chunks.schema.json#/properties/chunks/items/properties/citations/items"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "../schemas/qa.schema.json#/properties/qa/items/properties/evidence/items"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Invalid request"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Unknown or withdrawn resource"
|
||||||
|
},
|
||||||
|
"503": {
|
||||||
|
"description": "No validated release available"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/media/{media_id}": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "get_media",
|
||||||
|
"summary": "Fetch one catalog metadata record",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "media_id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Approved export data",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "../schemas/ai-index.schema.json#/properties/items/items"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Invalid request"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Unknown or withdrawn resource"
|
||||||
|
},
|
||||||
|
"503": {
|
||||||
|
"description": "No validated release available"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/media/{media_id}/chunks/{chunk_id}": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "get_media_chunk",
|
||||||
|
"summary": "Fetch a conceptual chunk with cited transcript evidence",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "media_id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "chunk_id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Approved export data",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "../schemas/chunks.schema.json#/properties/chunks/items"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Invalid request"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Unknown or withdrawn resource"
|
||||||
|
},
|
||||||
|
"503": {
|
||||||
|
"description": "No validated release available"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"identity": {
|
||||||
|
"owner": {
|
||||||
|
"name": "Eddie Soehnel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"publication": {
|
||||||
|
"companion_site_url": null,
|
||||||
|
"media_host": null,
|
||||||
|
"status": "local-draft"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"canonical_url": "https://projects.eddiesoehnel.com/adminprojects/structured-media-builder-OPEN",
|
||||||
|
"name": "structured-media-builder-OPEN",
|
||||||
|
"repository_id": "adminprojects-structured-media-builder-open"
|
||||||
|
},
|
||||||
|
"repository_profile": "software-template-workflow",
|
||||||
|
"rights": {
|
||||||
|
"license": null,
|
||||||
|
"license_status": "not-selected",
|
||||||
|
"notice_file": "LICENSE.md"
|
||||||
|
},
|
||||||
|
"schema_version": "1.0",
|
||||||
|
"updated_at": "2026-10-17",
|
||||||
|
"verified_from": "User-specified target and guide repository identity; local target Git config.",
|
||||||
|
"version": "0.2.0"
|
||||||
|
}
|
||||||
+228
@@ -0,0 +1,228 @@
|
|||||||
|
{
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Eddie Soehnel"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"canonical_url": "https://projects.eddiesoehnel.com/adminprojects/structured-media-builder-OPEN",
|
||||||
|
"contents": [
|
||||||
|
{
|
||||||
|
"path": "README.md",
|
||||||
|
"title": "Overview and quick start",
|
||||||
|
"type": "documentation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "AGENTS.md",
|
||||||
|
"title": "Repository operating instructions",
|
||||||
|
"type": "agent-guidance"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "docs/workflow.md",
|
||||||
|
"title": "Recording-to-discovery process",
|
||||||
|
"type": "workflow"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "docs/architecture.md",
|
||||||
|
"title": "Sources, contracts, and capability boundaries",
|
||||||
|
"type": "documentation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "docs/research.md",
|
||||||
|
"title": "Standards and platform research",
|
||||||
|
"type": "research"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "docs/interfaces.md",
|
||||||
|
"title": "Proposed API and MCP adapters",
|
||||||
|
"type": "design"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "PUBLICATION_WORKFLOW.md",
|
||||||
|
"title": "Publication approval and verification",
|
||||||
|
"type": "workflow"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "scripts/media_builder.py",
|
||||||
|
"title": "Deterministic builder and retrieval CLI",
|
||||||
|
"type": "software"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "schemas/",
|
||||||
|
"title": "Source and export JSON schemas",
|
||||||
|
"type": "schema-collection"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "templates/",
|
||||||
|
"title": "Blocked-by-default starter inputs",
|
||||||
|
"type": "template-collection"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "examples/",
|
||||||
|
"title": "Synthetic audio and video fixtures",
|
||||||
|
"type": "example-collection"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "skills.md",
|
||||||
|
"title": "Repo-local skill index",
|
||||||
|
"type": "skill-index"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "skills/structure-media/SKILL.md",
|
||||||
|
"title": "Media structuring workflow",
|
||||||
|
"type": "skill"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "tests/test_media_builder.py",
|
||||||
|
"title": "Pipeline regression coverage",
|
||||||
|
"type": "test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "interfaces/openapi.json",
|
||||||
|
"title": "Proposed read-only HTTP API",
|
||||||
|
"type": "design-contract"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "interfaces/mcp-tools.json",
|
||||||
|
"title": "Proposed read-only MCP tools",
|
||||||
|
"type": "design-contract"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "requirements.txt",
|
||||||
|
"title": "Python dependency range",
|
||||||
|
"type": "configuration"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "LICENSE.md",
|
||||||
|
"title": "License selection pending",
|
||||||
|
"type": "rights-status"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "CHANGELOG.md",
|
||||||
|
"title": "Completed versioned changes",
|
||||||
|
"type": "changelog"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "UPDATES.md",
|
||||||
|
"title": "Proposed additions",
|
||||||
|
"type": "roadmap"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "skills/media-intake/SKILL.md",
|
||||||
|
"title": "Upfront metadata interview",
|
||||||
|
"type": "skill"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "scripts/folder_builder.py",
|
||||||
|
"title": "Folder-first draft builder",
|
||||||
|
"type": "software"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "templates/media-intake.md",
|
||||||
|
"title": "Copyable human metadata checklist",
|
||||||
|
"type": "template"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "docs/public-export.md",
|
||||||
|
"title": "Later approved public exporter",
|
||||||
|
"type": "workflow"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "tests/test_folder_builder.py",
|
||||||
|
"title": "Folder-first regression coverage",
|
||||||
|
"type": "test"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"created_at": "2026-10-17",
|
||||||
|
"description": "Folder-first media intake, semantic structuring, and in-folder draft assets for human review, with an optional approved public exporter.",
|
||||||
|
"entrypoints": {
|
||||||
|
"ai": "AGENTS.md",
|
||||||
|
"human": "README.md",
|
||||||
|
"primary_script": "scripts/folder_builder.py",
|
||||||
|
"primary_skill": "skills/media-intake/SKILL.md",
|
||||||
|
"primary_template": "templates/media-intake.md"
|
||||||
|
},
|
||||||
|
"expected_outputs": [
|
||||||
|
"In-folder draft overview and review checklist",
|
||||||
|
"Static companion site",
|
||||||
|
"Timed transcript JSON",
|
||||||
|
"Chunks and Q&A JSON",
|
||||||
|
"Chapter JSON",
|
||||||
|
"Discovery files",
|
||||||
|
"Build receipt"
|
||||||
|
],
|
||||||
|
"implemented_capabilities": [
|
||||||
|
"Folder-based metadata intake and interview",
|
||||||
|
"Local draft assets before human review",
|
||||||
|
"Source-preserving transcript alignment and audit",
|
||||||
|
"Timed semantic chunks and cited Q&A",
|
||||||
|
"Chapter and known-fact JSON-LD export",
|
||||||
|
"Local keyword retrieval",
|
||||||
|
"Optional approved static public exporter"
|
||||||
|
],
|
||||||
|
"interfaces": {
|
||||||
|
"mcp_tools": "interfaces/mcp-tools.json",
|
||||||
|
"openapi": "interfaces/openapi.json",
|
||||||
|
"status": "design-only"
|
||||||
|
},
|
||||||
|
"license": null,
|
||||||
|
"license_status": "not-selected",
|
||||||
|
"maturity": "experimental",
|
||||||
|
"name": "structured-media-builder-OPEN",
|
||||||
|
"not_implemented": [
|
||||||
|
"STT integrations",
|
||||||
|
"Hosted API",
|
||||||
|
"MCP server",
|
||||||
|
"Embeddings",
|
||||||
|
"Platform sync",
|
||||||
|
"Deployment",
|
||||||
|
"Independent fact or consent verification"
|
||||||
|
],
|
||||||
|
"publication_status": "local-draft",
|
||||||
|
"related_repositories": [
|
||||||
|
{
|
||||||
|
"relationship": "conceptual-guidance",
|
||||||
|
"url": "https://projects.eddiesoehnel.com/adminprojects/ai-knowledge-structure-OPEN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"relationship": "implementation-pattern",
|
||||||
|
"url": "https://projects.eddiesoehnel.com/adminprojects/structured-website-builder-OPEN"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"repository_id": "adminprojects-structured-media-builder-open",
|
||||||
|
"repository_status": "active",
|
||||||
|
"required_inputs": [
|
||||||
|
"Original audio/video plus TXT and VTT in a folder",
|
||||||
|
"Partial metadata or source-page links",
|
||||||
|
"AI-authored draft intake and semantic plan"
|
||||||
|
],
|
||||||
|
"resource_types": [
|
||||||
|
"software",
|
||||||
|
"template",
|
||||||
|
"workflow",
|
||||||
|
"skill",
|
||||||
|
"documentation"
|
||||||
|
],
|
||||||
|
"runtime": {
|
||||||
|
"dependencies": "requirements.txt",
|
||||||
|
"network_calls": false,
|
||||||
|
"python": ">=3.11"
|
||||||
|
},
|
||||||
|
"schema_version": "1.0",
|
||||||
|
"title": "Structured Media Builder",
|
||||||
|
"topics": [
|
||||||
|
"media-discovery",
|
||||||
|
"audio",
|
||||||
|
"video",
|
||||||
|
"transcripts",
|
||||||
|
"structured-data",
|
||||||
|
"ai-retrieval"
|
||||||
|
],
|
||||||
|
"updated_at": "2026-10-17",
|
||||||
|
"validation": {
|
||||||
|
"example_build": "python scripts/media_builder.py build --catalog examples/catalog.json --output build/demo",
|
||||||
|
"folder_inspect": "python scripts/folder_builder.py inspect --folder <media-folder>",
|
||||||
|
"tests": "python -m unittest discover -s tests -v",
|
||||||
|
"verify": "python scripts/media_builder.py verify --root build/demo"
|
||||||
|
},
|
||||||
|
"version": "0.2.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
jsonschema>=4.23,<5
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Schema contracts
|
||||||
|
|
||||||
|
JSON Schema Draft 2020-12. The builder uses `jsonschema` with format checks and additional cross-file validation. Schemas are authoritative field contracts; edit and test them with the builder when adding capabilities.
|
||||||
|
|
||||||
|
| Schema | Validates |
|
||||||
|
| --- | --- |
|
||||||
|
| [intake](intake.schema.json) | Folder interview, selected sources, provenance, unknowns |
|
||||||
|
| [folder-export](folder-export.schema.json) | Local draft transcript, chunks, Q&A, and routing |
|
||||||
|
| [media](media.schema.json) | Source recording manifest |
|
||||||
|
| [plan](plan.schema.json) | Authored semantic plan and review record |
|
||||||
|
| [catalog](catalog.schema.json) | Collection release inputs |
|
||||||
|
| [transcript](transcript.schema.json) | Normalized timed cue export |
|
||||||
|
| [chunks](chunks.schema.json) | Semantic chunk export with citations |
|
||||||
|
| [qa](qa.schema.json) | Grounded Q&A export |
|
||||||
|
| [ai-index](ai-index.schema.json) | Collection discovery catalog |
|
||||||
|
|
||||||
|
`chapters.json` follows the external Podcast Namespace chapter format; `schema.jsonld` follows Schema.org. They are not covered by proprietary lookalike schemas here. External rich-result eligibility and public playback require separate published-site validation.
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"title": "Structured Media Builder: ai-index",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"site_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"kind": {
|
||||||
|
"enum": [
|
||||||
|
"audio",
|
||||||
|
"video"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"language": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"synthetic": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"canonical_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"rights": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"statement": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"usage_info": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"redistribution_allowed": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"statement",
|
||||||
|
"license",
|
||||||
|
"usage_info",
|
||||||
|
"redistribution_allowed"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"artifacts": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"media.json": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"transcript.txt": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"transcript.vtt": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"transcript.json": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"chunks.json": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"qa.json": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"chapters.json": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"schema.jsonld": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"media.json",
|
||||||
|
"transcript.txt",
|
||||||
|
"transcript.vtt",
|
||||||
|
"transcript.json",
|
||||||
|
"chunks.json",
|
||||||
|
"qa.json",
|
||||||
|
"chapters.json",
|
||||||
|
"schema.jsonld"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"media_id",
|
||||||
|
"title",
|
||||||
|
"description",
|
||||||
|
"kind",
|
||||||
|
"language",
|
||||||
|
"synthetic",
|
||||||
|
"canonical_url",
|
||||||
|
"updated_at",
|
||||||
|
"rights",
|
||||||
|
"artifacts"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"site_url",
|
||||||
|
"items"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"title": "Structured Media Builder: catalog",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"site_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"allow_synthetic": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"manifest": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"plan": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"manifest",
|
||||||
|
"plan"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"title",
|
||||||
|
"site_url",
|
||||||
|
"allow_synthetic",
|
||||||
|
"items"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,240 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"title": "Structured Media Builder: chunks",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"canonical_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"language": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"rights": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"statement": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"usage_info": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"redistribution_allowed": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"statement",
|
||||||
|
"license",
|
||||||
|
"usage_info",
|
||||||
|
"redistribution_allowed"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"input_sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-f0-9]{64}$"
|
||||||
|
},
|
||||||
|
"chunks": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"chunk_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"knowledge_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
|
"supersedes": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"heading_path": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
},
|
||||||
|
"summary": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"tags": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
},
|
||||||
|
"cue_ids": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"minItems": 1,
|
||||||
|
"uniqueItems": true
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"order": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"start_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"end_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"speakers": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
},
|
||||||
|
"citations": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"cue_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"start_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"end_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"transcript_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"playback_url": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"media_id",
|
||||||
|
"cue_id",
|
||||||
|
"start_seconds",
|
||||||
|
"end_seconds",
|
||||||
|
"transcript_url",
|
||||||
|
"playback_url"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"chunk_id",
|
||||||
|
"knowledge_id",
|
||||||
|
"version",
|
||||||
|
"supersedes",
|
||||||
|
"title",
|
||||||
|
"heading_path",
|
||||||
|
"summary",
|
||||||
|
"tags",
|
||||||
|
"cue_ids",
|
||||||
|
"media_id",
|
||||||
|
"order",
|
||||||
|
"content",
|
||||||
|
"start_seconds",
|
||||||
|
"end_seconds",
|
||||||
|
"speakers",
|
||||||
|
"citations"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"media_id",
|
||||||
|
"canonical_url",
|
||||||
|
"language",
|
||||||
|
"rights",
|
||||||
|
"input_sha256",
|
||||||
|
"chunks"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,567 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"title": "Local review folder exports",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"const": "local-review"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"const": "draft"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"input_sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-f0-9]{64}$"
|
||||||
|
},
|
||||||
|
"canonical_url": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"artifact_type": {
|
||||||
|
"const": "transcript"
|
||||||
|
},
|
||||||
|
"cues": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"cue_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"source_cue_id": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"start_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"end_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"speaker": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"cue_id",
|
||||||
|
"source_cue_id",
|
||||||
|
"start_seconds",
|
||||||
|
"end_seconds",
|
||||||
|
"speaker",
|
||||||
|
"text"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"excluded_cue_ids": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"profile",
|
||||||
|
"status",
|
||||||
|
"media_id",
|
||||||
|
"title",
|
||||||
|
"input_sha256",
|
||||||
|
"canonical_url",
|
||||||
|
"artifact_type",
|
||||||
|
"cues",
|
||||||
|
"excluded_cue_ids"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"const": "local-review"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"const": "draft"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"input_sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-f0-9]{64}$"
|
||||||
|
},
|
||||||
|
"canonical_url": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"artifact_type": {
|
||||||
|
"const": "chunks"
|
||||||
|
},
|
||||||
|
"chunks": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"chunk_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"knowledge_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
|
"supersedes": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"heading_path": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
},
|
||||||
|
"summary": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"tags": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
},
|
||||||
|
"cue_ids": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"minItems": 1,
|
||||||
|
"uniqueItems": true
|
||||||
|
},
|
||||||
|
"order": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"content_sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-f0-9]{64}$"
|
||||||
|
},
|
||||||
|
"start_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"end_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"speakers": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"citations": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"cue_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"start_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"end_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"transcript_ref": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"transcript_url": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"source_media": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"playback_url": {
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"media_id",
|
||||||
|
"cue_id",
|
||||||
|
"start_seconds",
|
||||||
|
"end_seconds",
|
||||||
|
"transcript_ref",
|
||||||
|
"transcript_url",
|
||||||
|
"source_media",
|
||||||
|
"playback_url"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"chunk_id",
|
||||||
|
"knowledge_id",
|
||||||
|
"version",
|
||||||
|
"supersedes",
|
||||||
|
"title",
|
||||||
|
"heading_path",
|
||||||
|
"summary",
|
||||||
|
"tags",
|
||||||
|
"cue_ids",
|
||||||
|
"order",
|
||||||
|
"media_id",
|
||||||
|
"content",
|
||||||
|
"content_sha256",
|
||||||
|
"start_seconds",
|
||||||
|
"end_seconds",
|
||||||
|
"speakers",
|
||||||
|
"citations"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"profile",
|
||||||
|
"status",
|
||||||
|
"media_id",
|
||||||
|
"title",
|
||||||
|
"input_sha256",
|
||||||
|
"canonical_url",
|
||||||
|
"artifact_type",
|
||||||
|
"chunks"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"const": "local-review"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"const": "draft"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"input_sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-f0-9]{64}$"
|
||||||
|
},
|
||||||
|
"canonical_url": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"artifact_type": {
|
||||||
|
"const": "qa"
|
||||||
|
},
|
||||||
|
"qa": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"qa_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"question": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"answer": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"answer_type": {
|
||||||
|
"enum": [
|
||||||
|
"extractive",
|
||||||
|
"synthesis"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"evidence": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"chunk_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"cue_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"quote": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"start_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"end_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"transcript_ref": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"transcript_url": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"source_media": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"playback_url": {
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"chunk_id",
|
||||||
|
"cue_id",
|
||||||
|
"quote",
|
||||||
|
"media_id",
|
||||||
|
"start_seconds",
|
||||||
|
"end_seconds",
|
||||||
|
"transcript_ref",
|
||||||
|
"transcript_url",
|
||||||
|
"source_media",
|
||||||
|
"playback_url"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"qa_id",
|
||||||
|
"question",
|
||||||
|
"answer",
|
||||||
|
"answer_type",
|
||||||
|
"evidence",
|
||||||
|
"media_id"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"profile",
|
||||||
|
"status",
|
||||||
|
"media_id",
|
||||||
|
"title",
|
||||||
|
"input_sha256",
|
||||||
|
"canonical_url",
|
||||||
|
"artifact_type",
|
||||||
|
"qa"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"const": "local-review"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"const": "draft"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"input_sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-f0-9]{64}$"
|
||||||
|
},
|
||||||
|
"canonical_url": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"artifact_type": {
|
||||||
|
"const": "index"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"artifacts": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"media.json": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"transcript.json": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"chunks.json": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"qa.json": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"chapters.json": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"schema.jsonld": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"README.md": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"review.md": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"media.json",
|
||||||
|
"transcript.json",
|
||||||
|
"chunks.json",
|
||||||
|
"qa.json",
|
||||||
|
"chapters.json",
|
||||||
|
"schema.jsonld",
|
||||||
|
"README.md",
|
||||||
|
"review.md"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"profile",
|
||||||
|
"status",
|
||||||
|
"media_id",
|
||||||
|
"title",
|
||||||
|
"input_sha256",
|
||||||
|
"canonical_url",
|
||||||
|
"artifact_type",
|
||||||
|
"description",
|
||||||
|
"artifacts"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,361 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"title": "Media folder intake",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"source_files": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"media": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"txt": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"vtt": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"media",
|
||||||
|
"txt",
|
||||||
|
"vtt"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"title": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"recording_date": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"recording_timezone": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"organizer": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"series": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"session_type": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"language": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"attribution": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rights_statement": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"sharing_notes": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"stt_tool": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"stt_model": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"publication_date": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"title"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"participants": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"role": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"affiliation": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"enum": [
|
||||||
|
"user-confirmed",
|
||||||
|
"transcript-unverified",
|
||||||
|
"web-page-confirmed"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"evidence_cue_ids": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"role",
|
||||||
|
"affiliation",
|
||||||
|
"status",
|
||||||
|
"evidence_cue_ids"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"audience": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"topics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"priority_questions": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"urls": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"original": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"canonical": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"slides": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"original",
|
||||||
|
"canonical",
|
||||||
|
"content",
|
||||||
|
"slides"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"related_links": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"label": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"label",
|
||||||
|
"url"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"field_sources": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"source": {
|
||||||
|
"enum": [
|
||||||
|
"user",
|
||||||
|
"file",
|
||||||
|
"transcript",
|
||||||
|
"web-page",
|
||||||
|
"assistant-draft",
|
||||||
|
"unknown"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"evidence": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"source",
|
||||||
|
"evidence"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unknowns": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"quality_notes": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"excluded_cue_ids": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"uniqueItems": true
|
||||||
|
},
|
||||||
|
"interview": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"status": {
|
||||||
|
"enum": [
|
||||||
|
"pending",
|
||||||
|
"partial",
|
||||||
|
"complete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"questions_asked": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notes": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"status",
|
||||||
|
"questions_asked",
|
||||||
|
"notes"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"media_id",
|
||||||
|
"source_files",
|
||||||
|
"metadata",
|
||||||
|
"participants",
|
||||||
|
"audience",
|
||||||
|
"topics",
|
||||||
|
"priority_questions",
|
||||||
|
"urls",
|
||||||
|
"related_links",
|
||||||
|
"field_sources",
|
||||||
|
"unknowns",
|
||||||
|
"quality_notes",
|
||||||
|
"excluded_cue_ids",
|
||||||
|
"interview"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,273 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"title": "Structured Media Builder: media",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"kind": {
|
||||||
|
"enum": [
|
||||||
|
"video",
|
||||||
|
"audio"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"language": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z]{2,8}(?:-[a-zA-Z0-9]{1,8})*$"
|
||||||
|
},
|
||||||
|
"canonical_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"content_url": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"embed_url": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"thumbnail_url": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"duration_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"recorded_at": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"published_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"synthetic": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"creators": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"role": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"role"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
},
|
||||||
|
"transcripts": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"txt": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"vtt": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"txt",
|
||||||
|
"vtt"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"transcription": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"method": {
|
||||||
|
"enum": [
|
||||||
|
"stt",
|
||||||
|
"human",
|
||||||
|
"synthetic"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"engine": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"model": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generated_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"reviewed_by": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"visual_coverage": {
|
||||||
|
"enum": [
|
||||||
|
"not-assessed",
|
||||||
|
"audio-only",
|
||||||
|
"reviewed-separately"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"method",
|
||||||
|
"engine",
|
||||||
|
"model",
|
||||||
|
"generated_at",
|
||||||
|
"reviewed_by",
|
||||||
|
"visual_coverage"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"rights": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"statement": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"usage_info": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"redistribution_allowed": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"statement",
|
||||||
|
"license",
|
||||||
|
"usage_info",
|
||||||
|
"redistribution_allowed"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"publication": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"consent": {
|
||||||
|
"enum": [
|
||||||
|
"pending",
|
||||||
|
"cleared"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"privacy_review": {
|
||||||
|
"enum": [
|
||||||
|
"pending",
|
||||||
|
"cleared"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"consent",
|
||||||
|
"privacy_review"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"media_id",
|
||||||
|
"kind",
|
||||||
|
"title",
|
||||||
|
"description",
|
||||||
|
"language",
|
||||||
|
"canonical_url",
|
||||||
|
"content_url",
|
||||||
|
"embed_url",
|
||||||
|
"thumbnail_url",
|
||||||
|
"duration_seconds",
|
||||||
|
"recorded_at",
|
||||||
|
"published_at",
|
||||||
|
"updated_at",
|
||||||
|
"synthetic",
|
||||||
|
"creators",
|
||||||
|
"transcripts",
|
||||||
|
"transcription",
|
||||||
|
"rights",
|
||||||
|
"publication"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,234 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"title": "Structured Media Builder: plan",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"chunks": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"chunk_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"knowledge_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
|
"supersedes": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"heading_path": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
},
|
||||||
|
"summary": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"tags": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
},
|
||||||
|
"cue_ids": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"minItems": 1,
|
||||||
|
"uniqueItems": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"chunk_id",
|
||||||
|
"knowledge_id",
|
||||||
|
"version",
|
||||||
|
"supersedes",
|
||||||
|
"title",
|
||||||
|
"heading_path",
|
||||||
|
"summary",
|
||||||
|
"tags",
|
||||||
|
"cue_ids"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
},
|
||||||
|
"qa": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"qa_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"question": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"answer": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"answer_type": {
|
||||||
|
"enum": [
|
||||||
|
"extractive",
|
||||||
|
"synthesis"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"evidence": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"chunk_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"cue_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"quote": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"chunk_id",
|
||||||
|
"cue_id",
|
||||||
|
"quote"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"qa_id",
|
||||||
|
"question",
|
||||||
|
"answer",
|
||||||
|
"answer_type",
|
||||||
|
"evidence"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
},
|
||||||
|
"chapters": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"chapter_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"start_cue_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"end_cue_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"chapter_id",
|
||||||
|
"title",
|
||||||
|
"start_cue_id",
|
||||||
|
"end_cue_id"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
},
|
||||||
|
"review": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"status": {
|
||||||
|
"enum": [
|
||||||
|
"draft",
|
||||||
|
"approved"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reviewer": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"reviewed_at": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"input_sha256": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-f0-9]{64}$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"status",
|
||||||
|
"reviewer",
|
||||||
|
"reviewed_at",
|
||||||
|
"input_sha256"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"media_id",
|
||||||
|
"chunks",
|
||||||
|
"qa",
|
||||||
|
"chapters",
|
||||||
|
"review"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"title": "Structured Media Builder: qa",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"canonical_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"language": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"rights": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"statement": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"usage_info": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"redistribution_allowed": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"statement",
|
||||||
|
"license",
|
||||||
|
"usage_info",
|
||||||
|
"redistribution_allowed"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"input_sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-f0-9]{64}$"
|
||||||
|
},
|
||||||
|
"qa": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"qa_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"question": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"answer": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"answer_type": {
|
||||||
|
"enum": [
|
||||||
|
"extractive",
|
||||||
|
"synthesis"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"evidence": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"chunk_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9:._-]*$"
|
||||||
|
},
|
||||||
|
"cue_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"quote": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"start_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"end_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"transcript_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"playback_url": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"chunk_id",
|
||||||
|
"cue_id",
|
||||||
|
"quote",
|
||||||
|
"media_id",
|
||||||
|
"start_seconds",
|
||||||
|
"end_seconds",
|
||||||
|
"transcript_url",
|
||||||
|
"playback_url"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"qa_id",
|
||||||
|
"question",
|
||||||
|
"answer",
|
||||||
|
"answer_type",
|
||||||
|
"evidence",
|
||||||
|
"media_id"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"media_id",
|
||||||
|
"canonical_url",
|
||||||
|
"language",
|
||||||
|
"rights",
|
||||||
|
"input_sha256",
|
||||||
|
"qa"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"title": "Structured Media Builder: transcript",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"schema_version": {
|
||||||
|
"const": "1.0"
|
||||||
|
},
|
||||||
|
"media_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
|
||||||
|
},
|
||||||
|
"canonical_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
"language": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"rights": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"statement": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"usage_info": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^https://"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"redistribution_allowed": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"statement",
|
||||||
|
"license",
|
||||||
|
"usage_info",
|
||||||
|
"redistribution_allowed"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"input_sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-f0-9]{64}$"
|
||||||
|
},
|
||||||
|
"cues": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"cue_id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^cue-[0-9]{6}$"
|
||||||
|
},
|
||||||
|
"source_cue_id": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"start_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
"end_seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"speaker": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"cue_id",
|
||||||
|
"source_cue_id",
|
||||||
|
"start_seconds",
|
||||||
|
"end_seconds",
|
||||||
|
"speaker",
|
||||||
|
"text"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"schema_version",
|
||||||
|
"media_id",
|
||||||
|
"canonical_url",
|
||||||
|
"language",
|
||||||
|
"rights",
|
||||||
|
"input_sha256",
|
||||||
|
"cues"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
"""Check repository JSON, document links, manifest paths, and local schema references."""
|
||||||
|
import ast
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
from urllib.parse import unquote
|
||||||
|
|
||||||
|
from jsonschema import Draft202012Validator
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
SKIP = {'build', '.git', '__pycache__', '.test-work', '.venv'}
|
||||||
|
|
||||||
|
|
||||||
|
def check():
|
||||||
|
files = [p for p in ROOT.rglob('*') if p.is_file() and not (set(p.relative_to(ROOT).parts) & SKIP)]
|
||||||
|
count = {'json': 0, 'markdown_links': 0, 'schema_refs': 0, 'python': 0}
|
||||||
|
errors = []
|
||||||
|
def local_ref(base, ref):
|
||||||
|
filename, _, pointer = ref.partition('#')
|
||||||
|
path = (base.parent / filename).resolve() if filename else base
|
||||||
|
assert path.is_relative_to(ROOT) and path.is_file(), f'Missing/outside reference {ref}'
|
||||||
|
doc = json.loads(path.read_text(encoding='utf-8-sig'))
|
||||||
|
for key in pointer.lstrip('/').split('/') if pointer else []:
|
||||||
|
key = unquote(key).replace('~1', '/').replace('~0', '~')
|
||||||
|
doc = doc[int(key)] if isinstance(doc, list) else doc[key]
|
||||||
|
def walk_refs(value, base):
|
||||||
|
if isinstance(value, dict):
|
||||||
|
for key, item in value.items():
|
||||||
|
if key == '$ref' and not item.startswith(('https:', 'http:')):
|
||||||
|
local_ref(base, item)
|
||||||
|
count['schema_refs'] += 1
|
||||||
|
else:
|
||||||
|
walk_refs(item, base)
|
||||||
|
elif isinstance(value, list):
|
||||||
|
for item in value:
|
||||||
|
walk_refs(item, base)
|
||||||
|
for path in files:
|
||||||
|
try:
|
||||||
|
if path.suffix in {'.md', '.py', '.json', '.txt', '.vtt'} or path.name in {'.gitignore', '.gitattributes', 'VERSION'}:
|
||||||
|
text = path.read_text(encoding='utf-8-sig')
|
||||||
|
assert all(line == line.rstrip(' \t') for line in text.splitlines()), 'Trailing whitespace'
|
||||||
|
assert not re.search(r'-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|AKIA[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9]{30,}', text), 'Potential credential pattern'
|
||||||
|
if path.suffix == '.json':
|
||||||
|
value = json.loads(path.read_text(encoding='utf-8-sig'))
|
||||||
|
count['json'] += 1
|
||||||
|
walk_refs(value, path)
|
||||||
|
if path.name.endswith('.schema.json'):
|
||||||
|
Draft202012Validator.check_schema(value)
|
||||||
|
elif path.suffix == '.py':
|
||||||
|
ast.parse(path.read_text(encoding='utf-8'), filename=str(path))
|
||||||
|
count['python'] += 1
|
||||||
|
elif path.suffix == '.md':
|
||||||
|
for target in re.findall(r'\[[^\]]*\]\(([^)]+)\)', path.read_text(encoding='utf-8')):
|
||||||
|
if target.startswith(('http:', 'https:', '#', 'mailto:')):
|
||||||
|
continue
|
||||||
|
linked = (path.parent / unquote(target.split('#')[0])).resolve()
|
||||||
|
assert linked.is_relative_to(ROOT) and linked.exists(), f'Missing local link {target}'
|
||||||
|
count['markdown_links'] += 1
|
||||||
|
except Exception as error:
|
||||||
|
errors.append(f'{path.relative_to(ROOT)}: {error}')
|
||||||
|
manifest = json.loads((ROOT/'repository.json').read_text(encoding='utf-8'))
|
||||||
|
for name in list(manifest['entrypoints'].values()) + [v['path'] for v in manifest['contents']]:
|
||||||
|
if not (ROOT/name).exists():
|
||||||
|
errors.append('Missing manifest path: ' + name)
|
||||||
|
if errors:
|
||||||
|
raise ValueError('\n'.join(errors))
|
||||||
|
print(json.dumps({'valid': True, **count}, indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
check()
|
||||||
@@ -0,0 +1,391 @@
|
|||||||
|
"""Inspect media folders and build in-folder draft assets before human review."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import difflib
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
from pathlib import Path
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
|
import media_builder as core
|
||||||
|
|
||||||
|
MEDIA_EXTENSIONS = {'.mp3', '.wav', '.m4a', '.flac', '.ogg', '.mp4', '.mov', '.mkv', '.webm', '.aac'}
|
||||||
|
VERSION = (core.ROOT / 'VERSION').read_text(encoding='utf-8').strip()
|
||||||
|
|
||||||
|
|
||||||
|
def sha_file(path):
|
||||||
|
import hashlib
|
||||||
|
h = hashlib.sha256()
|
||||||
|
with path.open('rb') as f:
|
||||||
|
for block in iter(lambda: f.read(1024 * 1024), b''):
|
||||||
|
h.update(block)
|
||||||
|
return h.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def mp3_duration(path):
|
||||||
|
"""Read MPEG frame timing; return unknown for unsupported/corrupt streams."""
|
||||||
|
if path.suffix.lower() != '.mp3':
|
||||||
|
return None
|
||||||
|
data = path.read_bytes()
|
||||||
|
pos = 0
|
||||||
|
if data[:3] == b'ID3' and len(data) >= 10:
|
||||||
|
pos = 10 + sum((b & 127) << shift for b, shift in zip(data[6:10], (21, 14, 7, 0)))
|
||||||
|
if data[5] & 16:
|
||||||
|
pos += 10
|
||||||
|
total = 0.0
|
||||||
|
frames = 0
|
||||||
|
rates1 = [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320]
|
||||||
|
rates2 = [0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160]
|
||||||
|
while pos + 4 <= len(data):
|
||||||
|
if data[pos:pos+3] in (b'TAG', b'APE'):
|
||||||
|
break
|
||||||
|
header = int.from_bytes(data[pos:pos+4], 'big')
|
||||||
|
if header >> 21 != 2047:
|
||||||
|
# Allow padding after the final frame, but never scan past corrupt audio.
|
||||||
|
if frames and not any(data[pos:]):
|
||||||
|
break
|
||||||
|
return None
|
||||||
|
version, layer = (header >> 19) & 3, (header >> 17) & 3
|
||||||
|
rate_index, sample_index = (header >> 12) & 15, (header >> 10) & 3
|
||||||
|
if version == 1 or layer != 1 or rate_index in (0, 15) or sample_index == 3:
|
||||||
|
return None
|
||||||
|
sample = [44100, 48000, 32000][sample_index] / (1 if version == 3 else 2 if version == 2 else 4)
|
||||||
|
bitrate = (rates1 if version == 3 else rates2)[rate_index] * 1000
|
||||||
|
length = int((144 if version == 3 else 72) * bitrate / sample) + ((header >> 9) & 1)
|
||||||
|
if pos + length > len(data):
|
||||||
|
return None
|
||||||
|
total += (1152 if version == 3 else 576) / sample
|
||||||
|
pos += length
|
||||||
|
frames += 1
|
||||||
|
return round(total, 3) if frames else None
|
||||||
|
|
||||||
|
|
||||||
|
def source_paths(folder, source_files=None):
|
||||||
|
folder = Path(folder).resolve()
|
||||||
|
core.require(folder.is_dir(), 'Media folder does not exist')
|
||||||
|
if source_files:
|
||||||
|
paths = {key: core.relative_file(folder, name) for key, name in source_files.items()}
|
||||||
|
else:
|
||||||
|
paths = {}
|
||||||
|
for key, extensions in [('media', MEDIA_EXTENSIONS), ('txt', {'.txt'}), ('vtt', {'.vtt'})]:
|
||||||
|
matches = [p for p in folder.iterdir() if p.is_file() and p.suffix.lower() in extensions]
|
||||||
|
core.require(len(matches) == 1, f'Expected one {key} file; choose source_files explicitly when ambiguous')
|
||||||
|
paths[key] = matches[0]
|
||||||
|
core.require(len(set(paths.values())) == 3, 'Media, TXT, and VTT must be distinct files')
|
||||||
|
core.require(paths['media'].suffix.lower() in MEDIA_EXTENSIONS, 'Unsupported media extension')
|
||||||
|
core.require(paths['txt'].suffix.lower() == '.txt' and paths['vtt'].suffix.lower() == '.vtt', 'Expected TXT and VTT sources')
|
||||||
|
return folder, paths
|
||||||
|
|
||||||
|
|
||||||
|
def inspect(folder, source_files=None):
|
||||||
|
folder, paths = source_paths(folder, source_files)
|
||||||
|
raw_vtt = paths['vtt'].read_text(encoding='utf-8-sig')
|
||||||
|
timestamps = re.findall(r'-->\s*(\S+)', raw_vtt)
|
||||||
|
core.require(timestamps, 'No VTT timing found')
|
||||||
|
end = max(core.seconds(t) for t in timestamps)
|
||||||
|
cues = core.parse_vtt(raw_vtt, end)
|
||||||
|
a = ' '.join(c['text'] for c in cues)
|
||||||
|
b = ' '.join(paths['txt'].read_text(encoding='utf-8-sig').split())
|
||||||
|
duration = mp3_duration(paths['media'])
|
||||||
|
core.require(duration is None or end <= duration + 0.1,
|
||||||
|
'Transcript extends beyond measured MPEG audio duration')
|
||||||
|
files = {key: {'path': p.relative_to(folder).as_posix(), 'bytes': p.stat().st_size,
|
||||||
|
'sha256': sha_file(p)} for key, p in paths.items()}
|
||||||
|
result = {'source_files': files, 'cue_count': len(cues), 'word_count': len(a.split()),
|
||||||
|
'transcript_end_seconds': end, 'media_duration_seconds': duration,
|
||||||
|
'duration_method': 'MPEG frame scan (encoded duration; encoder padding may apply)' if duration else 'unknown',
|
||||||
|
'txt_vtt_match': a == b, 'speaker_labels_present': any(c['speaker'] for c in cues),
|
||||||
|
'notes': []}
|
||||||
|
if a != b:
|
||||||
|
result['notes'].append('TXT and VTT differ. Draft uses timed VTT text; reconcile before publication.')
|
||||||
|
result['text_difference_sample'] = list(difflib.unified_diff(b.split(), a.split(), n=4))[:50]
|
||||||
|
if not result['speaker_labels_present']:
|
||||||
|
result['notes'].append('No VTT speaker labels. Do not infer cue-level speaker identity.')
|
||||||
|
return result, cues
|
||||||
|
|
||||||
|
|
||||||
|
def prepare(folder, output):
|
||||||
|
path = Path(output)
|
||||||
|
core.require(not path.exists(), 'Intake exists; preserve existing answers')
|
||||||
|
audit, _ = inspect(folder)
|
||||||
|
slug = re.sub(r'[^a-z0-9]+', '-', Path(folder).name.lower()).strip('-')
|
||||||
|
metadata = {key: None for key in ('title', 'recording_date', 'recording_timezone', 'organizer',
|
||||||
|
'series', 'session_type', 'description', 'language', 'attribution', 'rights_statement',
|
||||||
|
'license', 'sharing_notes', 'stt_tool', 'stt_model')}
|
||||||
|
value = {'schema_version': '1.0', 'media_id': slug,
|
||||||
|
'source_files': {k: v['path'] for k, v in audit['source_files'].items()},
|
||||||
|
'metadata': metadata, 'participants': [], 'audience': [], 'topics': [], 'priority_questions': [],
|
||||||
|
'urls': {k: None for k in ('original', 'canonical', 'content', 'slides')}, 'related_links': [],
|
||||||
|
'field_sources': {}, 'unknowns': [], 'quality_notes': [], 'excluded_cue_ids': [],
|
||||||
|
'interview': {'status': 'pending', 'questions_asked': [], 'notes': []}}
|
||||||
|
core.validate(value, 'intake')
|
||||||
|
core.write(path, value)
|
||||||
|
return {'intake': str(path), 'status': 'pending', 'source_audit': audit}
|
||||||
|
|
||||||
|
|
||||||
|
def seed(folder, intake_path, output):
|
||||||
|
intake = core.load(intake_path)
|
||||||
|
core.validate(intake, 'intake')
|
||||||
|
audit, cues = inspect(folder, intake['source_files'])
|
||||||
|
excluded = set(intake['excluded_cue_ids'])
|
||||||
|
core.require(excluded <= {c['cue_id'] for c in cues}, 'Excluded cue does not exist')
|
||||||
|
included = [c['cue_id'] for c in cues if c['cue_id'] not in excluded]
|
||||||
|
core.require(included, 'No included cues')
|
||||||
|
title = intake['metadata']['title'] or Path(folder).name
|
||||||
|
plan = {'schema_version': '1.0', 'media_id': intake['media_id'],
|
||||||
|
'chunks': [{'chunk_id': intake['media_id'] + ':chunk:starter',
|
||||||
|
'knowledge_id': intake['media_id'] + ':knowledge:starter', 'version': 1,
|
||||||
|
'supersedes': [], 'title': title, 'heading_path': [title],
|
||||||
|
'summary': 'DRAFT: replace starter with conceptual chunks.', 'tags': [], 'cue_ids': included}],
|
||||||
|
'qa': [], 'chapters': [],
|
||||||
|
'review': {'status': 'draft', 'reviewer': '', 'reviewed_at': None, 'input_sha256': None}}
|
||||||
|
core.require(not Path(output).exists(), 'Plan exists; preserve authored IDs and content')
|
||||||
|
core.write(Path(output), plan)
|
||||||
|
return {'plan': str(output), 'status': 'draft'}
|
||||||
|
|
||||||
|
|
||||||
|
def timecode(sec):
|
||||||
|
sec = int(sec)
|
||||||
|
return f'{sec//3600:02}:{sec//60%60:02}:{sec%60:02}'
|
||||||
|
|
||||||
|
|
||||||
|
def build(folder, intake_path, plan_path, output):
|
||||||
|
folder, output = Path(folder).resolve(), Path(output).resolve()
|
||||||
|
core.require(output.parent == folder, 'Draft output must be a new immediate subfolder of the media folder')
|
||||||
|
core.require(not output.exists(), 'Output exists; choose a new review directory')
|
||||||
|
intake, plan = core.load(intake_path), core.load(plan_path)
|
||||||
|
core.validate(intake, 'intake')
|
||||||
|
core.validate(plan, 'plan')
|
||||||
|
core.require(plan['review']['status'] == 'draft', 'Folder builds are drafts; use the public workflow for approved releases')
|
||||||
|
core.require(not plan['review']['reviewer'] and plan['review']['reviewed_at'] is None,
|
||||||
|
'Do not mix a draft build with a claimed human approval')
|
||||||
|
core.require(plan['media_id'] == intake['media_id'], 'Plan/intake ID mismatch')
|
||||||
|
audit, cues = inspect(folder, intake['source_files'])
|
||||||
|
source_snapshot = {k: v['sha256'] for k, v in audit['source_files'].items()}
|
||||||
|
excluded = set(intake['excluded_cue_ids'])
|
||||||
|
core.require(excluded <= {c['cue_id'] for c in cues}, 'Excluded cue does not exist')
|
||||||
|
cues = [c for c in cues if c['cue_id'] not in excluded]
|
||||||
|
by_cue = {c['cue_id']: c for c in cues}
|
||||||
|
title = intake['metadata']['title'] or folder.name
|
||||||
|
for key in ('chunks', 'qa', 'chapters'):
|
||||||
|
core.unique(plan[key], {'chunks':'chunk_id', 'qa':'qa_id', 'chapters':'chapter_id'}[key])
|
||||||
|
core.unique(plan['chunks'], 'knowledge_id')
|
||||||
|
for value in list(intake['urls'].values()) + [r['url'] for r in intake['related_links']]:
|
||||||
|
if value:
|
||||||
|
core.https(value)
|
||||||
|
fingerprint = core.digest(core.encoded({'builder_version': VERSION, 'intake': intake,
|
||||||
|
'plan': plan, 'source_files': audit['source_files']}))
|
||||||
|
common = {'schema_version': '1.0', 'profile': 'local-review', 'status': 'draft',
|
||||||
|
'media_id': intake['media_id'], 'title': title, 'input_sha256': fingerprint,
|
||||||
|
'canonical_url': intake['urls']['canonical']}
|
||||||
|
def cite(cue):
|
||||||
|
return {'media_id': intake['media_id'], 'cue_id': cue['cue_id'],
|
||||||
|
'start_seconds': cue['start_seconds'], 'end_seconds': cue['end_seconds'],
|
||||||
|
'transcript_ref': 'transcript.md#' + cue['cue_id'],
|
||||||
|
'transcript_url': (intake['urls']['canonical'].rstrip('/') + '/#' + cue['cue_id']) if intake['urls']['canonical'] else None,
|
||||||
|
'source_media': '../' + audit['source_files']['media']['path'], 'playback_url': None}
|
||||||
|
chunks = []
|
||||||
|
assigned = []
|
||||||
|
for order, item in enumerate(plan['chunks'], 1):
|
||||||
|
core.require(all(i in by_cue for i in item['cue_ids']), 'Chunk references missing or excluded cue')
|
||||||
|
selection = [by_cue[i] for i in item['cue_ids']]
|
||||||
|
assigned.extend(item['cue_ids'])
|
||||||
|
content = ' '.join(c['text'] for c in selection)
|
||||||
|
chunks.append({**item, 'order': order, 'media_id': intake['media_id'], 'content': content,
|
||||||
|
'content_sha256': core.digest(content.encode('utf-8')),
|
||||||
|
'start_seconds': selection[0]['start_seconds'], 'end_seconds': selection[-1]['end_seconds'],
|
||||||
|
'speakers': list(dict.fromkeys(c['speaker'] for c in selection if c['speaker'])),
|
||||||
|
'citations': [cite(c) for c in selection]})
|
||||||
|
core.require(assigned == list(by_cue), 'Chunks must cover each included cue exactly once in source order')
|
||||||
|
by_chunk = {c['chunk_id']: c for c in chunks}
|
||||||
|
qa = []
|
||||||
|
for item in plan['qa']:
|
||||||
|
evidence = []
|
||||||
|
for e in item['evidence']:
|
||||||
|
core.require(e['chunk_id'] in by_chunk and e['cue_id'] in by_cue, 'Missing Q&A source')
|
||||||
|
core.require(e['cue_id'] in by_chunk[e['chunk_id']]['cue_ids'], 'Q&A cue is outside cited chunk')
|
||||||
|
core.require(e['quote'] in by_cue[e['cue_id']]['text'], 'Q&A evidence quote is not an exact source substring')
|
||||||
|
evidence.append({**e, **cite(by_cue[e['cue_id']])})
|
||||||
|
qa.append({**item, 'media_id': intake['media_id'], 'evidence': evidence})
|
||||||
|
chapters = []
|
||||||
|
previous_end = 0
|
||||||
|
for item in plan['chapters']:
|
||||||
|
core.require(item['start_cue_id'] in by_cue and item['end_cue_id'] in by_cue, 'Chapter cue missing or excluded')
|
||||||
|
start, end = by_cue[item['start_cue_id']]['start_seconds'], by_cue[item['end_cue_id']]['end_seconds']
|
||||||
|
core.require(previous_end <= start < end, 'Chapters must be ordered, non-overlapping ranges')
|
||||||
|
chapters.append({'startTime': start, 'endTime': end, 'title': item['title'],
|
||||||
|
'url': 'transcript.md#' + item['start_cue_id']})
|
||||||
|
previous_end = end
|
||||||
|
media = {**common, 'metadata': intake['metadata'], 'participants': intake['participants'],
|
||||||
|
'audience': intake['audience'], 'topics': intake['topics'], 'priority_questions': intake['priority_questions'],
|
||||||
|
'urls': intake['urls'], 'related_links': intake['related_links'], 'field_sources': intake['field_sources'],
|
||||||
|
'unknowns': intake['unknowns'], 'quality_notes': intake['quality_notes'], 'source_audit': audit,
|
||||||
|
'human_approval': False, 'publication_ready': False}
|
||||||
|
data = {'media.json': media,
|
||||||
|
'transcript.json': {**common, 'artifact_type':'transcript', 'cues':cues, 'excluded_cue_ids':sorted(excluded)},
|
||||||
|
'chunks.json': {**common, 'artifact_type':'chunks', 'chunks':chunks},
|
||||||
|
'qa.json': {**common, 'artifact_type':'qa', 'qa':qa},
|
||||||
|
'chapters.json': {'version':'1.2.0','chapters':[{k:v for k,v in c.items() if k != 'url'} for c in chapters]},
|
||||||
|
'ai-index.json': {**common, 'artifact_type':'index', 'description':intake['metadata']['description'],
|
||||||
|
'artifacts': {name:name for name in ('media.json','transcript.json','chunks.json','qa.json','chapters.json','schema.jsonld','README.md','review.md')}}}
|
||||||
|
for name in ('transcript.json', 'chunks.json', 'qa.json', 'ai-index.json'):
|
||||||
|
core.validate(data[name], 'folder-export')
|
||||||
|
# Only known values become Schema.org properties. No public URL, date, or license is invented.
|
||||||
|
kind = 'AudioObject' if Path(audit['source_files']['media']['path']).suffix.lower() in {'.mp3','.wav','.m4a','.flac','.ogg','.aac'} else 'VideoObject'
|
||||||
|
ld = {'@context':'https://schema.org', '@type':kind, 'name':title,
|
||||||
|
'transcript':' '.join(c['text'] for c in cues)}
|
||||||
|
for source, target in [('description','description'),('language','inLanguage'),('recording_date','dateCreated'),('license','license')]:
|
||||||
|
if intake['metadata'].get(source):
|
||||||
|
ld[target] = intake['metadata'][source]
|
||||||
|
for source,target in [('canonical','url'),('content','contentUrl')]:
|
||||||
|
if intake['urls'][source]:
|
||||||
|
ld[target] = intake['urls'][source]
|
||||||
|
if audit['media_duration_seconds'] is not None:
|
||||||
|
ld['duration'] = f"PT{audit['media_duration_seconds']:g}S"
|
||||||
|
data['schema.jsonld'] = ld
|
||||||
|
def clean(value):
|
||||||
|
return str(value or 'Unknown / pending confirmation').replace('\n',' ')
|
||||||
|
intro = (f'# {title}\n\n**Draft for human review.** Built from the supplied recording, TXT, and VTT.\n\n'
|
||||||
|
+ (intake['metadata']['description'] or 'Description pending review.') + '\n\n'
|
||||||
|
+ f"- Recording: [{audit['source_files']['media']['path']}](../{quote(audit['source_files']['media']['path'])})\n"
|
||||||
|
+ f"- Timed transcript: {timecode(audit['transcript_end_seconds'])}; {len(cues)} included cues.\n"
|
||||||
|
+ f"- Structure: {len(chunks)} chunks, {len(qa)} Q&A entries, {len(chapters)} chapters.\n"
|
||||||
|
+ '- [Review notes and unknowns](review.md) · [Transcript](transcript.md) · [Chunks](chunks.json) · [Q&A](qa.json)\n\n'
|
||||||
|
+ '## Recording metadata\n\n'
|
||||||
|
+ '\n'.join(f'- **{key.replace("_"," ").title()}:** {clean(intake["metadata"].get(key))}' for key in
|
||||||
|
('title','recording_date','recording_timezone','publication_date','organizer','series','attribution','rights_statement'))
|
||||||
|
+ '\n\n## Audience and topics\n\n'
|
||||||
|
+ '- Audience: ' + ', '.join(intake['audience']) + '\n'
|
||||||
|
+ '- Topics: ' + ', '.join(intake['topics']) + '\n\n'
|
||||||
|
+ '## Participants and credits\n\n'
|
||||||
|
+ '\n'.join(f'- **{person["name"]}** — {clean(person["role"])}; {clean(person["affiliation"])}. '
|
||||||
|
f'Source status: {person["status"]}.' for person in intake['participants'])
|
||||||
|
+ '\n\nParticipant metadata does not establish cue-level speaker labels.\n\n'
|
||||||
|
+ '## Source pages and supporting material\n\n'
|
||||||
|
+ (f'- [Published source page]({intake["urls"]["original"]})\n' if intake['urls']['original'] else '- Published source page: unknown.\n')
|
||||||
|
+ (f'- [Slides]({intake["urls"]["slides"]})\n' if intake['urls']['slides'] else '')
|
||||||
|
+ '\n'.join(f'- [{item["label"]}]({item["url"]})' for item in intake['related_links'])
|
||||||
|
+ '\n\n## Chapters\n\n'
|
||||||
|
+ '\n'.join(f'- [{timecode(c["startTime"])} — {c["title"]}]({c["url"]})' for c in chapters)
|
||||||
|
+ '\n\n## Conceptual chunks\n\n'
|
||||||
|
+ '\n\n'.join(f'### {timecode(c["start_seconds"])} — {c["title"]}\n\n{c["summary"]}\n\n'
|
||||||
|
f'[Source](transcript.md#{c["cue_ids"][0]}) · `{c["chunk_id"]}`' for c in chunks)
|
||||||
|
+ '\n\n## Questions this recording can answer\n\n'
|
||||||
|
+ '\n\n'.join(f'### {q["question"]}\n\n{q["answer"]}\n\n' + ' · '.join(
|
||||||
|
f'[Evidence {timecode(e["start_seconds"])}]({e["transcript_ref"]})' for e in q['evidence']) for q in qa)
|
||||||
|
+ '\n\nThese answers summarize attributed transcript content. They are not independent verification of speaker claims.\n')
|
||||||
|
review = (f'# Review: {title}\n\nStatus: **draft — not human approved or publication ready**.\n\n'
|
||||||
|
+ '## Please review\n\n'
|
||||||
|
+ '- [ ] Confirm title, date, people/affiliations, and attribution.\n'
|
||||||
|
+ '- [ ] Check chunk boundaries, summaries, Q&A support, and chapter labels.\n'
|
||||||
|
+ '- [ ] Check names, acronyms, statistics, and caveats against the recording/slides.\n'
|
||||||
|
+ '- [ ] Resolve sharing permissions and public URLs before publication.\n\n'
|
||||||
|
+ '## Missing or unconfirmed metadata\n\n'
|
||||||
|
+ ('\n'.join('- '+x for x in intake['unknowns']) or '- See metadata fields for any unknown values.') + '\n\n'
|
||||||
|
+ '## Source and processing notes\n\n'
|
||||||
|
+ '\n'.join('- '+x for x in audit['notes'] + intake['quality_notes'])
|
||||||
|
+ f'\n- Excluded cues: {len(excluded)}. Original files remain untouched.\n'
|
||||||
|
+ '- Transcript wording is preserved, including apparent STT errors; no cue-level speaker identities were inferred.\n'
|
||||||
|
+ '- This run reads existing transcript text; it does not listen to the full recording or inspect missing slides/video.\n'
|
||||||
|
+ '- Mechanical checks establish source consistency and exact evidence quotes, not factual accuracy or human approval.\n')
|
||||||
|
data['README.md'], data['review.md'] = intro, review
|
||||||
|
data['transcript.md'] = '# Timed transcript\n\nSource wording; speaker labels only where provided by VTT.\n\n' + '\n\n'.join(
|
||||||
|
f'<a id="{c["cue_id"]}"></a>\n\n**{timecode(c["start_seconds"])}–{timecode(c["end_seconds"])}** '
|
||||||
|
+ (f'[{c["speaker"]}] ' if c['speaker'] else '') + c['text'] for c in cues) + '\n'
|
||||||
|
data['llms.txt'] = f'# {title}\n\n> Local draft for review; publication details may be unknown.\n\n## Assets\n\n' + '\n'.join(
|
||||||
|
f'- [{name}]({name})' for name in ('media.json','chunks.json','qa.json','transcript.json','review.md')) + '\n'
|
||||||
|
output.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
temp = Path(tempfile.mkdtemp(prefix='.structured-draft-', dir=output.parent))
|
||||||
|
try:
|
||||||
|
for name,value in data.items():
|
||||||
|
core.write(temp/name, value)
|
||||||
|
# A source change while structuring invalidates the build rather than mixing revisions.
|
||||||
|
_, paths = source_paths(folder, intake['source_files'])
|
||||||
|
core.require({k:sha_file(p) for k,p in paths.items()} == source_snapshot, 'Source changed during build')
|
||||||
|
receipt = {'builder_version': VERSION, 'profile':'local-review', 'status':'draft',
|
||||||
|
'input_sha256':fingerprint, 'source_files':audit['source_files'],
|
||||||
|
'source_files_unchanged':True, 'human_approval':False, 'publication_ready':False,
|
||||||
|
'counts':{'cues':len(cues),'chunks':len(chunks),'qa':len(qa),'chapters':len(chapters)},
|
||||||
|
'files':{p.name:sha_file(p) for p in sorted(temp.iterdir()) if p.is_file()}}
|
||||||
|
core.write(temp/'build-receipt.json', receipt)
|
||||||
|
temp.rename(output)
|
||||||
|
finally:
|
||||||
|
if temp.exists():
|
||||||
|
shutil.rmtree(temp)
|
||||||
|
return {'output':str(output),'status':'draft',**receipt['counts'],'source_files_unchanged':True}
|
||||||
|
|
||||||
|
|
||||||
|
def verify(output, check_sources=True):
|
||||||
|
output = Path(output).resolve()
|
||||||
|
receipt = core.load(output/'build-receipt.json')
|
||||||
|
actual = {p.relative_to(output).as_posix():sha_file(p) for p in output.rglob('*')
|
||||||
|
if p.is_file() and p != output/'build-receipt.json'}
|
||||||
|
core.require(actual == receipt['files'], 'Draft output differs from receipt')
|
||||||
|
for name in ('transcript.json','chunks.json','qa.json','ai-index.json'):
|
||||||
|
core.validate(core.load(output/name), 'folder-export')
|
||||||
|
if check_sources:
|
||||||
|
for record in receipt['source_files'].values():
|
||||||
|
path = core.relative_file(output.parent, record['path'])
|
||||||
|
core.require(sha_file(path) == record['sha256'], 'Original source changed since build')
|
||||||
|
return {'valid':True,'status':'draft','source_files_checked':check_sources,**receipt['counts']}
|
||||||
|
|
||||||
|
|
||||||
|
def search(output, query, limit=5):
|
||||||
|
verify(output)
|
||||||
|
core.require(1 <= limit <= 100, 'Limit must be between 1 and 100')
|
||||||
|
terms = set(re.findall(r'\w+', query.casefold()))
|
||||||
|
core.require(terms, 'Empty query')
|
||||||
|
results = []
|
||||||
|
for kind in ('chunks','qa'):
|
||||||
|
for r in core.load(Path(output)/(kind+'.json'))[kind]:
|
||||||
|
text = (r['title']+' '+r['summary']+' '+r['content']) if kind=='chunks' else r['question']+' '+r['answer']
|
||||||
|
heading = r['title'] if kind == 'chunks' else r['question']
|
||||||
|
abstract = r['summary'] if kind == 'chunks' else r['answer']
|
||||||
|
score = (len(terms & set(re.findall(r'\w+',text.casefold())))
|
||||||
|
+ 3 * len(terms & set(re.findall(r'\w+',heading.casefold())))
|
||||||
|
+ 2 * len(terms & set(re.findall(r'\w+',abstract.casefold()))))
|
||||||
|
if score:
|
||||||
|
results.append({'id':r.get('chunk_id',r.get('qa_id')),'type':kind,'score':score,
|
||||||
|
'text':text,'citations':r.get('citations',r.get('evidence')),'status':'draft'})
|
||||||
|
return sorted(results,key=lambda r:(-r['score'],r['id']))[:limit]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
p = argparse.ArgumentParser(description=__doc__)
|
||||||
|
sub = p.add_subparsers(dest='command', required=True)
|
||||||
|
for command in ('inspect','prepare','seed','build'):
|
||||||
|
cmd = sub.add_parser(command)
|
||||||
|
cmd.add_argument('--folder',type=Path,required=True)
|
||||||
|
if command in ('seed','build'):
|
||||||
|
cmd.add_argument('--intake',type=Path,required=True)
|
||||||
|
if command=='build':
|
||||||
|
cmd.add_argument('--plan',type=Path,required=True)
|
||||||
|
if command!='inspect':
|
||||||
|
cmd.add_argument('--output',type=Path,required=True)
|
||||||
|
for command in ('verify','search'):
|
||||||
|
cmd = sub.add_parser(command)
|
||||||
|
cmd.add_argument('--output',type=Path,required=True)
|
||||||
|
if command=='search':
|
||||||
|
cmd.add_argument('--query',required=True)
|
||||||
|
cmd.add_argument('--limit',type=int,default=5)
|
||||||
|
a = p.parse_args()
|
||||||
|
try:
|
||||||
|
if a.command=='inspect': result=inspect(a.folder)[0]
|
||||||
|
elif a.command=='prepare': result=prepare(a.folder,a.output)
|
||||||
|
elif a.command=='seed': result=seed(a.folder,a.intake,a.output)
|
||||||
|
elif a.command=='build': result=build(a.folder,a.intake,a.plan,a.output)
|
||||||
|
elif a.command=='verify': result=verify(a.output)
|
||||||
|
else: result=search(a.output,a.query,a.limit)
|
||||||
|
print(core.encoded(result).decode('utf-8'),end='')
|
||||||
|
return 0
|
||||||
|
except Exception as e:
|
||||||
|
print(f'ERROR: {e}',file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,473 @@
|
|||||||
|
"""Build reviewed, source-cited media discovery bundles. No network or inference calls."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import html
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
from pathlib import Path
|
||||||
|
from urllib.parse import parse_qsl, urlsplit
|
||||||
|
from xml.etree import ElementTree as ET
|
||||||
|
|
||||||
|
from jsonschema import Draft202012Validator, FormatChecker
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
VERSION = "0.2.0"
|
||||||
|
|
||||||
|
|
||||||
|
def require(condition, message):
|
||||||
|
if not condition:
|
||||||
|
raise ValueError(message)
|
||||||
|
|
||||||
|
|
||||||
|
def load(path):
|
||||||
|
def pairs(items):
|
||||||
|
result = {}
|
||||||
|
for key, value in items:
|
||||||
|
require(key not in result, f"Duplicate JSON key: {key}")
|
||||||
|
result[key] = value
|
||||||
|
return result
|
||||||
|
def bad_constant(value):
|
||||||
|
raise ValueError(f"Non-finite JSON number: {value}")
|
||||||
|
return json.loads(Path(path).read_text(encoding="utf-8-sig"),
|
||||||
|
object_pairs_hook=pairs, parse_constant=bad_constant)
|
||||||
|
|
||||||
|
|
||||||
|
def encoded(value):
|
||||||
|
return (json.dumps(value, ensure_ascii=False, sort_keys=True, indent=2,
|
||||||
|
allow_nan=False) + "\n").encode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def digest(value):
|
||||||
|
return hashlib.sha256(value).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def validate(value, schema):
|
||||||
|
spec = load(ROOT / "schemas" / f"{schema}.schema.json")
|
||||||
|
Draft202012Validator(spec, format_checker=FormatChecker()).validate(value)
|
||||||
|
|
||||||
|
|
||||||
|
def https(value):
|
||||||
|
parsed = urlsplit(value)
|
||||||
|
require(parsed.scheme == "https" and parsed.hostname and not parsed.username
|
||||||
|
and not parsed.password and not re.search(r"[\s<>\"{}]", value),
|
||||||
|
"Expected a stable public HTTPS URL without credentials or unsafe characters")
|
||||||
|
keys = [key.casefold() for key, _ in parse_qsl(parsed.query)]
|
||||||
|
require(not any(key in {"token", "access_token", "signature", "sig", "credential", "password", "api_key"}
|
||||||
|
or key.startswith(("x-amz-", "x-goog-")) for key in keys),
|
||||||
|
"Do not publish signed or credential-bearing URLs")
|
||||||
|
|
||||||
|
|
||||||
|
def relative_file(base, name):
|
||||||
|
path = (base / name).resolve()
|
||||||
|
require(path.is_relative_to(base.resolve()) and path.is_file(),
|
||||||
|
f"Source must be an existing file inside {base}: {name}")
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def seconds(value):
|
||||||
|
require(re.fullmatch(r"(?:\d{2,}:)?[0-5]\d:[0-5]\d\.\d{3}", value),
|
||||||
|
f"Unsupported WebVTT timestamp: {value}")
|
||||||
|
parts = value.split(":")
|
||||||
|
return round(sum(float(x) * (60 ** i) for i, x in enumerate(reversed(parts))), 3)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_vtt(text, duration):
|
||||||
|
"""Strict portable subset. Reject inline karaoke/rolling overlaps rather than lose data."""
|
||||||
|
text = text.lstrip("\ufeff").replace("\r\n", "\n").replace("\r", "\n")
|
||||||
|
blocks = re.split(r"\n[ \t]*\n", text.strip())
|
||||||
|
require(blocks and re.fullmatch(r"WEBVTT(?:[ \t][^\n]*)?", blocks[0]),
|
||||||
|
"Expected WEBVTT header (header metadata requires normalization)")
|
||||||
|
cues = []
|
||||||
|
last_end = 0
|
||||||
|
native_ids = set()
|
||||||
|
for block in blocks[1:]:
|
||||||
|
lines = block.strip().splitlines()
|
||||||
|
if not lines or lines[0] == "NOTE" or lines[0].startswith(("NOTE ", "NOTE\t")):
|
||||||
|
continue
|
||||||
|
require(lines[0] not in ("STYLE", "REGION"),
|
||||||
|
"Normalize STYLE/REGION WebVTT before semantic processing")
|
||||||
|
native_id = None
|
||||||
|
if "-->" not in lines[0]:
|
||||||
|
native_id = lines.pop(0)
|
||||||
|
require(native_id not in native_ids, "Duplicate WebVTT cue identifier")
|
||||||
|
native_ids.add(native_id)
|
||||||
|
require(len(lines) >= 2, "WebVTT cue needs timing and text")
|
||||||
|
match = re.fullmatch(r"(\S+)\s+-->\s+(\S+)(?:[ \t]+.*)?", lines[0])
|
||||||
|
require(match, f"Invalid WebVTT cue timing: {lines[0]}")
|
||||||
|
start, end = seconds(match[1]), seconds(match[2])
|
||||||
|
require(0 <= start < end <= duration, "Cue outside declared media duration")
|
||||||
|
require(start >= last_end, "Overlapping/out-of-order cues require reviewed normalization")
|
||||||
|
body = "\n".join(lines[1:])
|
||||||
|
voices = re.findall(r"<v(?:\.[^ >]+)*\s+([^>]+)>", body)
|
||||||
|
require(len(set(voices)) <= 1, "Split cues containing multiple voice labels")
|
||||||
|
body = re.sub(r"</?(?:v(?:\.[^ >]+)*(?:\s+[^>]+)?|b|i|u|c(?:\.[^ >]+)*|lang(?:\s+[^>]+)?)>", "", body)
|
||||||
|
require(not re.search(r"<[^>]+>", body),
|
||||||
|
"Unsupported WebVTT markup; normalize it explicitly")
|
||||||
|
body = " ".join(html.unescape(body).split())
|
||||||
|
require(body, "Empty WebVTT cue")
|
||||||
|
cues.append({"cue_id": f"cue-{len(cues)+1:06}", "source_cue_id": native_id,
|
||||||
|
"start_seconds": start, "end_seconds": end,
|
||||||
|
"speaker": html.unescape(voices[0]) if voices else None, "text": body})
|
||||||
|
last_end = end
|
||||||
|
require(cues, "No WebVTT cues found")
|
||||||
|
return cues
|
||||||
|
|
||||||
|
|
||||||
|
def inputs(manifest_path, plan_path):
|
||||||
|
manifest_path, plan_path = Path(manifest_path).resolve(), Path(plan_path).resolve()
|
||||||
|
media, plan = load(manifest_path), load(plan_path)
|
||||||
|
validate(media, "media")
|
||||||
|
validate(plan, "plan")
|
||||||
|
base = manifest_path.parent
|
||||||
|
vtt_path = relative_file(base, media["transcripts"]["vtt"])
|
||||||
|
txt_path = relative_file(base, media["transcripts"]["txt"])
|
||||||
|
for field in ("canonical_url", "content_url", "embed_url", "thumbnail_url"):
|
||||||
|
if media.get(field):
|
||||||
|
https(media[field])
|
||||||
|
for field in ("license", "usage_info"):
|
||||||
|
if media["rights"].get(field):
|
||||||
|
https(media["rights"][field])
|
||||||
|
require(media.get("content_url") or media.get("embed_url"),
|
||||||
|
"Provide a stable media content_url or embed_url")
|
||||||
|
vtt_bytes, txt_bytes = vtt_path.read_bytes(), txt_path.read_bytes()
|
||||||
|
cues = parse_vtt(vtt_bytes.decode("utf-8-sig"), media["duration_seconds"])
|
||||||
|
transcript = " ".join(c["text"] for c in cues)
|
||||||
|
txt = " ".join(txt_bytes.decode("utf-8-sig").split())
|
||||||
|
require(txt == transcript,
|
||||||
|
"TXT/VTT text differs. Reconcile reviewed copies; never invent timings from TXT.")
|
||||||
|
hash_inputs = {
|
||||||
|
"builder_version": VERSION, "manifest": media,
|
||||||
|
"vtt_sha256": digest(vtt_bytes),
|
||||||
|
"txt_sha256": digest(txt_bytes),
|
||||||
|
"plan": {k: v for k, v in plan.items() if k != "review"},
|
||||||
|
}
|
||||||
|
return media, plan, cues, transcript, digest(encoded(hash_inputs)), vtt_bytes, txt_bytes
|
||||||
|
|
||||||
|
|
||||||
|
def unique(items, key):
|
||||||
|
ids = [item[key] for item in items]
|
||||||
|
require(len(ids) == len(set(ids)), f"Duplicate {key}")
|
||||||
|
|
||||||
|
|
||||||
|
def citation(media, cue):
|
||||||
|
return {"media_id": media["media_id"], "cue_id": cue["cue_id"],
|
||||||
|
"start_seconds": cue["start_seconds"], "end_seconds": cue["end_seconds"],
|
||||||
|
"transcript_url": media["canonical_url"] + "#" + cue["cue_id"],
|
||||||
|
"playback_url": playback(media, cue["start_seconds"])}
|
||||||
|
|
||||||
|
|
||||||
|
def playback(media, start):
|
||||||
|
# The generated native player supports this query. External embeds have no implied seek support.
|
||||||
|
return (media["canonical_url"] + f"?t={start:g}") if media.get("content_url") else None
|
||||||
|
|
||||||
|
|
||||||
|
def artifacts(manifest_path, plan_path):
|
||||||
|
media, plan, cues, text, signature, vtt, txt = inputs(manifest_path, plan_path)
|
||||||
|
require(plan["media_id"] == media["media_id"], "Plan/manifest identity mismatch")
|
||||||
|
review = plan["review"]
|
||||||
|
require(review["status"] == "approved" and review["reviewer"].strip()
|
||||||
|
and review["reviewed_at"] and review["input_sha256"] == signature,
|
||||||
|
"Review missing or stale. Review content and paste the current signature.")
|
||||||
|
require(media["publication"]["consent"] == "cleared"
|
||||||
|
and media["publication"]["privacy_review"] == "cleared"
|
||||||
|
and media["rights"]["redistribution_allowed"],
|
||||||
|
"Public output requires cleared consent/privacy and redistribution rights")
|
||||||
|
unique(plan["chunks"], "chunk_id")
|
||||||
|
unique(plan["chunks"], "knowledge_id")
|
||||||
|
unique(plan["qa"], "qa_id")
|
||||||
|
unique(plan["chapters"], "chapter_id")
|
||||||
|
by_cue = {c["cue_id"]: c for c in cues}
|
||||||
|
assigned = []
|
||||||
|
chunks = []
|
||||||
|
for order, chunk in enumerate(plan["chunks"], 1):
|
||||||
|
ids = chunk["cue_ids"]
|
||||||
|
require(all(i in by_cue for i in ids), "Chunk refers to missing cue")
|
||||||
|
selected = [by_cue[i] for i in ids]
|
||||||
|
assigned.extend(ids)
|
||||||
|
chunks.append({**chunk, "media_id": media["media_id"], "order": order,
|
||||||
|
"content": " ".join(c["text"] for c in selected),
|
||||||
|
"start_seconds": selected[0]["start_seconds"],
|
||||||
|
"end_seconds": selected[-1]["end_seconds"],
|
||||||
|
"speakers": list(dict.fromkeys(c["speaker"] for c in selected if c["speaker"])),
|
||||||
|
"citations": [citation(media, c) for c in selected]})
|
||||||
|
require(assigned == list(by_cue),
|
||||||
|
"Chunks must cover every cue exactly once, contiguously and in source order")
|
||||||
|
by_chunk = {c["chunk_id"]: c for c in chunks}
|
||||||
|
qa = []
|
||||||
|
for item in plan["qa"]:
|
||||||
|
evidence = []
|
||||||
|
for e in item["evidence"]:
|
||||||
|
require(e["chunk_id"] in by_chunk and e["cue_id"] in by_cue,
|
||||||
|
"Q&A evidence refers to missing source")
|
||||||
|
require(e["cue_id"] in by_chunk[e["chunk_id"]]["cue_ids"],
|
||||||
|
"Q&A cue does not belong to cited chunk")
|
||||||
|
require(e["quote"] in by_cue[e["cue_id"]]["text"],
|
||||||
|
"Evidence quote is not an exact substring of the cited cue")
|
||||||
|
evidence.append({**e, **citation(media, by_cue[e["cue_id"]])})
|
||||||
|
qa.append({**item, "media_id": media["media_id"], "evidence": evidence})
|
||||||
|
chapters = []
|
||||||
|
chapter_end = 0
|
||||||
|
for chapter in plan["chapters"]:
|
||||||
|
require(chapter["start_cue_id"] in by_cue and chapter["end_cue_id"] in by_cue,
|
||||||
|
"Chapter refers to missing cue")
|
||||||
|
start = by_cue[chapter["start_cue_id"]]["start_seconds"]
|
||||||
|
end = by_cue[chapter["end_cue_id"]]["end_seconds"]
|
||||||
|
require(chapter_end <= start < end, "Chapters must be ordered and non-overlapping")
|
||||||
|
chapters.append({"startTime": start, "endTime": end, "title": chapter["title"],
|
||||||
|
"url": media["canonical_url"] + "#" + chapter["start_cue_id"]})
|
||||||
|
chapter_end = end
|
||||||
|
envelope = {"schema_version": "1.0", "media_id": media["media_id"],
|
||||||
|
"canonical_url": media["canonical_url"], "language": media["language"],
|
||||||
|
"rights": media["rights"], "input_sha256": signature}
|
||||||
|
result = {
|
||||||
|
"transcript.json": {**envelope, "cues": cues},
|
||||||
|
"chunks.json": {**envelope, "chunks": chunks},
|
||||||
|
"qa.json": {**envelope, "qa": qa},
|
||||||
|
"chapters.json": {"version": "1.2.0", "chapters": chapters},
|
||||||
|
}
|
||||||
|
for name in ("transcript", "chunks", "qa"):
|
||||||
|
validate(result[name + ".json"], name)
|
||||||
|
return media, plan, result, text, vtt, txt
|
||||||
|
|
||||||
|
|
||||||
|
def schema_org(media, data, text):
|
||||||
|
obj = {"@context": "https://schema.org", "@type": "VideoObject" if media["kind"] == "video" else "AudioObject",
|
||||||
|
"@id": media["canonical_url"] + "#media", "url": media["canonical_url"],
|
||||||
|
"name": media["title"], "description": media["description"],
|
||||||
|
"inLanguage": media["language"], "duration": f"PT{media['duration_seconds']:g}S",
|
||||||
|
"uploadDate": media["published_at"], "transcript": text,
|
||||||
|
"copyrightNotice": media["rights"]["statement"]}
|
||||||
|
for source, target in (("content_url", "contentUrl"), ("embed_url", "embedUrl"),
|
||||||
|
("thumbnail_url", "thumbnailUrl")):
|
||||||
|
if media.get(source):
|
||||||
|
obj[target] = media[source]
|
||||||
|
for source, target in (("license", "license"), ("usage_info", "usageInfo")):
|
||||||
|
if media["rights"].get(source):
|
||||||
|
obj[target] = media["rights"][source]
|
||||||
|
if media["kind"] == "video" and media.get("content_url"):
|
||||||
|
obj["hasPart"] = [{"@type": "Clip", "name": c["title"],
|
||||||
|
"startOffset": c["startTime"], "endOffset": c["endTime"],
|
||||||
|
"url": playback(media, c["startTime"])}
|
||||||
|
for c in data["chapters.json"]["chapters"]]
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def page_html(media, data, ld):
|
||||||
|
esc = html.escape
|
||||||
|
title = esc(media["title"])
|
||||||
|
links = "".join(f'<link rel="alternate" type="{mime}" href="{name}" title="{label}">'
|
||||||
|
for name, mime, label in (("transcript.txt", "text/plain", "Transcript"),
|
||||||
|
("transcript.vtt", "text/vtt", "Timed transcript"),
|
||||||
|
("chunks.json", "application/json", "Chunks"),
|
||||||
|
("qa.json", "application/json", "Questions and answers")))
|
||||||
|
player = f'<p><a href="{esc(media["embed_url"], quote=True)}">Open recording</a></p>' if media.get("embed_url") else ""
|
||||||
|
if media.get("content_url"):
|
||||||
|
tag = "video" if media["kind"] == "video" else "audio"
|
||||||
|
player = (f'<{tag} id="player" controls preload="metadata" src="{esc(media["content_url"], quote=True)}">'
|
||||||
|
f'<track kind="captions" src="transcript.vtt" srclang="{esc(media["language"])}" '
|
||||||
|
f'label="{esc(media["language"])}"></{tag}>')
|
||||||
|
cues = "\n".join(f'<p id="{c["cue_id"]}"><a href="?t={c["start_seconds"]:g}">{c["start_seconds"]:g}s</a> '
|
||||||
|
f'{esc(c["speaker"] + ": " if c["speaker"] else "")}{esc(c["text"])}</p>'
|
||||||
|
if media.get("content_url") else
|
||||||
|
f'<p id="{c["cue_id"]}">{c["start_seconds"]:g}s {esc(c["text"])}</p>'
|
||||||
|
for c in data["transcript.json"]["cues"])
|
||||||
|
qa = "\n".join(f'<section><h3>{esc(q["question"])}</h3><p>{esc(q["answer"])}</p><p>'
|
||||||
|
+ " ".join(f'<a href="#{e["cue_id"]}">Evidence at {e["start_seconds"]:g}s</a>' for e in q["evidence"])
|
||||||
|
+ '</p></section>' for q in data["qa.json"]["qa"])
|
||||||
|
chapters = "".join(f'<li><a href="{esc(c["url"], quote=True)}">{esc(c["title"])}</a></li>'
|
||||||
|
for c in data["chapters.json"]["chapters"])
|
||||||
|
ld_text = json.dumps(ld, ensure_ascii=False).replace("<", "\\u003c")
|
||||||
|
banner = '<p><strong>Synthetic example. Media URLs are placeholders.</strong></p>' if media["synthetic"] else ""
|
||||||
|
return f'''<!doctype html>
|
||||||
|
<html lang="{esc(media['language'])}"><head><meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"><title>{title}</title>
|
||||||
|
<meta name="description" content="{esc(media['description'], quote=True)}">
|
||||||
|
<link rel="canonical" href="{esc(media['canonical_url'], quote=True)}">{links}
|
||||||
|
<script type="application/ld+json">{ld_text}</script>
|
||||||
|
<style>body{{font:18px/1.6 system-ui;max-width:900px;margin:2rem auto;padding:0 1rem}}video{{width:100%}}:target{{background:#fff2b3}}a{{color:#174e92}}</style>
|
||||||
|
</head><body><h1>{title}</h1>{banner}<p>{esc(media['description'])}</p>{player}
|
||||||
|
<p><a href="transcript.txt">TXT</a> · <a href="transcript.vtt">VTT</a> · <a href="transcript.json">Timed JSON</a> ·
|
||||||
|
<a href="chunks.json">Chunks</a> · <a href="qa.json">Q&A</a> · <a href="chapters.json">Chapters</a></p>
|
||||||
|
<h2>Chapters</h2><ul>{chapters}</ul><h2>Questions and answers</h2>{qa}
|
||||||
|
<h2>Transcript</h2>{cues}<footer><p>{esc(media['rights']['statement'])}</p></footer>
|
||||||
|
<script>const p=document.getElementById('player');const t=Number(new URLSearchParams(location.search).get('t'));
|
||||||
|
if(p && Number.isFinite(t) && t>=0) p.addEventListener('loadedmetadata',()=>{{p.currentTime=Math.min(t,p.duration);}},{{once:true}});</script>
|
||||||
|
</body></html>'''
|
||||||
|
|
||||||
|
|
||||||
|
def write(path, value):
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_bytes(encoded(value) if not isinstance(value, str) else value.encode("utf-8"))
|
||||||
|
|
||||||
|
|
||||||
|
def build(catalog_path, output):
|
||||||
|
catalog_path, output = Path(catalog_path).resolve(), Path(output).resolve()
|
||||||
|
require(not output.exists(), "Output already exists. Use a new release directory.")
|
||||||
|
catalog = load(catalog_path)
|
||||||
|
validate(catalog, "catalog")
|
||||||
|
site = catalog["site_url"].rstrip("/")
|
||||||
|
https(site)
|
||||||
|
require(not urlsplit(site).query and not urlsplit(site).fragment, "site_url cannot contain query/fragment")
|
||||||
|
prepared = []
|
||||||
|
for entry in catalog["items"]:
|
||||||
|
manifest = relative_file(catalog_path.parent, entry["manifest"])
|
||||||
|
plan = relative_file(catalog_path.parent, entry["plan"])
|
||||||
|
require(not output.is_relative_to(manifest.parent), "Keep generated output outside media source folders")
|
||||||
|
bundle = artifacts(manifest, plan)
|
||||||
|
media = bundle[0]
|
||||||
|
require(media["canonical_url"] == f"{site}/media/{media['media_id']}/",
|
||||||
|
"Canonical URL must match site_url/media/media_id/")
|
||||||
|
require(catalog["allow_synthetic"] or not media["synthetic"],
|
||||||
|
"Synthetic media blocked in this catalog")
|
||||||
|
prepared.append(bundle)
|
||||||
|
unique([p[0] for p in prepared], "media_id")
|
||||||
|
output.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
temp = Path(tempfile.mkdtemp(prefix=".media-build-", dir=output.parent))
|
||||||
|
try:
|
||||||
|
index = {"schema_version": "1.0", "site_url": site, "items": []}
|
||||||
|
sitemap = ET.Element("urlset", xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
|
||||||
|
for media, plan, data, text, vtt, txt in prepared:
|
||||||
|
folder = temp / "media" / media["media_id"]
|
||||||
|
for name, value in data.items():
|
||||||
|
write(folder / name, value)
|
||||||
|
(folder / "transcript.vtt").write_bytes(vtt)
|
||||||
|
(folder / "transcript.txt").write_bytes(txt)
|
||||||
|
# Source filenames/paths and private ingestion notes never enter the public export.
|
||||||
|
public_media = {k: v for k, v in media.items() if k != "transcripts"}
|
||||||
|
write(folder / "media.json", public_media)
|
||||||
|
ld = schema_org(media, data, text)
|
||||||
|
write(folder / "schema.jsonld", ld)
|
||||||
|
write(folder / "index.html", page_html(media, data, ld))
|
||||||
|
index["items"].append({"media_id": media["media_id"], "title": media["title"],
|
||||||
|
"description": media["description"], "kind": media["kind"],
|
||||||
|
"language": media["language"], "synthetic": media["synthetic"],
|
||||||
|
"canonical_url": media["canonical_url"], "updated_at": media["updated_at"],
|
||||||
|
"rights": media["rights"],
|
||||||
|
"artifacts": {n: media["canonical_url"] + n for n in
|
||||||
|
("media.json", "transcript.txt", "transcript.vtt", "transcript.json",
|
||||||
|
"chunks.json", "qa.json", "chapters.json", "schema.jsonld")}})
|
||||||
|
node = ET.SubElement(sitemap, "url")
|
||||||
|
ET.SubElement(node, "loc").text = media["canonical_url"]
|
||||||
|
ET.SubElement(node, "lastmod").text = media["updated_at"]
|
||||||
|
validate(index, "ai-index")
|
||||||
|
write(temp / "ai-index.json", index)
|
||||||
|
write(temp / "sitemap.xml", ET.tostring(sitemap, encoding="unicode"))
|
||||||
|
write(temp / "llms.txt", "# " + catalog["title"] + "\n\n"
|
||||||
|
+ "> Reviewed media with timed transcript citations.\n\n"
|
||||||
|
+ "Read [the index](" + site + "/ai-index.json), then chunks and Q&A; cite original cue URLs.\n"
|
||||||
|
+ "Q&A is reviewed synthesis; transcript text records what was said, not independently verified facts.\n"
|
||||||
|
+ "API and MCP services are not provided by this static export.\n\n"
|
||||||
|
+ "## Recordings\n\n"
|
||||||
|
+ "\n".join(f"- [{m['title']}]({m['canonical_url']}): {m['description']}" for m, *_ in prepared) + "\n")
|
||||||
|
write(temp / "index.html", '<!doctype html><html lang="en"><meta charset="utf-8"><title>'
|
||||||
|
+ html.escape(catalog["title"]) + '</title><h1>' + html.escape(catalog["title"]) + '</h1><ul>'
|
||||||
|
+ ''.join(f'<li><a href="media/{m["media_id"]}/">{html.escape(m["title"])}</a></li>' for m, *_ in prepared)
|
||||||
|
+ '</ul><a href="ai-index.json">AI index</a></html>')
|
||||||
|
files = {p.relative_to(temp).as_posix(): digest(p.read_bytes())
|
||||||
|
for p in sorted(temp.rglob("*")) if p.is_file()}
|
||||||
|
write(temp / "build-receipt.json", {"builder_version": VERSION,
|
||||||
|
"catalog_sha256": digest(catalog_path.read_bytes()), "files": files,
|
||||||
|
"inputs": {m["media_id"]: data["chunks.json"]["input_sha256"] for m, _, data, *_ in prepared},
|
||||||
|
"deployment_verified": False})
|
||||||
|
temp.rename(output)
|
||||||
|
finally:
|
||||||
|
if temp.exists():
|
||||||
|
shutil.rmtree(temp)
|
||||||
|
return {"output": str(output), "media_count": len(prepared), "deployment_verified": False}
|
||||||
|
|
||||||
|
|
||||||
|
def verify_export(root):
|
||||||
|
root = Path(root).resolve()
|
||||||
|
receipt = load(root / "build-receipt.json")
|
||||||
|
actual = {p.relative_to(root).as_posix(): digest(p.read_bytes()) for p in root.rglob("*")
|
||||||
|
if p.is_file() and p.name != "build-receipt.json"}
|
||||||
|
require(actual == receipt["files"], "Export files differ from build receipt")
|
||||||
|
return root
|
||||||
|
|
||||||
|
|
||||||
|
def search(root, query, limit=5):
|
||||||
|
root = verify_export(root)
|
||||||
|
require(1 <= limit <= 100, "limit must be between 1 and 100")
|
||||||
|
terms = set(re.findall(r"\w+", query.casefold()))
|
||||||
|
require(terms, "Search query is empty")
|
||||||
|
results = []
|
||||||
|
index = load(root / "ai-index.json")
|
||||||
|
for item in index["items"]:
|
||||||
|
folder = root / "media" / item["media_id"]
|
||||||
|
for kind, filename in (("chunks", "chunks.json"), ("qa", "qa.json")):
|
||||||
|
for record in load(folder / filename)[kind]:
|
||||||
|
body = (record["title"] + " " + record["summary"] + " " + record["content"]
|
||||||
|
if kind == "chunks" else record["question"] + " " + record["answer"])
|
||||||
|
score = len(terms & set(re.findall(r"\w+", body.casefold())))
|
||||||
|
if score:
|
||||||
|
results.append({"media_id": item["media_id"], "type": kind,
|
||||||
|
"id": record.get("chunk_id", record.get("qa_id")),
|
||||||
|
"score": score, "text": body, "rights": item["rights"],
|
||||||
|
"citations": record.get("citations", record.get("evidence"))})
|
||||||
|
return sorted(results, key=lambda r: (-r["score"], r["media_id"], r["id"]))[:limit]
|
||||||
|
|
||||||
|
|
||||||
|
def draft(manifest_path, plan_path):
|
||||||
|
path = Path(plan_path)
|
||||||
|
require(not path.exists(), "Plan already exists; preserve assigned IDs")
|
||||||
|
media = load(manifest_path)
|
||||||
|
validate(media, "media")
|
||||||
|
cues = parse_vtt(relative_file(Path(manifest_path).resolve().parent,
|
||||||
|
media["transcripts"]["vtt"]).read_text(encoding="utf-8-sig"),
|
||||||
|
media["duration_seconds"])
|
||||||
|
plan = {"schema_version": "1.0", "media_id": media["media_id"],
|
||||||
|
"chunks": [{"chunk_id": media["media_id"] + ":chunk:introduction",
|
||||||
|
"knowledge_id": media["media_id"] + ":knowledge:introduction",
|
||||||
|
"version": 1, "supersedes": [], "title": media["title"],
|
||||||
|
"heading_path": [media["title"]], "summary": "REVIEW: split into conceptual units",
|
||||||
|
"tags": [], "cue_ids": [c["cue_id"] for c in cues]}],
|
||||||
|
"qa": [], "chapters": [],
|
||||||
|
"review": {"status": "draft", "reviewer": "", "reviewed_at": None, "input_sha256": None}}
|
||||||
|
write(path, plan)
|
||||||
|
return {"plan": str(path), "status": "draft", "cue_count": len(cues)}
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
sub = parser.add_subparsers(dest="command", required=True)
|
||||||
|
for command in ("draft", "signature", "validate"):
|
||||||
|
p = sub.add_parser(command)
|
||||||
|
p.add_argument("--manifest", type=Path, required=True)
|
||||||
|
p.add_argument("--plan", type=Path, required=True)
|
||||||
|
p = sub.add_parser("build")
|
||||||
|
p.add_argument("--catalog", type=Path, required=True)
|
||||||
|
p.add_argument("--output", type=Path, required=True)
|
||||||
|
p = sub.add_parser("search")
|
||||||
|
p.add_argument("--root", type=Path, required=True)
|
||||||
|
p.add_argument("--query", required=True)
|
||||||
|
p.add_argument("--limit", type=int, default=5)
|
||||||
|
p = sub.add_parser("verify")
|
||||||
|
p.add_argument("--root", type=Path, required=True)
|
||||||
|
args = parser.parse_args()
|
||||||
|
try:
|
||||||
|
if args.command == "draft":
|
||||||
|
result = draft(args.manifest, args.plan)
|
||||||
|
elif args.command == "signature":
|
||||||
|
result = {"input_sha256": inputs(args.manifest, args.plan)[4]}
|
||||||
|
elif args.command == "validate":
|
||||||
|
result = {"media_id": artifacts(args.manifest, args.plan)[0]["media_id"], "valid": True}
|
||||||
|
elif args.command == "build":
|
||||||
|
result = build(args.catalog, args.output)
|
||||||
|
elif args.command == "search":
|
||||||
|
result = search(args.root, args.query, args.limit)
|
||||||
|
else:
|
||||||
|
result = {"root": str(verify_export(args.root)), "valid": True}
|
||||||
|
print(encoded(result).decode("utf-8"), end="")
|
||||||
|
except Exception as error:
|
||||||
|
print(f"ERROR: {error}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Skills
|
||||||
|
|
||||||
|
- [media-intake](skills/media-intake/SKILL.md): inspect the sources, extract metadata from supplied pages, and interview the owner about missing useful facts. Start here.
|
||||||
|
- [structure-media](skills/structure-media/SKILL.md): use the intake to author chunks, grounded Q&A, and chapters; build inside the supplied folder, then return for human review.
|
||||||
|
|
||||||
|
Both skills are repository-local. Primary executable: [folder_builder.py](scripts/folder_builder.py). [media_builder.py](scripts/media_builder.py) is the later optional approved public exporter. Neither installs transcription, publication, API, or MCP services.
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
name: media-intake
|
||||||
|
description: Interview the owner about an audio or video folder before creating structured media assets. Inspect existing recording, TXT, and VTT files, collect missing metadata in one grouped intake, preserve unknowns, and hand off to structure-media for a local draft and human review.
|
||||||
|
---
|
||||||
|
|
||||||
|
The user supplies a folder containing a recording plus its TXT and VTT speech-to-text files. Read the repository README and `templates/media-intake.md`. Inspect the folder and any existing intake/review records first. Do not ask the user to create JSON, run a web server, or provide metadata already in their prompt.
|
||||||
|
|
||||||
|
1. Run `scripts/folder_builder.py inspect --folder <folder>` to inventory sources, duration evidence, transcript alignment, and source hashes. Resolve ambiguous source sets with the user. Preserve all three originals unchanged.
|
||||||
|
2. Prefill file-derived facts and inspect official source pages supplied by the user. Record page URLs as provenance. Treat filename titles/dates as candidates; STT names and URLs remain unverified unless supported elsewhere. Keep recording date separate from article/upload date. Extract page-supported participant spellings without silently correcting transcript text or assigning speaker labels. A public video does not establish reuse rights.
|
||||||
|
3. Ask one grouped interview for missing useful information using the README checklist: identity/date/participants, purpose/audience/retrieval questions, links/supporting material, attribution/rights/sharing limits, and transcript quality. Consolidate into a small number of questions; accept a partial answer or “unknown.” Do not repeat questions already answered.
|
||||||
|
4. Record the answers in `media-intake.json`, with field-level provenance and unresolved items. Unknown URLs, licenses, dates, speaker identities, or publication decisions remain null/unknown; do not substitute example-domain facts. The user may approve inferred descriptions/tags later. Resolve source ambiguity and requested sensitive-content exclusions before generating affected text. Missing optional publication facts do not block a local draft.
|
||||||
|
5. Tell the user the assumptions that materially affect the draft. If optional questions remain unanswered after a reasonable opportunity to reply, preserve them as pending and continue independent work; an elapsed wait is not approval or an answer. Hand off to `skills/structure-media/SKILL.md` after intake, using the same answers rather than interviewing again.
|
||||||
|
|
||||||
|
The default deliverable is `structured/` inside the supplied folder, built for review. Building it does not mark the transcript, identity, rights, or derived answers approved, and does not publish anything. The existing public-site exporter is a later optional step after human review and real publication details exist.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
name: structure-media
|
||||||
|
description: Build draft chunks, grounded Q&A, chapters, and discovery assets inside an audio/video folder after metadata intake. Use existing recording, TXT, and VTT files; leave the result for human review and preserve unknown publication facts.
|
||||||
|
---
|
||||||
|
|
||||||
|
Read `README.md`, `docs/workflow.md`, the folder's intake record, and its VTT/TXT. Complete `skills/media-intake/SKILL.md` first if intake has not occurred. Use `schemas/` for field details. Run commands from the template repository root; the supplied recording folder can be anywhere authorized by the user.
|
||||||
|
|
||||||
|
The recording, TXT, and VTT are already supplied. Preserve their bytes and filenames. This skill does not retranscribe, download, move, or publish them. Use VTT for timing and exact quoted words; compare TXT and report differences rather than rewriting either source. Inspect the whole transcript, including limitations, Q&A, and closing context. Flag STT errors and visual information unavailable from audio.
|
||||||
|
|
||||||
|
Use `folder_builder.py seed` to initialize a draft plan only when none exists. Author conceptual chunks that collectively cover every included cue exactly once. Use topic boundaries and self-contained retrieval units, not a single whole-recording chunk or arbitrary time windows. Preserve existing semantic IDs when meaning continues; increment changed chunk versions. For splits/merges assign new IDs and record prior IDs in `supersedes`. Never regenerate all identities from ordinal positions or timestamps.
|
||||||
|
|
||||||
|
Write Q&A that helps a person or agent retrieve useful information. Ground each answer in exact quotes and correct chunk/cue references. Label extractive versus synthesized answers and cite every material supporting source. If the recording does not answer a question, omit it or explicitly describe the stated limitation with evidence. Do not invent decisions, tasks, attribution, facts, confidence, or visually presented content from speech alone.
|
||||||
|
|
||||||
|
Chapters describe navigation, not necessarily every semantic chunk. Choose ordered, non-overlapping cue ranges. Summaries, Q&A, and labels are interpretations; exact chunk text is materialized by the script.
|
||||||
|
|
||||||
|
Build with `folder_builder.py build --folder <folder> --intake <folder>/media-intake.json --plan <folder>/structure-plan.json --output <folder>/structured`. Keep review status draft. Supply an accurate overview, grounded Q&A, useful topic tags, chapters, and a concise review checklist calling out unconfirmed identities, numbers, source artifacts, and missing metadata. A local draft must not be blocked by missing hosted URLs or publication approval. Never invent human review or rights clearance to satisfy a schema.
|
||||||
|
|
||||||
|
Run folder-export verification, cue coverage, exact quote checks, source-hash readback, and representative retrieval checks. Return direct links to `structured/README.md` and `structured/review.md`. Leave existing outputs intact; use `structured-002/` or another new directory for revisions. Record unknowns and unfinished checks plainly. Human review follows the build. For a later public export, follow `PUBLICATION_WORKFLOW.md` and the approved-release commands in `docs/public-export.md`; this skill does not authorize Git pushes or deployment.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Starter inputs
|
||||||
|
|
||||||
|
Default folder-first workflow: use [media-intake.md](media-intake.md). The AI inspects sources, asks missing questions, and creates intake/plan JSON for you. Unknown publication facts do not block local drafts.
|
||||||
|
|
||||||
|
The following templates support only the later optional approved public exporter:
|
||||||
|
|
||||||
|
Copy [media.json](media.json) into each recording's source folder and [catalog.json](catalog.json) into its parent collection folder. Replace every example fact and URL. Set real rights and review states only after checking them. Templates intentionally start with consent/privacy pending and redistribution disallowed.
|
||||||
|
|
||||||
|
Generate `plan.json` with the builder's `draft` command after preparing TXT/VTT. This avoids hand-creating nonexistent cue references. Never copy an example's approval hash into a real plan.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"schema_version": "1.0",
|
||||||
|
"title": "Replace with collection title",
|
||||||
|
"site_url": "https://media.example.org",
|
||||||
|
"allow_synthetic": false,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"manifest": "replace-with-media-id/media.json",
|
||||||
|
"plan": "replace-with-media-id/plan.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Optional metadata to include with your processing request
|
||||||
|
|
||||||
|
Copy this list into your prompt and fill in what you know. Partial answers are enough; the AI will inspect the files first and ask for useful missing information. “Unknown” is a valid answer.
|
||||||
|
|
||||||
|
- **Folder:** path containing the original audio/video, TXT, and VTT files.
|
||||||
|
- **Identity:** official title; recording date and timezone; organizer/publisher; series and part/episode; event type.
|
||||||
|
- **People:** hosts, speakers, moderators, affiliations, preferred name spellings, and any credits to include.
|
||||||
|
- **Purpose:** short description; intended audience; topics/tags; questions someone should be able to answer or actions the recording should support. The AI can draft these from the transcript.
|
||||||
|
- **Links:** original recording/webinar page, intended landing page, media URL, slides, reports, datasets, resources, related sessions. These can be added later.
|
||||||
|
- **Rights and scope:** preferred attribution, known license/rights statement, sharing restrictions, sections to exclude, and whether this is only a local review draft. Publication is a separate decision.
|
||||||
|
- **Transcript quality:** STT tool/model if known, whether you reviewed it, known errors, speaker labels, missing sections, languages, and whether visuals/slides carry information absent from the transcript.
|
||||||
|
- **Preferences:** desired depth, priority topics, terminology, output language, or special downstream API/MCP/RAG needs.
|
||||||
|
|
||||||
|
The AI records confirmed facts separately from file observations, transcript claims, draft interpretations, and unknowns. You review the generated structure after the build; you do not need to preapprove every chunk or manually populate machine files.
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"schema_version": "1.0",
|
||||||
|
"media_id": "replace-with-media-id",
|
||||||
|
"kind": "video",
|
||||||
|
"title": "Replace with recording title",
|
||||||
|
"description": "Replace with an accurate description",
|
||||||
|
"language": "en",
|
||||||
|
"canonical_url": "https://media.example.org/media/replace-with-media-id/",
|
||||||
|
"content_url": "https://cdn.example.org/example-webinar.mp4",
|
||||||
|
"embed_url": null,
|
||||||
|
"thumbnail_url": "https://cdn.example.org/example-webinar.jpg",
|
||||||
|
"duration_seconds": 60,
|
||||||
|
"recorded_at": null,
|
||||||
|
"published_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"updated_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"synthetic": false,
|
||||||
|
"creators": [
|
||||||
|
{
|
||||||
|
"name": "Example presenter",
|
||||||
|
"role": "speaker"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transcripts": {
|
||||||
|
"txt": "transcript.txt",
|
||||||
|
"vtt": "transcript.vtt"
|
||||||
|
},
|
||||||
|
"transcription": {
|
||||||
|
"method": "stt",
|
||||||
|
"engine": "Replace with STT tool",
|
||||||
|
"model": null,
|
||||||
|
"generated_at": "2026-10-17T12:00:00-06:00",
|
||||||
|
"reviewed_by": "Replace with reviewer",
|
||||||
|
"visual_coverage": "not-assessed"
|
||||||
|
},
|
||||||
|
"rights": {
|
||||||
|
"statement": "Replace with verified rights and attribution",
|
||||||
|
"license": null,
|
||||||
|
"usage_info": null,
|
||||||
|
"redistribution_allowed": false
|
||||||
|
},
|
||||||
|
"publication": {
|
||||||
|
"consent": "pending",
|
||||||
|
"privacy_review": "pending"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
import json
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
sys.path.insert(0, str(ROOT/'scripts'))
|
||||||
|
import folder_builder as fb
|
||||||
|
import media_builder as core
|
||||||
|
|
||||||
|
|
||||||
|
class FolderBuilderTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
(ROOT/'.test-work').mkdir(exist_ok=True)
|
||||||
|
self.temp = tempfile.TemporaryDirectory(dir=ROOT/'.test-work')
|
||||||
|
self.folder = Path(self.temp.name)/'recording'
|
||||||
|
self.folder.mkdir()
|
||||||
|
source = ROOT/'examples/example-webinar'
|
||||||
|
for ext in ('txt','vtt'):
|
||||||
|
shutil.copyfile(source/('transcript.'+ext),self.folder/('different-name.'+ext))
|
||||||
|
(self.folder/'recording.mp3').write_bytes(b'synthetic unavailable audio')
|
||||||
|
self.intake = self.folder/'media-intake.json'
|
||||||
|
self.plan = self.folder/'structure-plan.json'
|
||||||
|
self.output = self.folder/'structured'
|
||||||
|
fb.prepare(self.folder,self.intake)
|
||||||
|
fb.seed(self.folder,self.intake,self.plan)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.temp.cleanup()
|
||||||
|
|
||||||
|
def edit(self,path,change):
|
||||||
|
value=core.load(path);change(value);core.write(path,value)
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
return fb.build(self.folder,self.intake,self.plan,self.output)
|
||||||
|
|
||||||
|
def test_unknown_metadata_and_no_approval_allow_local_draft(self):
|
||||||
|
before=fb.inspect(self.folder)[0]['source_files']
|
||||||
|
self.build()
|
||||||
|
self.assertTrue(fb.verify(self.output)['valid'])
|
||||||
|
media=core.load(self.output/'media.json')
|
||||||
|
self.assertIsNone(media['canonical_url'])
|
||||||
|
self.assertFalse(media['human_approval'])
|
||||||
|
self.assertFalse(media['publication_ready'])
|
||||||
|
self.assertEqual(media['source_audit']['source_files'],before)
|
||||||
|
self.assertNotIn('url',core.load(self.output/'schema.jsonld'))
|
||||||
|
|
||||||
|
def test_originals_and_prior_output_preserved(self):
|
||||||
|
self.build()
|
||||||
|
original=(self.folder/'different-name.txt').read_bytes()
|
||||||
|
receipt=(self.output/'build-receipt.json').read_bytes()
|
||||||
|
with self.assertRaisesRegex(ValueError,'Output exists'):
|
||||||
|
self.build()
|
||||||
|
self.assertEqual((self.folder/'different-name.txt').read_bytes(),original)
|
||||||
|
self.assertEqual((self.output/'build-receipt.json').read_bytes(),receipt)
|
||||||
|
|
||||||
|
def test_txt_mismatch_is_review_issue_not_silent_rewrite(self):
|
||||||
|
(self.folder/'different-name.txt').write_text('An alternate transcript.',encoding='utf-8')
|
||||||
|
self.build()
|
||||||
|
self.assertFalse(core.load(self.output/'media.json')['source_audit']['txt_vtt_match'])
|
||||||
|
self.assertIn('TXT and VTT differ',(self.output/'review.md').read_text(encoding='utf-8'))
|
||||||
|
self.assertEqual((self.folder/'different-name.txt').read_text(),'An alternate transcript.')
|
||||||
|
|
||||||
|
def test_source_tampering_invalidates_verification(self):
|
||||||
|
self.build()
|
||||||
|
(self.folder/'recording.mp3').write_bytes(b'changed')
|
||||||
|
with self.assertRaisesRegex(ValueError,'Original source changed'):
|
||||||
|
fb.verify(self.output)
|
||||||
|
|
||||||
|
def test_mechanical_coverage_before_write(self):
|
||||||
|
self.edit(self.plan,lambda p:p['chunks'][0]['cue_ids'].pop())
|
||||||
|
with self.assertRaisesRegex(ValueError,'each included cue'):
|
||||||
|
self.build()
|
||||||
|
self.assertFalse(self.output.exists())
|
||||||
|
|
||||||
|
def test_local_exact_evidence_and_search(self):
|
||||||
|
quote='Keep the plain text transcript and the timed VTT file together.'
|
||||||
|
def change(plan):
|
||||||
|
plan['qa']=[{'qa_id':'recording:qa:files','question':'Which transcript files are useful?',
|
||||||
|
'answer':quote,'answer_type':'extractive','evidence':[{'chunk_id':plan['chunks'][0]['chunk_id'],
|
||||||
|
'cue_id':'cue-000002','quote':quote}]}]
|
||||||
|
self.edit(self.plan,change)
|
||||||
|
self.build()
|
||||||
|
results = fb.search(self.output,'transcript files',10)
|
||||||
|
self.assertEqual(results[0]['type'],'qa')
|
||||||
|
q=next(r for r in results if r['type']=='qa')
|
||||||
|
self.assertEqual(q['citations'][0]['transcript_ref'],'transcript.md#cue-000002')
|
||||||
|
self.assertIsNone(q['citations'][0]['transcript_url'])
|
||||||
|
self.assertIsNone(q['citations'][0]['playback_url'])
|
||||||
|
|
||||||
|
def test_excluded_cue_not_exported_and_original_kept(self):
|
||||||
|
self.edit(self.intake,lambda i:i.update(excluded_cue_ids=['cue-000001']))
|
||||||
|
self.edit(self.plan,lambda p:p['chunks'][0]['cue_ids'].remove('cue-000001'))
|
||||||
|
self.build()
|
||||||
|
cues=core.load(self.output/'transcript.json')['cues']
|
||||||
|
self.assertNotIn('cue-000001',{c['cue_id'] for c in cues})
|
||||||
|
self.assertIn('Today we discuss',(self.folder/'different-name.vtt').read_text())
|
||||||
|
|
||||||
|
def test_ambiguous_sources_require_selection(self):
|
||||||
|
(self.folder/'second.mp3').write_bytes(b'other')
|
||||||
|
with self.assertRaisesRegex(ValueError,'Expected one media'):
|
||||||
|
fb.inspect(self.folder)
|
||||||
|
# Existing explicit selection still works.
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_mp3_encoded_duration_from_frames(self):
|
||||||
|
path=self.folder/'encoded.mp3'
|
||||||
|
frame=bytes.fromhex('fffb9000')+bytes(413)
|
||||||
|
path.write_bytes(frame*100)
|
||||||
|
self.assertAlmostEqual(fb.mp3_duration(path),100*1152/44100,places=3)
|
||||||
|
|
||||||
|
def test_no_fake_human_approval(self):
|
||||||
|
self.edit(self.plan,lambda p:p['review'].update(reviewer='Invented reviewer'))
|
||||||
|
with self.assertRaisesRegex(ValueError,'claimed human approval'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_outside_source_folder_rejected(self):
|
||||||
|
with self.assertRaisesRegex(ValueError,'immediate subfolder'):
|
||||||
|
fb.build(self.folder,self.intake,self.plan,Path(self.temp.name)/'outside')
|
||||||
|
|
||||||
|
def test_deterministic_local_builds(self):
|
||||||
|
self.build()
|
||||||
|
other=self.folder/'structured-002'
|
||||||
|
fb.build(self.folder,self.intake,self.plan,other)
|
||||||
|
self.assertEqual(core.load(self.output/'build-receipt.json'),core.load(other/'build-receipt.json'))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,243 @@
|
|||||||
|
import copy
|
||||||
|
import json
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from jsonschema import Draft202012Validator
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
sys.path.insert(0, str(ROOT / 'scripts'))
|
||||||
|
import media_builder as mb
|
||||||
|
|
||||||
|
|
||||||
|
class MediaBuilderTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
temp_root = ROOT / '.test-work'
|
||||||
|
temp_root.mkdir(exist_ok=True)
|
||||||
|
self.temp = tempfile.TemporaryDirectory(dir=temp_root)
|
||||||
|
self.work = Path(self.temp.name)
|
||||||
|
shutil.copytree(ROOT / 'examples', self.work / 'source')
|
||||||
|
self.folder = self.work / 'source' / 'example-webinar'
|
||||||
|
self.manifest = self.folder / 'media.json'
|
||||||
|
self.plan = self.folder / 'plan.json'
|
||||||
|
self.catalog = self.work / 'source' / 'catalog.json'
|
||||||
|
self.out = self.work / 'release'
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.temp.cleanup()
|
||||||
|
|
||||||
|
def edit(self, path, change):
|
||||||
|
value = mb.load(path)
|
||||||
|
change(value)
|
||||||
|
mb.write(path, value)
|
||||||
|
|
||||||
|
def approve_fixture(self):
|
||||||
|
signature = mb.inputs(self.manifest, self.plan)[4]
|
||||||
|
self.edit(self.plan, lambda p: p['review'].update(input_sha256=signature))
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
return mb.build(self.catalog, self.out)
|
||||||
|
|
||||||
|
def test_all_schemas_valid(self):
|
||||||
|
for path in (ROOT / 'schemas').glob('*.schema.json'):
|
||||||
|
Draft202012Validator.check_schema(mb.load(path))
|
||||||
|
|
||||||
|
def test_audio_video_and_source_citations(self):
|
||||||
|
self.assertEqual(self.build()['media_count'], 2)
|
||||||
|
mb.verify_export(self.out)
|
||||||
|
video = self.out / 'media' / 'example-webinar'
|
||||||
|
data = mb.load(video / 'chunks.json')
|
||||||
|
self.assertEqual(data['chunks'][1]['content'],
|
||||||
|
'A conceptual chunk should cover one topic and preserve the words from its source cues. '
|
||||||
|
'Each answer needs a transcript citation with start and end times.')
|
||||||
|
self.assertEqual(data['chunks'][1]['citations'][1]['start_seconds'], 30)
|
||||||
|
self.assertEqual(mb.load(video / 'schema.jsonld')['@type'], 'VideoObject')
|
||||||
|
self.assertEqual(mb.load(self.out / 'media/example-audio/schema.jsonld')['@type'], 'AudioObject')
|
||||||
|
self.assertNotIn('transcripts', mb.load(video / 'media.json'))
|
||||||
|
self.assertEqual((video / 'transcript.vtt').read_bytes(), (self.folder / 'transcript.vtt').read_bytes())
|
||||||
|
self.assertFalse(mb.load(self.out / 'build-receipt.json')['deployment_verified'])
|
||||||
|
|
||||||
|
def test_deterministic_release(self):
|
||||||
|
self.build()
|
||||||
|
other = self.work / 'release-2'
|
||||||
|
mb.build(self.catalog, other)
|
||||||
|
self.assertEqual(mb.load(self.out / 'build-receipt.json'), mb.load(other / 'build-receipt.json'))
|
||||||
|
|
||||||
|
def test_search_returns_timed_cross_chunk_evidence(self):
|
||||||
|
self.build()
|
||||||
|
matches = mb.search(self.out, 'transcript citations', 10)
|
||||||
|
result = next(r for r in matches if r['id'] == 'example-webinar:qa:two')
|
||||||
|
self.assertEqual({c['chunk_id'] for c in result['citations']},
|
||||||
|
{'example-webinar:chunk:transcripts', 'example-webinar:chunk:citations'})
|
||||||
|
self.assertTrue(all(c['transcript_url'].endswith(c['cue_id']) for c in result['citations']))
|
||||||
|
self.assertEqual(mb.search(self.out, 'unmentionedword'), [])
|
||||||
|
|
||||||
|
def test_stale_approval_and_no_partial_output(self):
|
||||||
|
self.edit(self.manifest, lambda m: m.update(title='Changed title'))
|
||||||
|
with self.assertRaisesRegex(ValueError, 'stale'):
|
||||||
|
self.build()
|
||||||
|
self.assertFalse(self.out.exists())
|
||||||
|
|
||||||
|
def test_changed_plan_invalidates_approval(self):
|
||||||
|
self.edit(self.plan, lambda p: p['qa'][0].update(answer='Changed answer'))
|
||||||
|
with self.assertRaisesRegex(ValueError, 'stale'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_draft_cannot_build(self):
|
||||||
|
self.edit(self.plan, lambda p: p['review'].update(status='draft'))
|
||||||
|
with self.assertRaisesRegex(ValueError, 'Review missing'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_privacy_and_rights_gates(self):
|
||||||
|
original = mb.load(self.manifest)
|
||||||
|
for branch, field, value in [('publication', 'consent', 'pending'),
|
||||||
|
('publication', 'privacy_review', 'pending'),
|
||||||
|
('rights', 'redistribution_allowed', False)]:
|
||||||
|
media = copy.deepcopy(original)
|
||||||
|
media[branch][field] = value
|
||||||
|
mb.write(self.manifest, media)
|
||||||
|
self.approve_fixture()
|
||||||
|
with self.assertRaisesRegex(ValueError, 'cleared consent/privacy'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_exact_quote_required(self):
|
||||||
|
self.edit(self.plan, lambda p: p['qa'][0]['evidence'][0].update(quote='This was never said.'))
|
||||||
|
self.approve_fixture()
|
||||||
|
with self.assertRaisesRegex(ValueError, 'exact substring'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_quote_must_belong_to_cited_chunk(self):
|
||||||
|
self.edit(self.plan, lambda p: p['qa'][0]['evidence'][0].update(chunk_id='example-webinar:chunk:citations'))
|
||||||
|
self.approve_fixture()
|
||||||
|
with self.assertRaisesRegex(ValueError, 'does not belong'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_source_coverage_and_duplicate_identity(self):
|
||||||
|
original = mb.load(self.plan)
|
||||||
|
for mutation, error in [
|
||||||
|
(lambda p: p['chunks'][0]['cue_ids'].pop(), 'cover every cue'),
|
||||||
|
(lambda p: p['chunks'][1].update(chunk_id=p['chunks'][0]['chunk_id']), 'Duplicate chunk_id')]:
|
||||||
|
plan = copy.deepcopy(original)
|
||||||
|
mutation(plan)
|
||||||
|
mb.write(self.plan, plan)
|
||||||
|
self.approve_fixture()
|
||||||
|
with self.assertRaisesRegex(ValueError, error):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_overlap_and_bad_duration_rejected(self):
|
||||||
|
for vtt, duration, error in [
|
||||||
|
('WEBVTT\n\n00:00.000 --> 00:02.000\na\n\n00:01.000 --> 00:03.000\nb\n', 4, 'Overlapping'),
|
||||||
|
('WEBVTT\n\n00:00.000 --> 00:02.000\na\n', 1, 'outside declared')]:
|
||||||
|
with self.assertRaisesRegex(ValueError, error):
|
||||||
|
mb.parse_vtt(vtt, duration)
|
||||||
|
|
||||||
|
def test_vtt_normalization_preserves_voice_unicode_and_entities(self):
|
||||||
|
text = '\ufeffWEBVTT\r\n\r\nNOTE example\r\n\r\noriginal\r\n00:00.000 --> 00:02.000 align:start\r\n<v Ana><b>Café</b> & tea.\r\nSecond line.</v>\r\n'
|
||||||
|
cue = mb.parse_vtt(text, 2)[0]
|
||||||
|
self.assertEqual(cue['text'], 'Café & tea. Second line.')
|
||||||
|
self.assertEqual(cue['speaker'], 'Ana')
|
||||||
|
self.assertEqual(cue['source_cue_id'], 'original')
|
||||||
|
|
||||||
|
def test_unsupported_vtt_fails_explicitly(self):
|
||||||
|
for body in ['STYLE\n::cue {color:red}', '00:00.000 --> 00:02.000\n<00:01.000>word']:
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
mb.parse_vtt('WEBVTT\n\n' + body, 2)
|
||||||
|
|
||||||
|
def test_txt_mismatch_rejected(self):
|
||||||
|
(self.folder / 'transcript.txt').write_text('Unrelated source.', encoding='utf-8')
|
||||||
|
with self.assertRaisesRegex(ValueError, 'TXT/VTT text differs'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_catalog_path_traversal_and_synthetic_gate(self):
|
||||||
|
original = mb.load(self.catalog)
|
||||||
|
self.edit(self.catalog, lambda c: c['items'][0].update(manifest='../escape.json'))
|
||||||
|
with self.assertRaisesRegex(ValueError, 'inside'):
|
||||||
|
self.build()
|
||||||
|
mb.write(self.catalog, original)
|
||||||
|
self.edit(self.catalog, lambda c: c.update(allow_synthetic=False))
|
||||||
|
with self.assertRaisesRegex(ValueError, 'Synthetic media blocked'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_duplicate_media_and_later_failure_leave_no_output(self):
|
||||||
|
self.edit(self.catalog, lambda c: c['items'].append(c['items'][0]))
|
||||||
|
with self.assertRaisesRegex(ValueError, 'Duplicate media_id'):
|
||||||
|
self.build()
|
||||||
|
self.assertFalse(self.out.exists())
|
||||||
|
|
||||||
|
def test_existing_output_preserved(self):
|
||||||
|
self.out.mkdir()
|
||||||
|
marker = self.out / 'keep.txt'
|
||||||
|
marker.write_text('keep', encoding='utf-8')
|
||||||
|
with self.assertRaisesRegex(ValueError, 'already exists'):
|
||||||
|
self.build()
|
||||||
|
self.assertEqual(marker.read_text(encoding='utf-8'), 'keep')
|
||||||
|
|
||||||
|
def test_failure_in_second_recording_does_not_write_first(self):
|
||||||
|
audio = self.work / 'source/example-audio/media.json'
|
||||||
|
self.edit(audio, lambda m: m.update(title='Unreviewed change'))
|
||||||
|
with self.assertRaisesRegex(ValueError, 'stale'):
|
||||||
|
self.build()
|
||||||
|
self.assertFalse(self.out.exists())
|
||||||
|
self.assertFalse(list(self.work.glob('.media-build-*')))
|
||||||
|
|
||||||
|
def test_export_tampering_blocks_search(self):
|
||||||
|
self.build()
|
||||||
|
with (self.out / 'media/example-webinar/qa.json').open('a', encoding='utf-8') as f:
|
||||||
|
f.write(' ')
|
||||||
|
with self.assertRaisesRegex(ValueError, 'differ from build receipt'):
|
||||||
|
mb.search(self.out, 'transcript')
|
||||||
|
|
||||||
|
def test_embed_only_does_not_claim_time_seeking(self):
|
||||||
|
self.edit(self.manifest, lambda m: m.update(content_url=None, embed_url='https://video.example.org/player/1'))
|
||||||
|
self.approve_fixture()
|
||||||
|
self.build()
|
||||||
|
folder = self.out / 'media/example-webinar'
|
||||||
|
self.assertNotIn('hasPart', mb.load(folder / 'schema.jsonld'))
|
||||||
|
self.assertIsNone(mb.load(folder / 'chunks.json')['chunks'][0]['citations'][0]['playback_url'])
|
||||||
|
|
||||||
|
def test_html_and_jsonld_escape_script_content(self):
|
||||||
|
self.edit(self.manifest, lambda m: m.update(title='</script><script>alert(1)</script>'))
|
||||||
|
self.approve_fixture()
|
||||||
|
self.build()
|
||||||
|
page = (self.out / 'media/example-webinar/index.html').read_text(encoding='utf-8')
|
||||||
|
self.assertNotIn('</script><script>alert(1)</script>', page)
|
||||||
|
self.assertIn('</script>', page)
|
||||||
|
self.assertIn('\\u003c/script>', page)
|
||||||
|
|
||||||
|
def test_signed_url_rejected(self):
|
||||||
|
self.edit(self.manifest, lambda m: m.update(content_url='https://cdn.example.org/video?token=private'))
|
||||||
|
with self.assertRaisesRegex(ValueError, 'signed or credential'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_draft_is_blocked_and_does_not_replace_plan(self):
|
||||||
|
draft = self.folder / 'draft.json'
|
||||||
|
mb.draft(self.manifest, draft)
|
||||||
|
self.assertEqual(mb.load(draft)['review']['status'], 'draft')
|
||||||
|
with self.assertRaisesRegex(ValueError, 'Review missing'):
|
||||||
|
mb.artifacts(self.manifest, draft)
|
||||||
|
with self.assertRaisesRegex(ValueError, 'already exists'):
|
||||||
|
mb.draft(self.manifest, draft)
|
||||||
|
|
||||||
|
def test_unknown_contract_fields_rejected(self):
|
||||||
|
self.edit(self.manifest, lambda m: m.update(secret_note='should not export'))
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
def test_empty_qa_is_valid(self):
|
||||||
|
self.edit(self.plan, lambda p: p.update(qa=[]))
|
||||||
|
self.approve_fixture()
|
||||||
|
self.build()
|
||||||
|
self.assertEqual(mb.load(self.out / 'media/example-webinar/qa.json')['qa'], [])
|
||||||
|
|
||||||
|
def test_chapter_range_reversed(self):
|
||||||
|
self.edit(self.plan, lambda p: p['chapters'][0].update(start_cue_id='cue-000002', end_cue_id='cue-000001'))
|
||||||
|
self.approve_fixture()
|
||||||
|
with self.assertRaisesRegex(ValueError, 'ordered and non-overlapping'):
|
||||||
|
self.build()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Reference in new issue
Block a user