{
  "schemaVersion": "1",
  "revision": "22ce5d34dbcb5a78",
  "id": "factory-video-analysis-reference",
  "slug": "video-analysis-reference",
  "title": "Video analysis recipes, prompts, and evidence gates",
  "summary": "Complete media-normalization commands, long/short analysis branches, omission and reconciliation prompts, keyframe procedures, and publication evidence gates.",
  "category": "Verification",
  "tags": [
    "video",
    "prompts",
    "ffmpeg",
    "evidence",
    "oracle"
  ],
  "sources": [
    {
      "label": "Published repeatable video reference",
      "url": "https://shiny-rosette-m6zy.here.now/skills/oracle-video/references/repeatable-video-followup-process.md"
    }
  ],
  "sourceUnits": [
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Long Recording Workflow",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Short Recording Workflow",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Gemini Readiness And Failure Recovery",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Gemini Browser Cleanup",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Prompt Templates",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Verification Gates",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Keyframes",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Final Packet Review",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Project Setup",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Run Config",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Mode Matrix",
    "08-oracle-video/skills/oracle-video/references/repeatable-video-followup-process.md#Decision Tree"
  ],
  "collection": "factory",
  "categoryId": "verification",
  "wordCount": 3758,
  "url": "/topics/factory-video-analysis-reference/",
  "markdownUrl": "/markdown/factory-video-analysis-reference.md?raw=1&v=22ce5d34dbcb5a78",
  "jsonUrl": "/api/v1/documents/factory-video-analysis-reference.json",
  "headings": [
    {
      "id": "prerequisites-and-safe-local-setup",
      "text": "Prerequisites and safe local setup",
      "level": 2
    },
    {
      "id": "run-config",
      "text": "Run Config",
      "level": 2
    },
    {
      "id": "mode-matrix",
      "text": "Mode Matrix",
      "level": 2
    },
    {
      "id": "decision-tree",
      "text": "Decision Tree",
      "level": 2
    },
    {
      "id": "long-recording-workflow",
      "text": "Long Recording Workflow",
      "level": 2
    },
    {
      "id": "short-recording-workflow",
      "text": "Short Recording Workflow",
      "level": 2
    },
    {
      "id": "gemini-readiness-and-failure-recovery",
      "text": "Gemini Readiness And Failure Recovery",
      "level": 2
    },
    {
      "id": "gemini-browser-cleanup",
      "text": "Gemini Browser Cleanup",
      "level": 2
    },
    {
      "id": "prompt-templates",
      "text": "Prompt Templates",
      "level": 2
    },
    {
      "id": "gemini-chunk-analysis",
      "text": "Gemini Chunk Analysis",
      "level": 3
    },
    {
      "id": "omissions-pass",
      "text": "Omissions Pass",
      "level": 3
    },
    {
      "id": "local-reconciliation",
      "text": "Local Reconciliation",
      "level": 3
    },
    {
      "id": "short-clip-analysis",
      "text": "Short Clip Analysis",
      "level": 3
    },
    {
      "id": "final-packet-generation",
      "text": "Final Packet Generation",
      "level": 3
    },
    {
      "id": "oracle-review",
      "text": "Oracle Review",
      "level": 3
    },
    {
      "id": "verification-gates",
      "text": "Verification Gates",
      "level": 2
    },
    {
      "id": "keyframes",
      "text": "Keyframes",
      "level": 2
    },
    {
      "id": "final-packet-review",
      "text": "Final Packet Review",
      "level": 2
    }
  ],
  "markdown": "# Video analysis recipes, prompts, and evidence gates\n\nComplete portable procedures for preparing analysis media, proving video understanding, extracting and reconciling evidence, and reviewing a follow-up packet. These are reference recipes—not a claim that this knowledge base independently processed the recording. Commands use generic local run paths; raw logs and source conversations remain private.\n\nThe short-clip and follow-up-packet prompts retain their original output audience as task examples for teammates preparing those materials. They are not instructions to publish unreviewed source data.\n\n## Prerequisites and safe local setup\n\nUse a dedicated, existing Git repository for the analysis artifacts—not the source software project. Install `ffmpeg`, `ffprobe`, `git`, `jq`, `python3`, and a SHA-256 utility (`shasum` in these examples) before starting. The later consult stages additionally require the configured Oracle browser workflow, Packx, and a signed-in Gemini browser profile; the setup below does not configure accounts or read credentials.\n\nRun the setup in Bash and keep the same shell for later snippets, so `RUN_ID` and `RUN_DIR` remain defined. Set `SOURCE_VIDEO` to your existing source MP4 and `RUN_ID` to a new, simple label first. Missing values, invalid labels, absent media, and an existing run directory stop before creating or overwriting a run. Optional transcript/chat inputs must be separately approved for local processing and remain private until reviewed and redacted.\n\n```bash\nset -euo pipefail\n: \"${SOURCE_VIDEO:?Set SOURCE_VIDEO to an existing source MP4}\"\n: \"${RUN_ID:?Set RUN_ID to a new analysis label}\"\ncase \"$RUN_ID\" in\n  ''|*[!a-zA-Z0-9_-]*) printf 'RUN_ID must contain only letters, digits, underscore, or hyphen\\n' >&2; exit 1 ;;\nesac\nPROJECT_ROOT=\"$(git rev-parse --show-toplevel)\"\ncd \"$PROJECT_ROOT\"\ntest -f \"$SOURCE_VIDEO\"\nRUN_DIR=\"$PROJECT_ROOT/runs/$RUN_ID\"\nif test -e \"$RUN_DIR\"; then\n  printf 'Run already exists: %s\\n' \"$RUN_DIR\" >&2\n  exit 1\nfi\nmkdir -p \"$RUN_DIR\"/{inputs,receipts,analysis,segments,break-chat,chunks,oracle/sessions,final,publication}\ngit status --short > \"$RUN_DIR/receipts/git-status.before.txt\"\ncp \"$SOURCE_VIDEO\" \"$RUN_DIR/inputs/source-video.mp4\"\nif test -n \"${SOURCE_TRANSCRIPT:-}\"; then\n  cp \"$SOURCE_TRANSCRIPT\" \"$RUN_DIR/inputs/transcript.vtt\"\nfi\nif test -n \"${SOURCE_CHAT:-}\"; then\n  cp \"$SOURCE_CHAT\" \"$RUN_DIR/inputs/chat.txt\"\nfi\n```\n\nThe original media remains untouched. The following receipt commands record tool versions, checksums, and media properties; they do not establish that Gemini can read the attachment. That requires the later source-specific probes. Keep raw inputs and receipts private; committing a local receipt is not authorization to push it or publish it.\n\nRecord tool versions:\n\n```bash\n{\n  echo \"# Tool Versions\"\n  echo\n  echo \"date: $(date -u +%Y-%m-%dT%H:%M:%SZ)\"\n  echo\n  echo \"## ffmpeg\"\n  ffmpeg -version | head -n 3 || true\n  echo\n  echo \"## ffprobe\"\n  ffprobe -version | head -n 3 || true\n  echo\n  echo \"## git\"\n  git --version || true\n  echo\n  echo \"## jq\"\n  jq --version || true\n  echo\n  echo \"## python\"\n  python3 --version || true\n} > \"$RUN_DIR/receipts/tool-versions.txt\"\n```\n\nHash source assets and save file list:\n\n```bash\nshasum -a 256 \"$RUN_DIR/inputs/source-video.mp4\" > \"$RUN_DIR/inputs/source-video.sha256\"\nfind \"$RUN_DIR/inputs\" -maxdepth 2 -type f -print0 \\\n  | xargs -0 shasum -a 256 \\\n  > \"$RUN_DIR/receipts/source-file-list.txt\"\n```\n\nProbe the source video:\n\n```bash\nffprobe -hide_banner -show_format -show_streams -of json \\\n  \"$RUN_DIR/inputs/source-video.mp4\" \\\n  > \"$RUN_DIR/receipts/ffprobe.source.json\"\n```\n\nCreate a human-readable media receipt:\n\n```bash\n{\n  echo \"# Media Info\"\n  echo\n  echo \"source: $RUN_DIR/inputs/source-video.mp4\"\n  echo \"sha256: $(cut -d ' ' -f1 \"$RUN_DIR/inputs/source-video.sha256\")\"\n  echo\n  jq -r '.format | \"- duration: \\(.duration)\\n- size: \\(.size)\\n- bit_rate: \\(.bit_rate)\"' \\\n    \"$RUN_DIR/receipts/ffprobe.source.json\"\n  echo\n  echo \"## Streams\"\n  jq -r '.streams[] | \"- index=\\(.index) type=\\(.codec_type) codec=\\(.codec_name) duration=\\(.duration // \"unknown\") width=\\(.width // \"-\") height=\\(.height // \"-\")\"' \\\n    \"$RUN_DIR/receipts/ffprobe.source.json\"\n} > \"$RUN_DIR/receipts/media-info.md\"\n```\n\n\n## Run Config\n\nCreate `$RUN_DIR/run-config.json` before processing. Set `run_id` to the same value as `RUN_ID`, and set unavailable optional transcript/chat paths to `null`:\n\n```json\n{\n  \"run_id\": \"example-workshop\",\n  \"title\": \"Example Workshop\",\n  \"mode\": \"long_workshop\",\n  \"source\": {\n    \"video\": \"inputs/source-video.mp4\",\n    \"transcript\": \"inputs/transcript.vtt\",\n    \"chat\": \"inputs/chat.txt\",\n    \"screenshots\": \"inputs/screenshots\",\n    \"clips\": \"inputs/clips\"\n  },\n  \"policy\": {\n    \"preserve_original_timestamps\": true,\n    \"canonical_chapters\": \"semantic\",\n    \"canonical_chapter_max_minutes\": 30,\n    \"analysis_shard_target_minutes\": 4,\n    \"analysis_shard_max_minutes\": 4,\n    \"analysis_attachment_target_mib\": 9,\n    \"analysis_media\": \"h264-main-yuv420p-29.97fps-aac-lc-44.1khz-faststart\",\n    \"dead_space_removal\": \"only verified long silence plus transcript/chat break evidence\",\n    \"default_video_overlap_seconds\": 0,\n    \"semantic_boundary_overlap_seconds\": 5,\n    \"qa_boundary_overlap_seconds\": 15,\n    \"chat_carry_forward\": true,\n    \"dedupe_final_materials\": true,\n    \"large_binary_git_policy\": \"local-only-unless-explicitly-approved\"\n  },\n  \"outputs\": {\n    \"student_packet\": true,\n    \"keyframes\": true,\n    \"contact_sheets\": true,\n    \"verification_reports\": true\n  }\n}\n```\n\n## Mode Matrix\n\n| Mode | Typical input | Segmentation | Transcript/chat | Keyframes | Gemini video pass | Output |\n|---|---|---:|---:|---:|---:|---|\n| Long workshop | 2-8 hour Zoom/workshop recording | Required | Required if available | Required | Required | Full student packet |\n| Medium tutorial | 20-60 minute lesson | Optional semantic chunks | Transcript required, chat optional | Recommended | Required when deriving facts from video | Guide, chapter index, resources |\n| Short bug reproduction | 30 sec-8 min screen recording | Skip | Optional | Required | Required for observed behavior | Bug report, repro steps, implementation brief |\n| Quick design feedback | 1-12 min screen and voice | Skip | Recommended if voiceover matters | Required | Required for visual/audio claims | Design-change brief, QA checklist |\n| Raw app walkthrough | 5-30 min app demo | Skip under 12 min; segment over 20 min | Recommended | Required | Required for requirements/QA extraction | Requirements doc, acceptance criteria |\n\n\"Optional\" applies only to extra Oracle planning/review over text artifacts. It does\nnot mean the video-watching step can be skipped when the deliverable depends on what\nis visible or audible in the recording.\n\n## Decision Tree\n\nSegment when any of these are true:\n\n- Video duration is over 30 minutes.\n- There are real breaks, lunch, pre-roll, or dead air.\n- Q&A spans topic transitions.\n- Chat must be aligned to the video.\n- The target output is a course packet, student packet, chapter index, or publication bundle.\n\nSkip segmentation when all of these are true:\n\n- Video duration is 12 minutes or less.\n- There is no long dead air or break.\n- Chat is absent, irrelevant, or small enough to include directly.\n- One model pass can analyze the whole video reliably.\n- The target output is a short note, bug report, design feedback memo, or compact implementation plan.\n\nUse a medium path when the video is 12-45 minutes, has no real breaks, and has 2-4 obvious sections. In that case, keep one physical video and create timestamped sections unless model upload/runtime gets awkward.\n\nRemove a video span only when long silence or inactive-screen evidence, transcript evidence, and chat evidence agree that the span is a break or dead space. Never discard chat from a removed span. Save it in `break-chat/` and carry it forward to the next spoken chunk when it contains a question, answer, link, or context used later.\n\nExtract keyframes when screen share, terminal commands, browser pages, demos, design feedback, or visual claims appear. Skip keyframes only for pure audio/talking-head content where visual evidence cannot change the output.\n\nRun an omissions pass when coverage is incomplete, missing URLs exist, missing chat questions exist, keyframe candidates are thin, machine JSON is missing/unparseable, timestamps are out of range, or hallucination checks find invented tools/links/commands.\n\n\n## Long Recording Workflow\n\n1. Detect silence:\n\n```bash\nffmpeg -hide_banner -i \"$RUN_DIR/inputs/source-video.mp4\" \\\n  -af silencedetect=noise=-35dB:d=5 \\\n  -f null - 2> \"$RUN_DIR/analysis/silencedetect-35db-5s.log\"\n```\n\n2. Draft `analysis/boundary-candidates.md` from silence, transcript, and chat evidence.\n\n3. Create `segments/segment-manifest.v1.json` and `.md`. Preserve original timestamps.\n   Define semantic chapters under 30 minutes for the canonical teaching structure, but\n   define separate technical analysis shards no longer than four minutes until a\n   source-specific production-shard probe proves a longer duration safe. Map each shard\n   back to its canonical chapter. Remove break spans only when evidence supports removal.\n\n4. Run `$oracle` before finalizing segmentation when the run is long, public, or ambiguous. Bundle only text artifacts:\n\n```bash\nmkdir -p ~/.oracle/bundles\nfind \"$RUN_DIR\" -type f \\( -name '*.md' -o -name '*.json' -o -name '*.log' -o -name '*.sh' \\) \\\n  | xargs packx --preview --no-interactive\n\nfind \"$RUN_DIR\" -type f \\( -name '*.md' -o -name '*.json' -o -name '*.log' -o -name '*.sh' \\) \\\n  | xargs packx --limit 900k -f markdown --no-interactive --stdout --strip-comments --minify \\\n  > ~/.oracle/bundles/video-followup-segmentation-review.txt\n\ntest -s ~/.oracle/bundles/video-followup-segmentation-review.txt\n```\n\nAsk Oracle in browser mode only. If using the skill, invoke `$oracle`; if using the CLI fallback, keep browser mode explicit:\n\n```bash\noracle --engine browser \\\n  --model gpt-5.6-pro \\\n  --browser-thinking-time extended \\\n  --slug video-followup-segmentation-review \\\n  --file ~/.oracle/bundles/video-followup-segmentation-review.txt \\\n  -p \"$(cat \"$RUN_DIR/oracle/planning.md\")\"\n```\n\nSave the Oracle conversation URL, local bundle path, prompt, and `~/.oracle/sessions/<slug>/output.log` reference in `oracle/sessions/<slug>.md`.\n\n5. Revise into `segments/segment-manifest.v2.json` and `.md`.\n\n6. Cut archival chapters and Gemini analysis shards from the original source. A\n   stream-copy cut is acceptable only as an archival artifact; do not send stream-copy\n   chunks to Gemini by default. A file can pass `ffprobe` and still stall indefinitely\n   in Gemini.\n\n```bash\nmkdir -p \"$RUN_DIR/chunks/01\"\nSTART_SECONDS=344\nDURATION_SECONDS=240\nSOURCE=\"$RUN_DIR/inputs/source-video.mp4\"\nANALYSIS_SHARD=\"$RUN_DIR/chunks/01/chunk.mp4\"\n\nffmpeg -hide_banner -loglevel error -y \\\n  -ss \"$START_SECONDS\" -i \"$SOURCE\" -t \"$DURATION_SECONDS\" \\\n  -map 0:v:0 -map 0:a:0 \\\n  -vf 'fps=30000/1001,format=yuv420p' \\\n  -c:v libx264 -preset veryfast -crf 30 -profile:v main \\\n  -c:a aac -b:a 80k -ar 44100 -ac 2 \\\n  -movflags +faststart \"$ANALYSIS_SHARD\"\n\nffprobe -hide_banner -show_format -show_streams -of json \\\n  \"$RUN_DIR/chunks/01/chunk.mp4\" \\\n  > \"$RUN_DIR/chunks/01/chunk.ffprobe.json\"\n```\n\nKeep every shard below the configured Oracle attachment ceiling. When the ceiling is\n10 MiB, target <=9 MiB. Avoid low-fidelity derivatives such as 4 fps video or 24 kHz\nmono audio: they may upload, then become `This file has been removed` or unreadable.\nAfter any encoding change, rerun the source-specific audio+visual probe before batching.\n\n7. Slice transcript and chat into `chunks/<nn>/transcript.md`, `chat.md`, and `carry-forward-chat.md`.\n\n8. Create `chunks/video-manifest.json` with chunk id, original range, file path, transcript path, chat path, carry-forward path, ffprobe path, and verification status.\n\n## Short Recording Workflow\n\nUse this path for quick screen captures, short bug reproductions, design notes, and small app walkthroughs.\n\n```bash\nRUN_ID=\"$(date +%Y-%m-%d)-quick-clip\"\nRUN_DIR=\"runs/$RUN_ID\"\nmkdir -p \"$RUN_DIR\"/{inputs,receipts,chunks/01,final}\ncp \"/absolute/path/to/clip.mov\" \"$RUN_DIR/inputs/source-video.mov\"\nshasum -a 256 \"$RUN_DIR/inputs/source-video.mov\" > \"$RUN_DIR/inputs/source-video.sha256\"\nffprobe -hide_banner -show_format -show_streams -of json \\\n  \"$RUN_DIR/inputs/source-video.mov\" \\\n  > \"$RUN_DIR/receipts/ffprobe.source.json\"\n```\n\nFor short clips, use the source directly only after `ffprobe` plus the source-specific\naudio+visual probe confirms Gemini can retain and read it. Otherwise create the same\nH.264 Main/yuv420p/AAC-LC/faststart analysis encode used by the long workflow. Do not\ndownsample to 4 fps or 24 kHz mono merely to reduce size.\n\n```bash\nln -s ../../inputs/source-video.mov \"$RUN_DIR/chunks/01/chunk.mov\"\n```\n\nCreate `chunks/01/gemini-prompt.md` using the short clip prompt in this doc, attach the clip directly to Gemini/video model, and save:\n\n```text\nchunks/01/expected-sentinel.txt\nchunks/01/gemini-run.log\nchunks/01/gemini-result.json\nchunks/01/gemini-analysis.md\nchunks/01/final-reconciled.md\nfinal/README.md\n```\n\nFinal output by short mode:\n\n- Bug reproduction: `final/bug-report.md`, `final/repro-steps.md`, `final/acceptance-checks.md`\n- Design feedback: `final/design-brief.md`, `final/visual-acceptance-criteria.md`\n- App walkthrough: `final/requirements.md`, `final/qa-checklist.md`\n- Tiny tutorial: `final/summary.md`, `final/resources-and-links.md`\n\nRun the same malformed URL and hallucination checks even for short clips.\n\nFor YouTube research batches, add these source-selection rules before downloading:\n\n- Search broadly, but select by actual YouTube metadata (`upload_date`), not title text.\n- Enforce user cutoffs exactly. Use an explicit cutoff parameter, e.g.\n  `upload_date >= cutoff_yyyymmdd`.\n- Exclude topic collisions, coupon/affiliate uploads, auto-generated music/topic\n  uploads, and unrelated videos.\n- Save selected videos in `queue.json` with `id`, `title`, `uploader`,\n  `upload_date`, `duration`, and `url`.\n- Use Chrome cookies with `yt-dlp` when YouTube challenges require it.\n- Space Gemini upload starts by about five minutes for batch runs only after the first\n  attached-video probe passes and no unresolved run is pending, unless the user asks\n  for a different cadence.\n\nFor each batch item, use a topic-specific prompt. Do not copy old prompt text from a\ndifferent topic without replacing the product/domain language.\n\n## Gemini Readiness And Failure Recovery\n\nBefore a large batch, run two source-specific attached-video probes: a 30-60 second\nsource-native sample, then one production-size <=4 minute analysis shard using the real\nprompt shape. Each prompt must request one spoken phrase and one visual observation at\na specified timestamp, plus an alphabetic-ending sentinel. Independently verify the\nphrase against audio/captions and the visual observation against an extracted frame.\nDo not rely on a sentinel-only or text-only probe.\n\nRequired preflight receipts:\n\n- configured browser mode and Gemini provider routing;\n- visible signed-in Gemini UI and both completed attached-video probes;\n- prompt path and exact expected sentinel;\n- run/session metadata;\n- a real submitted `user-query` retaining its attachment chip/duration, with the prompt\n  absent from the composer and a `model-response` begun;\n- locally verified source-specific audio and visual facts plus the expected sentinel;\n- completed tab cleanup.\n\nOn any `send not accepted`, `prompt-empty`, consent modal, sign-in, quota, rate-limit,\nor upload warning, stop new batch starts. Inspect the active Gemini tab, classify the\nstate, and retry only the affected chunk if no valid sentinel response exists.\n\nWrite the exact expected sentinel into `chunks/<nn>/expected-sentinel.txt` before each\nGemini run. Verification and recovery should compare against that file, not infer the\nsentinel shape from memory. End the sentinel with letters, for example\n`END_OF_VIDEO_ANALYSIS workshop SHARD_004_COMPLETE`, not a bare number that may be\nvisually joined to a following timestamp.\n\nOracle log lines such as `Attachment upload complete`, `Sending prompt`, and `still\ngenerating` are diagnostics, not proof. The live Gemini DOM is authoritative. A title,\nsidebar/body text match, empty composer, or broad `Stop` button match does not prove a\nsubmitted turn. Re-check state before long waits because an apparent turn can regress\nand return to the composer.\n\nFor liveness, snapshot the real `model-response message-content` text/HTML and\n`aria-busy` state 2-3 times over about three minutes. If content grows, keep waiting. If\nan `Analyzing`/`Gemini said` placeholder does not grow, record a confirmed stall, close\nonly that exact target, frame-exact re-encode the shard, and retry once. Do not loop the\nsame media bytes.\n\nOn a fresh `/app` conversation, the upload menu can initially be empty. Initialize the\nconversation with one harmless text turn, wait for completion, reopen the upload menu,\nthen run the actual source-specific video probe. The initializer is not video proof.\n\n## Gemini Browser Cleanup\n\nWhen using Oracle CLI fallback with `--browser-keep-browser`, cleanup is mandatory:\n\n1. Wait for the run to finish.\n2. Save every needed extraction artifact from the Gemini response:\n   `gemini-result.json`, `gemini-analysis.md`, `gemini-analysis.extracted.json` when\n   expected, machine JSON, and any recovery note if the response was recovered by tab\n   inspection.\n3. Verify the analysis is non-empty and contains the expected\n   `END_OF_VIDEO_ANALYSIS ...` sentinel.\n4. Close only the completed and fully extracted Gemini tab for that run.\n5. Do not close tabs for active uploads, still-generating sessions, unresolved wrapper\n   errors, or completed-looking tabs whose visible response has not been extracted.\n6. Do not kill Chrome; Oracle needs the signed-in profile for future runs.\n\nFor scripted runs, implement cleanup as a post-extraction step, not as a generic\n`finally` block. A safe script order is: save wrapper result, inspect/recover tab output\nif needed, write extracted JSON, verify the exact expected sentinel, then close the\nspecific Gemini tab target. If any extraction or sentinel check fails, leave the tab\nopen and record the Chrome port/target for recovery.\n\nIf exact target close tooling is available, use Chrome DevTools Protocol to close the\nspecific `gemini.google.com/app` target created for the run. If not, list tabs first,\nidentify completed or empty Gemini tabs, and close only those. Avoid broad \"close all\nGemini\" actions while a batch is running.\n\nThe Chrome target id returned by `/json/list` is different from the Gemini conversation\nid in `/app/<conversation-id>`. Close `/json/close/<target-id>`, then list targets again\nto prove removal. Do not pass the conversation-id suffix to the close endpoint.\n\nWhen classifying stale tabs:\n\n- Empty generic Gemini tabs from failed diagnostics may be closed after inspection.\n- Active upload/generation tabs must stay open.\n- Tabs with conversation state or auto-generated titles must be checked for saved\n  output and the expected sentinel before closing.\n- Never use broad \"close all Gemini tabs\" while a batch is active.\n\n## Prompt Templates\n\n### Gemini Chunk Analysis\n\n```markdown\nYou are analyzing one source-preserving video chunk for a follow-up packet.\n\nRun metadata:\n- run_key: {{run_key}}\n- chunk_id: {{chunk_id}}\n- original_recording_range: {{start_time}} -> {{end_time}}\n- chunk_video: {{chunk_video_path}}\n- transcript: included below\n- chat: included below\n- carry_forward_chat: included below\n- next_chunk_preview: included below\n\nHard rules:\n1. Preserve original recording timestamps.\n2. Separate transcript evidence, chat evidence, visual evidence, and inference.\n3. Do not invent tools, commands, URLs, files, speakers, or UI labels.\n4. Include unanswered and deferred questions.\n5. Flag every policy-sensitive area, especially browser automation, cookies, quota/rate limits, private accounts, and publishing.\n6. Return both Markdown and fenced JSON.\n7. End with: END_OF_VIDEO_ANALYSIS {{run_key}} {{chunk_id}}_COMPLETE\n\nReturn:\n# Chunk Analysis: {{chunk_id}}\n## 1. Overview\n## 2. Dense Timeline\n## 3. Concept Inventory\n## 4. Demo / Screen Activity\n## 5. Questions And Answers\n## 6. Links / Tools / Commands / References\n## 7. Keyframes To Capture\n## 8. Student Exercises\n## 9. Uncertainties / Needs Review\n## 10. Machine JSON\n```\n\n### Omissions Pass\n\n```markdown\nYou are auditing a prior video analysis for omissions.\n\nInputs:\n- chunk_id: {{chunk_id}}\n- original_recording_range: {{start_time}} -> {{end_time}}\n- coverage_report: {{coverage_report}}\n- expected_items: {{expected_items_json}}\n- prior_analysis: {{prior_analysis}}\n\nFind only omissions and corrections. Do not repeat complete items.\n\nRequired focus:\n1. Missing URLs exactly as they appeared.\n2. Missing chat questions, including unanswered/deferred questions.\n3. Missing demo steps.\n4. Missing keyframe candidates.\n5. Unsupported visual claims.\n6. Hallucinated tools, commands, links, or files.\n7. Parseable fenced JSON.\n\nReturn:\n# Omissions And Corrections: {{chunk_id}}\n## Additions\n## Corrections\n## Remove Or Downgrade\n## Remaining Human Review\n## Machine JSON\n```\n\n### Local Reconciliation\n\n```markdown\nReconcile one analyzed chunk into an evidence-grounded final chunk record.\n\nInputs:\n- segment manifest entry\n- transcript slice\n- chat slice\n- carry-forward chat\n- main analysis\n- omissions analysis\n- verification reports\n- keyframe review\n\nRules:\n1. Preserve original timestamps.\n2. Remove malformed URLs.\n3. Do not include any URL/tool/command unless supported by transcript, chat, carry-forward chat, local path, or keyframe review.\n4. Do not claim a visual is visible unless keyframe review confirms it.\n5. Preserve unanswered/deferred questions.\n6. Preserve editorial warnings.\n7. Deduplicate overlap by normalized timestamp + item type + text hash.\n\nReturn Markdown and JSON with:\n- status: PASS | PASS_WITH_WARNINGS | FAIL\n- counts\n- timeline summary\n- concepts\n- Q&A\n- links/tools/commands\n- demos\n- keyframes\n- warnings\n- student-material candidates\n```\n\n### Short Clip Analysis\n\n```markdown\nYou are analyzing a short screen recording or app walkthrough.\n\nSource:\n- run_key: {{run_key}}\n- recording_type: short_clip | bug_reproduction | design_feedback | app_walkthrough\n- original_recording_range: 00:00:00 -> {{duration}}\n- source_video_sha256: {{source_video_sha256}}\n\nHard rules:\n1. Use timestamps relative to the clip unless an original recording timeline is provided.\n2. Do not invent commands, files, UI labels, URLs, or implementation details.\n3. Separate observed behavior from inferred intent.\n4. Include timestamped screenshot/keyframe candidates for visual claims.\n5. For a bug reproduction, produce repro steps and expected vs actual behavior.\n6. For design feedback, produce requested changes and visual acceptance criteria.\n7. For an app walkthrough, produce requirements and QA checks.\n8. Include uncertainties and manual review points.\n\nReturn:\n# Short Video Analysis: {{run_key}}\n## 1. Summary\n## 2. Observed Timeline\n## 3. User Intent / Requirements\n## 4. Reproduction Steps Or Walkthrough Steps\n## 5. Expected Vs Actual Behavior\n## 6. Implementation Notes\n## 7. QA / Acceptance Criteria\n## 8. Keyframes To Extract\n## 9. Risks / Unknowns\n## 10. Machine JSON\n```\n\n### Final Packet Generation\n\n```markdown\nAssemble a student follow-up packet from verified chunk records.\n\nInputs:\n- segments/segment-manifest.v2.md\n- chunks/*/final-reconciled.md\n- chunks/*/final-reconciled.json\n- chunks/*/verification/*.md\n- final/keyframes-manifest.json if present\n- resources extracted from chat/transcript\n\nRules:\n1. Use original recording timestamps.\n2. Do not include unverified visual claims.\n3. Do not include malformed URLs.\n4. Do not present experimental tools as official recommendations unless approved.\n5. Keep policy-sensitive automation/cookie/quota/rate-limit sections as editorial notes.\n6. Distinguish publication-ready files from reference drafts.\n7. Deduplicate overlap and carry-forward repeated material.\n\nCreate:\n- final/README.md\n- final/student-followup-guide.md\n- final/chapter-index.md\n- final/resources-and-links.md\n- final/qa-index.md\n- final/exercises.md\n- final/keyframes-manifest.md\n- final/keyframes-manifest.json\n- final/instructor-review-checklist.md\n```\n\n### Oracle Review\n\n```markdown\n[{{slug}}]\n\nProject briefing:\n{{project_briefing}}\n\nGoal:\n{{goal}}\n\nPrior-State Ledger:\n- prior_oracle_session: {{prior_oracle_session_or_none}}\n- last_oracle_recommendation: {{summary_or_none}}\n- implemented_since_prior_oracle: {{files_or_none}}\n- verified_since_prior_oracle: {{commands_or_none}}\n- failed_proof_or_blocker: {{receipt_or_none}}\n- narrowing_decision: {{one_slice}}\n- files_functions_now_in_scope: {{paths}}\n- files_functions_out_of_scope: {{paths}}\n- next_falsifiable_verification: {{command_or_receipt}}\n- forward_progress_index: {{score_and_arithmetic}}\n\nDeliverable:\nEvaluate segmentation, chat carry-forward, analysis prompts, verification gates, final packet readiness, privacy/security risks, and the one highest-leverage next local action.\n\nReturn your answer as text in this response only. Do not create, attach, export, or offer any downloadable file. Do not create local project artifacts yourself. The local agent will write any needed files, plans, notes, goals, commits, or verification logs using local tools.\n```\n\n## Verification Gates\n\nTreat `~/.oracle/sessions/<slug>/output.log`, browser logs, and raw Gemini responses as\nprivate evidence. The MCP return can be truncated, so recover the full response from\nthe persisted session log before reconciliation. Before copying any material into\n`publication/public-draft/` or another public wiki, scan and redact credentials,\nauth/callback URLs, account/model identifiers, local usernames and paths,\nsigned/private URLs, notifications, and personal data. Gemini can repeat these even\nwhen told not to.\n\nEvery pull quote and timestamp must be checked against local audio/captions and the\nsource frame or clip. Gemini-supplied quote timestamps are candidates, not receipts.\nRecord the verified timestamp and evidence path in the reconciliation artifact.\n\nRun malformed URL checks on every final packet:\n\n```bash\nrg -n 'https://www\\.\\.\\.|https://www\\s|/\"|\\| .*: \\||Context:' \"$RUN_DIR/final\" || true\n```\n\nExtract exact URLs from chat/transcript and compare against final resources:\n\n```bash\nrg -o 'https?://[^[:space:])>\"'\"'\"']+' \"$RUN_DIR/chunks\" \"$RUN_DIR/break-chat\" \\\n  | sed 's/[,:;.!\"]$//' \\\n  | sort -u \\\n  > \"$RUN_DIR/verification.expected-urls.txt\"\n\nrg -o 'https?://[^[:space:])>\"'\"'\"']+' \"$RUN_DIR/final/resources-and-links.md\" \\\n  | sed 's/[,:;.!\"]$//' \\\n  | sort -u \\\n  > \"$RUN_DIR/verification.final-urls.txt\"\n\ncomm -23 \"$RUN_DIR/verification.expected-urls.txt\" \"$RUN_DIR/verification.final-urls.txt\" \\\n  > \"$RUN_DIR/verification.missing-urls.txt\"\n```\n\nValidate timestamps stay within range, except carry-forward chat:\n\n```bash\npython3 scripts/validate-timestamps.py \"$RUN_DIR\" \\\n  > \"$RUN_DIR/receipts/timestamp-validation.log\"\n```\n\nIf the script does not exist yet, perform a manual timestamp pass and save it as `chunks/<nn>/verification/timestamp-report.md`.\n\nCheck machine JSON:\n\n```bash\nfind \"$RUN_DIR/chunks\" -name '*.json' -print0 | xargs -0 -n1 jq empty\n```\n\nRequired chunk gate files:\n\n```text\nchunks/<nn>/verification/coverage-report.md\nchunks/<nn>/verification/hallucination-report.md\nchunks/<nn>/verification/timestamp-report.md\nchunks/<nn>/verification/qa-report.md\nchunks/<nn>/final-reconciled.md\nchunks/<nn>/final-reconciled.json\n```\n\nChunk status meanings:\n\n- `PASS`: complete and publication-safe after ordinary instructor review.\n- `PASS_WITH_WARNINGS`: usable evidence, but warnings must be reviewed before publication.\n- `FAIL`: rerun analysis, omissions, or reconciliation before using the chunk.\n\n## Keyframes\n\nCandidate extraction prompt output should include timestamp, reason, expected visual, priority, and confidence.\n\nExtract deterministic frames:\n\n```bash\nmkdir -p \"$RUN_DIR/chunks/01/keyframes/extracted\"\nffmpeg -hide_banner -ss 00:23:48 \\\n  -i \"$RUN_DIR/inputs/source-video.mp4\" \\\n  -frames:v 1 \\\n  \"$RUN_DIR/chunks/01/keyframes/extracted/00-23-48-automation-verification.jpg\"\n```\n\nCreate contact sheet:\n\n```bash\nfind \"$RUN_DIR/chunks/01/keyframes/extracted\" -name '*.jpg' | sort \\\n  > \"$RUN_DIR/chunks/01/keyframes/contact-sheet-inputs.txt\"\n\nffmpeg -hide_banner -f concat -safe 0 \\\n  -i <(sed \"s#^#file '#; s#$#'#\" \"$RUN_DIR/chunks/01/keyframes/contact-sheet-inputs.txt\") \\\n  -vf \"scale=320:-1,tile=3x4\" \\\n  \"$RUN_DIR/chunks/01/keyframes/contact-sheet.jpg\"\n```\n\nIf process substitution is unavailable, generate the concat list as a real file and pass it to ffmpeg.\n\n## Final Packet Review\n\nTreat these as first publication candidates:\n\n- `final/README.md`\n- `final/student-followup-guide.md`\n- `final/chapter-index.md`\n- `final/resources-and-links.md`\n- `final/instructor-review-checklist.md`\n\nTreat these as reference drafts until edited:\n\n- `final/qa-index.md`\n- `final/exercises.md`\n- `final/keyframes-manifest.md`\n\nManual approval is mandatory for:\n\n- platform automation\n- browser automation\n- cookies\n- session replay\n- quota/rate-limit behavior\n- account credentials\n- private emails\n- private chat exports\n- meeting transcript bot URLs\n- student names\n- screenshots of private repos\n- local network addresses\n- QR codes\n- API keys\n- package security claims\n- third-party service recommendations\n- public publishing"
}
