From 201bde10834c150e12775e285e43ed1bdaafe7af Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 09:01:14 -0400 Subject: [PATCH 01/12] feat(creator): add yt control worktree review and source classes --- pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md | 11 +- .../PMOVES_YT_CONTROL_WORKTREE_REVIEW.md | 132 ++++++++++++++++++ pmoves/docs/AGENTS/README.md | 8 +- .../PMOVES-transcribe-and-fetch.md | 4 + .../AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md | 1 + pmoves/services/channel-monitor/README.md | 10 +- .../channel-monitor/channel_monitor/config.py | 1 + .../channel-monitor/channel_monitor/main.py | 12 +- .../channel_monitor/monitor.py | 19 ++- .../channel-monitor/tests/test_monitor.py | 12 +- 10 files changed, 197 insertions(+), 13 deletions(-) create mode 100644 pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md diff --git a/pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md b/pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md index 24183fffd3..b177d454f4 100644 --- a/pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md +++ b/pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md @@ -81,10 +81,11 @@ transcripts, Discord, Jellyfin, or cross-model orchestration. ### Primary traversal order 1. `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` -2. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` -3. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md` -4. `pmoves/services/channel-monitor/README.md` -5. `pmoves/docs/AGENTS/JELLYFIN_CREATOR_WORKTREE_REVIEW.md` +2. `pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md` +3. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` +4. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md` +5. `pmoves/services/channel-monitor/README.md` +6. `pmoves/docs/AGENTS/JELLYFIN_CREATOR_WORKTREE_REVIEW.md` ### Service posture @@ -208,6 +209,8 @@ For a comprehensive view of what's implemented vs. what's still planned, see: - `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` - PMOVES-transcribe-and-fetch submodule home: - `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md` +- PMOVES.YT control worktree review: + - `pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md` - Jellyfin creator review: - `pmoves/docs/AGENTS/JELLYFIN_CREATOR_WORKTREE_REVIEW.md` - Codex submodule audit: diff --git a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md new file mode 100644 index 0000000000..7d974ecf04 --- /dev/null +++ b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md @@ -0,0 +1,132 @@ +# PMOVES.YT Control Worktree Review + +Use this runbook when the task is not just "fix PMOVES.YT", but review the creator-control +path around it in one isolated worktree. + +This is the correct lane when you need to validate: +- PMOVES.YT runtime behavior +- channel-monitor discovery and queue handoff +- transcribe-and-fetch fallback or repair posture +- Invidious / companion fallback reachability +- Jellyfin packaging or playback linkage +- Discord / BoTZ operator interaction +- model-routing posture for transcript, summarization, embeddings, rerank, and multimodal work + +## Worktree setup + +```bash +git worktree add ../PMOVES.AI-wt-yt-integration -b review/pmoves-yt-control +cd ../PMOVES.AI-wt-yt-integration +``` + +Recommended branch naming: +- `review/pmoves-yt-control` +- `feat/pmoves-yt-integration-review` +- `fix/pmoves-yt-control-plane` + +## Traversal order + +1. Read `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` +2. Read `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` +3. Read `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md` +4. Read `pmoves/services/channel-monitor/README.md` +5. Read `pmoves/docs/AGENTS/JELLYFIN_CREATOR_WORKTREE_REVIEW.md` +6. Then inspect the live service contracts in code and compose + +## Review lanes + +### Lane A — PMOVES.YT runtime + +- Files: + - `PMOVES.YT/pmoves_yt_service/yt.py` + - `PMOVES.YT/pmoves_yt_service/docs_catalog.py` + - `PMOVES.YT/pmoves_yt_service/docs_sync.py` + - `PMOVES.YT/pmoves_yt_service/tests/` +- Questions: + - Is PMOVES.YT still the canonical runtime rather than a compatibility shadow? + - Are ingest, transcript, summarize, chapters, emit, search, docs sync, and docs catalog coherent? + - Are fallback chains explicit and current? + +### Lane B — discovery and source control + +- Files: + - `pmoves/services/channel-monitor/README.md` + - `pmoves/config/channel_monitor.json` + - `pmoves/services/channel-monitor/` +- Questions: + - Does channel-monitor treat PMOVES.YT as the authoritative queue target? + - Are source classes and review modes explicit? + - Is Google API / OAuth preferred where it should be? + +### Lane C — transcript/fetch auxiliary path + +- Files: + - `PMOVES-transcribe-and-fetch/` + - `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md` +- Questions: + - Is the auxiliary lane still additive rather than divergent? + - Is transcript provenance preserved for downstream consumers? + - Are repair/fallback paths documented against PMOVES.YT rather than replacing it? + +### Lane D — playback and creator packaging + +- Files: + - `pmoves/tools/yt_jellyfin_smoke.py` + - `pmoves/docs/AGENTS/JELLYFIN_CREATOR_WORKTREE_REVIEW.md` + - Jellyfin bridge and publisher surfaces referenced there +- Questions: + - Does PMOVES.YT emit enough metadata for Jellyfin linkage and playback? + - Are publisher and playback paths still aligned with ingest/search contracts? + +### Lane E — operator interaction and outreach + +- Files: + - `PMOVES-BoTZ/` + - `pmoves/services/publisher-discord/` + - `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` +- Questions: + - Are Discord and agent-facing actions review-gated when public-facing? + - Is creator outreach framed as attribution-aware and human-approved by default? + +### Lane F — model-routing and provenance + +- Files: + - `pmoves/docs/MODEL_FABRIC_CONTRACT.md` + - `pmoves/services/model-registry/` + - PMOVES.YT runtime env/model references +- Questions: + - Are models selected by role and registry mapping rather than hardcoded IDs? + - Do transcript, summary, embedding, rerank, and multimodal outputs preserve model-family provenance? + +## Minimum checks + +```bash +curl -fsS http://localhost:8077/healthz +curl -fsS http://localhost:8077/yt/docs/catalog | jq . +curl -fsS http://localhost:8097/api/monitor/status | jq . +make -C pmoves channel-monitor-smoke +make -C pmoves yt-jellyfin-smoke +make -C pmoves transcribe-and-fetch-smoke +``` + +If model-routing changed: + +```bash +make -C pmoves model-readiness +GPU_SMOKE_STRICT=true make -C pmoves smoke-gpu +``` + +## Output expectations + +Use a code-review mindset by default: +- findings first +- then concrete code/doc changes +- then validation evidence +- then merge order + +If no findings are present, say so explicitly and call out residual risks: +- creator outreach governance +- transcript/fetch divergence +- Jellyfin linkage drift +- model-routing env drift + diff --git a/pmoves/docs/AGENTS/README.md b/pmoves/docs/AGENTS/README.md index f5addce539..561bb405f1 100644 --- a/pmoves/docs/AGENTS/README.md +++ b/pmoves/docs/AGENTS/README.md @@ -32,9 +32,10 @@ transcripts, Jellyfin playback, Discord outreach, or model-routing across the PM 1. **[CODEX_OPERATOR_HOME.md](./CODEX_OPERATOR_HOME.md)** — Codex-first operator runbook with creator control plane commands 2. **[../PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md](../PMOVES.AI%20PLANS/CREATOR_NETWORK_CONTROL_PLANE.md)** — 2026 creator-network operating model -3. **[JELLYFIN_CREATOR_WORKTREE_REVIEW.md](./JELLYFIN_CREATOR_WORKTREE_REVIEW.md)** — Jellyfin/creator worktree review and current gaps -4. **[SUBMODULE_CODEX_HOMES/PMOVES.YT.md](./SUBMODULE_CODEX_HOMES/PMOVES.YT.md)** — authoritative YouTube runtime traversal -5. **[SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md](./SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md)** — transcript/fetch auxiliary lane +3. **[PMOVES_YT_CONTROL_WORKTREE_REVIEW.md](./PMOVES_YT_CONTROL_WORKTREE_REVIEW.md)** — PMOVES.YT integration worktree runbook across discovery, transcripts, playback, and model routing +4. **[JELLYFIN_CREATOR_WORKTREE_REVIEW.md](./JELLYFIN_CREATOR_WORKTREE_REVIEW.md)** — Jellyfin/creator worktree review and current gaps +5. **[SUBMODULE_CODEX_HOMES/PMOVES.YT.md](./SUBMODULE_CODEX_HOMES/PMOVES.YT.md)** — authoritative YouTube runtime traversal +6. **[SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md](./SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md)** — transcript/fetch auxiliary lane The creator-network lane treats Codex as a legendary operator that can traverse: - PMOVES.YT for owned/watched channel ingest, playlist control, metadata sync, and downloader fallback @@ -106,6 +107,7 @@ single-service codebase. | File | Purpose | |------|---------| | [../PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md](../PMOVES.AI%20PLANS/CREATOR_NETWORK_CONTROL_PLANE.md) | 2026 creator-network map across PMOVES.YT, Channel Monitor, Discord, Jellyfin, and Tokenism | +| [PMOVES_YT_CONTROL_WORKTREE_REVIEW.md](./PMOVES_YT_CONTROL_WORKTREE_REVIEW.md) | Worktree-first review path for PMOVES.YT, channel-monitor, transcribe-and-fetch, Jellyfin, and model routing | | [JELLYFIN_CREATOR_WORKTREE_REVIEW.md](./JELLYFIN_CREATOR_WORKTREE_REVIEW.md) | Current creator/Jellyfin worktree findings and follow-ups | | [SUBMODULE_CODEX_HOMES/PMOVES.YT.md](./SUBMODULE_CODEX_HOMES/PMOVES.YT.md) | Codex home for YouTube ingest and creator control | | [SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md](./SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md) | Codex home for transcript and fetch support | diff --git a/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md b/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md index 0010c97364..1ae8598914 100644 --- a/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md +++ b/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md @@ -23,6 +23,10 @@ Core checks: - `curl -fsS http://localhost:8077/healthz` - `curl -fsS http://localhost:8097/api/monitor/status | jq .` +Worktree review: +- use `pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md` when the task spans + PMOVES.YT, channel-monitor, Jellyfin, Discord, or model-routing parity + Operating rules: - do not fork behavior away from PMOVES.YT without documenting why the auxiliary lane is needed - preserve metadata that lets downstream services track source, model family, and transcript provenance diff --git a/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md b/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md index e7b4cd6bcf..0c34cd6281 100644 --- a/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md +++ b/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md @@ -27,6 +27,7 @@ Operator intent classes: Preferred traversal: - start with `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` +- then use `pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md` if the task spans multiple companion services - then verify the PMOVES.YT service and its downloader posture - then inspect Channel Monitor and transcribe-and-fetch if the task spans discovery or transcript fallback - only use direct downloader overrides when the default PMOVES.YT strategy is insufficient diff --git a/pmoves/services/channel-monitor/README.md b/pmoves/services/channel-monitor/README.md index 64a66a1cee..b28f9b9c7e 100644 --- a/pmoves/services/channel-monitor/README.md +++ b/pmoves/services/channel-monitor/README.md @@ -43,9 +43,17 @@ The service maintains a JSON config at `CHANNEL_MONITOR_CONFIG_PATH`. If the fil ```bash curl -X POST http://localhost:8097/api/monitor/channel \ -H 'content-type: application/json' \ - -d '{"channel_id":"UCabc123xyz","channel_name":"Example Channel","auto_process":true}' + -d '{"channel_id":"UCabc123xyz","channel_name":"Example Channel","source_class":"watched","auto_process":true}' ``` +`source_class` is the operator-intent class for a source: +- `owned` — PMOVES-managed channels or playlists +- `partner` — explicit collaborator or shared-lane sources +- `watched` — monitored third-party creators +- `candidate` — scout/review sources that should stay gated by default + +If omitted, configured channels default to `watched` and Discord/manual drops default to `candidate`. + `yt_options` blocks (global or per-channel) are forwarded to pmoves-yt, letting you tune yt-dlp behaviour without rebuilding containers. Example knobs: - `download_archive`: absolute path to the archive file so yt-dlp skips previously ingested videos. diff --git a/pmoves/services/channel-monitor/channel_monitor/config.py b/pmoves/services/channel-monitor/channel_monitor/config.py index 50cde0cda1..d2de61b659 100644 --- a/pmoves/services/channel-monitor/channel_monitor/config.py +++ b/pmoves/services/channel-monitor/channel_monitor/config.py @@ -35,6 +35,7 @@ "channel_name": "Google Developers", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@GoogleDevelopers", "enabled": False, "check_interval_minutes": 60, diff --git a/pmoves/services/channel-monitor/channel_monitor/main.py b/pmoves/services/channel-monitor/channel_monitor/main.py index 8efed8713c..162148eb40 100644 --- a/pmoves/services/channel-monitor/channel_monitor/main.py +++ b/pmoves/services/channel-monitor/channel_monitor/main.py @@ -34,7 +34,6 @@ import os import re from contextlib import asynccontextmanager -from pathlib import Path from datetime import datetime from typing import Any, Dict, List @@ -134,6 +133,7 @@ class AddChannelRequest(BaseModel): Attributes: channel_id: YouTube channel ID to monitor. channel_name: Optional friendly name for the channel. + source_class: Operator intent class ('owned', 'partner', 'watched', 'candidate'). auto_process: Whether to automatically process new videos. Default is True. check_interval_minutes: Interval in minutes between checks. Must be >= 1. Default is 60. priority: Processing priority (higher values = higher priority). Default is 0. @@ -151,6 +151,10 @@ class AddChannelRequest(BaseModel): channel_id: str = Field(..., description="YouTube channel ID") channel_name: str | None = Field(None, description="Friendly name for the channel") + source_class: str | None = Field( + None, + description="Operator intent class (owned, partner, watched, candidate)", + ) auto_process: bool = True check_interval_minutes: int = Field(60, ge=1) priority: int = 0 @@ -294,6 +298,10 @@ class DiscordDropRequest(BaseModel): namespace: str | None = Field(None, description="Target namespace for ingestion") tags: List[str] | None = Field(None, description="Tags to attach to queued payloads") source: str = Field("discord_drop", description="Logical source label for tracking") + source_class: str | None = Field( + None, + description="Operator intent class (owned, partner, watched, candidate)", + ) approval_mode: str | None = Field( None, description="`auto` queues immediately, `ask` stores as pending for explicit approval", @@ -535,6 +543,8 @@ async def ingest_discord_drop( metadata: Dict[str, Any] = {} if isinstance(payload.metadata, dict): metadata.update(payload.metadata) + if payload.source_class: + metadata["source_class"] = payload.source_class if discord_context: metadata["discord"] = discord_context diff --git a/pmoves/services/channel-monitor/channel_monitor/monitor.py b/pmoves/services/channel-monitor/channel_monitor/monitor.py index 676ab48cc9..cab73d73dd 100644 --- a/pmoves/services/channel-monitor/channel_monitor/monitor.py +++ b/pmoves/services/channel-monitor/channel_monitor/monitor.py @@ -6,7 +6,7 @@ import logging from datetime import datetime, timezone, timedelta from functools import partial -from typing import Any, Dict, Iterable, List, Optional, Set +from typing import Any, Dict, List, Optional, Set from uuid import UUID from urllib.parse import parse_qs, urlparse @@ -23,6 +23,7 @@ VALID_STATUSES = {"pending", "processing", "queued", "completed", "failed"} TERMINAL_STATUSES = {"completed", "failed"} +SOURCE_CLASSES = {"owned", "partner", "watched", "candidate"} def utcnow() -> datetime: @@ -77,6 +78,14 @@ def _best_thumbnail(thumbnails: Any) -> Optional[str]: return None +def _normalize_source_class(value: Any, *, default: str) -> str: + if isinstance(value, str): + normalized = value.strip().lower() + if normalized in SOURCE_CLASSES: + return normalized + return default + + def _extract_playlist_id_from_url(url: Optional[str]) -> Optional[str]: if not url: return None @@ -515,6 +524,7 @@ async def _queue_videos(self, channel: Dict[str, Any], videos: List[Dict[str, An or "unknown" ) channel_identifier = self._resolve_channel_identifier(channel) + source_class = _normalize_source_class(channel.get("source_class"), default="watched") for video in videos: monitor_metadata = self._build_metadata(channel, video) channel_context = ( @@ -527,6 +537,7 @@ async def _queue_videos(self, channel: Dict[str, Any], videos: List[Dict[str, An { "platform": channel.get("platform", "youtube"), "source_type": channel.get("source_type", "channel"), + "source_class": source_class, "channel_name": channel_label, "channel_id": channel_identifier, "channel_url": channel_context.get("url"), @@ -1418,6 +1429,10 @@ async def ingest_manual_urls( channel_payload_metadata: Dict[str, Any] = {"ingest_source": normalized_source} if context_metadata: channel_payload_metadata["source_context"] = context_metadata + source_class = _normalize_source_class( + context_metadata.get("source_class") if isinstance(context_metadata, dict) else None, + default="candidate", + ) channel: Dict[str, Any] = { "channel_id": synthetic_channel_id, @@ -1427,6 +1442,7 @@ async def ingest_manual_urls( "priority": 0, "platform": "discord" if "discord" in normalized_source else "manual", "source_type": normalized_source, + "source_class": source_class, "ingest_source": normalized_source, "media_type": media_type or "video", "payload_metadata": channel_payload_metadata, @@ -1762,6 +1778,7 @@ async def add_channel(self, data: Dict[str, Any]) -> Dict[str, Any]: new_channel = { "channel_id": channel_id, "channel_name": channel_name or channel_id, + "source_class": _normalize_source_class(data.get("source_class"), default="watched"), "enabled": data.get("enabled", True), "check_interval_minutes": data.get("check_interval_minutes", 60), "auto_process": data.get("auto_process", True), diff --git a/pmoves/services/channel-monitor/tests/test_monitor.py b/pmoves/services/channel-monitor/tests/test_monitor.py index 42c4834eb0..fa596023c2 100644 --- a/pmoves/services/channel-monitor/tests/test_monitor.py +++ b/pmoves/services/channel-monitor/tests/test_monitor.py @@ -83,7 +83,7 @@ def extract_info(self, *_args, **_kwargs): yt_dlp_stub.YoutubeDL = _YoutubeDL # type: ignore[attr-defined] sys.modules["yt_dlp"] = yt_dlp_stub -from channel_monitor.monitor import ChannelMonitor, _extract_youtube_video_id +from channel_monitor.monitor import ChannelMonitor, _extract_youtube_video_id # noqa: E402 def _build_monitor(tmp_path, config_name: str = "channel.json") -> ChannelMonitor: @@ -370,6 +370,7 @@ async def post(self, url, json): "ingest_source": "discord_agent", "platform": "discord", "source_type": "discord_drop", + "source_class": "candidate", } videos = [ { @@ -386,6 +387,7 @@ async def post(self, url, json): assert payload["source"] == "discord_agent" assert payload["metadata"]["platform"] == "discord" assert payload["metadata"]["source_type"] == "discord_drop" + assert payload["metadata"]["source_class"] == "candidate" assert statuses[0][0:3] == ("custom-source-1", "processing", None) assert statuses[1][0:3] == ("custom-source-1", "queued", None) @@ -407,7 +409,7 @@ def test_ingest_manual_urls_queues_discord_drop(tmp_path): source="discord_agent", channel_id="discord:ops", channel_name="ops-drops", - metadata={"guild_id": "guild-1"}, + metadata={"guild_id": "guild-1", "source_class": "candidate"}, ) ) @@ -423,7 +425,11 @@ def test_ingest_manual_urls_queues_discord_drop(tmp_path): queued_videos = persist_args[1] assert channel_payload["platform"] == "discord" assert channel_payload["ingest_source"] == "discord_agent" - assert channel_payload["payload_metadata"]["source_context"] == {"guild_id": "guild-1"} + assert channel_payload["source_class"] == "candidate" + assert channel_payload["payload_metadata"]["source_context"] == { + "guild_id": "guild-1", + "source_class": "candidate", + } assert channel_payload["tags"] == ["review", "discord"] assert queued_videos[0]["payload_metadata"]["manual_drop_source"] == "discord_agent" From f3e174d351753d876044d028c5c52506ef2d2e72 Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 09:14:16 -0400 Subject: [PATCH 02/12] docs(creator): classify monitored sources and record yt audit --- pmoves/config/channel_monitor.json | 13 +++++++++ .../PMOVES_YT_CONTROL_WORKTREE_REVIEW.md | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/pmoves/config/channel_monitor.json b/pmoves/config/channel_monitor.json index c1a1e7b4c8..bfb9ddb361 100644 --- a/pmoves/config/channel_monitor.json +++ b/pmoves/config/channel_monitor.json @@ -5,6 +5,7 @@ "channel_name": "DARKSXIDE AI Playlist", "platform": "youtube", "source_type": "playlist", + "source_class": "owned", "source_url": "https://www.youtube.com/playlist?list=PLGupOT04oMfok7S8W8Js7lZZIlhM8ufc8", "enabled": true, "check_interval_minutes": 120, @@ -32,6 +33,7 @@ "channel_name": "Code4AI", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@code4AI", "enabled": true, "check_interval_minutes": 240, @@ -59,6 +61,7 @@ "channel_name": "AI Trepreneur", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@Aitrepreneur", "enabled": true, "check_interval_minutes": 240, @@ -86,6 +89,7 @@ "channel_name": "Theories of Everything", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@TheoriesofEverything", "enabled": true, "check_interval_minutes": 240, @@ -113,6 +117,7 @@ "channel_name": "Sabine Hossenfelder", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@SabineHossenfelder", "enabled": true, "check_interval_minutes": 240, @@ -140,6 +145,7 @@ "channel_name": "Meet Kevin", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@MeetKevin", "enabled": true, "check_interval_minutes": 240, @@ -167,6 +173,7 @@ "channel_name": "IndyDevDan", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@indydevdan", "enabled": true, "check_interval_minutes": 240, @@ -194,6 +201,7 @@ "channel_name": "Closer To Truth", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@CloserToTruthTV", "enabled": true, "check_interval_minutes": 240, @@ -221,6 +229,7 @@ "channel_name": "Dr. Michael Levin", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@drmichaellevin", "enabled": true, "check_interval_minutes": 240, @@ -248,6 +257,7 @@ "channel_name": "Wes Roth", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@WesRoth", "enabled": true, "check_interval_minutes": 240, @@ -275,6 +285,7 @@ "channel_name": "AI Code King", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@AICodeKing", "enabled": true, "check_interval_minutes": 240, @@ -302,6 +313,7 @@ "channel_name": "Cole Medin", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@ColeMedin", "enabled": true, "check_interval_minutes": 240, @@ -329,6 +341,7 @@ "channel_name": "Bijan Bowen", "platform": "youtube", "source_type": "channel", + "source_class": "watched", "source_url": "https://www.youtube.com/@Bijanbowen", "enabled": true, "check_interval_minutes": 240, diff --git a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md index 7d974ecf04..a256cd45f9 100644 --- a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md +++ b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md @@ -130,3 +130,32 @@ If no findings are present, say so explicitly and call out residual risks: - Jellyfin linkage drift - model-routing env drift +## Current audit snapshot + +As of March 12, 2026, use these findings as the starting bias for this worktree lane: + +- `channel-monitor` now supports `source_class`, but the checked-in monitor config must also + classify sources explicitly so owned vs watched behavior is not inferred at runtime. +- `PMOVES.YT` is the canonical runtime, but its summary lane still hardcodes provider/model envs + (`YT_SUMMARY_PROVIDER`, `YT_GEMMA_MODEL`, `HF_GEMMA_MODEL`) inside + `PMOVES.YT/pmoves_yt_service/yt.py`. +- `PMOVES-transcribe-and-fetch` already exposes a registry-shaped `/api/v1/models` UI path, but + its backend still carries a large static `AVAILABLE_MODELS` catalog in + `PMOVES-transcribe-and-fetch/backend/app/app_config.py`. +- This means creator-model posture is only partially modernized: + - the UI is closer to registry-driven + - PMOVES.YT and transcribe/fetch runtime defaults still need convergence on shared + model-role aliases +- Invidious + companion fallback is present and should remain part of the runtime review path for + owned and watched YouTube sources. + +## Recommended next implementation steps + +1. Keep `channel-monitor` source metadata explicit in config, API payloads, and downstream PMOVES.YT + ingest metadata. +2. Move PMOVES.YT summary selection from model-id envs to model-role aliases documented in + `pmoves/docs/MODEL_FABRIC_CONTRACT.md`. +3. Collapse `PMOVES-transcribe-and-fetch` static model inventory behind the same registry/alias + contract its UI already expects. +4. Review owned-channel playlist control against Google API credentials and Discord approval flow, + not only yt-dlp ingest. From fea8aa6c71034f86a43d32955641fc1b30210411 Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 12:04:38 -0400 Subject: [PATCH 03/12] feat(creator): add youtube control action audit table --- PMOVES.YT | 2 +- .../PMOVES_YT_CONTROL_WORKTREE_REVIEW.md | 8 +++ ...20260312095500_youtube_control_actions.sql | 72 +++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 pmoves/supabase/migrations/20260312095500_youtube_control_actions.sql diff --git a/PMOVES.YT b/PMOVES.YT index 0c459e1279..eca1e7a333 160000 --- a/PMOVES.YT +++ b/PMOVES.YT @@ -1 +1 @@ -Subproject commit 0c459e1279d7b54b213629f50c07947583c197cb +Subproject commit eca1e7a333f2d19d54dc2e7bc0709b57a48ec970 diff --git a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md index a256cd45f9..2be9bb22f5 100644 --- a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md +++ b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md @@ -148,6 +148,14 @@ As of March 12, 2026, use these findings as the starting bias for this worktree model-role aliases - Invidious + companion fallback is present and should remain part of the runtime review path for owned and watched YouTube sources. +- PMOVES.YT is still stronger on ingest/read/download than owned-channel mutation: + - yt-dlp + companion + Invidious cover extraction and fallback download paths + - PMOVES.YT now has a first owned-channel YouTube Data API control slice for playlist-add and + comment/reply actions, but it is intentionally narrow and approval-gated + - preview/executed actions now append to `pmoves_core.youtube_control_actions` so the creator + lane has a durable Supabase audit trail instead of event-only visibility + - broader channel-management tasks, richer review flow, and Discord interaction wiring are still + follow-up work ## Recommended next implementation steps diff --git a/pmoves/supabase/migrations/20260312095500_youtube_control_actions.sql b/pmoves/supabase/migrations/20260312095500_youtube_control_actions.sql new file mode 100644 index 0000000000..86a42a5cc3 --- /dev/null +++ b/pmoves/supabase/migrations/20260312095500_youtube_control_actions.sql @@ -0,0 +1,72 @@ +create schema if not exists pmoves_core; + +create table if not exists pmoves_core.youtube_control_actions ( + id uuid primary key, + action text not null, + status text not null, + execute_requested boolean not null default false, + request_source text not null default 'pmoves-yt', + approved_by text, + approval_note text, + video_id text, + playlist_id text, + parent_comment_id text, + details jsonb not null default '{}'::jsonb, + result jsonb, + error text, + created_at timestamptz not null default now() +); + +create index if not exists idx_youtube_control_actions_created_at + on pmoves_core.youtube_control_actions (created_at desc); + +create index if not exists idx_youtube_control_actions_action_status + on pmoves_core.youtube_control_actions (action, status); + +create index if not exists idx_youtube_control_actions_video_id + on pmoves_core.youtube_control_actions (video_id) + where video_id is not null; + +create index if not exists idx_youtube_control_actions_playlist_id + on pmoves_core.youtube_control_actions (playlist_id) + where playlist_id is not null; + +alter table pmoves_core.youtube_control_actions enable row level security; + +drop policy if exists "Public read youtube control actions" on pmoves_core.youtube_control_actions; +create policy "Public read youtube control actions" + on pmoves_core.youtube_control_actions for select + using (true); + +drop policy if exists "Service write youtube control actions" on pmoves_core.youtube_control_actions; +create policy "Service write youtube control actions" + on pmoves_core.youtube_control_actions for all + using (auth.role() = 'service_role') + with check (auth.role() = 'service_role'); + +do $$ +begin + begin + execute 'grant usage on schema pmoves_core to anon'; + execute 'grant select on pmoves_core.youtube_control_actions to anon'; + exception when undefined_object then + null; + end; + + begin + execute 'grant usage on schema pmoves_core to authenticated'; + execute 'grant select on pmoves_core.youtube_control_actions to authenticated'; + exception when undefined_object then + null; + end; + + begin + grant usage on schema pmoves_core to service_role; + grant select, insert on pmoves_core.youtube_control_actions to service_role; + exception when undefined_object then + null; + end; +end $$; + +comment on table pmoves_core.youtube_control_actions is + 'Append-only audit trail for PMOVES.YT YouTube Data API playlist/comment control actions.'; From 942ebf6147e1b06615e0658517dba2913508ff99 Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 13:12:19 -0400 Subject: [PATCH 04/12] feat(channel-monitor): bridge youtube control approvals --- .../PMOVES_YT_CONTROL_WORKTREE_REVIEW.md | 19 +- pmoves/services/channel-monitor/README.md | 26 +++ .../channel-monitor/channel_monitor/main.py | 59 +++++ .../channel_monitor/monitor.py | 206 +++++++++++++++++- .../channel-monitor/tests/test_monitor.py | 93 ++++++++ 5 files changed, 394 insertions(+), 9 deletions(-) diff --git a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md index 2be9bb22f5..d983002f7c 100644 --- a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md +++ b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md @@ -154,16 +154,19 @@ As of March 12, 2026, use these findings as the starting bias for this worktree comment/reply actions, but it is intentionally narrow and approval-gated - preview/executed actions now append to `pmoves_core.youtube_control_actions` so the creator lane has a durable Supabase audit trail instead of event-only visibility - - broader channel-management tasks, richer review flow, and Discord interaction wiring are still - follow-up work + - `channel-monitor` now provides queue/list/review endpoints for those actions and approves them + by calling PMOVES.YT control endpoints directly + - broader channel-management tasks and first-class Discord interaction wiring are still follow-up + work ## Recommended next implementation steps 1. Keep `channel-monitor` source metadata explicit in config, API payloads, and downstream PMOVES.YT ingest metadata. -2. Move PMOVES.YT summary selection from model-id envs to model-role aliases documented in - `pmoves/docs/MODEL_FABRIC_CONTRACT.md`. -3. Collapse `PMOVES-transcribe-and-fetch` static model inventory behind the same registry/alias - contract its UI already expects. -4. Review owned-channel playlist control against Google API credentials and Discord approval flow, - not only yt-dlp ingest. +2. Replace PMOVES.YT alias-env bridging with live registry-backed alias resolution where the + model-registry service is available. +3. Move PMOVES-transcribe-and-fetch runtime call paths fully onto shared alias/role resolution, + since the fallback catalog and registry compatibility seams are now PMOVES-native but the + backend still mixes direct model ids and alias-based calls in older modules. +4. Expand the new PMOVES.YT owned-channel control plane from approval-gated playlist/comment + actions into richer YouTube Data API coverage plus first-class Discord interaction wiring. diff --git a/pmoves/services/channel-monitor/README.md b/pmoves/services/channel-monitor/README.md index b28f9b9c7e..f47d905cab 100644 --- a/pmoves/services/channel-monitor/README.md +++ b/pmoves/services/channel-monitor/README.md @@ -152,6 +152,32 @@ curl -X POST http://localhost:8097/api/monitor/discord-drop/approve \ -d '{"video_ids":["dQw4w9WgXcQ"],"approve":true,"actor":"discord-agent"}' ``` +Queue/review owned-channel PMOVES.YT control actions: + +```bash +curl -X POST http://localhost:8097/api/monitor/youtube-control \ + -H 'content-type: application/json' \ + -H 'x-channel-monitor-token: $CHANNEL_MONITOR_SECRET' \ + -d '{ + "action": "playlist_add", + "details": { + "playlist_id": "PL123", + "video_id": "dQw4w9WgXcQ" + }, + "request_source": "discord_agent" + }' + +curl -X GET "http://localhost:8097/api/monitor/youtube-control/pending" \ + -H 'x-channel-monitor-token: $CHANNEL_MONITOR_SECRET' + +curl -X POST http://localhost:8097/api/monitor/youtube-control/review \ + -H 'content-type: application/json' \ + -H 'x-channel-monitor-token: $CHANNEL_MONITOR_SECRET' \ + -d '{"action_ids":["11111111-1111-1111-1111-111111111111"],"approve":true,"actor":"discord-agent"}' +``` + +Set `CHANNEL_MONITOR_YT_API_KEY` when PMOVES.YT control endpoints require `X-API-Key`. + ### Observability `GET /api/monitor/stats` now returns: diff --git a/pmoves/services/channel-monitor/channel_monitor/main.py b/pmoves/services/channel-monitor/channel_monitor/main.py index 162148eb40..1cf33ea290 100644 --- a/pmoves/services/channel-monitor/channel_monitor/main.py +++ b/pmoves/services/channel-monitor/channel_monitor/main.py @@ -327,6 +327,19 @@ class DiscordDropApprovalRequest(BaseModel): reason: str | None = Field(None, description="Optional rejection reason") +class YouTubeControlRequest(BaseModel): + action: str = Field(..., description="Control action type: playlist_add or comment_create") + details: Dict[str, Any] = Field(..., description="PMOVES.YT control payload without execute fields") + request_source: str = Field("channel_monitor", description="Logical request source for audit rows") + + +class YouTubeControlReviewRequest(BaseModel): + action_ids: List[str] = Field(..., description="Pending action IDs to approve or reject") + approve: bool = Field(True, description="When true execute the control action, otherwise reject it") + actor: str | None = Field(None, description="Reviewer/agent id performing the action") + reason: str | None = Field(None, description="Optional review note or rejection reason") + + async def require_secret(token: str | None = Header(default=None, alias="X-Channel-Monitor-Token")) -> None: """Verify authentication token for protected endpoints. @@ -613,6 +626,52 @@ async def review_discord_drop( raise HTTPException(status_code=400, detail=str(exc)) from exc +@app.post("/api/monitor/youtube-control") +async def queue_youtube_control_action( + payload: YouTubeControlRequest, + _: None = Depends(require_secret), + monitor: ChannelMonitor = Depends(get_monitor), +): + try: + result = await monitor.create_youtube_control_request( + action=payload.action, + details=payload.details, + request_source=payload.request_source, + ) + return {"status": "ok", "queued": True, "approval_state": "pending_review", "request": result} + except ValueError as exc: + raise HTTPException(status_code=400, detail=str(exc)) from exc + + +@app.get("/api/monitor/youtube-control/pending") +async def list_pending_youtube_control_actions( + _: None = Depends(require_secret), + monitor: ChannelMonitor = Depends(get_monitor), + action: str | None = Query(default=None, description="Optional action filter"), + limit: int = Query(default=100, ge=1, le=500, description="Maximum pending rows to return"), +): + pending = await monitor.list_pending_youtube_control_actions(action=action, limit=limit) + return {"status": "ok", "count": len(pending), "pending": pending} + + +@app.post("/api/monitor/youtube-control/review") +async def review_youtube_control_actions( + payload: YouTubeControlReviewRequest, + _: None = Depends(require_secret), + monitor: ChannelMonitor = Depends(get_monitor), +): + try: + result = await monitor.review_youtube_control_actions( + action_ids=payload.action_ids, + approve=payload.approve, + actor=payload.actor, + reason=payload.reason, + ) + return {"status": "ok", **result} + except ValueError as exc: + raise HTTPException(status_code=400, detail=str(exc)) from exc + + @app.post("/api/monitor/status") async def update_status( payload: UpdateStatusRequest, diff --git a/pmoves/services/channel-monitor/channel_monitor/monitor.py b/pmoves/services/channel-monitor/channel_monitor/monitor.py index cab73d73dd..b587f5f1c5 100644 --- a/pmoves/services/channel-monitor/channel_monitor/monitor.py +++ b/pmoves/services/channel-monitor/channel_monitor/monitor.py @@ -4,10 +4,11 @@ import hashlib import json import logging +import os from datetime import datetime, timezone, timedelta from functools import partial from typing import Any, Dict, List, Optional, Set -from uuid import UUID +from uuid import UUID, uuid4 from urllib.parse import parse_qs, urlparse import asyncpg @@ -216,6 +217,14 @@ def __init__( LOGGER.warning("YouTube API integration disabled due to configuration error: %s", exc) self._youtube_client = None # Explicitly disable if init fails + def _yt_control_base_url(self) -> str: + base = self.queue_url.rstrip("/") + if base.endswith("/yt/ingest"): + return base[: -len("/yt/ingest")] + if base.endswith("/yt"): + return base + return base + async def start(self) -> None: if self._pool is None: try: @@ -1651,6 +1660,201 @@ async def reject_pending_manual_urls( rejected += 1 return {"rejected": rejected, "requested": len(wanted_ids)} + async def create_youtube_control_request( + self, + *, + action: str, + details: Dict[str, Any], + request_source: str, + ) -> Dict[str, Any]: + assert self._pool + action_id = str(uuid4()) + row = { + "id": action_id, + "action": action, + "status": "pending_review", + "execute_requested": True, + "request_source": request_source, + "details": details, + } + async with self._pool.acquire() as conn: + await conn.execute( + """ + INSERT INTO pmoves_core.youtube_control_actions ( + id, action, status, execute_requested, request_source, details + ) VALUES ($1::uuid, $2, $3, $4, $5, $6::jsonb) + """, + action_id, + action, + "pending_review", + True, + request_source, + json.dumps(details), + ) + return row + + async def list_pending_youtube_control_actions( + self, + *, + action: Optional[str] = None, + limit: int = 100, + ) -> List[Dict[str, Any]]: + assert self._pool + capped_limit = max(1, min(limit, 500)) + async with self._pool.acquire() as conn: + if action: + rows = await conn.fetch( + """ + SELECT id, action, status, request_source, approved_by, approval_note, details, result, error, created_at + FROM pmoves_core.youtube_control_actions + WHERE status = 'pending_review' AND action = $1 + ORDER BY created_at ASC + LIMIT $2 + """, + action, + capped_limit, + ) + else: + rows = await conn.fetch( + """ + SELECT id, action, status, request_source, approved_by, approval_note, details, result, error, created_at + FROM pmoves_core.youtube_control_actions + WHERE status = 'pending_review' + ORDER BY created_at ASC + LIMIT $1 + """, + capped_limit, + ) + + pending: List[Dict[str, Any]] = [] + for row in rows: + pending.append( + { + "id": str(row.get("id")), + "action": row.get("action"), + "status": row.get("status"), + "request_source": row.get("request_source"), + "approved_by": row.get("approved_by"), + "approval_note": row.get("approval_note"), + "details": row.get("details") if isinstance(row.get("details"), dict) else {}, + "result": row.get("result"), + "error": row.get("error"), + "created_at": _to_iso(row.get("created_at")), + } + ) + return pending + + async def _invoke_yt_control_action( + self, + *, + action: str, + details: Dict[str, Any], + approved_by: str, + approval_note: Optional[str], + ) -> Dict[str, Any]: + endpoint_map = { + "playlist_add": "/yt/control/playlist/add", + "comment_create": "/yt/control/comment", + } + endpoint = endpoint_map.get(action) + if not endpoint: + raise ValueError(f"Unsupported YouTube control action: {action}") + + payload = dict(details) + payload["execute"] = True + payload["approved_by"] = approved_by + if approval_note: + payload["approval_note"] = approval_note + + headers: Dict[str, str] = {} + api_key = ( + os.getenv("CHANNEL_MONITOR_YT_API_KEY") + or os.getenv("NEXT_PUBLIC_BACKEND_API_KEY") + or os.getenv("BACKEND_API_KEY") + or "" + ).strip() + if api_key: + headers["X-API-Key"] = api_key + + async with httpx.AsyncClient(timeout=60.0) as client: + response = await client.post( + f"{self._yt_control_base_url()}{endpoint}", + json=payload, + headers=headers, + ) + response.raise_for_status() + return response.json() + + async def review_youtube_control_actions( + self, + *, + action_ids: List[str], + approve: bool, + actor: Optional[str] = None, + reason: Optional[str] = None, + ) -> Dict[str, Any]: + assert self._pool + wanted_ids = [value.strip() for value in action_ids if isinstance(value, str) and value.strip()] + if not wanted_ids: + raise ValueError("action_ids is required") + + async with self._pool.acquire() as conn: + rows = await conn.fetch( + """ + SELECT id, action, details + FROM pmoves_core.youtube_control_actions + WHERE status = 'pending_review' + AND id = ANY($1::uuid[]) + ORDER BY created_at ASC + """, + wanted_ids, + ) + + processed_ids: List[str] = [] + for row in rows: + action_id = str(row.get("id")) + action = row.get("action") + details = row.get("details") if isinstance(row.get("details"), dict) else {} + new_status = "rejected" + result_payload: Dict[str, Any] | None = None + error_text = reason if not approve else None + if approve: + result_payload = await self._invoke_yt_control_action( + action=action, + details=details, + approved_by=actor or "channel-monitor", + approval_note=reason, + ) + new_status = "approved" + + async with self._pool.acquire() as conn: + await conn.execute( + """ + UPDATE pmoves_core.youtube_control_actions + SET status = $2, + approved_by = $3, + approval_note = COALESCE($4, approval_note), + result = COALESCE($5::jsonb, result), + error = $6 + WHERE id = $1::uuid + """, + action_id, + new_status, + actor, + reason, + json.dumps(result_payload) if result_payload is not None else None, + error_text, + ) + processed_ids.append(action_id) + + missing_ids = sorted(set(wanted_ids) - set(processed_ids)) + return { + "processed": len(processed_ids), + "processed_ids": processed_ids, + "missing_ids": missing_ids, + "approved": approve, + } + async def get_stats(self) -> Dict[str, Any]: assert self._pool async with self._pool.acquire() as conn: diff --git a/pmoves/services/channel-monitor/tests/test_monitor.py b/pmoves/services/channel-monitor/tests/test_monitor.py index fa596023c2..5de50c5ec7 100644 --- a/pmoves/services/channel-monitor/tests/test_monitor.py +++ b/pmoves/services/channel-monitor/tests/test_monitor.py @@ -95,6 +95,25 @@ def _build_monitor(tmp_path, config_name: str = "channel.json") -> ChannelMonito ) +class _FakeAcquire: + def __init__(self, conn): + self._conn = conn + + async def __aenter__(self): + return self._conn + + async def __aexit__(self, exc_type, exc, tb): + return False + + +class _FakePool: + def __init__(self, conn): + self._conn = conn + + def acquire(self): + return _FakeAcquire(self._conn) + + def test_apply_filters_respects_age_and_keywords(tmp_path): monitor = _build_monitor(tmp_path) now = datetime.now(timezone.utc) @@ -479,3 +498,77 @@ def test_extract_youtube_video_id_allows_valid_hosts(url, expected): ) def test_extract_youtube_video_id_rejects_spoofed_hosts(url): assert _extract_youtube_video_id(url) is None + + +def test_create_youtube_control_request_persists_pending_row(tmp_path): + monitor = _build_monitor(tmp_path) + conn = SimpleNamespace(execute=AsyncMock()) + monitor._pool = _FakePool(conn) # type: ignore[assignment] + + result = asyncio.run( + monitor.create_youtube_control_request( + action="playlist_add", + details={"playlist_id": "PL123", "video_id": "vid-123"}, + request_source="discord_agent", + ) + ) + + assert result["status"] == "pending_review" + assert result["action"] == "playlist_add" + conn.execute.assert_awaited_once() + + +def test_review_youtube_control_actions_executes_pmoves_yt_call(tmp_path, monkeypatch): + monitor = _build_monitor(tmp_path) + rows = [ + { + "id": "11111111-1111-1111-1111-111111111111", + "action": "comment_create", + "details": {"video_id": "vid-123", "text": "hello"}, + } + ] + conn = SimpleNamespace(fetch=AsyncMock(return_value=rows), execute=AsyncMock()) + monitor._pool = _FakePool(conn) # type: ignore[assignment] + + requests_made = [] + + class DummyResponse: + def raise_for_status(self): + return None + + def json(self): + return {"status": "executed", "result": {"id": "comment-1"}} + + class DummyAsyncClient: + def __init__(self, *args, **kwargs): + pass + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + return False + + async def post(self, url, json=None, headers=None): + requests_made.append((url, json, headers)) + return DummyResponse() + + monkeypatch.setenv("CHANNEL_MONITOR_YT_API_KEY", "secret-key") + monkeypatch.setattr("channel_monitor.monitor.httpx.AsyncClient", DummyAsyncClient) + + result = asyncio.run( + monitor.review_youtube_control_actions( + action_ids=["11111111-1111-1111-1111-111111111111"], + approve=True, + actor="discord-agent", + reason="approved in ops", + ) + ) + + assert result["approved"] is True + assert result["processed"] == 1 + assert requests_made[0][0] == "http://example.test/yt/control/comment" + assert requests_made[0][1]["execute"] is True + assert requests_made[0][1]["approved_by"] == "discord-agent" + assert requests_made[0][2]["X-API-Key"] == "secret-key" + assert conn.execute.await_count == 1 From 4aff5a2dcd4e92045b622c503ca73a1c7e8958aa Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 13:16:57 -0400 Subject: [PATCH 05/12] feat(channel-monitor): notify messaging gateway for yt approvals --- .../PMOVES_YT_CONTROL_WORKTREE_REVIEW.md | 2 + pmoves/services/channel-monitor/README.md | 5 +- .../channel-monitor/channel_monitor/main.py | 5 ++ .../channel_monitor/monitor.py | 56 +++++++++++++++++++ .../channel-monitor/tests/test_monitor.py | 43 ++++++++++++++ 5 files changed, 110 insertions(+), 1 deletion(-) diff --git a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md index d983002f7c..98a8c3bfd0 100644 --- a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md +++ b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md @@ -156,6 +156,8 @@ As of March 12, 2026, use these findings as the starting bias for this worktree lane has a durable Supabase audit trail instead of event-only visibility - `channel-monitor` now provides queue/list/review endpoints for those actions and approves them by calling PMOVES.YT control endpoints directly + - queued control requests can now optionally notify `messaging-gateway` so Discord-ready review + prompts come from the same request path - broader channel-management tasks and first-class Discord interaction wiring are still follow-up work diff --git a/pmoves/services/channel-monitor/README.md b/pmoves/services/channel-monitor/README.md index f47d905cab..89bf47a39c 100644 --- a/pmoves/services/channel-monitor/README.md +++ b/pmoves/services/channel-monitor/README.md @@ -164,7 +164,8 @@ curl -X POST http://localhost:8097/api/monitor/youtube-control \ "playlist_id": "PL123", "video_id": "dQw4w9WgXcQ" }, - "request_source": "discord_agent" + "request_source": "discord_agent", + "notify_platforms": ["discord"] }' curl -X GET "http://localhost:8097/api/monitor/youtube-control/pending" \ @@ -177,6 +178,8 @@ curl -X POST http://localhost:8097/api/monitor/youtube-control/review \ ``` Set `CHANNEL_MONITOR_YT_API_KEY` when PMOVES.YT control endpoints require `X-API-Key`. +Set `CHANNEL_MONITOR_MESSAGING_URL` to the messaging gateway `/v1/send` endpoint to emit +Discord-ready approval notifications when requests are queued. ### Observability diff --git a/pmoves/services/channel-monitor/channel_monitor/main.py b/pmoves/services/channel-monitor/channel_monitor/main.py index 1cf33ea290..ce2c60f21f 100644 --- a/pmoves/services/channel-monitor/channel_monitor/main.py +++ b/pmoves/services/channel-monitor/channel_monitor/main.py @@ -331,6 +331,10 @@ class YouTubeControlRequest(BaseModel): action: str = Field(..., description="Control action type: playlist_add or comment_create") details: Dict[str, Any] = Field(..., description="PMOVES.YT control payload without execute fields") request_source: str = Field("channel_monitor", description="Logical request source for audit rows") + notify_platforms: List[str] | None = Field( + None, + description="Optional messaging-gateway platforms to notify (e.g. ['discord'])", + ) class YouTubeControlReviewRequest(BaseModel): @@ -637,6 +641,7 @@ async def queue_youtube_control_action( action=payload.action, details=payload.details, request_source=payload.request_source, + notify_platforms=payload.notify_platforms, ) return {"status": "ok", "queued": True, "approval_state": "pending_review", "request": result} except ValueError as exc: diff --git a/pmoves/services/channel-monitor/channel_monitor/monitor.py b/pmoves/services/channel-monitor/channel_monitor/monitor.py index b587f5f1c5..f7b796c741 100644 --- a/pmoves/services/channel-monitor/channel_monitor/monitor.py +++ b/pmoves/services/channel-monitor/channel_monitor/monitor.py @@ -1666,6 +1666,7 @@ async def create_youtube_control_request( action: str, details: Dict[str, Any], request_source: str, + notify_platforms: Optional[List[str]] = None, ) -> Dict[str, Any]: assert self._pool action_id = str(uuid4()) @@ -1691,8 +1692,63 @@ async def create_youtube_control_request( request_source, json.dumps(details), ) + notified = await self._notify_youtube_control_request( + action_id=action_id, + action=action, + details=details, + request_source=request_source, + platforms=notify_platforms or [], + ) + row["notified"] = notified return row + async def _notify_youtube_control_request( + self, + *, + action_id: str, + action: str, + details: Dict[str, Any], + request_source: str, + platforms: List[str], + ) -> bool: + active_platforms = [value for value in platforms if isinstance(value, str) and value.strip()] + if not active_platforms: + return False + messaging_url = (os.getenv("CHANNEL_MONITOR_MESSAGING_URL") or "").strip() + if not messaging_url: + LOGGER.info("Skipping YouTube control notification; CHANNEL_MONITOR_MESSAGING_URL is not set") + return False + + content = ( + f"YouTube control request pending review\n" + f"- action: {action}\n" + f"- source: {request_source}\n" + f"- action_id: {action_id}" + ) + buttons = [ + {"id": f"ytcontrol:approve:{action_id}", "label": "Approve", "style": "primary"}, + {"id": f"ytcontrol:reject:{action_id}", "label": "Reject", "style": "danger"}, + ] + payload = { + "platforms": active_platforms, + "content": content, + "buttons": buttons, + "metadata": { + "action_id": action_id, + "action": action, + "request_source": request_source, + "details": details, + }, + } + try: + async with httpx.AsyncClient(timeout=20.0) as client: + response = await client.post(messaging_url, json=payload) + response.raise_for_status() + return True + except Exception as exc: # pragma: no cover - best effort + LOGGER.warning("Failed to notify messaging gateway for YouTube control request %s: %s", action_id, exc) + return False + async def list_pending_youtube_control_actions( self, *, diff --git a/pmoves/services/channel-monitor/tests/test_monitor.py b/pmoves/services/channel-monitor/tests/test_monitor.py index 5de50c5ec7..6e0c33b56a 100644 --- a/pmoves/services/channel-monitor/tests/test_monitor.py +++ b/pmoves/services/channel-monitor/tests/test_monitor.py @@ -504,6 +504,7 @@ def test_create_youtube_control_request_persists_pending_row(tmp_path): monitor = _build_monitor(tmp_path) conn = SimpleNamespace(execute=AsyncMock()) monitor._pool = _FakePool(conn) # type: ignore[assignment] + monitor._notify_youtube_control_request = AsyncMock(return_value=False) # type: ignore[method-assign] result = asyncio.run( monitor.create_youtube_control_request( @@ -515,9 +516,51 @@ def test_create_youtube_control_request_persists_pending_row(tmp_path): assert result["status"] == "pending_review" assert result["action"] == "playlist_add" + assert result["notified"] is False conn.execute.assert_awaited_once() +def test_create_youtube_control_request_can_notify_messaging_gateway(tmp_path, monkeypatch): + monitor = _build_monitor(tmp_path) + conn = SimpleNamespace(execute=AsyncMock()) + monitor._pool = _FakePool(conn) # type: ignore[assignment] + requests_made = [] + + class DummyResponse: + def raise_for_status(self): + return None + + class DummyAsyncClient: + def __init__(self, *args, **kwargs): + pass + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + return False + + async def post(self, url, json=None): + requests_made.append((url, json)) + return DummyResponse() + + monkeypatch.setenv("CHANNEL_MONITOR_MESSAGING_URL", "http://messaging.test/v1/send") + monkeypatch.setattr("channel_monitor.monitor.httpx.AsyncClient", DummyAsyncClient) + + result = asyncio.run( + monitor.create_youtube_control_request( + action="playlist_add", + details={"playlist_id": "PL123", "video_id": "vid-123"}, + request_source="discord_agent", + notify_platforms=["discord"], + ) + ) + + assert result["notified"] is True + assert requests_made[0][0] == "http://messaging.test/v1/send" + assert requests_made[0][1]["platforms"] == ["discord"] + + def test_review_youtube_control_actions_executes_pmoves_yt_call(tmp_path, monkeypatch): monitor = _build_monitor(tmp_path) rows = [ From 4052a4bdb77cc548d453ca2fa07d6d6d019ce0fc Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 13:23:46 -0400 Subject: [PATCH 06/12] feat(messaging): route yt approval buttons to channel monitor --- .../PMOVES_YT_CONTROL_WORKTREE_REVIEW.md | 3 + pmoves/services/channel-monitor/README.md | 2 + pmoves/services/messaging-gateway/main.py | 76 ++++++++++ .../services/messaging-gateway/test_main.py | 140 ++++++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 pmoves/services/messaging-gateway/test_main.py diff --git a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md index 98a8c3bfd0..8e6fc9b847 100644 --- a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md +++ b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md @@ -158,6 +158,9 @@ As of March 12, 2026, use these findings as the starting bias for this worktree by calling PMOVES.YT control endpoints directly - queued control requests can now optionally notify `messaging-gateway` so Discord-ready review prompts come from the same request path + - `messaging-gateway` now intercepts `ytcontrol:*` button clicks and turns them into + `channel-monitor` review calls, closing the approval loop from Discord click to PMOVES.YT + execution - broader channel-management tasks and first-class Discord interaction wiring are still follow-up work diff --git a/pmoves/services/channel-monitor/README.md b/pmoves/services/channel-monitor/README.md index 89bf47a39c..250700dab9 100644 --- a/pmoves/services/channel-monitor/README.md +++ b/pmoves/services/channel-monitor/README.md @@ -180,6 +180,8 @@ curl -X POST http://localhost:8097/api/monitor/youtube-control/review \ Set `CHANNEL_MONITOR_YT_API_KEY` when PMOVES.YT control endpoints require `X-API-Key`. Set `CHANNEL_MONITOR_MESSAGING_URL` to the messaging gateway `/v1/send` endpoint to emit Discord-ready approval notifications when requests are queued. +`messaging-gateway` now intercepts `ytcontrol:approve:` / `ytcontrol:reject:` button +interactions and maps them back into `POST /api/monitor/youtube-control/review`. ### Observability diff --git a/pmoves/services/messaging-gateway/main.py b/pmoves/services/messaging-gateway/main.py index 0f1307c0fc..33fc737a3b 100644 --- a/pmoves/services/messaging-gateway/main.py +++ b/pmoves/services/messaging-gateway/main.py @@ -9,6 +9,7 @@ from contextlib import asynccontextmanager from typing import Any, Dict, Optional +import httpx from fastapi import FastAPI, HTTPException, Request from nats.aio.client import Client as NATS from pydantic import BaseModel @@ -64,6 +65,8 @@ async def lifespan(app: FastAPI): DISCORD_APPLICATION_ID = os.environ.get("DISCORD_APPLICATION_ID", "") DISCORD_PUBLIC_KEY = os.environ.get("DISCORD_PUBLIC_KEY", "") WHATSAPP_ACCESS_TOKEN = os.environ.get("WHATSAPP_ACCESS_TOKEN", "") +CHANNEL_MONITOR_URL = os.environ.get("CHANNEL_MONITOR_URL", "http://channel-monitor:8097") +CHANNEL_MONITOR_SECRET = os.environ.get("CHANNEL_MONITOR_SECRET", "") # NATS subjects to subscribe to for auto-forwarding SUBJECTS = os.environ.get( @@ -118,6 +121,75 @@ class SendMessageRequest(BaseModel): metadata: Optional[dict] = None +def _interaction_actor(payload: Dict[str, Any]) -> str: + member = payload.get("member") if isinstance(payload.get("member"), dict) else {} + user = member.get("user") if isinstance(member.get("user"), dict) else payload.get("user", {}) + username = user.get("username") if isinstance(user, dict) else None + user_id = user.get("id") if isinstance(user, dict) else None + if username and user_id: + return f"{username}:{user_id}" + if user_id: + return str(user_id) + return "discord-user" + + +async def _handle_ytcontrol_interaction(payload: Dict[str, Any]) -> Optional[Dict[str, Any]]: + data = payload.get("data") if isinstance(payload.get("data"), dict) else {} + custom_id = data.get("custom_id") + if not isinstance(custom_id, str) or not custom_id.startswith("ytcontrol:"): + return None + + parts = custom_id.split(":", 2) + if len(parts) != 3: + return { + "type": 4, + "data": {"content": "Invalid YouTube control action id.", "flags": 64}, + } + _, action, action_id = parts + approve = action == "approve" + if action not in {"approve", "reject"}: + return { + "type": 4, + "data": {"content": f"Unsupported YouTube control action: {action}", "flags": 64}, + } + + headers = {"content-type": "application/json"} + if CHANNEL_MONITOR_SECRET: + headers["X-Channel-Monitor-Token"] = CHANNEL_MONITOR_SECRET + review_payload = { + "action_ids": [action_id], + "approve": approve, + "actor": _interaction_actor(payload), + "reason": "approved from Discord" if approve else "rejected from Discord", + } + + try: + async with httpx.AsyncClient(timeout=20.0) as client: + response = await client.post( + f"{CHANNEL_MONITOR_URL.rstrip('/')}/api/monitor/youtube-control/review", + headers=headers, + json=review_payload, + ) + response.raise_for_status() + body = response.json() + except Exception as exc: + logger.warning("YouTube control Discord interaction failed for %s: %s", action_id, exc) + return { + "type": 4, + "data": {"content": f"Review action failed for {action_id}: {exc}", "flags": 64}, + } + + processed = body.get("processed", 0) + if approve: + content = f"Approved YouTube control request `{action_id}`. Processed: {processed}." + else: + content = f"Rejected YouTube control request `{action_id}`. Processed: {processed}." + return { + "type": 4, + "data": {"content": content, "flags": 64}, + } + + @app.get("/healthz") async def healthz(): """Health check endpoint.""" @@ -217,6 +289,10 @@ async def discord_webhook(request: Request): if payload.get("type") == 1: return {"type": 1} + ytcontrol_response = await _handle_ytcontrol_interaction(payload) + if ytcontrol_response is not None: + return ytcontrol_response + return await discord_platform.handle_interaction(payload) diff --git a/pmoves/services/messaging-gateway/test_main.py b/pmoves/services/messaging-gateway/test_main.py new file mode 100644 index 0000000000..ee7693eeac --- /dev/null +++ b/pmoves/services/messaging-gateway/test_main.py @@ -0,0 +1,140 @@ +from __future__ import annotations + +import importlib.util +import sys +from pathlib import Path +from types import ModuleType + + +_CACHED_MODULE = None + + +def _load_main_module(): + global _CACHED_MODULE + if _CACHED_MODULE is not None: + return _CACHED_MODULE + + platforms_pkg = ModuleType("platforms") + discord_mod = ModuleType("platforms.discord") + telegram_mod = ModuleType("platforms.telegram") + whatsapp_mod = ModuleType("platforms.whatsapp") + + class _Platform: + def __init__(self, *args, **kwargs): + pass + + async def initialize(self): + return None + + def is_configured(self): + return True + + def verify_signature(self, signature, timestamp, body): + return True + + async def handle_interaction(self, payload): + return {"ok": True, "passthrough": True} + + async def handle_update(self, payload): + return {"ok": True} + + async def send(self, **kwargs): + return True + + discord_mod.DiscordPlatform = _Platform + telegram_mod.TelegramPlatform = _Platform + whatsapp_mod.WhatsAppPlatform = _Platform + sys.modules["platforms"] = platforms_pkg + sys.modules["platforms.discord"] = discord_mod + sys.modules["platforms.telegram"] = telegram_mod + sys.modules["platforms.whatsapp"] = whatsapp_mod + + module_path = Path(__file__).resolve().parent / "main.py" + spec = importlib.util.spec_from_file_location("messaging_gateway_main_test", module_path) + module = importlib.util.module_from_spec(spec) + assert spec and spec.loader + spec.loader.exec_module(module) + _CACHED_MODULE = module + return module + + +def test_handle_ytcontrol_interaction_approve(monkeypatch): + module = _load_main_module() + requests_made = [] + + class DummyResponse: + def raise_for_status(self): + return None + + def json(self): + return {"processed": 1} + + class DummyAsyncClient: + def __init__(self, *args, **kwargs): + pass + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + return False + + async def post(self, url, headers=None, json=None): + requests_made.append((url, headers, json)) + return DummyResponse() + + monkeypatch.setattr(module.httpx, "AsyncClient", DummyAsyncClient) + monkeypatch.setattr(module, "CHANNEL_MONITOR_URL", "http://channel-monitor:8097") + monkeypatch.setattr(module, "CHANNEL_MONITOR_SECRET", "secret-token") + + payload = { + "type": 3, + "data": {"custom_id": "ytcontrol:approve:11111111-1111-1111-1111-111111111111"}, + "member": {"user": {"username": "tester", "id": "42"}}, + } + + response = module.asyncio.run(module._handle_ytcontrol_interaction(payload)) + + assert response["type"] == 4 + assert "Approved YouTube control request" in response["data"]["content"] + assert requests_made[0][0] == "http://channel-monitor:8097/api/monitor/youtube-control/review" + assert requests_made[0][1]["X-Channel-Monitor-Token"] == "secret-token" + assert requests_made[0][2]["approve"] is True + assert requests_made[0][2]["actor"] == "tester:42" + + +def test_handle_ytcontrol_interaction_reject(monkeypatch): + module = _load_main_module() + + class DummyResponse: + def raise_for_status(self): + return None + + def json(self): + return {"processed": 1} + + class DummyAsyncClient: + def __init__(self, *args, **kwargs): + pass + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + return False + + async def post(self, url, headers=None, json=None): + return DummyResponse() + + monkeypatch.setattr(module.httpx, "AsyncClient", DummyAsyncClient) + + payload = { + "type": 3, + "data": {"custom_id": "ytcontrol:reject:22222222-2222-2222-2222-222222222222"}, + "user": {"id": "77"}, + } + + response = module.asyncio.run(module._handle_ytcontrol_interaction(payload)) + + assert response["type"] == 4 + assert "Rejected YouTube control request" in response["data"]["content"] From 157d1514c784b8a481eb5a0da82a61a06ebadca1 Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 13:35:46 -0400 Subject: [PATCH 07/12] docs(agents): add creator notebook traversal context --- pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md | 25 ++++++++-- .../PMOVES_YT_CONTROL_WORKTREE_REVIEW.md | 50 +++++++++++++++---- pmoves/docs/AGENTS/README.md | 17 +++++-- .../SUBMODULE_CODEX_HOMES/PMOVES-Creator.md | 25 +++++++++- .../PMOVES-Open-Notebook.md | 24 ++++++++- pmoves/docs/NEXT_STEPS.md | 1 + pmoves/docs/PMOVES.AI PLANS/ROADMAP.md | 1 + 7 files changed, 119 insertions(+), 24 deletions(-) diff --git a/pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md b/pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md index b177d454f4..5c1ba91e70 100644 --- a/pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md +++ b/pmoves/docs/AGENTS/CODEX_OPERATOR_HOME.md @@ -81,14 +81,21 @@ transcripts, Discord, Jellyfin, or cross-model orchestration. ### Primary traversal order 1. `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` -2. `pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md` -3. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` -4. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md` -5. `pmoves/services/channel-monitor/README.md` -6. `pmoves/docs/AGENTS/JELLYFIN_CREATOR_WORKTREE_REVIEW.md` +2. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Creator.md` +3. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md` +4. `pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md` +5. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` +6. `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md` +7. `pmoves/services/channel-monitor/README.md` +8. `pmoves/docs/AGENTS/JELLYFIN_CREATOR_WORKTREE_REVIEW.md` +9. `pmoves/docs/PMOVESCHIT/CATACLYSM_STUDIOS_INC.md` ### Service posture +- `PMOVES-Creator` should be treated as the strategy and collaboration lane where creator goals, + networking intent, and campaign posture are defined before execution. +- `PMOVES-Open-Notebook` should be treated as the drafting, evidence, and operator memory lane + where notes, approval artifacts, and reusable context are staged. - `PMOVES.YT` is the authoritative runtime for YouTube ingest, metadata, docs catalog, and downloader fallback strategy. - `Channel Monitor` owns source discovery, polling cadence, and fan-out into PMOVES.YT ingest. @@ -99,6 +106,8 @@ transcripts, Discord, Jellyfin, or cross-model orchestration. to human approval unless the workflow explicitly declares autonomous behavior. - `Tokenism` should be treated as the value-tracking lane for attribution, monetization, and network effects that result from creator operations. +- `CATACLYSM_STUDIOS_INC` is the governing business and brand context; use it to decide whether a + creator action aligns with the larger platform story, audience, and partnership posture. ### Creator control checks @@ -205,6 +214,10 @@ For a comprehensive view of what's implemented vs. what's still planned, see: - Creator-network control plane: - `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` +- PMOVES-Creator submodule home: + - `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Creator.md` +- PMOVES-Open-Notebook submodule home: + - `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md` - PMOVES.YT submodule home: - `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` - PMOVES-transcribe-and-fetch submodule home: @@ -233,6 +246,8 @@ For a comprehensive view of what's implemented vs. what's still planned, see: - `pmoves/docs/AGENTS/CODEX_CIPHER_MEMORY_IMPLEMENTATION_MAP.md` - PMOVES skill bundles: - `pmoves/docs/AGENTS/PmovesSKillZ.md` +- Cataclysm Studios context: + - `pmoves/docs/PMOVESCHIT/CATACLYSM_STUDIOS_INC.md` - Existing Claude context stack: - `.claude/CLAUDE.md` - `.claude/context/` diff --git a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md index 8e6fc9b847..78982342f1 100644 --- a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md +++ b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md @@ -4,6 +4,7 @@ Use this runbook when the task is not just "fix PMOVES.YT", but review the creat path around it in one isolated worktree. This is the correct lane when you need to validate: +- creator strategy and notebook context - PMOVES.YT runtime behavior - channel-monitor discovery and queue handoff - transcribe-and-fetch fallback or repair posture @@ -27,14 +28,29 @@ Recommended branch naming: ## Traversal order 1. Read `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` -2. Read `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` -3. Read `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md` -4. Read `pmoves/services/channel-monitor/README.md` -5. Read `pmoves/docs/AGENTS/JELLYFIN_CREATOR_WORKTREE_REVIEW.md` -6. Then inspect the live service contracts in code and compose +2. Read `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Creator.md` +3. Read `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md` +4. Read `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` +5. Read `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md` +6. Read `pmoves/services/channel-monitor/README.md` +7. Read `pmoves/docs/AGENTS/JELLYFIN_CREATOR_WORKTREE_REVIEW.md` +8. Read `pmoves/docs/PMOVESCHIT/CATACLYSM_STUDIOS_INC.md` +9. Then inspect the live service contracts in code and compose ## Review lanes +### Lane 0 — creator strategy and notebook context + +- Files: + - `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Creator.md` + - `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md` + - `pmoves/docs/PMOVESCHIT/CATACLYSM_STUDIOS_INC.md` + - `CATACLYSM_STUDIOS_INC/README.md` +- Questions: + - Is the operator task aligned with creator strategy rather than just service mechanics? + - Should the task produce notebook artifacts, drafts, or evidence before execution? + - Does the action fit the Cataclysm Studios platform story, brand, and community posture? + ### Lane A — PMOVES.YT runtime - Files: @@ -124,6 +140,11 @@ Use a code-review mindset by default: - then validation evidence - then merge order +When the task affects creator actions, also say: +- where creator intent should live +- where notebook evidence should live +- which CATACLYSM_STUDIOS_INC constraints shaped the recommendation + If no findings are present, say so explicitly and call out residual risks: - creator outreach governance - transcript/fetch divergence @@ -161,17 +182,24 @@ As of March 12, 2026, use these findings as the starting bias for this worktree - `messaging-gateway` now intercepts `ytcontrol:*` button clicks and turns them into `channel-monitor` review calls, closing the approval loop from Discord click to PMOVES.YT execution - - broader channel-management tasks and first-class Discord interaction wiring are still follow-up - work +- broader channel-management tasks and first-class Discord interaction wiring are still follow-up + work +- `PMOVES-Creator` and `PMOVES-Open-Notebook` are now part of the intended traversal path for + creator-control work, but their current Codex homes still need richer operational examples as + the action surface grows. +- `CATACLYSM_STUDIOS_INC` should now be treated as the governing context for creator-network + actions so outreach, automation, and monetization stay aligned with the platform story. ## Recommended next implementation steps -1. Keep `channel-monitor` source metadata explicit in config, API payloads, and downstream PMOVES.YT +1. Keep creator strategy and notebook artifacts explicit in the AGENTS traversal so action + requests start with intent, draft context, and approval posture instead of raw endpoint input. +2. Keep `channel-monitor` source metadata explicit in config, API payloads, and downstream PMOVES.YT ingest metadata. -2. Replace PMOVES.YT alias-env bridging with live registry-backed alias resolution where the +3. Replace PMOVES.YT alias-env bridging with live registry-backed alias resolution where the model-registry service is available. -3. Move PMOVES-transcribe-and-fetch runtime call paths fully onto shared alias/role resolution, +4. Move PMOVES-transcribe-and-fetch runtime call paths fully onto shared alias/role resolution, since the fallback catalog and registry compatibility seams are now PMOVES-native but the backend still mixes direct model ids and alias-based calls in older modules. -4. Expand the new PMOVES.YT owned-channel control plane from approval-gated playlist/comment +5. Expand the new PMOVES.YT owned-channel control plane from approval-gated playlist/comment actions into richer YouTube Data API coverage plus first-class Discord interaction wiring. diff --git a/pmoves/docs/AGENTS/README.md b/pmoves/docs/AGENTS/README.md index 561bb405f1..09b798e42b 100644 --- a/pmoves/docs/AGENTS/README.md +++ b/pmoves/docs/AGENTS/README.md @@ -32,17 +32,23 @@ transcripts, Jellyfin playback, Discord outreach, or model-routing across the PM 1. **[CODEX_OPERATOR_HOME.md](./CODEX_OPERATOR_HOME.md)** — Codex-first operator runbook with creator control plane commands 2. **[../PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md](../PMOVES.AI%20PLANS/CREATOR_NETWORK_CONTROL_PLANE.md)** — 2026 creator-network operating model -3. **[PMOVES_YT_CONTROL_WORKTREE_REVIEW.md](./PMOVES_YT_CONTROL_WORKTREE_REVIEW.md)** — PMOVES.YT integration worktree runbook across discovery, transcripts, playback, and model routing -4. **[JELLYFIN_CREATOR_WORKTREE_REVIEW.md](./JELLYFIN_CREATOR_WORKTREE_REVIEW.md)** — Jellyfin/creator worktree review and current gaps -5. **[SUBMODULE_CODEX_HOMES/PMOVES.YT.md](./SUBMODULE_CODEX_HOMES/PMOVES.YT.md)** — authoritative YouTube runtime traversal -6. **[SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md](./SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md)** — transcript/fetch auxiliary lane +3. **[SUBMODULE_CODEX_HOMES/PMOVES-Creator.md](./SUBMODULE_CODEX_HOMES/PMOVES-Creator.md)** — creator strategy, networking, and campaign lane +4. **[SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md](./SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md)** — planning, drafting, evidence, and operator memory lane +5. **[PMOVES_YT_CONTROL_WORKTREE_REVIEW.md](./PMOVES_YT_CONTROL_WORKTREE_REVIEW.md)** — PMOVES.YT integration worktree runbook across discovery, transcripts, playback, control, and model routing +6. **[JELLYFIN_CREATOR_WORKTREE_REVIEW.md](./JELLYFIN_CREATOR_WORKTREE_REVIEW.md)** — Jellyfin/creator worktree review and current gaps +7. **[SUBMODULE_CODEX_HOMES/PMOVES.YT.md](./SUBMODULE_CODEX_HOMES/PMOVES.YT.md)** — authoritative YouTube runtime traversal +8. **[SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md](./SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md)** — transcript/fetch auxiliary lane +9. **[../PMOVESCHIT/CATACLYSM_STUDIOS_INC.md](../PMOVESCHIT/CATACLYSM_STUDIOS_INC.md)** — platform, brand, and governance context for creator actions The creator-network lane treats Codex as a legendary operator that can traverse: +- PMOVES-Creator for channel strategy, outreach posture, collaboration plays, and campaign framing +- PMOVES-Open-Notebook for draft assembly, evidence capture, notes, and reusable operator context - PMOVES.YT for owned/watched channel ingest, playlist control, metadata sync, and downloader fallback - Channel Monitor for source discovery, scheduling, and event routing - transcribe-and-fetch for transcript and fetch augmentation - Jellyfin and publisher surfaces for playback, packaging, and downstream publishing - Discord and BoTZ for agent-mediated response, routing, and operator interaction +- CATACLYSM_STUDIOS_INC for business, brand, and community constraints that govern what the stack should do - local and remote model tiers for extraction, embedding, rerank, narration, and orchestration --- @@ -107,10 +113,13 @@ single-service codebase. | File | Purpose | |------|---------| | [../PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md](../PMOVES.AI%20PLANS/CREATOR_NETWORK_CONTROL_PLANE.md) | 2026 creator-network map across PMOVES.YT, Channel Monitor, Discord, Jellyfin, and Tokenism | +| [SUBMODULE_CODEX_HOMES/PMOVES-Creator.md](./SUBMODULE_CODEX_HOMES/PMOVES-Creator.md) | Creator strategy, networking, and campaign traversal | +| [SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md](./SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md) | Planning, drafting, evidence, and notebook memory traversal | | [PMOVES_YT_CONTROL_WORKTREE_REVIEW.md](./PMOVES_YT_CONTROL_WORKTREE_REVIEW.md) | Worktree-first review path for PMOVES.YT, channel-monitor, transcribe-and-fetch, Jellyfin, and model routing | | [JELLYFIN_CREATOR_WORKTREE_REVIEW.md](./JELLYFIN_CREATOR_WORKTREE_REVIEW.md) | Current creator/Jellyfin worktree findings and follow-ups | | [SUBMODULE_CODEX_HOMES/PMOVES.YT.md](./SUBMODULE_CODEX_HOMES/PMOVES.YT.md) | Codex home for YouTube ingest and creator control | | [SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md](./SUBMODULE_CODEX_HOMES/PMOVES-transcribe-and-fetch.md) | Codex home for transcript and fetch support | +| [../PMOVESCHIT/CATACLYSM_STUDIOS_INC.md](../PMOVESCHIT/CATACLYSM_STUDIOS_INC.md) | Cataclysm Studios platform/brand context that governs creator operations | ### Tier 5: Vision & Notes (12 files) diff --git a/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Creator.md b/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Creator.md index 470b8a7f05..53bf985bc0 100644 --- a/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Creator.md +++ b/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Creator.md @@ -1,16 +1,37 @@ # Codex Home Overlay: PMOVES-Creator Scope: -- PMOVES-Creator submodule integration lane alignment for PMOVES hardened release operations. +- PMOVES-Creator is the strategy and campaign lane for creator-network operations. +- Use this home when the task is about audience targeting, collaboration posture, outreach + planning, channel growth, creator partnership framing, or how PMOVES should present value to + creators and communities. + +Traversal role: +- Define creator intent before implementation starts in PMOVES.YT, channel-monitor, Discord, or + Tokenism surfaces. +- Treat PMOVES-Creator as the place to shape campaign structure, response posture, and what kind + of network effect the operator is trying to create. + +Read alongside: +- `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` +- `pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md` +- `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` +- `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md` +- `pmoves/docs/PMOVESCHIT/CATACLYSM_STUDIOS_INC.md` Core checks: - `git submodule status -- PMOVES-Creator` - `make -C pmoves submodule-layer-validate-one SUBMODULE=PMOVES-Creator` - `make -C pmoves submodule-branch-policy-check` +Operator prompts: +- What is the creator or campaign trying to accomplish? +- Is this an owned-channel action, a watched-channel networking action, or a partner/candidate lane? +- What approval surface should exist before the action executes? +- What should be recorded in PMOVES-Open-Notebook or Supabase for audit, memory, or follow-up? + Related parity tokens: - `/worktree:status` - `/github:checks` - `/deploy:status` - diff --git a/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md b/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md index 55a067e517..878619c95a 100644 --- a/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md +++ b/pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Open-Notebook.md @@ -1,16 +1,36 @@ # Codex Home Overlay: PMOVES-Open-Notebook Scope: -- PMOVES-Open-Notebook submodule integration lane alignment for PMOVES hardened release operations. +- PMOVES-Open-Notebook is the drafting, evidence, memory, and operator review lane for creator + operations. +- Use this home when the task needs structured notes, campaign drafts, creator research, approval + artifacts, reusable prompts, or cross-session memory for a creator workflow. + +Traversal role: +- Stage drafts, notes, and supporting evidence before public-facing actions are executed. +- Use the notebook lane to preserve rationale, source evidence, and follow-up tasks so creator + operations are traceable instead of ephemeral. + +Read alongside: +- `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` +- `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES-Creator.md` +- `pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md` +- `pmoves/docs/AGENTS/SUBMODULE_CODEX_HOMES/PMOVES.YT.md` +- `pmoves/docs/PMOVESCHIT/CATACLYSM_STUDIOS_INC.md` Core checks: - `git submodule status -- PMOVES-Open-Notebook` - `make -C pmoves submodule-layer-validate-one SUBMODULE=PMOVES-Open-Notebook` - `make -C pmoves submodule-branch-policy-check` +Operator prompts: +- What notes or evidence should be captured before action is approved? +- What draft, comment template, playlist rationale, or creator brief should live in notebook form? +- What context should persist for later agent or human review? +- Which artifacts belong in notebook memory versus runtime audit rows in Supabase? + Related parity tokens: - `/worktree:status` - `/github:checks` - `/deploy:status` - diff --git a/pmoves/docs/NEXT_STEPS.md b/pmoves/docs/NEXT_STEPS.md index aa86086233..d090b22bc3 100644 --- a/pmoves/docs/NEXT_STEPS.md +++ b/pmoves/docs/NEXT_STEPS.md @@ -10,6 +10,7 @@ _Last updated: 2026-03-12_ - Kept the root `pmoves/services/pmoves-yt` package as a compatibility shim so existing tests and import paths remain stable during the production transition. - Modernized the downloader path around the authoritative runtime: PMOVES.YT now documents current yt-dlp client/token behavior, root compose passes companion URLs explicitly, and Jellyfin/channel-monitor docs are moving off older MCP/future-work framing. - Added `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` to frame YouTube, Discord agents, transcribe-and-fetch, model routing, and Tokenism as one creator-network lane. +- Updated the AGENTS creator fast path so `PMOVES-Creator`, `PMOVES-Open-Notebook`, and `CATACLYSM_STUDIOS_INC` are explicit traversal docs for creator strategy, notebook evidence, and brand/governance context. - Next focus: finish review cleanup, get PMOVES.YT/root checks green, and keep the creator/channel-monitor runbooks aligned with the authoritative runtime instead of the compatibility mirror. ### Latest changes (Mar 12, 2026) — n8n Production Control Plane Refresh diff --git a/pmoves/docs/PMOVES.AI PLANS/ROADMAP.md b/pmoves/docs/PMOVES.AI PLANS/ROADMAP.md index 6b2f426cbd..11129bca41 100644 --- a/pmoves/docs/PMOVES.AI PLANS/ROADMAP.md +++ b/pmoves/docs/PMOVES.AI PLANS/ROADMAP.md @@ -18,6 +18,7 @@ A production-ready, self-hostable orchestration mesh for creative + agent worklo - n8n owner/bootstrap automation is scripted (`n8n-api-bootstrap`) so Public API keys no longer depend on manual UI steps. - workflow activation now targets the n8n 2.1 Public API (`/api/v1/workflows/{id}/activate|deactivate`) instead of the brittle CLI publish fallback. - Supabase tracking contract added: `pmoves_core.n8n_workflow_registry` stores live workflow state synced from n8n. + - creator-control traversal now explicitly routes through `PMOVES-Creator`, `PMOVES-Open-Notebook`, and `CATACLYSM_STUDIOS_INC` so strategy, drafting, and platform-governance context are part of the operator path instead of living outside the service runbooks. - March 7 merge wave completed on `main`: `#814`, `#815`, `#816`, `#817`, `#818`, `#819`, `#820`, `#821` (8 PRs, 3 batches). - Chrome extension security hardening landed in `#821`: 9 CodeRabbit review items addressed (auth storage isolation, XSS remediation, mock server hardening, timeout guards, state management fixes, CSP). - Distributed topology documentation + examples landed in `#820`. From b38cdcd7d76a13e4346bfb0d35bcb118a771487b Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 13:53:37 -0400 Subject: [PATCH 08/12] feat(creator): add notebook-backed youtube control review --- PMOVES.YT | 2 +- .../PMOVES_YT_CONTROL_WORKTREE_REVIEW.md | 13 +- pmoves/services/channel-monitor/README.md | 33 +- .../channel-monitor/channel_monitor/main.py | 15 +- .../channel_monitor/monitor.py | 291 +++++++++++++++++- .../channel-monitor/tests/test_monitor.py | 62 +++- pmoves/services/messaging-gateway/main.py | 24 +- .../services/messaging-gateway/test_main.py | 15 +- 8 files changed, 422 insertions(+), 33 deletions(-) diff --git a/PMOVES.YT b/PMOVES.YT index eca1e7a333..643e39e4cb 160000 --- a/PMOVES.YT +++ b/PMOVES.YT @@ -1 +1 @@ -Subproject commit eca1e7a333f2d19d54dc2e7bc0709b57a48ec970 +Subproject commit 643e39e4cb0e1210d1afcafafd9d7897147e1436 diff --git a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md index 78982342f1..d2d311bb8e 100644 --- a/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md +++ b/pmoves/docs/AGENTS/PMOVES_YT_CONTROL_WORKTREE_REVIEW.md @@ -189,6 +189,14 @@ As of March 12, 2026, use these findings as the starting bias for this worktree the action surface grows. - `CATACLYSM_STUDIOS_INC` should now be treated as the governing context for creator-network actions so outreach, automation, and monetization stay aligned with the platform story. +- `channel-monitor` now publishes notebook-ready creator-control artifacts when Open Notebook + credentials plus `CHANNEL_MONITOR_YT_NOTEBOOK_ID` are configured, and it persists the resulting + notebook metadata alongside the pending audit row. +- `comment_create` review requests can now render a draft template into final comment text before + approval, and the same rendered summary is surfaced in Discord review messages. +- the PMOVES.YT control plane now covers `playlist_add`, `playlist_remove`, `playlist_reorder`, + and `comment_create`; `channel-monitor` strips draft/notebook metadata before execution so the + live YouTube API payload stays narrow. ## Recommended next implementation steps @@ -201,5 +209,6 @@ As of March 12, 2026, use these findings as the starting bias for this worktree 4. Move PMOVES-transcribe-and-fetch runtime call paths fully onto shared alias/role resolution, since the fallback catalog and registry compatibility seams are now PMOVES-native but the backend still mixes direct model ids and alias-based calls in older modules. -5. Expand the new PMOVES.YT owned-channel control plane from approval-gated playlist/comment - actions into richer YouTube Data API coverage plus first-class Discord interaction wiring. +5. Expand the PMOVES.YT owned-channel control plane further into broader channel-management + actions and richer comment/reply policy templates now that playlist mutation, notebook + artifacts, and Discord approval summaries are in place. diff --git a/pmoves/services/channel-monitor/README.md b/pmoves/services/channel-monitor/README.md index 250700dab9..e57ef1f129 100644 --- a/pmoves/services/channel-monitor/README.md +++ b/pmoves/services/channel-monitor/README.md @@ -159,14 +159,25 @@ curl -X POST http://localhost:8097/api/monitor/youtube-control \ -H 'content-type: application/json' \ -H 'x-channel-monitor-token: $CHANNEL_MONITOR_SECRET' \ -d '{ - "action": "playlist_add", - "details": { - "playlist_id": "PL123", - "video_id": "dQw4w9WgXcQ" - }, - "request_source": "discord_agent", - "notify_platforms": ["discord"] - }' + "action": "comment_create", + "details": { + "video_id": "dQw4w9WgXcQ", + "text_template": "Thanks {creator_name} for the {topic} breakdown. We used it in PMOVES." + }, + "request_source": "discord_agent", + "draft": { + "variables": { + "creator_name": "Example Creator", + "topic": "Qwen 3" + }, + "channel_name": "Example Creator", + "source_class": "watched" + }, + "notebook": { + "title_prefix": "Creator draft" + }, + "notify_platforms": ["discord"] + }' curl -X GET "http://localhost:8097/api/monitor/youtube-control/pending" \ -H 'x-channel-monitor-token: $CHANNEL_MONITOR_SECRET' @@ -182,6 +193,12 @@ Set `CHANNEL_MONITOR_MESSAGING_URL` to the messaging gateway `/v1/send` endpoint Discord-ready approval notifications when requests are queued. `messaging-gateway` now intercepts `ytcontrol:approve:` / `ytcontrol:reject:` button interactions and maps them back into `POST /api/monitor/youtube-control/review`. +Set `CHANNEL_MONITOR_YT_NOTEBOOK_ID` together with `OPEN_NOTEBOOK_API_URL` and +`OPEN_NOTEBOOK_API_TOKEN` to publish notebook-ready review artifacts for queued creator actions. +Queued requests now carry: +- rendered comment text when a draft template is supplied +- a `request_summary` used for Discord review prompts +- optional notebook artifact metadata persisted in `details.notebook` ### Observability diff --git a/pmoves/services/channel-monitor/channel_monitor/main.py b/pmoves/services/channel-monitor/channel_monitor/main.py index ce2c60f21f..4ce5da5432 100644 --- a/pmoves/services/channel-monitor/channel_monitor/main.py +++ b/pmoves/services/channel-monitor/channel_monitor/main.py @@ -328,13 +328,24 @@ class DiscordDropApprovalRequest(BaseModel): class YouTubeControlRequest(BaseModel): - action: str = Field(..., description="Control action type: playlist_add or comment_create") + action: str = Field( + ..., + description="Control action type: playlist_add, playlist_remove, playlist_reorder, or comment_create", + ) details: Dict[str, Any] = Field(..., description="PMOVES.YT control payload without execute fields") request_source: str = Field("channel_monitor", description="Logical request source for audit rows") notify_platforms: List[str] | None = Field( None, description="Optional messaging-gateway platforms to notify (e.g. ['discord'])", ) + draft: Dict[str, Any] | None = Field( + None, + description="Optional draft/template metadata used for notebook artifacts and comment rendering", + ) + notebook: Dict[str, Any] | None = Field( + None, + description="Optional Open Notebook publish overrides (notebook_id, title_prefix, embed, async_processing)", + ) class YouTubeControlReviewRequest(BaseModel): @@ -642,6 +653,8 @@ async def queue_youtube_control_action( details=payload.details, request_source=payload.request_source, notify_platforms=payload.notify_platforms, + draft=payload.draft, + notebook=payload.notebook, ) return {"status": "ok", "queued": True, "approval_state": "pending_review", "request": result} except ValueError as exc: diff --git a/pmoves/services/channel-monitor/channel_monitor/monitor.py b/pmoves/services/channel-monitor/channel_monitor/monitor.py index f7b796c741..8cc1a6fa79 100644 --- a/pmoves/services/channel-monitor/channel_monitor/monitor.py +++ b/pmoves/services/channel-monitor/channel_monitor/monitor.py @@ -25,6 +25,18 @@ VALID_STATUSES = {"pending", "processing", "queued", "completed", "failed"} TERMINAL_STATUSES = {"completed", "failed"} SOURCE_CLASSES = {"owned", "partner", "watched", "candidate"} +YOUTUBE_CONTROL_ACTION_LABELS = { + "playlist_add": "Playlist add", + "playlist_remove": "Playlist remove", + "playlist_reorder": "Playlist reorder", + "comment_create": "Comment create", +} +YOUTUBE_CONTROL_ENDPOINTS = { + "playlist_add": "/yt/control/playlist/add", + "playlist_remove": "/yt/control/playlist/remove", + "playlist_reorder": "/yt/control/playlist/reorder", + "comment_create": "/yt/control/comment", +} def utcnow() -> datetime: @@ -87,6 +99,118 @@ def _normalize_source_class(value: Any, *, default: str) -> str: return default +def _truncate_text(value: Any, *, limit: int = 180) -> Optional[str]: + if not isinstance(value, str): + return None + text = " ".join(value.strip().split()) + if not text: + return None + if len(text) <= limit: + return text + return text[: limit - 3] + "..." + + +class _TemplateVariables(dict[str, str]): + def __missing__(self, key: str) -> str: + return "{" + key + "}" + + +def _render_template_text(template: str, variables: Dict[str, Any]) -> str: + return template.format_map( + _TemplateVariables({key: "" if value is None else str(value) for key, value in variables.items()}) + ) + + +def _build_youtube_control_summary(action: str, details: Dict[str, Any], draft: Optional[Dict[str, Any]] = None) -> str: + label = YOUTUBE_CONTROL_ACTION_LABELS.get(action, action.replace("_", " ")) + draft = draft if isinstance(draft, dict) else {} + source_class = draft.get("source_class") or details.get("source_class") + channel_name = draft.get("channel_name") + video_ref = draft.get("video_title") or details.get("video_id") or details.get("playlist_item_id") or "unknown target" + if action == "playlist_add": + summary = f"{label}: add {video_ref} to playlist {details.get('playlist_id', 'unknown playlist')}" + elif action == "playlist_remove": + summary = f"{label}: remove item {details.get('playlist_item_id', video_ref)}" + elif action == "playlist_reorder": + summary = ( + f"{label}: move item {details.get('playlist_item_id', video_ref)} " + f"to position {details.get('position', '?')}" + ) + elif action == "comment_create": + comment_target = "reply" if details.get("parent_comment_id") else "comment" + summary = f"{label}: {comment_target} on {video_ref} — {_truncate_text(details.get('text'), limit=100) or 'no text'}" + else: + summary = f"{label}: {video_ref}" + context_parts = [part for part in [channel_name, source_class] if isinstance(part, str) and part] + if context_parts: + summary = f"{summary} ({', '.join(context_parts)})" + return summary + + +def _prepare_youtube_control_details( + action: str, + details: Dict[str, Any], + draft: Optional[Dict[str, Any]] = None, +) -> Dict[str, Any]: + normalized = dict(details) + draft_dict = dict(draft) if isinstance(draft, dict) else {} + if draft_dict.get("source_class") and not normalized.get("source_class"): + normalized["source_class"] = draft_dict["source_class"] + if action == "comment_create": + text_value = normalized.get("text") + if not isinstance(text_value, str) or not text_value.strip(): + template = normalized.get("text_template") or draft_dict.get("text_template") or draft_dict.get("template") + template_vars = normalized.get("template_vars") or draft_dict.get("template_vars") or draft_dict.get("variables") or {} + if isinstance(template, str) and template.strip(): + rendered = _render_template_text(template, template_vars if isinstance(template_vars, dict) else {}) + normalized["text"] = rendered.strip() + normalized["template_rendered"] = True + else: + raise ValueError("comment_create requires text or text_template") + normalized["text_preview"] = _truncate_text(normalized.get("text"), limit=160) + if draft_dict: + normalized["draft"] = draft_dict + normalized["request_summary"] = _build_youtube_control_summary(action, normalized, draft_dict) + return normalized + + +def _build_youtube_control_execution_payload(action: str, details: Dict[str, Any]) -> Dict[str, Any]: + if action == "playlist_add": + return _compact( + { + "playlist_id": details.get("playlist_id"), + "video_id": details.get("video_id"), + "position": details.get("position"), + } + ) or {} + if action == "playlist_remove": + return _compact( + { + "playlist_item_id": details.get("playlist_item_id"), + "playlist_id": details.get("playlist_id"), + "video_id": details.get("video_id"), + } + ) or {} + if action == "playlist_reorder": + return _compact( + { + "playlist_item_id": details.get("playlist_item_id"), + "playlist_id": details.get("playlist_id"), + "video_id": details.get("video_id"), + "position": details.get("position"), + } + ) or {} + if action == "comment_create": + return _compact( + { + "video_id": details.get("video_id"), + "text": details.get("text"), + "parent_comment_id": details.get("parent_comment_id"), + } + ) or {} + raise ValueError(f"Unsupported YouTube control action: {action}") + + def _extract_playlist_id_from_url(url: Optional[str]) -> Optional[str]: if not url: return None @@ -1667,16 +1791,28 @@ async def create_youtube_control_request( details: Dict[str, Any], request_source: str, notify_platforms: Optional[List[str]] = None, + draft: Optional[Dict[str, Any]] = None, + notebook: Optional[Dict[str, Any]] = None, ) -> Dict[str, Any]: assert self._pool action_id = str(uuid4()) + normalized_details = _prepare_youtube_control_details(action, details, draft) + notebook_meta = await self._publish_youtube_control_notebook_artifact( + action_id=action_id, + action=action, + details=normalized_details, + request_source=request_source, + notebook=notebook, + ) + if notebook_meta: + normalized_details["notebook"] = notebook_meta row = { "id": action_id, "action": action, "status": "pending_review", "execute_requested": True, "request_source": request_source, - "details": details, + "details": normalized_details, } async with self._pool.acquire() as conn: await conn.execute( @@ -1690,18 +1826,96 @@ async def create_youtube_control_request( "pending_review", True, request_source, - json.dumps(details), + json.dumps(normalized_details), ) notified = await self._notify_youtube_control_request( action_id=action_id, action=action, - details=details, + details=normalized_details, request_source=request_source, platforms=notify_platforms or [], ) row["notified"] = notified return row + async def _publish_youtube_control_notebook_artifact( + self, + *, + action_id: str, + action: str, + details: Dict[str, Any], + request_source: str, + notebook: Optional[Dict[str, Any]] = None, + ) -> Optional[Dict[str, Any]]: + notebook_overrides = dict(notebook) if isinstance(notebook, dict) else {} + base_url = (os.getenv("OPEN_NOTEBOOK_API_URL") or "").rstrip("/") + api_token = (os.getenv("OPEN_NOTEBOOK_API_TOKEN") or "").strip() + notebook_id = ( + notebook_overrides.get("notebook_id") + or os.getenv("CHANNEL_MONITOR_YT_NOTEBOOK_ID") + or os.getenv("OPEN_NOTEBOOK_NOTEBOOK_ID") + or os.getenv("DEEPRESEARCH_NOTEBOOK_ID") + or "" + ) + if not base_url or not api_token or not notebook_id: + return None + + title_prefix = ( + notebook_overrides.get("title_prefix") + or os.getenv("CHANNEL_MONITOR_YT_NOTEBOOK_TITLE_PREFIX") + or "YouTube control" + ) + title = f"{title_prefix} · {details.get('request_summary') or YOUTUBE_CONTROL_ACTION_LABELS.get(action, action)}" + sections = [ + "## Action", + f"- action_id: {action_id}", + f"- action: {action}", + f"- source: {request_source}", + "", + "## Summary", + str(details.get("request_summary") or _build_youtube_control_summary(action, details, details.get("draft"))), + "", + "## Details", + "```json", + json.dumps(_compact(details) or {}, indent=2, sort_keys=True), + "```", + ] + content = "\n".join(sections) + payload = { + "type": "text", + "title": title[:160], + "notebooks": [str(notebook_id)], + "content": content, + "embed": bool(notebook_overrides.get("embed", True)), + "async_processing": bool(notebook_overrides.get("async_processing", True)), + } + headers = { + "Authorization": f"Bearer {api_token}", + "Accept": "application/json", + } + try: + async with httpx.AsyncClient(base_url=base_url, headers=headers, timeout=30.0) as client: + response = await client.post("/api/sources/json", json=payload) + response.raise_for_status() + body = response.json() + entry_id = body.get("id") if isinstance(body, dict) else None + return _compact( + { + "entry_id": entry_id, + "title": title[:160], + "notebook_id": str(notebook_id), + } + ) + except Exception as exc: # pragma: no cover - best effort + LOGGER.warning("Failed to publish YouTube control notebook artifact for %s: %s", action_id, exc) + return _compact( + { + "error": str(exc), + "title": title[:160], + "notebook_id": str(notebook_id), + } + ) + async def _notify_youtube_control_request( self, *, @@ -1719,11 +1933,30 @@ async def _notify_youtube_control_request( LOGGER.info("Skipping YouTube control notification; CHANNEL_MONITOR_MESSAGING_URL is not set") return False + summary = details.get("request_summary") or _build_youtube_control_summary(action, details, details.get("draft")) + notebook_meta = details.get("notebook") if isinstance(details.get("notebook"), dict) else {} + fields = [ + {"name": "Action", "value": str(YOUTUBE_CONTROL_ACTION_LABELS.get(action, action)), "inline": True}, + {"name": "Source", "value": request_source, "inline": True}, + {"name": "Summary", "value": str(summary)[:1024], "inline": False}, + ] + if details.get("playlist_id"): + fields.append({"name": "Playlist", "value": str(details.get("playlist_id")), "inline": True}) + if details.get("video_id"): + fields.append({"name": "Video", "value": str(details.get("video_id")), "inline": True}) + if details.get("text_preview"): + fields.append({"name": "Comment Preview", "value": str(details.get("text_preview"))[:1024], "inline": False}) + if notebook_meta.get("entry_id"): + fields.append({"name": "Notebook Entry", "value": str(notebook_meta.get("entry_id")), "inline": False}) + elif notebook_meta.get("error"): + fields.append({"name": "Notebook Publish", "value": str(notebook_meta.get("error"))[:1024], "inline": False}) + content = ( f"YouTube control request pending review\n" - f"- action: {action}\n" + f"- action: {YOUTUBE_CONTROL_ACTION_LABELS.get(action, action)}\n" f"- source: {request_source}\n" - f"- action_id: {action_id}" + f"- action_id: {action_id}\n" + f"- summary: {summary}" ) buttons = [ {"id": f"ytcontrol:approve:{action_id}", "label": "Approve", "style": "primary"}, @@ -1732,12 +1965,20 @@ async def _notify_youtube_control_request( payload = { "platforms": active_platforms, "content": content, + "embeds": [ + { + "title": "YouTube control request pending review", + "description": str(summary)[:4096], + "fields": fields, + } + ], "buttons": buttons, "metadata": { "action_id": action_id, "action": action, "request_source": request_source, "details": details, + "summary": summary, }, } try: @@ -1808,15 +2049,11 @@ async def _invoke_yt_control_action( approved_by: str, approval_note: Optional[str], ) -> Dict[str, Any]: - endpoint_map = { - "playlist_add": "/yt/control/playlist/add", - "comment_create": "/yt/control/comment", - } - endpoint = endpoint_map.get(action) + endpoint = YOUTUBE_CONTROL_ENDPOINTS.get(action) if not endpoint: raise ValueError(f"Unsupported YouTube control action: {action}") - payload = dict(details) + payload = _build_youtube_control_execution_payload(action, details) payload["execute"] = True payload["approved_by"] = approved_by if approval_note: @@ -1867,13 +2104,20 @@ async def review_youtube_control_actions( ) processed_ids: List[str] = [] + action_summaries: List[Dict[str, Any]] = [] for row in rows: action_id = str(row.get("id")) action = row.get("action") details = row.get("details") if isinstance(row.get("details"), dict) else {} + summary = details.get("request_summary") or _build_youtube_control_summary(action, details, details.get("draft")) + notebook_meta = details.get("notebook") if isinstance(details.get("notebook"), dict) else {} new_status = "rejected" - result_payload: Dict[str, Any] | None = None - error_text = reason if not approve else None + result_payload: Dict[str, Any] | None = { + "status": "rejected", + "reason": reason or "rejected", + "summary": summary, + } + error_text = reason or "rejected" if approve: result_payload = await self._invoke_yt_control_action( action=action, @@ -1882,6 +2126,7 @@ async def review_youtube_control_actions( approval_note=reason, ) new_status = "approved" + error_text = None async with self._pool.acquire() as conn: await conn.execute( @@ -1902,6 +2147,24 @@ async def review_youtube_control_actions( error_text, ) processed_ids.append(action_id) + action_summaries.append( + _compact( + { + "id": action_id, + "action": action, + "status": new_status, + "summary": summary, + "notebook_entry_id": notebook_meta.get("entry_id"), + "reason": reason, + } + ) + or { + "id": action_id, + "action": action, + "status": new_status, + "summary": summary, + } + ) missing_ids = sorted(set(wanted_ids) - set(processed_ids)) return { @@ -1909,6 +2172,8 @@ async def review_youtube_control_actions( "processed_ids": processed_ids, "missing_ids": missing_ids, "approved": approve, + "actions": action_summaries, + "reason": reason, } async def get_stats(self) -> Dict[str, Any]: diff --git a/pmoves/services/channel-monitor/tests/test_monitor.py b/pmoves/services/channel-monitor/tests/test_monitor.py index 6e0c33b56a..069c88b8ae 100644 --- a/pmoves/services/channel-monitor/tests/test_monitor.py +++ b/pmoves/services/channel-monitor/tests/test_monitor.py @@ -517,6 +517,7 @@ def test_create_youtube_control_request_persists_pending_row(tmp_path): assert result["status"] == "pending_review" assert result["action"] == "playlist_add" assert result["notified"] is False + assert result["details"]["request_summary"].startswith("Playlist add:") conn.execute.assert_awaited_once() @@ -559,6 +560,64 @@ async def post(self, url, json=None): assert result["notified"] is True assert requests_made[0][0] == "http://messaging.test/v1/send" assert requests_made[0][1]["platforms"] == ["discord"] + assert requests_made[0][1]["embeds"][0]["title"] == "YouTube control request pending review" + + +def test_create_youtube_control_request_renders_template_and_publishes_notebook(tmp_path, monkeypatch): + monitor = _build_monitor(tmp_path) + conn = SimpleNamespace(execute=AsyncMock()) + monitor._pool = _FakePool(conn) # type: ignore[assignment] + requests_made = [] + + class DummyResponse: + def __init__(self, payload): + self._payload = payload + + def raise_for_status(self): + return None + + def json(self): + return self._payload + + class DummyAsyncClient: + def __init__(self, *args, **kwargs): + self.base_url = kwargs.get("base_url") + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + return False + + async def post(self, url, json=None): + requests_made.append((str(self.base_url or ""), url, json)) + return DummyResponse({"id": "notebook-entry-1"}) + + monkeypatch.setenv("OPEN_NOTEBOOK_API_URL", "http://notebook.test") + monkeypatch.setenv("OPEN_NOTEBOOK_API_TOKEN", "nb-token") + monkeypatch.setenv("CHANNEL_MONITOR_YT_NOTEBOOK_ID", "nb-123") + monkeypatch.setattr("channel_monitor.monitor.httpx.AsyncClient", DummyAsyncClient) + + result = asyncio.run( + monitor.create_youtube_control_request( + action="comment_create", + details={"video_id": "vid-123", "text_template": "Thanks {creator_name} for the {topic} breakdown."}, + request_source="discord_agent", + draft={ + "variables": {"creator_name": "Alice", "topic": "Qwen"}, + "channel_name": "Alice AI", + "source_class": "watched", + }, + notebook={"title_prefix": "Creator draft"}, + ) + ) + + assert result["details"]["text"] == "Thanks Alice for the Qwen breakdown." + assert result["details"]["template_rendered"] is True + assert result["details"]["notebook"]["entry_id"] == "notebook-entry-1" + assert requests_made[0][0] == "http://notebook.test" + assert requests_made[0][1] == "/api/sources/json" + assert requests_made[0][2]["title"].startswith("Creator draft") def test_review_youtube_control_actions_executes_pmoves_yt_call(tmp_path, monkeypatch): @@ -567,7 +626,7 @@ def test_review_youtube_control_actions_executes_pmoves_yt_call(tmp_path, monkey { "id": "11111111-1111-1111-1111-111111111111", "action": "comment_create", - "details": {"video_id": "vid-123", "text": "hello"}, + "details": {"video_id": "vid-123", "text": "hello", "request_summary": "Comment create: hello"}, } ] conn = SimpleNamespace(fetch=AsyncMock(return_value=rows), execute=AsyncMock()) @@ -610,6 +669,7 @@ async def post(self, url, json=None, headers=None): assert result["approved"] is True assert result["processed"] == 1 + assert result["actions"][0]["summary"] == "Comment create: hello" assert requests_made[0][0] == "http://example.test/yt/control/comment" assert requests_made[0][1]["execute"] is True assert requests_made[0][1]["approved_by"] == "discord-agent" diff --git a/pmoves/services/messaging-gateway/main.py b/pmoves/services/messaging-gateway/main.py index 33fc737a3b..c00e7030f2 100644 --- a/pmoves/services/messaging-gateway/main.py +++ b/pmoves/services/messaging-gateway/main.py @@ -133,6 +133,24 @@ def _interaction_actor(payload: Dict[str, Any]) -> str: return "discord-user" +def _format_ytcontrol_response(body: Dict[str, Any], action_id: str, approve: bool) -> str: + actions = body.get("actions") if isinstance(body.get("actions"), list) else [] + first_action = actions[0] if actions and isinstance(actions[0], dict) else {} + summary = first_action.get("summary") + notebook_entry_id = first_action.get("notebook_entry_id") + reason = body.get("reason") + state = "Approved" if approve else "Rejected" + parts = [f"{state} YouTube control request `{action_id}`."] + if summary: + parts.append(str(summary)) + if reason: + parts.append(f"Note: {reason}") + if notebook_entry_id: + parts.append(f"Notebook: `{notebook_entry_id}`") + parts.append(f"Processed: {body.get('processed', 0)}.") + return " ".join(parts) + + async def _handle_ytcontrol_interaction(payload: Dict[str, Any]) -> Optional[Dict[str, Any]]: data = payload.get("data") if isinstance(payload.get("data"), dict) else {} custom_id = data.get("custom_id") @@ -179,11 +197,7 @@ async def _handle_ytcontrol_interaction(payload: Dict[str, Any]) -> Optional[Dic "data": {"content": f"Review action failed for {action_id}: {exc}", "flags": 64}, } - processed = body.get("processed", 0) - if approve: - content = f"Approved YouTube control request `{action_id}`. Processed: {processed}." - else: - content = f"Rejected YouTube control request `{action_id}`. Processed: {processed}." + content = _format_ytcontrol_response(body, action_id, approve) return { "type": 4, "data": {"content": content, "flags": 64}, diff --git a/pmoves/services/messaging-gateway/test_main.py b/pmoves/services/messaging-gateway/test_main.py index ee7693eeac..cbc8dac4b8 100644 --- a/pmoves/services/messaging-gateway/test_main.py +++ b/pmoves/services/messaging-gateway/test_main.py @@ -67,7 +67,11 @@ def raise_for_status(self): return None def json(self): - return {"processed": 1} + return { + "processed": 1, + "reason": "approved from Discord", + "actions": [{"summary": "Playlist add: add vid-123 to playlist PL123", "notebook_entry_id": "nb-1"}], + } class DummyAsyncClient: def __init__(self, *args, **kwargs): @@ -97,6 +101,8 @@ async def post(self, url, headers=None, json=None): assert response["type"] == 4 assert "Approved YouTube control request" in response["data"]["content"] + assert "Playlist add" in response["data"]["content"] + assert "Notebook: `nb-1`" in response["data"]["content"] assert requests_made[0][0] == "http://channel-monitor:8097/api/monitor/youtube-control/review" assert requests_made[0][1]["X-Channel-Monitor-Token"] == "secret-token" assert requests_made[0][2]["approve"] is True @@ -111,7 +117,11 @@ def raise_for_status(self): return None def json(self): - return {"processed": 1} + return { + "processed": 1, + "reason": "rejected from Discord", + "actions": [{"summary": "Comment create: reply on vid-123"}], + } class DummyAsyncClient: def __init__(self, *args, **kwargs): @@ -138,3 +148,4 @@ async def post(self, url, headers=None, json=None): assert response["type"] == 4 assert "Rejected YouTube control request" in response["data"]["content"] + assert "Comment create" in response["data"]["content"] From 24cb93d4ed5123ced2a394a93442b510b3138efd Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 14:24:34 -0400 Subject: [PATCH 09/12] fix(creator): harden youtube control review flow --- PMOVES.YT | 2 +- .../channel-monitor/channel_monitor/main.py | 7 ++ .../channel_monitor/monitor.py | 99 +++++++++++++++---- .../channel-monitor/tests/test_monitor.py | 78 ++++++++++++++- pmoves/services/messaging-gateway/main.py | 8 +- 5 files changed, 171 insertions(+), 23 deletions(-) diff --git a/PMOVES.YT b/PMOVES.YT index 643e39e4cb..6bb3b3d979 160000 --- a/PMOVES.YT +++ b/PMOVES.YT @@ -1 +1 @@ -Subproject commit 643e39e4cb0e1210d1afcafafd9d7897147e1436 +Subproject commit 6bb3b3d979e9c4a0e42380f86da747da6792f791 diff --git a/pmoves/services/channel-monitor/channel_monitor/main.py b/pmoves/services/channel-monitor/channel_monitor/main.py index 4ce5da5432..d53d2786fd 100644 --- a/pmoves/services/channel-monitor/channel_monitor/main.py +++ b/pmoves/services/channel-monitor/channel_monitor/main.py @@ -347,6 +347,13 @@ class YouTubeControlRequest(BaseModel): description="Optional Open Notebook publish overrides (notebook_id, title_prefix, embed, async_processing)", ) + @validator("action") + def _validate_action(cls, value: str) -> str: + valid_actions = {"playlist_add", "playlist_remove", "playlist_reorder", "comment_create"} + if value not in valid_actions: + raise ValueError(f"action must be one of {sorted(valid_actions)}") + return value + class YouTubeControlReviewRequest(BaseModel): action_ids: List[str] = Field(..., description="Pending action IDs to approve or reject") diff --git a/pmoves/services/channel-monitor/channel_monitor/monitor.py b/pmoves/services/channel-monitor/channel_monitor/monitor.py index 8cc1a6fa79..b7cf3fe275 100644 --- a/pmoves/services/channel-monitor/channel_monitor/monitor.py +++ b/pmoves/services/channel-monitor/channel_monitor/monitor.py @@ -37,6 +37,11 @@ "playlist_reorder": "/yt/control/playlist/reorder", "comment_create": "/yt/control/comment", } +YOUTUBE_CONTROL_REQUIRED_FIELDS = { + "playlist_add": ("playlist_id", "video_id"), + "playlist_remove": ("playlist_item_id",), + "playlist_reorder": ("playlist_item_id", "position"), +} def utcnow() -> datetime: @@ -152,10 +157,19 @@ def _prepare_youtube_control_details( details: Dict[str, Any], draft: Optional[Dict[str, Any]] = None, ) -> Dict[str, Any]: + if action not in YOUTUBE_CONTROL_ACTION_LABELS: + raise ValueError( + f"Unsupported YouTube control action: {action!r}. " + f"Valid actions: {sorted(YOUTUBE_CONTROL_ACTION_LABELS)}" + ) normalized = dict(details) draft_dict = dict(draft) if isinstance(draft, dict) else {} if draft_dict.get("source_class") and not normalized.get("source_class"): normalized["source_class"] = draft_dict["source_class"] + required_fields = YOUTUBE_CONTROL_REQUIRED_FIELDS.get(action, ()) + missing_fields = [field for field in required_fields if normalized.get(field) in (None, "")] + if missing_fields: + raise ValueError(f"{action} requires {', '.join(missing_fields)}") if action == "comment_create": text_value = normalized.get("text") if not isinstance(text_value, str) or not text_value.strip(): @@ -342,6 +356,9 @@ def __init__( self._youtube_client = None # Explicitly disable if init fails def _yt_control_base_url(self) -> str: + explicit = (os.getenv("CHANNEL_MONITOR_YT_CONTROL_URL") or "").strip().rstrip("/") + if explicit: + return explicit base = self.queue_url.rstrip("/") if base.endswith("/yt/ingest"): return base[: -len("/yt/ingest")] @@ -1977,8 +1994,19 @@ async def _notify_youtube_control_request( "action_id": action_id, "action": action, "request_source": request_source, - "details": details, "summary": summary, + "details": _compact( + { + "playlist_id": details.get("playlist_id"), + "playlist_item_id": details.get("playlist_item_id"), + "video_id": details.get("video_id"), + "position": details.get("position"), + "text_preview": details.get("text_preview"), + "source_class": details.get("source_class"), + "notebook_entry_id": notebook_meta.get("entry_id"), + } + ) + or {}, }, } try: @@ -2075,7 +2103,13 @@ async def _invoke_yt_control_action( json=payload, headers=headers, ) - response.raise_for_status() + try: + response.raise_for_status() + except httpx.HTTPStatusError as exc: + raise RuntimeError( + f"PMOVES.YT returned {exc.response.status_code}: " + f"{exc.response.text[:500]}" + ) from exc return response.json() async def review_youtube_control_actions( @@ -2092,16 +2126,25 @@ async def review_youtube_control_actions( raise ValueError("action_ids is required") async with self._pool.acquire() as conn: - rows = await conn.fetch( - """ - SELECT id, action, details - FROM pmoves_core.youtube_control_actions - WHERE status = 'pending_review' - AND id = ANY($1::uuid[]) - ORDER BY created_at ASC - """, - wanted_ids, - ) + async with conn.transaction(): + rows = await conn.fetch( + """ + WITH claimed AS ( + SELECT id + FROM pmoves_core.youtube_control_actions + WHERE status = 'pending_review' + AND id = ANY($1::uuid[]) + ORDER BY created_at ASC + FOR UPDATE SKIP LOCKED + ) + UPDATE pmoves_core.youtube_control_actions AS actions + SET status = 'processing' + FROM claimed + WHERE actions.id = claimed.id + RETURNING actions.id, actions.action, actions.details + """, + wanted_ids, + ) processed_ids: List[str] = [] action_summaries: List[Dict[str, Any]] = [] @@ -2119,14 +2162,29 @@ async def review_youtube_control_actions( } error_text = reason or "rejected" if approve: - result_payload = await self._invoke_yt_control_action( - action=action, - details=details, - approved_by=actor or "channel-monitor", - approval_note=reason, - ) - new_status = "approved" - error_text = None + try: + result_payload = await self._invoke_yt_control_action( + action=action, + details=details, + approved_by=actor or "channel-monitor", + approval_note=reason, + ) + new_status = "approved" + error_text = None + except Exception as exc: + new_status = "failed" + error_text = str(exc) + result_payload = { + "status": "failed", + "error": str(exc), + "summary": summary, + } + LOGGER.error( + "YouTube control execution failed for %s (%s): %s", + action_id, + action, + exc, + ) async with self._pool.acquire() as conn: await conn.execute( @@ -2156,6 +2214,7 @@ async def review_youtube_control_actions( "summary": summary, "notebook_entry_id": notebook_meta.get("entry_id"), "reason": reason, + "error": error_text, } ) or { diff --git a/pmoves/services/channel-monitor/tests/test_monitor.py b/pmoves/services/channel-monitor/tests/test_monitor.py index 069c88b8ae..2bf51de1b8 100644 --- a/pmoves/services/channel-monitor/tests/test_monitor.py +++ b/pmoves/services/channel-monitor/tests/test_monitor.py @@ -114,6 +114,14 @@ def acquire(self): return _FakeAcquire(self._conn) +class _FakeTransaction: + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + return False + + def test_apply_filters_respects_age_and_keywords(tmp_path): monitor = _build_monitor(tmp_path) now = datetime.now(timezone.utc) @@ -521,6 +529,40 @@ def test_create_youtube_control_request_persists_pending_row(tmp_path): conn.execute.assert_awaited_once() +def test_create_youtube_control_request_rejects_invalid_action(tmp_path): + monitor = _build_monitor(tmp_path) + conn = SimpleNamespace(execute=AsyncMock()) + monitor._pool = _FakePool(conn) # type: ignore[assignment] + + with pytest.raises(ValueError, match="Unsupported YouTube control action"): + asyncio.run( + monitor.create_youtube_control_request( + action="playlist_replace", + details={"playlist_id": "PL123", "video_id": "vid-123"}, + request_source="discord_agent", + ) + ) + + conn.execute.assert_not_awaited() + + +def test_create_youtube_control_request_requires_action_fields(tmp_path): + monitor = _build_monitor(tmp_path) + conn = SimpleNamespace(execute=AsyncMock()) + monitor._pool = _FakePool(conn) # type: ignore[assignment] + + with pytest.raises(ValueError, match="playlist_add requires playlist_id, video_id"): + asyncio.run( + monitor.create_youtube_control_request( + action="playlist_add", + details={}, + request_source="discord_agent", + ) + ) + + conn.execute.assert_not_awaited() + + def test_create_youtube_control_request_can_notify_messaging_gateway(tmp_path, monkeypatch): monitor = _build_monitor(tmp_path) conn = SimpleNamespace(execute=AsyncMock()) @@ -561,6 +603,10 @@ async def post(self, url, json=None): assert requests_made[0][0] == "http://messaging.test/v1/send" assert requests_made[0][1]["platforms"] == ["discord"] assert requests_made[0][1]["embeds"][0]["title"] == "YouTube control request pending review" + assert requests_made[0][1]["metadata"]["details"] == { + "playlist_id": "PL123", + "video_id": "vid-123", + } def test_create_youtube_control_request_renders_template_and_publishes_notebook(tmp_path, monkeypatch): @@ -629,7 +675,7 @@ def test_review_youtube_control_actions_executes_pmoves_yt_call(tmp_path, monkey "details": {"video_id": "vid-123", "text": "hello", "request_summary": "Comment create: hello"}, } ] - conn = SimpleNamespace(fetch=AsyncMock(return_value=rows), execute=AsyncMock()) + conn = SimpleNamespace(fetch=AsyncMock(return_value=rows), execute=AsyncMock(), transaction=lambda: _FakeTransaction()) monitor._pool = _FakePool(conn) # type: ignore[assignment] requests_made = [] @@ -675,3 +721,33 @@ async def post(self, url, json=None, headers=None): assert requests_made[0][1]["approved_by"] == "discord-agent" assert requests_made[0][2]["X-API-Key"] == "secret-key" assert conn.execute.await_count == 1 + + +def test_review_youtube_control_actions_marks_failed_when_execution_errors(tmp_path): + monitor = _build_monitor(tmp_path) + rows = [ + { + "id": "11111111-1111-1111-1111-111111111111", + "action": "comment_create", + "details": {"video_id": "vid-123", "text": "hello", "request_summary": "Comment create: hello"}, + } + ] + conn = SimpleNamespace(fetch=AsyncMock(return_value=rows), execute=AsyncMock(), transaction=lambda: _FakeTransaction()) + monitor._pool = _FakePool(conn) # type: ignore[assignment] + monitor._invoke_yt_control_action = AsyncMock(side_effect=RuntimeError("upstream boom")) # type: ignore[method-assign] + + result = asyncio.run( + monitor.review_youtube_control_actions( + action_ids=["11111111-1111-1111-1111-111111111111"], + approve=True, + actor="discord-agent", + reason="approved in ops", + ) + ) + + assert result["processed"] == 1 + assert result["actions"][0]["status"] == "failed" + assert result["actions"][0]["error"] == "upstream boom" + update_args = conn.execute.await_args.args + assert update_args[2] == "failed" + assert update_args[6] == "upstream boom" diff --git a/pmoves/services/messaging-gateway/main.py b/pmoves/services/messaging-gateway/main.py index c00e7030f2..138c3f9205 100644 --- a/pmoves/services/messaging-gateway/main.py +++ b/pmoves/services/messaging-gateway/main.py @@ -188,7 +188,13 @@ async def _handle_ytcontrol_interaction(payload: Dict[str, Any]) -> Optional[Dic headers=headers, json=review_payload, ) - response.raise_for_status() + try: + response.raise_for_status() + except httpx.HTTPStatusError as exc: + raise RuntimeError( + f"channel-monitor returned {exc.response.status_code}: " + f"{exc.response.text[:500]}" + ) from exc body = response.json() except Exception as exc: logger.warning("YouTube control Discord interaction failed for %s: %s", action_id, exc) From e4eb794ff949dca06825b28f9e8b35da23230bb8 Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 14:52:13 -0400 Subject: [PATCH 10/12] fix(ci): fetch submodules and harden yt control audit policy --- .github/workflows/python-tests.yml | 2 ++ pmoves/services/pmoves-yt/yt.py | 2 ++ ...20260312095500_youtube_control_actions.sql | 33 +++++++++++++------ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 3a1255e44a..2276291e57 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -52,6 +52,8 @@ jobs: files.pythonhosted.org:443 - uses: actions/checkout@v4 + with: + submodules: recursive - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main continue-on-error: true # Self-hosted runner: bash arithmetic fails on large disks (scientific notation) diff --git a/pmoves/services/pmoves-yt/yt.py b/pmoves/services/pmoves-yt/yt.py index dac1a034b2..c90cdf19d7 100644 --- a/pmoves/services/pmoves-yt/yt.py +++ b/pmoves/services/pmoves-yt/yt.py @@ -11,6 +11,8 @@ sys.path.insert(0, str(_SUBMODULE_ROOT)) _IMPL = _SUBMODULE_ROOT / "pmoves_yt_service" / "yt.py" +__package__ = "pmoves_yt_service" +__path__ = [str(_SUBMODULE_ROOT / "pmoves_yt_service")] code = _IMPL.read_text(encoding="utf-8") exec(compile(code, str(_IMPL), "exec")) diff --git a/pmoves/supabase/migrations/20260312095500_youtube_control_actions.sql b/pmoves/supabase/migrations/20260312095500_youtube_control_actions.sql index 86a42a5cc3..0cff917351 100644 --- a/pmoves/supabase/migrations/20260312095500_youtube_control_actions.sql +++ b/pmoves/supabase/migrations/20260312095500_youtube_control_actions.sql @@ -1,8 +1,24 @@ create schema if not exists pmoves_core; +create or replace function pmoves_core.current_user_matches_request_source(source text) +returns boolean +language sql +stable +as $$ + select + auth.role() = 'service_role' + or ( + auth.uid() is not null + and source is not null + and source = concat('user:', auth.uid()::text) + ); +$$; + create table if not exists pmoves_core.youtube_control_actions ( id uuid primary key, - action text not null, + action text not null check ( + action in ('playlist_add', 'playlist_remove', 'playlist_reorder', 'comment_create') + ), status text not null, execute_requested boolean not null default false, request_source text not null default 'pmoves-yt', @@ -23,6 +39,9 @@ create index if not exists idx_youtube_control_actions_created_at create index if not exists idx_youtube_control_actions_action_status on pmoves_core.youtube_control_actions (action, status); +create index if not exists idx_youtube_control_actions_status_created_at + on pmoves_core.youtube_control_actions (status, created_at desc, action); + create index if not exists idx_youtube_control_actions_video_id on pmoves_core.youtube_control_actions (video_id) where video_id is not null; @@ -34,9 +53,10 @@ create index if not exists idx_youtube_control_actions_playlist_id alter table pmoves_core.youtube_control_actions enable row level security; drop policy if exists "Public read youtube control actions" on pmoves_core.youtube_control_actions; -create policy "Public read youtube control actions" +create policy "Authenticated read youtube control actions" on pmoves_core.youtube_control_actions for select - using (true); + to authenticated + using (pmoves_core.current_user_matches_request_source(request_source)); drop policy if exists "Service write youtube control actions" on pmoves_core.youtube_control_actions; create policy "Service write youtube control actions" @@ -46,13 +66,6 @@ create policy "Service write youtube control actions" do $$ begin - begin - execute 'grant usage on schema pmoves_core to anon'; - execute 'grant select on pmoves_core.youtube_control_actions to anon'; - exception when undefined_object then - null; - end; - begin execute 'grant usage on schema pmoves_core to authenticated'; execute 'grant select on pmoves_core.youtube_control_actions to authenticated'; From 765e9012d59b684dcbb48f566ba19dafbddbcd1f Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 15:09:55 -0400 Subject: [PATCH 11/12] fix(ci): fetch only pmoves-yt submodule in python tests --- .github/workflows/python-tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 2276291e57..1f10781a39 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -52,8 +52,11 @@ jobs: files.pythonhosted.org:443 - uses: actions/checkout@v4 - with: - submodules: recursive + - name: Fetch PMOVES.YT submodule for shim tests + shell: bash + run: | + git submodule sync -- PMOVES.YT + git -c protocol.version=2 submodule update --init --depth=1 PMOVES.YT - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main continue-on-error: true # Self-hosted runner: bash arithmetic fails on large disks (scientific notation) From 9e7c245a8612690f2e8bd0055a83118af1aabb41 Mon Sep 17 00:00:00 2001 From: Shaela Bello Date: Thu, 12 Mar 2026 15:29:22 -0400 Subject: [PATCH 12/12] docs(plan): refresh creator-control merge lane --- pmoves/docs/NEXT_STEPS.md | 22 +++++++++++++++++++++- pmoves/docs/PMOVES.AI PLANS/ROADMAP.md | 10 ++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/pmoves/docs/NEXT_STEPS.md b/pmoves/docs/NEXT_STEPS.md index d090b22bc3..88323ad3a4 100644 --- a/pmoves/docs/NEXT_STEPS.md +++ b/pmoves/docs/NEXT_STEPS.md @@ -11,7 +11,10 @@ _Last updated: 2026-03-12_ - Modernized the downloader path around the authoritative runtime: PMOVES.YT now documents current yt-dlp client/token behavior, root compose passes companion URLs explicitly, and Jellyfin/channel-monitor docs are moving off older MCP/future-work framing. - Added `pmoves/docs/PMOVES.AI PLANS/CREATOR_NETWORK_CONTROL_PLANE.md` to frame YouTube, Discord agents, transcribe-and-fetch, model routing, and Tokenism as one creator-network lane. - Updated the AGENTS creator fast path so `PMOVES-Creator`, `PMOVES-Open-Notebook`, and `CATACLYSM_STUDIOS_INC` are explicit traversal docs for creator strategy, notebook evidence, and brand/governance context. -- Next focus: finish review cleanup, get PMOVES.YT/root checks green, and keep the creator/channel-monitor runbooks aligned with the authoritative runtime instead of the compatibility mirror. +- Added the first creator-control production lane now under review: + - `PMOVES.YT #4` adds approval-gated YouTube Data API actions, summary model-role routing, and modernized overlay lint/CI coverage. + - `PMOVES.AI #884` adds channel-monitor review queue endpoints, Discord approval routing, Supabase audit storage, and notebook-backed creator review artifacts. +- Next focus: merge `PMOVES.YT #4` then `PMOVES.AI #884`, then expand the creator-control surface instead of doing more compatibility-mirror work. ### Latest changes (Mar 12, 2026) — n8n Production Control Plane Refresh - `PMOVES-n8n` is now the authoritative n8n runtime/workflow lane; root `pmoves` consumes it instead of treating `pmoves/n8n/flows` as canon. @@ -21,6 +24,23 @@ _Last updated: 2026-03-12_ - Added Supabase tracking schema `pmoves_core.n8n_workflow_registry` plus `make -C pmoves n8n-sync-supabase-registry` so PMOVES can inventory live workflow state. - Next focus: validate the full bootstrap against Postgres-backed n8n, refresh PMOVES.YT from demo to production against the same automation lane, and decide which BotZ/MCP workflows join the shared canonical catalog. +## Immediate Actions + +1. Close the current hardened merge lane. + - merge `PMOVES.YT #4` + - merge `PMOVES.AI #884` + - verify hardened stays green after the submodule-first merge order + +2. Expand the M2 creator-control surface. + - add broader playlist and channel-management actions beyond the first owned-channel slice + - improve Discord rejection metadata and operator feedback + - move comment/reply generation onto policy-driven templates tied to `PMOVES-Creator`, `PMOVES-Open-Notebook`, and CATACLYSM context + +3. Keep the n8n control plane aligned with the creator lane. + - validate Postgres-backed `PMOVES-n8n` bootstrap end-to-end + - decide which BotZ/MCP workflows become canonical shared automation flows + - keep Supabase workflow registry sync green as creator automation expands + ### Latest changes (Mar 8, 2026) — CI Runner Migration + RG-3 Automation - **AB-9 mitigation:** Migrated 10 lightweight CI jobs from `[self-hosted, Linux, X64]` to `ubuntu-latest`: - `sql-policy-lint`, `python-tests`, `webhook-smoke`, `yt-dlp-bump`, `deploy-gateway-agent` (validate only) diff --git a/pmoves/docs/PMOVES.AI PLANS/ROADMAP.md b/pmoves/docs/PMOVES.AI PLANS/ROADMAP.md index 11129bca41..5c1f4075ce 100644 --- a/pmoves/docs/PMOVES.AI PLANS/ROADMAP.md +++ b/pmoves/docs/PMOVES.AI PLANS/ROADMAP.md @@ -4,7 +4,7 @@ Last updated: 2026-03-12 ## Vision A production-ready, self-hostable orchestration mesh for creative + agent workloads across GPU boxes and Jetsons: **hybrid Hi‑RAG**, **Supabase Studio**, **n8n orchestration**, **Jellyfin publishing**, and **graph-aware retrieval**. -## Audit Snapshot (2026-03-07) +## Audit Snapshot (2026-03-12) - March 12 PMOVES.YT production-path remediation landed locally: - `PMOVES.YT` is now the authoritative runtime/docs lane for the YouTube ingest service; root `pmoves` consumes the submodule Dockerfile directly instead of treating `pmoves/services/pmoves-yt` as canon. @@ -12,6 +12,10 @@ A production-ready, self-hostable orchestration mesh for creative + agent worklo - the Supabase docs sync contract was refreshed for the current CLI stack: `pmoves_core.tool_docs` writes now use schema-profile headers plus URL-encoded `on_conflict`. - root `pmoves/services/pmoves-yt` remains as a compatibility shim so existing tests/import paths keep working while production moves to the submodule. - downloader defaults are being normalized around the authoritative runtime: PMOVES.YT now documents the modern client/token path, root compose passes explicit companion wiring, and Jellyfin/channel-monitor docs are being moved off older MCP and future-work framing. +- March 12 creator-control merge lane is active on hardened: + - `PMOVES.YT #4` stages the authoritative owned-channel control path with approval-gated YouTube Data API actions, summary model-role routing, and overlay lint/CI modernization. + - `PMOVES.AI #884` stages the root integration path with channel-monitor queue/review endpoints, Discord approval routing, Supabase audit persistence, and notebook-backed creator review artifacts. + - merge order remains submodule-first (`PMOVES.YT #4` -> `PMOVES.AI #884`) so hardened never points at an unmerged submodule head. - March 12 n8n production-path remediation landed locally: - `PMOVES-n8n` is now the authoritative runtime/workflow lane consumed by the root repo. - `make -C pmoves up-n8n` now defaults to the dedicated `n8n-db` Postgres sidecar instead of SQLite. @@ -38,7 +42,7 @@ A production-ready, self-hostable orchestration mesh for creative + agent worklo - Branch strategy: `PMOVES.AI-Edition-Hardened` is the production release branch; `main` receives promoted merges from hardened. - Production Python GHCR image toolchains now use reproducible exact pins with automated weekly canary validation (`.github/workflows/python-images-toolchain-canary.yml`): detect latest PyPI candidate -> patch managed Dockerfiles (`supaserch`, `deepresearch`, `pmoves-yt`, `archon`) -> build -> Trivy HIGH/CRITICAL gate -> auto-PR on pass. - PR queue and workflow health are tracked in `pmoves/docs/PRODUCTION_AUDIT_DASHBOARD.md`; use that doc as the live source before merge decisions. -- Open PR queue (live): `0` open. +- Open PR queue (live): `1` open in `PMOVES.AI` (`#884` on `PMOVES.AI-Edition-Hardened`). - Dependency/code scanning backlog (live): Dependabot open `1` (`1 medium`); Code Scanning open `0`. - Active remediation focus: production-mode bring-up parity (no dev-target defaults), dynamic port/namespace hygiene, hardened runtime auth consistency across compose/submodules, and recurring self-hosted queue starvation for CodeQL/GHCR lanes. - Queue-governance hardening landed for self-hosted CI pressure: stale push/PR runs now auto-cancel per ref, heavy matrix jobs are throttled (`max-parallel`), and GHCR autobuild triggers are scoped to image-affecting paths. @@ -149,6 +153,7 @@ A production-ready, self-hostable orchestration mesh for creative + agent worklo | ✅ | PDF/MinIO ingestion | `services/pdf-ingest/app.py` pulls PDFs from MinIO, extracts text, forwards chunks, and emits ingest events. | | ✅ | DeepResearch agent service | `services/deepresearch/worker.py` routes `research.deepresearch.*` events, calls Tongyi DeepResearch (OpenRouter/local), and mirrors summaries into Open Notebook. | | ✅ | PMOVES.YT geometry smoke hardening | `services/pmoves-yt/yt.py` now signs Supabase requests with the service-role key and falls back to direct pack lookups so `make smoke` stays green. | +| 🚧 | Creator control plane (YouTube + Discord approvals) | `PMOVES.YT #4` and `PMOVES.AI #884` stage the owned-channel action path: approval-gated YouTube Data API calls, Supabase audit rows, channel-monitor review queue, messaging-gateway Discord buttons, and notebook-backed creator review artifacts. | | ✅ | Cloudflare remote access profile | `cloudflared` Compose profile + `make up-cloudflare`/`make cloudflare-url` provide one-command WAN exposure for laptops and VPS hosts. | | ✅ | n8n flows (Discord/webhooks + Voice Agents) | `pmoves/n8n/flows/*.json` are sanitized, importable exports (no project/user metadata). Use `make -C pmoves n8n-import-flows` then `make -C pmoves n8n-activate-flows`. Includes Voice Agent router + Discord/Telegram flows plus publisher/approval flows. | | ✅ | Health/Finance integrations (Wger + Firefly) | Supabase schemas created; event topics added (`health.metrics.updated.v1`, `finance.transactions.ingested.v1`); n8n flow stubs added; import via Public API/UI. | @@ -168,6 +173,7 @@ A production-ready, self-hostable orchestration mesh for creative + agent worklo - CHIT EvoSwarm loop: enable controller, confirm `geometry.swarm.meta.v1` events; ensure pack selection by producers and pack_id persisted in constellation meta (gateway v2) - Codex parity for focus submodules is now complete (8/8); continue expanding Codex onboarding across non-focus modules - PMOVES.YT SABR handling: prefer Invidious when needed; add Whisper transcript fallback in pipeline; update smokes accordingly. +- once `PMOVES.YT #4` and `PMOVES.AI #884` merge, expand the creator-control surface with broader playlist/channel-management actions, richer Discord rejection UX, and policy-driven comment/reply templates tied to `PMOVES-Creator`, `PMOVES-Open-Notebook`, and CATACLYSM context. - [ ] CI TODO — surface `make lint-packs` as the pack manifest linter prior to publish, blocking `kb.pack.published.v1` unless manifests validate. - [ ] CI TODO — retrieval-eval persona gate must succeed (`persona.publish.request.v1` → `persona.published.v1`) with thresholds persisted to `pmoves_core.persona_eval_gates`. - [x] v2 realtime DNS fallback (host‑gateway derivation) — 2025‑10‑19