Skip to content

feat(chat): set follow-up checks and read them from tracking data, for people and agents (W3-05) - #2029

Merged
gkhngyk merged 11 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-follow-up-checks
Nov 5, 2026
Merged

gkhngyk merged 11 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-follow-up-checks

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Follow-up checks (CHAT-20 §13, CHAT-12 v2) and an agent's own check after it ships, behind CHAT_AGENTIC. Stacked on #2028 (W3-04b, on W3-03, W3-04a, W3-02, W3-01): merge those first. No migration of its own: it uses chat_schedules (00457) and the followup_result notice kind from 00461 (W3-04a). Plan: Chat waves plan, W3-05.

The set_follow_up_check registry row (CHAT-20 §9 row 79, Scheduling area)

  • WRITE, Ask (auto allowed in Full auto) as both its default and its maximum: never Always. Admins and Managers. No MCP tool. At most 3 a run (the existing run-limits.ts cap).
  • In Ask me first and Auto: a one-click card built on W3-02's editable card. It shows the check's name and when it runs (7 / 14 / 30 / 90 days, or the day asked), "Scheduled tracking data · no extra cost" and "The result comes to this chat and your Inbox", with Set check / Not now. ChatConfirmForm gains kind: 'followup' and an optional cancel label.
  • In Full auto (Growth and up): set by itself and logged in the Activity log. Undo deletes the check until it runs; after that, Undo says it changed.
  • The check is saved as a chat_schedules row:
    • kind followup_check, due on its day at 09:00 in the person's time zone;
    • in the chat that set it, with target_json (a page URL, an action, or prompts and their platforms) and metric;
    • created_via card / full_auto, plus set_by_run_id.
  • The precheck checks the role and brand access, and that the prompts and the action belong to the brand. Checks don't count toward the plan's active jobs.
  • The step reads "Follow-up check set: {title}", then "{date} · Scheduled tracking data · no extra cost".

The worker (schedule/worker.ts) no longer opens follow-up checks as Chat runs (kind <> followup_check). The server's evaluator handles them.

The evaluator (server/src/lib/impact-ledger/follow-up.js, hourly at :17, started in server.js next to the impact ledger)

  • It makes no engine query, no model call and writes no usage row.
  • It claims each due check from the next_run_at it read, so two servers run a check once.
  • A shipped change (an agent's ship events, or the action's or the page's ship event): it reads the impact ledger's latest measured checkpoint, in the ledger's outcome words (runOutcome). It never measures again, and waits while the ledger still says Pending.
  • Prompts: it reads the Insights rollups. It compares the first tracked day on or after the check's date with the 14 days before the check was set, as the brand's share of answers (visibility) or of citing answers (citations), on the named platforms. A change under 3 points is No meaningful change. There is no control set, so the message says "Correlation, not causation".
  • With no data yet, it waits (retries every 6 hours) up to 3 days after its date, then says Not measurable. A check that fails is retried in 6 hours.
  • The result: an assistant message in the chat that set the check, a followup_result notice in the creator's Inbox, and one chat_schedule_runs row (done). Then last_run_at closes the check and its Undo.
  • Pattern chosen: a separate hourly cron next to the nightly ledger job, rather than a step inside runImpactLedger. A check due at 09:00 is answered within the hour once its tracking day is in, and the ledger's job and tests stay unchanged.

Agents: when a run ships something (markShipped), openAgentFollowUps opens one check per run. It is due the version's followup_days after the first change it shipped, on its ship events, in the run's chat, as the person it acted as, with agent_id / agent_run_id. agent-driver.ts gets a single line. Agents' Schedule triggers stay in chat_agent_triggers (decision 15).

Inbox: a followup_result notice shows as news, not amber: "{title} · result", the outcome line, and Open.

Help: new help/chat/follow-up-checks.md (approved: false).

Related issue

None. Chat waves plan, Wave 3 (W3-05).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

With CHAT_AGENTIC on, as an Admin on Growth:

  1. In Auto, ask: "I refreshed /pricing. Set a follow-up check on its citations in 14 days." A card shows Set check / Not now, the date, and "no extra cost". Pick 30 days and click Set check. A chat_schedules row appears (followup_check, created_via card), and the step reads "Follow-up check set: …".
  2. In Full auto, ask the same. No card: the check is set, and the Activity log has it with Undo. Undo deletes it.
  3. Set a check's next_run_at to the past, with tracking rows on or after its date for its prompts. Within the hour (or by calling runFollowUpChecks()), the chat gets "Follow-up check · …: Improved · Visibility 25% → 45% (+20 pts)", the Inbox shows the result, and the check doesn't run again.
  4. Finish an agent run that published a page. A follow-up check with the agent's id appears, due its follow-up days later.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint passes (changed files: 0 errors)
  • yarn typecheck passes
  • yarn format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

After merging W3-04b (W3-03 included; one conflict in worker.test.ts, both sides kept) and a follow-up fix (a followup_result notice's Open goes to the chat the result was posted in, with a test): eslint and typecheck pass again; 18 web test files / 300 tests and 6 server files / 144 tests pass.

Run locally: web — format:check, eslint on the changed files, typecheck; 20 test files / 572 tests (schedule, registry, undo, write, engine, agent driver, card-form, form-card, chat-inbox, help, subscription-guard coverage). Server — format, lint; impact-ledger and demo-brand tests (5 files / 137 tests). Full suites and the build run in the fork's CI.

Screens: shown to the owner in a local preview (1024px, light and dark, with preview data) and approved on 2026-11-02.

CI passed on this branch (7186c3b), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41523450977): schema is up to date; web format:check, lint, typecheck, all tests and yarn build pass; server lint, format:check and all tests pass.

🤖 Generated with Claude Code

cihan-gyk and others added 3 commits November 2, 2026 19:21
…r people and agents (W3-05)

- set_follow_up_check registry row (CHAT-20 §9 row 79, §13): WRITE,
  Ask (auto allowed in Full auto) as default and maximum, Admins and
  Managers, at most 3 a run. In Ask me first and Auto a one-click card
  on the editable card (Set check / Not now; ChatConfirmForm gains kind
  'followup' and a cancel label); in Full auto it is set by itself,
  logged with Undo until the check runs. Kept as a chat_schedules row of
  kind followup_check, due on its day at 09:00 on the person's clock, in
  the chat that set it. Checks don't count toward the active-job limit.
- The minute worker leaves followup_check rows alone.
- Server evaluator (impact-ledger/follow-up.js, hourly): no engine
  query, no model call. A shipped change reads the impact ledger's
  latest checkpoint; prompts read the Insights rollups (first tracked
  day on or after the date vs the 14 days before it was set; under 3
  points is No meaningful change). Waits up to 3 days for data. Writes
  the result to the chat that set the check, a followup_result notice
  to the creator's Inbox, one done run, and closes the check.
- Agents: a run that shipped something opens one check, its version's
  follow-up days after its first change (agent-driver.ts: one line).
- Inbox shows a follow-up result as news, with Open.
- Help: help/chat/follow-up-checks.md (approved: false).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…p-checks

# Conflicts:
#	web/src/lib/chat/schedule/worker.test.ts
…in (W3-05)

A followup_result notice's Open went to the check's page in Scheduled
after W3-03's change; the result is a message in the chat that set the
check, so Open goes there. Job notices still open the job's page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Nov 2, 2026
# Conflicts:
#	web/src/components/chat/inbox-notices.tsx
#	web/src/lib/actions/chat-notices.ts
#	web/src/lib/chat/engine.test.ts
…den the evaluator

- A follow-up check on a page or an action alone reads the impact ledger's
  measurement of its change; without a ship event it closed as Not
  measurable on its first read. The precheck now refuses it and tells the
  model to name tracked prompts or mark the change shipped first.
- The evaluator closes a check as skipped, delivering nothing, when its
  creator left the workspace or no longer reaches the brand.
- With CHAT_AGENTIC_ORGS set, the due-check read is narrowed to those
  workspaces, so other workspaces' checks never fill it.
- The rollup reads are paged, so a baseline past max_rows is read whole.
When a check names an action, only the action's ship events count,
even if a page is also set, so a shipped page no longer lets an
unshipped action through. The skipped reason for a check with no
brand now says the creator left the workspace.
gkhngyk
gkhngyk previously approved these changes Nov 3, 2026
…p-checks

# Conflicts:
#	web/messages/en.json
#	web/src/components/chat/inbox-notices.tsx
#	web/src/lib/chat/agent-driver.ts
#	web/src/lib/chat/engine.test.ts
#	web/src/lib/chat/notices.ts
#	web/src/lib/chat/registry/tools.test.ts
#	web/src/lib/chat/registry/tools.ts
#	web/src/lib/chat/undo.ts
#	web/src/lib/chat/write.test.ts
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Nov 4, 2026
gkhngyk
gkhngyk previously approved these changes Nov 4, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

gkhngyk pushed a commit that referenced this pull request Nov 4, 2026
…2118)

#2043 merged the second batch of What's new entries before the pull
requests they describe. Three of them name things main doesn't have yet,
so they would show once New Chat goes live:

- Follow-up checks: no follow-up check tool, Set check card or result
  notice on main (#2029).
- Scheduled jobs: the schedule card and Inbox delivery are on main, but
  runs aren't e-mailed (#2028) and there is no Scheduled page in the
  Chat menu (#2018).
- Your time zone: Settings › Account has no time zone yet (#2034,
  migration 00468).

Each keeps its approved text and gets published: 2099-12-31, so
pickWhatsNew leaves it out until its pull request sets its merge day.
entries.json regenerated.


Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

Co-authored-by: Claude <[email protected]>
…p-checks

# Conflicts:
#	server/src/server.js
#	web/src/lib/chat/engine.test.ts
@cihan-gyk
cihan-gyk dismissed gkhngyk’s stale review November 4, 2026 19:55

The merge-base changed after approval.

gkhngyk pushed a commit that referenced this pull request Nov 4, 2026
…ain (#2128)

#2118 held three entries back with published 2099-12-31 until their
features merged. Scheduled jobs' Scheduled page (#2018) and e-mailed runs
(#2028), and the time zone setting (#2034), merged on 2026-11-04, so both
entries now show from that day. Follow-up checks stays held: #2029 is open.


Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

Co-authored-by: Claude <[email protected]>
gkhngyk
gkhngyk previously approved these changes Nov 4, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@gkhngyk
gkhngyk merged commit 92d0b52 into ansvisor:main Nov 5, 2026
12 checks passed
gkhngyk pushed a commit that referenced this pull request Nov 5, 2026
#2029 merged on 2026-11-05, so its entry no longer needs holding back:
published moves from 2099-12-31 to the merge day. entries.json
regenerated.


Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

Co-authored-by: Claude <[email protected]>
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.

3 participants