> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcollate.io/llms.txt
> Use this file to discover all available pages before exploring further.

# PROCESS OVERVIEW

# Release Watchers — Process Overview

Reference doc for the automated doc-need detection built into this repo.
Mirrors `docs-om`'s equivalent doc, adapted for this repo's differences:
one current version instead of per-directory versions, and three source
repos instead of one.

***

## Overview — the problem this solves

Before this existed, the gap between "code merged upstream" and "someone
realizes a doc is needed" was entirely manual, and mostly only caught
around release time. Two independent, symmetric workflows close that
gap — one per release type, because they're genuinely different problems
with different cadences and risks.

```
                 ┌─────────────────────────┐        ┌─────────────────────────┐
                 │  Minor Release Watcher   │        │  Major Release Watcher  │
                 │  (Mon + Thu)             │        │  (every other Monday)   │
                 │  2.0.1 → 2.0.2 → 2.0.3…  │        │  2.0 (current) → 2.1 →…  │
                 └────────────┬─────────────┘        └────────────┬─────────────┘
                              │                                    │
                              ▼                                    ▼
                     tracked GitHub issue (no label needed — every issue
                     either workflow files already means "needs docs")
                              │                                    │
                              ▼                                    ▼
                     you comment /create-draft on it (create-draft.yml)
                              │
                              ▼
              TW-standards review (PR #568, separate effort) + human review → merge
```

Both watchers feed the same downstream: a human-triggered draft
(`/create-draft`), then whatever review automation this repo has live.

***

## Design principles

Same as `docs-om`'s:

* **Deterministic gates, never an AI judgment call for "should this run
  today" or "what version is current."**
* **Self-healing lookback, not a fixed day-count** — both workflows ask
  "when did I last succeed?" via a Jobs-API walk checking whether a marker
  step (`Ensure tracking labels exist`, gated to non-dry, on-week-if-major
  runs only) actually ran to completion, not just whether the run reported
  success. This matters for both workflows, not just major: while
  `FORCE_DRY_RUN` is `"true"` (see "First live rollout" below), a
  *scheduled* run of either workflow still reports overall success while
  writing nothing, and a naive "most recent successful run"
  would silently advance the watermark past a window nothing was ever
  scanned-and-written for. A successful live `workflow_dispatch` from
  `main` with `since` seeds the baseline; later schedules recognize it.
  Live runs without a baseline or explicit `since` fail closed.
* **Current version comes from docs-om's own published release notes, not
  a separately-maintained config file.** Both repos track the same
  OpenMetadata release cycle, so there's no need for this repo to keep its
  own copy of "what's current" — it reads docs-om's
  `snippets/releases/latest.mdx` directly (public repo, no token needed)
  and computes next-minor/next-major from it, deterministically, in bash.
* **Verify before notify** — CONFIRMED / RULED OUT / NEEDS A LOOK / HELD,
  never a guess, backed by the real `gh pr diff`, not just PR metadata.
* **Dry-run is enforced structurally, not just by instruction** — the
  notify job runs no model at all. `.github/scripts/watcher-notify.sh`
  only calls `gh issue create/edit/comment` when neither `dry_run` nor the
  `FORCE_DRY_RUN` safety switch (see "First live rollout" below) is
  active. In dry-run it writes what it would have created, updated, or
  commented to the run's job summary instead.
* **Deterministic work stays out of the model.** Listing PRs, dropping
  noise (tests, CI, lockfiles, assets, dependency bots), backport matching,
  the bug-fix exclusion, diff fetching and trimming, doc-coverage grepping,
  the Part B completeness check, and every issue write are plain bash/jq
  (`watcher-prefetch.sh`, `watcher-assemble.sh`, `watcher-notify.sh`). The
  model only judges prefiltered candidates and returns verdicts through
  `--json-schema`; URLs, counts, and tracking references are filled in from
  prefetch data, so the model cannot invent a PR or mis-count.
* **No guessing on ambiguity, ever** — major-vs-minor classification, doc
  relevance, and feature completeness all have an explicit "I don't know"
  outcome.
* **Write-capable steps are gated outside the model.** `create-draft.yml`
  checks, in plain bash before Claude ever runs, that `/create-draft` was
  used as a standalone command (not incidental prose) and that the target
  issue was actually filed by this repo's own watcher bot identity
  (`github-actions[bot]`) and carries a genuine watcher marker — an issue
  the watchers never filed can't reach the agent that has push/PR-create
  credentials, no matter what a collaborator's comment says or what a
  forged marker in an attacker-opened issue's body claims.
* **Read-only and write-capable sessions run in separate jobs, not just
  separate steps.** All three workflows split into a read-only job (where
  contributor-controlled upstream content actually gets read, by a model
  with local Write access) and a downstream write-capable job (issue
  create/edit/comment, or for `create-draft.yml`, git push + PR open).
  Because GitHub Actions gives every job its own fresh runner and
  workspace, the write-capable job never shares a filesystem with the
  read-only one: a planted file, a modified startup hook, anything a
  compromised read-only session could leave behind on disk simply isn't
  there when the privileged job starts. The only thing that crosses the
  boundary is an explicit artifact (`actions/upload-artifact` /
  `download-artifact`), and it's schema-validated twice: once by the
  read-only job before upload, once by the write-capable job after
  download, so a compromised read-only job can't skip its own check by
  uploading something malformed. For the two watchers that artifact is
  `summary.json`, checked field-by-field against a fixed shape by
  `.github/scripts/validate-watcher-summary.sh`. For `create-draft.yml` --
  the one workflow where the read-only job also edits real files -- the
  artifact is a `git diff --binary` patch, and every path it touches is
  checked against a fixed allowlist of doc-content directories (in the
  read-only job before packaging, and again in the write-capable job
  before `git apply`) before the patch is ever applied to the fresh
  checkout that gets pushed.
* **The cross-repo read wrapper validates arguments, not just the
  subcommand.** `.github/scripts/gh-source-read.sh` restricts which `gh`
  subcommands the model can run under `RELEASE_WATCHER_READ_TOKEN`, but
  subcommand restriction alone isn't enough -- `gh`'s own `--jq` and
  `--template` flags can read process environment variables, so
  `pr view ... --jq 'env.RELEASE_WATCHER_READ_TOKEN'` would otherwise
  print the token itself even through an "allowed" subcommand (confirmed
  with a harmless `--jq 'env.SENTINEL'` probe). The wrapper now parses a
  fixed per-subcommand flag grammar -- only `--repo`, `--state`, `--base`,
  `--search`, `--limit`, `--json`, each accepted at most once and only
  where the real prompts use it -- and rejects everything else outright:
  unknown flags, `--jq`/`--template`, short-flag aliases, a duplicated
  `--repo`.

***

## What's different here vs. docs-om

* **One current version, not per-directory versions.** Both current and
  next-minor/next-major versions are derived from docs-om's published
  release notes (see Design principles above), not a per-directory config.
* **Three source repos, not one.** `SOURCE_REPOS` (hardcoded directly in
  each workflow, since it changes rarely) lists
  `open-metadata/OpenMetadata` (public core), plus two private Collate
  repos: `open-metadata/openmetadata-collate` and
  `open-metadata/ai-platform`. Every scan step loops over all three.
* **The two private repos don't maintain long-lived per-patch backport
  branches** the way core does — they mostly develop on `main`, and
  Collate bundles a release from that state at release time. The Major
  Watcher's classification logic (step A3, below) accounts for this
  explicitly: fewer backport matches for those two repos is expected, not
  a gap to fix.
* **One flat page tree, not per-version directories** — `create-draft.yml`
  looks for the right page under `connectors/`, `how-to-guides/`,
  `collate-ai/`, `ai-2-0/`, `deployment/`, `features/`, etc., rather than
  picking a version directory first.

***

## Token budget (lossless)

Measured on 2026-10-05 before this design: the minor scan alone took 79
turns and the notify session 30 more, because each tool turn resends the
whole conversation and multi-MB `gh` outputs were paged in through the
30k-character tool limit. The current design cuts cost without dropping
anything the model could need:

* **Every scanned PR reaches a model session.** PRs the deterministic
  prefilter flags (noise titles and paths, dependency bots, and in major
  mode `backport_found` / `bugfix_type`) stay in the session's index with
  the path of their full diff; the model can promote any of them.
* **Trimmed views, full files on disk.** Each candidate's view keeps one
  context line, lists schema/config/UI files first, drops imports, tests,
  lockfiles, and assets, and caps the diff (9 KB minor, 7 KB major). The
  complete body and untrimmed diff of every PR sit next to it, and the
  prompt requires reading them whenever a view is truncated or leaves out
  something the verdict depends on.
* **No session grows until it compacts.** Candidates are split into chunks
  of about 160 KB of views; `watcher-verify.sh` runs one fresh
  `claude -p` session per chunk (Claude Code 2.1.285, pinned, with the
  same `CLAUDE_CODE_OAUTH_TOKEN`) and merges the verdicts.
* **Every candidate ends with a verdict.** One a session skips becomes
  NEEDS A LOOK in the digest.

| Control | Where |
| - | - |
| Sonnet 5.5 at `--effort high`, Read/Grep only (no `/proc`), `--json-schema` output, turn cap per session (30 minor, 40 major) | `watcher-verify.sh` |
| Five-minute prompt cache (`CLAUDE_CODE_PROMPT_CACHE_TTL=5m`): subscription runs default to one hour, which bills cache writes at 2x input instead of 1.25x | `watcher-verify.sh` |
| Bundles of at most 40 KB, so each fits one Read call | `watcher-prefetch.sh` |
| Custom system prompt; no CLAUDE.md, memory, skills, MCP, or subagents | `watcher-verify.sh` |
| Live runs start at the previous run's exact start time, so no PR is reviewed twice | setup job, `lookback_ts` |
| No model in notify or Part B | `watcher-notify.sh`, `watcher-prefetch.sh completeness` |
| Turns and estimated cost per session | scan job summary, "Model usage" |

Local replays (Sonnet 5.5 high): minor window of 2026-10-01..05, 24 PRs
and 21 candidates in one session, about $0.39. Major window of
2026-09-20..10-05, 666 PRs and 150 candidates in 9 sessions, about $0.48
per session measured on 2 of them, so roughly $4.3 per biweekly run. Cost
scales with the number of candidates (about $0.015-0.025 each).

Prompts and schemas live in `.ai/release-watchers/`:
`scan-system-prompt.md` and `verdicts.schema.json`.

## Workflow 1 — Minor Release Watcher

**File:** `.github/workflows/minor-release-watcher.yml`
**Schedule:** `0 6 * * 1,4` — 06:00 UTC, every Monday and Thursday
**Scope:** the current minor/patch line only (e.g. `2.0.1 → 2.0.2`),
across all three source repos. Never touches `main`.

| Step | What it does |
| - | - |
| Lookback | Last successful live run on `main`, whether scheduled or manually dispatched; the `since` input overrides it. A live run with neither fails closed. Preview runs can use a 4-day window. |
| Version | Parses the current version out of docs-om's `snippets/releases/latest.mdx` (cross-repo, public, no token), then computes the next minor version and the minor release branch name |
| 1. Select (bash) | `pr list --base <minor-release-branch>` on every repo in `SOURCE_REPOS` since the lookback; flag noise titles, dependency bots, and PRs touching only tests/CI/locks/assets as `skipped` (still indexed) |
| 2. Bundle (bash) | Full body and diff of every PR on disk; trimmed candidate views with doc-coverage hints (connector and schema property names grepped in this repo's MDX); chunks with per-session indexes |
| 3. Verify (Sonnet, one session per chunk) | HELD / RULED OUT / NEEDS A LOOK / CONFIRMED, each citing a path, a quoted diff line, or a docs page; same-feature PRs grouped, including across repos |
| 4. Assemble (bash) | Builds `summary.json` from verdicts plus prefetch data; candidates without a verdict become NEEDS A LOOK |
| 5. Notify (bash) | Dedup by exact hidden markers (`pr-<repo>#<number>`, shared tracking issue, original PR of a backport) before creating or updating one issue |
| 6. Digest (bash) | Comment on "Minor Release Watcher -- Scan Digest" every run |
| 7. Slack | Only if CONFIRMED this run (and not forced/dry-run): posts to `SLACK_WEBHOOK_URL` |

## Workflow 2 — Major Release Watcher

**File:** `.github/workflows/major-release-watcher.yml`
**Schedule:** `0 6 * * 1` + ISO-week-parity gate — every other Monday
**Scope:** `main` only, across all three source repos, targeting the next
major version (computed from the current version, e.g. `2.0 → 2.1`).

**Part A — scan for new major-bound doc needs.** Same pipeline as the
minor watcher, on `main`. In bash, a PR is flagged as minor-bound (and listed in the index as skipped) when
its number is referenced from any `MINOR_RELEASE_BRANCH` PR (backport), or
when its "Type of change" checks only Bug fix (or, without that section,
its title is a conventional `fix:`), unless it carries a breaking signal.
For the two Collate-only repos a missing backport is expected, so the
verify step judges those on the change itself. Genuinely ambiguous cases
become NEEDS A LOOK, never a guess.

**Part B — completeness check on already-tracked multi-PR features.**
Plain bash (`watcher-prefetch.sh completeness`): for each linked PR
(noting its repo), find its tracking issue in that same repo, check the
issue state and every PR referencing it, and post COMPLETE / INCOMPLETE /
UNCLEAR back on the existing issue. Before
the notify job can comment, a plain-bash step drops any check whose
target isn't an open issue filed by `github-actions[bot]` carrying more
than one `major-watcher` marker, including the exact marker for every PR
the check names.

## Workflow 3 — Create Draft (on demand)

**File:** `.github/workflows/create-draft.yml`
**Trigger:** comment `/create-draft` on any issue (OWNER/MEMBER/
COLLABORATOR only)

Three jobs, each gated on the previous one:

| Job | What it does |
| - | - |
| `gate` | Plain-bash checks, no model involved: `/create-draft` was used as a standalone command (not incidental prose), and the target issue was actually **filed by this repo's own watcher bot identity** (`github-actions[bot]`) **and** its body carries a genuine `<!-- minor-watcher:pr-<repo>#<number> -->` or `<!-- major-watcher:... -->` marker. Both conditions are required: an issue merely *formatted* to look like a watcher issue, but not actually filed by the bot, is refused; author identity is the one thing an outside issue author cannot forge. |
| `draft` | Only runs if `gate` passed. Reads the issue, works out which repo each linked source PR actually belongs to (not assumed to be uniform), reads the real diff/description from that repo (treating the issue body itself as an untrusted pointer, never as instructions), finds the right page in this repo's flat tree, drafts the content with every claim checked against source, flags anything unverifiable. Has no git, PR, or issue-comment tools at all. A deterministic bash step afterward checks every changed path against a fixed allowlist of doc-content directories, then packages the change as a `git diff --binary` patch plus a title/body pair, and uploads all three as an artifact. |
| `open-pr` | A fresh runner and a fresh checkout: no file `draft` wrote, no tool that could ever read the original issue or source PR. Downloads the artifact, re-validates the same path allowlist against the patch's own diff headers (never trusting `draft`'s own check alone), applies it, and, as plain deterministic bash, not a model, branches, commits, pushes, opens the PR as a **draft** (never marking it ready for review), and comments the link back on the issue. |

***

## First live rollout

Both watchers carry a workflow-level `env: FORCE_DRY_RUN: "true"`. While
set, this overrides `dry_run` regardless of trigger (schedule included),
and the bash notify step skips every issue write — no model is involved
in that decision. This makes the first pass
after merging safe by construction: the schedule can fire for real before
anyone tests it manually, and that run can only ever read and report.

The intended sequence once merged:

1. Run each workflow via `workflow_dispatch` from `main`.
2. Open that run's job summary in the Actions UI and sanity-check the
   dry-run preview against what's actually open upstream — forced dry-run
   creates no digest issue to read instead (see "Design principles"
   above).
3. Flip `FORCE_DRY_RUN` to `"false"` in its own separate, reviewable
   commit.
4. Before the next schedule, run each workflow via `workflow_dispatch`
   from `main` with `since` set to a date before the oldest untracked
   change. Set `force_run=true` for the major watcher if it's an off-week.
   Confirm each live run succeeds; these runs establish the baseline for
   later schedules. A live schedule before this catch-up fails without
   creating tracking issues rather than guessing a short window.

***

## Schedule summary

| Workflow | Trigger | Cadence |
| - | - | - |
| Minor Release Watcher | `schedule` | Mon + Thu, 06:00 UTC |
| Major Release Watcher | `schedule` + week-parity gate | Every other Monday, 06:00 UTC |
| Create Draft | `issue_comment` | On demand — `/create-draft` |
| Automatic TW-standards review | `pull_request` | **Separate effort — PR #568, not part of this build** |
| On-demand TW-standards review (`/content-review`) | `issue_comment` | Already live (`doc-review.yml`) |
| Broken-links check | `pull_request` | Already live |

***

## Secrets and variables this depends on

| Name | Kind | Used for |
| - | - | - |
| `CLAUDE_CODE_OAUTH_TOKEN` | secret | Auth for the verify sessions (pre-existing). Usage counts against the token owner's Claude subscription limits. |
| `RELEASE_WATCHER_READ_TOKEN` | secret | A fine-grained PAT scoped **only** to `open-metadata/openmetadata-collate` and `open-metadata/ai-platform`, with **read-only** access (the public `OpenMetadata` repo needs no auth at all, and docs-om's public `latest.mdx` is fetched with the ordinary `github.token`). Confirmed working against both private repos, and confirmed genuinely read-only, on a disposable branch. Used only inside `.github/scripts/gh-source-read.sh`, a wrapper that the deterministic prefetch steps call for cross-repo reads (the model never receives this token) — every other `gh` command (all issue and PR operations against this repo) uses `github.token` directly, which is itself incapable of reaching the two private repos at all. The wrapper itself validates a fixed per-subcommand argument grammar, not just the subcommand (see Design principles above): `--jq`/`--template`-based environment exfiltration was found and closed. This split means there is no path — bug or prompt injection — through which either token can write somewhere it isn't meant to, or read the token itself back out. |
| `SLACK_WEBHOOK_URL` | secret | Confirmed-only digest DM (pre-existing) |
| `RELEASE_WATCHER_ASSIGNEES` | variable | Comma-separated GitHub usernames assigned to tracked issues and both digest issues (currently `kiran1287`) |

No GitHub Projects board integration wired in.

***

## Known limitations / what's still open

* **No project-board integration.**
* **Email notification** not built.
* **The automatic TW-standards check is a separate, independent effort**
  (PR #568) — not something this build created or depends on; the two
  can merge in either order.
* **First run of each workflow has no history to look back on** — the
  first live dispatch needs an explicit `since`. A live run without it
  fails closed until a successful live baseline exists. Previews can use
  a fixed window (4 days minor, 15 major).
* **`create-draft.yml`'s real git-push/PR-open path has never executed
  successfully** — `issue_comment` only fires from the default branch, so
  this can only be tested for real after merging.
* **The job-split / artifact-handoff / path-allowlist logic has only been
  tested locally**, using a stub `gh`, a disposable local git repo, and
  hand-fed valid and malicious diffs/summaries, confirming the wrapper's
  flag grammar, the schema validator, and the patch-path allowlist all
  reject what they should and accept what they should. None of it has
  executed inside a real GitHub Actions run yet (cross-job artifact
  upload/download, real runner isolation, real `git apply` against a live
  checkout); that's still open, same caveat as the model
  step below.

## Verified before this went anywhere near `main`

Everything below was checked on disposable branches (never a PR).

**Confirmed working, via real live-API calls:**

* The plain `gh` CLI commands both workflows depend on (label create,
  issue create/comment/edit/close) work against the live API on this repo
  specifically, not assumed from docs-om
* `RELEASE_WATCHER_READ_TOKEN` genuinely has read access to both private
  source repos, the actual `gh-source-read.sh` wrapper script works
  end-to-end, and the token is genuinely incapable of writing
* An earlier repo-*variable* lookback approach was confirmed broken
  (403, same root cause as docs-om) before being replaced with a
  `gh run list` / Jobs-API step-marker walk. The live-dispatch baseline
  and fail-closed behavior require separate verification before rollout.
* The `since` override and the `FORCE_DRY_RUN` safety switch (gating
  logic, tool-list construction, and `DRY_RUN` resolution all confirmed
  on a disposable branch)
* The version-derivation step: confirmed the cross-repo fetch of
  docs-om's `latest.mdx` and the computed next-minor/next-major/branch
  values all match real, live data
* The author-check fix on `create-draft.yml`: confirmed all three
  branches (bot-authored + real marker accepted; human-authored + forged
  marker rejected; bot-authored + no marker rejected)
* The full three-repo scan manually walked against real live data on both
  the minor branch and `main` — confirming `ai-platform`'s near-idle `2.0`
  branch but active `main`, and a genuine candidate in
  `openmetadata-collate` that correctly required a real judgment call
  rather than an obvious rule-in/rule-out

**NOT yet verified — and can't be, before this merges:**
`schedule`, `workflow_dispatch`, and `issue_comment` only fire from a
repo's default branch. The actual model verify step (the part
that reads real PRs and would create/update issues) has never executed
successfully in a real run yet — only the surrounding bash/`gh` logic
above has been proven live. See "First live rollout" above for how this
is being handled safely.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.