Skip to content

feat: policy-grounded comment triage (#57) - #65

Open
jdwit wants to merge 6 commits into
mainfrom
feat/comment-triage
Open

jdwit wants to merge 6 commits into
mainfrom
feat/comment-triage

Conversation

@jdwit

@jdwit jdwit commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Proposal for the v1 scope of #57. All items are in. The 0a live check is still open (see below), so this PR is "Part of" and not "Closes".

Changes per item

  • 0b fetch_comments() follows nextPageToken until --limit. -n 500 now returns up to 500.
  • 0c The CLI now sends --status together with --video. comments list -v X --status held returns the held queue of that video.
  • 1 profile policy show|edit|set for profiles/<name>/moderation.md. Brand and policy now use one show/edit/set factory, so the two cannot drift. show prints the file verbatim.
  • 2 reject, publish and reply are dry-run by default and need --execute. --ban also needs --execute. The preview gets author, text and video from the API. It searches for ids in this order: commentThreads.list(id=), comments.list(id=), the held and spam queues, then the local log. If the CLI cannot find an id, the command stops, also with --execute. Each batch of 50 goes to moderation-log.jsonl (0600, fsync) before the API call, with an applied, unknown or failed line after it. If a batch fails, the command stops and exits with code 1. It prints three groups: applied, status unknown (5xx, timeout or network error, so check these) and not applied (never sent, or refused with a 4xx).
  • 3 + 6 The skill has the loop, the label table and the hard rules. It also has the undo path through the log and the quota rule "all ids in one command".
  • 4 -o json adds author_channel_id, reply_count, has_link, link_hosts, off_youtube_link, duplicate_of and impersonation_suspect. The impersonation check strips the @ of the handle and compares with the channel title and handle. It only flags authors that are not the owner.
  • 5 comments list --unanswered: published threads with no reply from the owner. It reads part=snippet,replies and calls comments.list(parentId=) only when totalReplyCount is higher than the inline replies.
  • docs/api-quota.md has a new quota note. I updated the docs in comments.md and profiles.md.

0a result

I did not do the 0a live check. The stored refresh token of the default profile is revoked ("Session expired or revoked"). A new login needs browser consent. I made no live calls. The resolver works for both outcomes. If commentThreads.list(id=) does not return held comments, the preview finds them in the held or spam queue (1 unit per 100 comments). That is still API data and not text from the agent. Please run once after ytstudio login:

ytstudio comments list --status held -o json -n 5
ytstudio comments reject <held-id>    # preview only

If the preview shows the comment, the result answers 0a for this code path.

Release

Release this as 0.6.0 (0.5.0 is already on PyPI). The release notes must name the dry-run flip: comments reject, comments publish and comments reply now only preview. Scripts must add --execute to apply. I did not change the version in this PR.

Open questions

  • Settled: reply keeps --execute, and an unknown id blocks the whole command.
  • The CLI finds duplicates only inside one list run. Cross-run detection needs stored state, which is out of scope for v1.
  • The YouTube documentation still does not say if YouTube accepts a publish on a rejected comment. It needs the same kind of live spike as 0a.

Follow-ups

Part of #57

Add 'profile policy show|edit|set' for profiles/<name>/moderation.md,
built on the same show/edit/set code as 'profile brand'. Add an
owner-only append-only JSONL log in the profile directory.
- comments list follows nextPageToken up to --limit
- --status now applies together with --video
- reject, publish and reply preview by default; --execute applies
- the preview resolves ids from the API (thread, comment, held and
  spam queues), then from the local log; unknown ids stop the command
- each batch is logged before the API call; on failure the command
  stops and reports applied and unapplied ids
- -o json adds deterministic signals (links, duplicates, author
  channel id, impersonation suspect)
- comments list --unanswered
@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.98281% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.40%. Comparing base (3af7e99) to head (b912e71).

Files with missing lines Patch % Lines
src/ytstudio/commands/comments.py 92.47% 7 Missing and 10 partials ⚠️
src/ytstudio/comment_signals.py 94.00% 1 Missing and 2 partials ⚠️
src/ytstudio/commands/profile.py 97.61% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
+ Coverage   85.66%   86.40%   +0.73%     
==========================================
  Files          15       16       +1     
  Lines        2686     2964     +278     
  Branches      401      458      +57     
==========================================
+ Hits         2301     2561     +260     
- Misses        258      264       +6     
- Partials      127      139      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- catch network, timeout and httplib2 errors in the batch loop
- report 5xx and network failures as status unknown, not as unapplied
- duplicate_of points to the earliest qualifying earlier copy
- preview passes the owner, so impersonation_suspect shows
- rename off_channel_link to off_youtube_link
- request textFormat=plainText on lookups and lists
- write the moderation log through os.fdopen
- docs: fallback cost, three result groups

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant