Skip to content

feat(platform): fan out @mentions in task descriptions - #3519

Merged
yannickmonney merged 5 commits into
mainfrom
feat/task-description-mentions
Sep 27, 2026
Merged

yannickmonney merged 5 commits into
mainfrom
feat/task-description-mentions

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What changed

The create dialog and the description editor show MentionTriggerChips under the description
("{agent} will respond"). But createTask ended in TODO(collab): description mention fan-out
and updateTask never resolved the description. So a teammate named in a brief got no bell, and
a named agent never started. Description mentions now do what comment mentions do.

  • Resolution (backend/domains/collab/mention-directory.ts): resolveSurfaceMentions takes
    an optional previousBody and returns added. Both texts are read against one directory
    build, so an edit fans out only who it newly names. Rewording prose around an existing
    @handle, or naming the same person by another of their handles, fires nothing again.
  • Wiring (backend/domains/tasks/service.ts): createTask (in place of the TODO) and
    updateTask (when the description changed) call fanOutDescriptionMentions.
    • A token pre-check keeps the directory build (an org-wide member scan) off descriptions that
      name nobody, as 0.4 did, and off edits that add no @token the replaced text lacked.
      Resolution maps each token on its own, so such an edit names nobody new.
    • On create it runs after the In progress kick, so a card created In progress keeps the
      run its agent assignee was given (one engine per task), and before the review gate: a card
      created In review whose description puts an agent to work moves to In progress without
      first opening (and at once withdrawing) a review. A card still at In review gets its gate.
  • Bells for humans (backend/domains/collab/service.ts): notifyTaskMentions subscribes each
    named human (reason: 'mention') and writes the mention row with resourceType: 'task'.
    • It shares one loop with notifyTaskComment's mention half, and uses the same keys
      (inbox.mentionByBody reads "{actor} mentioned you on "{title}"").
    • It never rings the actor, and never tells watchers: a description edit is not a new comment.
  • Agent kicks (dispatchMentionedProjectAgent): moved verbatim from comments.ts into the
    task core, so both surfaces share it. service.ts importing comments.ts would have added an
    import cycle; comments.ts now imports it from service.ts.
    • A named project agent is steered while it runs, or assigned and kicked with a mention run
      while the task is idle. A description kick stores no copy of the text: migration 0123
      adds project_agent_runs.mention_source (comment | description), and the run reads the
      description as it stands when it starts. A copy taken at kick time sat beside an edit made
      while the run waited, as reviewer feedback that outranks it.
    • The kick sits behind the task automation switch that mentionTriggerPreview reports as
      pack_disabled (mentionAutomationEnabled, the old commentAutomationEnabled moved to
      run-start.ts: a broken policy reads as off).
    • The other refusals are unchanged: a live run of another engine, a queued run, an agent without
      a model.
  • Prompt (backend/core/tasks/agent_run_host.ts, buildKickPrompts): both opening prompts
    come from the brief read at start. A fresh conversation reads the description as its brief. A
    resumed one does not re-read the brief, so it gets the current description as "The task
    description was edited to mention you", not as reviewer feedback. The source rides the steer
    job too (task.agent_steer.mentionSource): the stdin line and the restart prompts say the
    description was edited, and a steer that misses kicks a description run that reads the text at
    its start.
  • Retry safety: a serialization conflict (40001/40P01) inside a directory read is rethrown
    unwrapped, so transactSerializable retries it. Wrapped as MENTION_DIRECTORY_UNAVAILABLE, it
    surfaced as a 503. The create and edit doors are SERIALIZABLE and now read the directory, as the
    comment door already did.
  • Docs (EN/DE/FR): platform/projects/tasks.md gets one paragraph on mentions in the
    description (any column moves to In progress; the agent reads the description at run start);
    admin/governance/usage-attribution.md names a description mention as a way to start a billed
    run. Manual layer: box TASK-F34 plus its reference/automation.md row, and a
    reference/error-codes.md row for MENTION_DIRECTORY_UNAVAILABLE on the comment, create and
    edit doors. Ledger: the MIGRATION.md collab row records TALE-46.

Schema: migration 0123_project_agent_runs_mention_source.sql, one nullable column plus three
checks (the two values; only on mention runs; a description run stores no feedback). Rolling-deploy
safe: the previous image neither writes nor reads it. No new strings, no contract change. A
description save that names someone now fails with 503 MENTION_DIRECTORY_UNAVAILABLE if the
directory cannot be listed, as a comment already does. The TODO is gone.

How I verified it

  • Unit: bunx vitest run --project server over backend/domains/tasks, backend/domains/collab,
    backend/core/tasks, backend/domains/provisioning, backend/jobs, lib/shared and every
    other test that imports a changed module: 128 files, 1346 tests pass. New:

    • service.description-mentions.test.ts, 8 cases:
      • create with no mention builds no directory;
      • create bells the teammate and assigns, kicks and moves the agent;
      • a card created In progress keeps its one run;
      • an edit passes the replaced text and fans out only the added mention;
      • unchanged mentions fire nothing and no dispatcher runs;
      • no resolution when the description is untouched or cleared;
      • task automation off: the bell rings, no kick, and the preview answers pack_disabled from
        the same policy;
      • a running agent that is newly named is steered with the edited description.
    • mention-directory.test.ts: added with and without previousBody, another handle for the
      same person, a reworded text, a 40001 passing through.
    • collab/service.test.ts: the task-bound mention row, no actor, no agent, no watchers; a comment
      row still points at its comment.
    • run-start.test.ts: a broken policy reads as off.
    • agent_run_host.task_prompt.test.ts: the description is said once, and a comment's feedback
      still leads.
  • Real Postgres 16 (+ pgvector + pg_search, no Docker), filtered run
    ITEST_LANES=checkTaskDescriptionMentions,checkCollabMentions,checkRunProvenance,checkTaskRunStartFence,checkTasksCollabIntegrity,
    new lane checkTaskDescriptionMentions (4 checks) through createTask / updateTask under
    transactSerializable:

    • With the change (rebased on 9121a4ab7): 52/52 pass. That includes the comment lanes the
      moved dispatcher serves (steer, idle kick, queued quiet, agent author, live automation blocks,
      the disabled/unavailable policy) and upstream's reviewer re-target lane.
    • Same lane, implementation reverted to origin/main: all 4 new checks fail (bells=0,
      runs=none, task=backlog/null). The 14 new unit cases fail the same way.
    • backend:integration is not a CI job, so this local run is the real-Postgres proof.
  • Gates:

    • A scoped tsc over the changed files and their import graph is clean. The workspace-wide
      tsc does not fit the sandbox's 4 GB and is left to CI.
    • bunx oxlint --type-aware on every changed file, oxfmt --check, bun run lint:manual,
      check-guide.ts on suites/tasks.md, and the pinned opengrep on the changed files (0 findings)
      are all clean.
    • bunx knip --workspace services/platform: only the pre-existing oidcOrganizationClaims.
    • Docs suite (services/docs, bunx vitest run): 34 files, 166 tests pass, with no i18n
      report-mode findings.
  • Review round 1 (ba9581540..8bd89239e, fixes for the independent review):

    • Unit: the whole bunx vitest run --project server (814 files, 10245 tests) passes. New or
      changed: agent_run_host.task_prompt.test.ts (a run kicked with the German text opens on the
      French edit, fresh and resumed; a resumed description kick is phrased as an edit; steer
      texts), agent_run_host.steer_fallback.test.ts (the fallback kick keeps the source),
      service.description-mentions.test.ts (no copy on the kick; both In review outcomes; a card
      born In progress for a person whose description names an agent gets one mention run; an
      edit adding no @token builds no directory; a new handle for someone named fires nothing).
    • Workspace-wide tsc --noEmit is clean on this machine; oxlint --type-aware on every
      changed file, oxfmt --check, knip, lint:manual, check-guide.ts on suites/tasks.md
      and the docs suite (166 tests) are clean.
    • Real Postgres 16 + MinIO, lane checkTaskDescriptionMentions (7 checks): a run kicked before
      an edit opens on the edit, fresh and resumed; the schema refuses a description run that
      stores a copy; a create or an edit whose directory cannot be listed answers
      MENTION_DIRECTORY_UNAVAILABLE/503 and writes no card, no edit, no bell. The lane now removes
      its project, agent, tasks, runs, jobs, bells, members and users in one outer finally
      (verified: no rows left).
    • The full backend:integration run: 814/821 checks across 162/162 lanes. The 7 failures
      (teams' last-member door; six organization-lifecycle teardown checks) fail the same way on
      origin/main 835236313 in the same environment (809/818, the same 7 plus 2 more), so they
      are not this change's.

Left open (not in this change)

  • Automations: naming the task's owning automation in the description starts nothing. The
    chips preview agents only, and a workflow reads the description when it runs.
  • The task.mentioned event (0.4 emitted it) stays in RESERVED_EVENT_TYPES. Raising it is a
    contract change: the event list, the OpenAPI trigger enum and the API reference.
  • Machine intake: REST intake (upsertTaskByExternalRef) and source-issue sync write
    descriptions without a fan-out. An external @handle is not a Tale member.
  • Agent-filed tasks: agentCreateTaskTrusted (the task_create workspace tool) writes a
    description without a fan-out, so a person an agent names there gets no bell, while the same
    agent naming them in a comment does. Belling humans only (never an agent dispatch, to avoid
    loops) is the likely shape; it is a product call on agent-sent bells, left for its own change.
  • Misses: an @token in a description that matches nobody is not reported back. The comment
    composer's "Mention not recognized" toast has no description twin yet.

Task: TALE-46 (triage T45, P2).

yannickmonney and others added 5 commits September 27, 2026 16:38
The create dialog and the description editor promise "X will respond" under
the field, but createTask ended in a TODO and updateTask never resolved the
text, so a teammate named in a brief got no bell and a named agent never
started.

- createTask and updateTask resolve the description with the mention
  directory (resolveSurfaceMentions): on create in full, on an edit only for
  the mentions it adds. The directory reads the replaced text too
  (previousBody), so rewording prose around an existing @handle fires
  nothing again. A token pre-check keeps the directory build off
  descriptions that name nobody.
- Named humans follow the task and get the mention bell, which points at the
  task (notifyTaskMentions shares the comment's mention loop).
- A named project agent goes through the comment lane's dispatcher, moved
  into the task core so both surfaces share it: steered while it runs,
  otherwise assigned and kicked with a 'mention' run carrying the
  description, under the task automation switch the chips preview
  (pack_disabled). A card created In progress keeps its assignee's run.
- A fresh prompt no longer repeats feedback that is the description itself;
  a resumed conversation still gets the edit as its feedback.
- A serialization conflict inside a directory read reaches the serializable
  retry loop instead of surfacing as a 503.
- Docs (EN/DE/FR), manual box TASK-F34, integration lane
  checkTaskDescriptionMentions.
A description kick stored the description as it read at kick time in
the run's feedback. The host reads the brief fresh when the turn starts,
after reaping, sweeping, staging and any capacity park, and only dropped
the feedback block when both strings matched exactly. An edit made while
the run waited names nobody new, so nothing fired again, and the prompt
showed the edited Description beside the replaced text as reviewer
feedback that outranks it.

- Migration 0123 adds `mention_source` ('comment' | 'description') to
  `project_agent_runs`. A description kick stores no copy of the text;
  a check constraint holds that rule, and two more tie the column to
  mention runs.
- `buildKickPrompts` builds both opening prompts from the brief read at
  start. A fresh conversation reads the description as its brief. A
  resumed one gets it as "The task description was edited to mention
  you", not as reviewer feedback.
- The source rides the steer job too: a running agent is told the
  description was edited, the restart prompts say so, and a steer that
  misses kicks a description run that reads the text at its start.
- The integration lane proves a run kicked before an edit opens on the
  edit, that the schema refuses a stored copy, and that a create or an
  edit whose directory cannot be listed answers
  MENTION_DIRECTORY_UNAVAILABLE and writes nothing. Its fixtures
  (project, agent, tasks, runs, bells, jobs, users) are removed in one
  outer `finally`.
A card created at In review opened the review gate (the reviewer's bell
rang), and then its description's agent mention reassigned the card,
kicked the agent, moved it to In progress and withdrew that review in
the same write.

The fan-out now runs before the review gate, and the gate opens only for
a card still at In review: no agent named, or its start refused. A named
agent is put to work whatever column the card was created in, as a
comment naming it on a closed card already does; the In progress kick
still runs first, so a card born working for its agent keeps that run.

Tests pin both In review outcomes and a card born In progress for a
person whose description names an agent (one mention run). TASK-F34
gains the In review step.
Every description save that kept an existing `@token` (or text such as
`@tale/ui`) rebuilt the org-wide mention directory under SERIALIZABLE,
even when the edit added nothing: more predicate reads and more 40001
retries for no fan-out.

Resolution maps each token on its own, so a text whose tokens the
replaced text already had resolves to nobody new. The edit path now
skips the build in that case, which is the answer the build would give.
A new handle for someone already named still resolves, and still fires
nothing.
- Usage attribution (EN/DE/FR): a description save that names an agent
  starts a billed run under whoever saved it, like a comment does.
- Tasks (EN/DE/FR): a run a description mention starts moves the card to
  In progress whichever column it was created in, and the agent reads
  the description as it is when its run starts.
- Error register: MENTION_DIRECTORY_UNAVAILABLE (503) on the comment,
  create and description-edit doors, with how the lanes provoke it.
- Automation register: the TASK-F34 row names the stored source, the
  no-copy rule and the new tests.
- Migration ledger: the collab row records TALE-46 and drops the two
  PENDING phrases for description mentions; still open are the reserved
  `task.mentioned` event, an owning automation named in a description,
  and descriptions written by machine intake or an agent's `task_create`
  tool, which fan out nothing.
@yannickmonney
yannickmonney merged commit bb20373 into main Sep 27, 2026
50 checks passed
@yannickmonney
yannickmonney deleted the feat/task-description-mentions branch September 27, 2026 19:12
yannickmonney added a commit that referenced this pull request Sep 27, 2026
TASK-F34 now names the description mentions box that #3519 landed, and open
#3535 claims TASK-F35, so the box for a connector running for the run's
starter becomes TASK-F36, and TASK-B10 points at it. The suite's cost and
the readme's tasks row and total are re-derived from the merged suite.

The registers follow the run-bound caller: the automation row names the
run_ended refusal, the auto-retry pin and the relayed connector refusals,
the error-codes row adds run_ended, and B10 and its pin name Cancel run
before a new start. BL-2 records the remaining exposure: two runs of one
agent share its session and user, so a live run's token can be read by its
sibling.
yannickmonney added a commit that referenced this pull request Sep 27, 2026
#3519 landed 0123_project_agent_runs_mention_source.sql on main first,
so the trigger failure streak takes the next free number.
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