Skip to content

fix(v2): name a human in a grant audience instead of calling them "an agent" (TASK-050) - #1757

Merged
lilyshen0722 merged 2 commits into
mainfrom
kai/task050-audience-human-names
Sep 19, 2026
Merged

lilyshen0722 merged 2 commits into
mainfrom
kai/task050-audience-human-names

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Fixes the label half of TASK-050 — C4-4, the stranger's Tools row reading "an agent, an agent, C4 smoke may use it" for Sam + c3stranger0912 + the seat.

Why it said that

Three measurements, each from a different layer:

  • A pod grant's default audience is the room's whole member list: backend/routes/grants.ts:177 — body.audience === undefined ? members : body.audience, where members is Pod.members (humans included). The mint form only offers agent rows (seats, V2ConnectorTools.tsx:661), so the audience is read as "agents" while the default writes "members".
  • Enforcement needs an agent identity: backend/services/roomGrantService.ts:415-418 — effectiveAudience(grant, currentMemberIds) then if (!audience.includes(String(options.agentUserId))) throw not_in_audience. A human id in the audience can therefore never authorize anything; it is inert.
  • The frontend resolved each audience id against seats only — the /api/registry/pods/:podId/agents list, which is agents — and labelled everything else t('tools.aSeat') = "an agent". Two humans, two "an agent"s.

The fix

seatLabel falls back to memberName(userId) — the same helper the "Granted by …" line already uses — before the generic label. So the row reads "sam, Scout may use it · every write asks first".

The row offered two options; this is the first one, deliberately. Naming the person is accurate under either reading of what an audience means, whereas dropping non-seats silently would be wrong if the audience is meant as a people-snapshot. The model question itself — is an audience a set of agent identities, or a snapshot of the room? — is a real fork and I have not settled it in this PR. If it is "agent identities", then the mint default at grants.ts:177 is the root cause and should intersect with bot members at mint and read; that touches the enforcement path's membership context, so it wants a ruling, not a patch.

Verification

  • Mutation-proven: removing the fallback reds exactly the new case (TASK-050: a human member in the audience is named, not called "an agent"), 1 failed / 18 passed.
  • Frontend 108 suites / 884 passed, tsc --noEmit clean.
  • Tests only on the fix side: one component hunk + one test. No version bump — the guard watches cli/src and commonly-mcp/src, and frontend is not a published package.
  • Ordering with fix(grants): a parked call whose approval resolved stops counting as "awaiting a person" (TASK-058) #1750, which touches the same two files: measured rather than reasoned — git merge-tree --write-tree in both orders produces the identical tree 26ce75da, and running this component's test on that combined tree gives 19/19 passing. Either merge order is safe; no rebase follows.

The live C4 grant still carries the two human ids, so the stranger's page corrects itself as soon as this deploys.

… agent"

A pod grant's audience is a snapshot of the room's members, so it can
name a human; `seats` holds agents only, and every id it could not find
was labelled "an agent". The stranger's Tools row read "an agent, an
agent, C4 smoke may use it" for two people.

Resolve the member's username before falling back to the generic label,
the same helper the grantor line already uses. The row named two options;
this is the first one, and the reason is on the row: enforcement needs an
agent identity, so naming the person is accurate under either reading of
what an audience means, and the audience-model question is left to the
pod rather than settled here.

Mutation-proven: dropping the fallback reds exactly the new case.
Frontend 108 suites / 884 tests, tsc clean. TASK-050.
…side (TASK-050)

The UI hold asks for a before/after pair at 390 and 1200. Wren's read named the one
view that can carry this fix on a phone: the row's `… may use it` line is hidden under
760px by v2.css (#1712), so the audience only paints in the Manage aside.

- before = main dbd5270, after = dbd5270 + this PR's head ede0647
- one backend at main, both frontends pointed at it, same seeded pod and grant
- harness: scripts/ui-evidence-shot.mjs on kai/harness-width-flag @ a730a1e (#1770).
  It now takes --width/--height and --click, refuses a flag it does not implement, and
  prints the viewport it used — so these files are 780x1800 and 2400x1800, not the
  2880x1800 that `--width 390` used to produce under a `-390` name.

Measured: aside @390 `agents allowed` an agent -> localdev; row @1200 same change; row
@390 unchanged, which is what the hide rule requires.
@lilyshen0722
lilyshen0722 force-pushed the kai/task050-audience-human-names branch from 2944a02 to 716abcf Compare September 19, 2026 17:13
@lilyshen0722
lilyshen0722 merged commit 79306fd into main Sep 19, 2026
14 checks passed
samxu01 pushed a commit that referenced this pull request Sep 25, 2026
…(TASK-131)

Captured with `scripts/ui-evidence-shot.mjs` against the harness in
`docs/runbooks/local-ui-render-harness.md`. After side: this branch's worktree
(backend 5050, vite 3000) — `06391f11`'s page plus the working-tree copy commit
that is now `70fcaece`. Before side: `a2913955`, the revision this PR is cut from
(backend 5051, vite 3001). Same database, same token, and the pair for each width
was captured back to back so the row's relative age line does not differ between
the two.

The subject is a catalogue installation in the error state. Two rows, so one frame
carries both flag states:

- Slack, `errorMessageUserFacing: true` -> "This connector's channel is gone.
  Retry to rebuild it." in both revisions (a flagged message is already verbatim;
  this is the "user-facing reason when the flag is set" frame).
- Telegram, `errorMessageUserFacing: false`, `errorMessage` = the raw
  `connect ECONNREFUSED 10.4.4.7:443` -> before: printed in the row (the
  disclosure this PR fixes); after: "Setup didn't finish."

`diff` of the two `document.body.innerText` dumps at each width is that one line
and nothing else, which is why the `.txt` pair ships beside the PNGs — a raster is
the illustration, the text is the evidence:

    14c14
    < connect ECONNREFUSED 10.4.4.7:443
    ---
    > Setup didn't finish.

Measured, not assumed: the phone width does render the row's line (the `#1757`
caveat, where `v2.css` hides a row's detail at 390, does not apply here), and both
revisions reported `non-2xx: none` and `console errors: none`.

Harness notes, because they decide whether the frame is reachable at all: the
provider readiness gate renders "Not enabled on this instance." *instead of* the
error state, so the after backend boots with the dummy `TELEGRAM_*` / `SLACK_*` /
`CONNECTOR_SECRET_*` values a local instance needs; the installation rows are
seeded directly (the install route refuses with `provider_not_configured` before
those values exist), and the flagged row's string is the reconciler's own constant,
not a string this harness produced. Source blobs are untouched by this commit.
lilyshen0722 added a commit to thantiklermcirony/commonly that referenced this pull request Oct 9, 2026
…iter declared it readable (TASK-131) (Team-Commonly#1881)

* feat(connectors): the catalog half renders a message only when a writer declared it readable

`V2ConnectorsPage`'s catalogue branch was `installation.errorMessage || <generic>`,
and `InstallableInstallation.errorMessage` has two kinds of writer: the
reconciler's human-authored constants and `markProjectionFailure`, which stores
the projector's own exception text (`connect ECONNREFUSED <addr>:443`). So a raw
exception was printed in a stranger's connector row — disclosure, not diagnosis
(the same class Team-Commonly#1878 fixed on the pod-scoped half, measured and disclosed rather
than folded in there).

Team-Commonly#1878's shape, carried across: `errorMessageUserFacing`, written together with the
message by one owner so no writer can set half.

- `userFacingInstallationError(reason)` / `diagnosticInstallationError(error)` are
  the two ways the field gets a value; the reconciler's two `$set`s and
  `markProjectionFailure` now take the builder instead of assembling the pair by
  hand.
- `InstallableInstallation.errorMessageUserFacing` (Boolean, default false).
- `installableCatalogService.publicInstallation` hands the flag over with the
  message, so the page never infers provenance from the shape of the string.
- The page gates the catalogue branch the way it already gates the pod-scoped
  one: `errorMessageUserFacing && errorMessage`, else the generic sentence.

Witnesses:
- a real projection failure stores `errorMessageUserFacing: false` (the raw
  exception is the writer that must say so);
- the reconciler's stale-lock and missing-projection sweeps store `true`, read
  back from the database after `sweep()`;
- the mapper carries `true` and `false` through, with the message still present in
  both cases — the page, not the mapper, decides what to show;
- the page renders the generic sentence for an unflagged catalogue failure and the
  message verbatim when the flag is set. The pre-existing catalogue fixture that
  asserted `projection missing` verbatim now carries the flag its writer sets,
  which is the contract change rather than a relaxed assertion.

Scope note: `components[].errorMessage` is left alone — the mapper carries it but
no reader renders it (the page reads component `status` only), so a flag there
would be a contract with no consumer.

TASK-131.

* fix(connectors): the feed writer states errorMessageUserFacing instead of omitting it (wren 73858)

A `$set` that leaves a key out inherits the row's stored value, so
`externalFeedService`'s error write was only safe on a row that had never carried
a flag: a row that had been flipped by a permanent delivery failure kept
`errorMessageUserFacing: true`, and this writer's provider text or raw exception
would then render under that earlier provenance. It now says `false` explicitly,
and its comment says why rather than claiming the flag "stays unset".

The delivery-failure service's docstring gains the fallback line: the flag is
stated, not defaulted, so a writer that omits it is making a claim it cannot make.

Witness: the sync-failure test now asserts the `$set` names the flag, beside the
status and message it already asserted. Reachability is contract-tightening, not a
live disclosure (wren 73858): the only writer of `true` runs on the Telegram and
Slack flip paths, which need a bound `config.chatId`, and no `x`/`instagram` row
can have one.

TASK-131.

* copy(connectors): the two catalogue reasons say what happened and what to do (TASK-131)

The mechanism in this PR is what makes these two strings user-facing: the page now
prints `errorMessage` verbatim whenever a writer declares it readable, and the only
two writers that declare it are the reconciler's constants. Leaving them as
`'install lock expired'` and `'projection missing'` would put the lock lifecycle
vocabulary in front of the person whose connector failed (vera 73913, wren 73914).

- `installableReconciler:61` -> "Setup was interrupted before it finished. Try again."
- `installableReconciler:90` -> "This connector's channel is gone. Retry to rebuild it."

The second is not wren's 73914 wording ("Setup didn't finish in this pod. Try
again."), and the difference is vera 73915's constraint rather than taste: the
page's generic fallback is "Setup didn't finish.", so a flagged reason that reads
as a variation on it makes the evidence pair - and the UI - say the same thing in
two states. Her adjustment clause ("adjust the wording if a string reads wrong in
context") covers this, and the event it names is genuinely different: the connector
existed and its channel record vanished, which is why the row offers Retry. Both
strings stay free of internals - no lock, no projection, no step name.

The copy is pinned where it is produced: the stale-lock sweep's witness now asserts
the exact string, and the missing-projection witness already asserted its own, so
either constant moving is a red test rather than a silent UI change.

Every consumer of both strings was swept, not just the ones with assertions on
them (vera 73915 listed 4 assertions and 5 doc references; the string appears in 13
places):
- tests: 3 fixtures in `installableCatalogService.test.js`, 1 assertion in
  `installableInstallationService.test.js`, 5 sites in `V2ConnectorsPage.test.tsx`
  (the page test now names the reason once as `REASON_CHANNEL_GONE`, so the copy
  lives in one line of that file);
- plans: `d8-phase-2-gate-surface.md` (`:9`, `:36`, `:65` as vera listed, plus
  `:104` and `:117` which also quote the value) and
  `connector-as-installable-app.md` (`:310`, `:423`).

No functional reader of either string exists - neither is a discriminator in a
query or a branch - so this is a pure copy change. Verified: backend 30 tests / 2
suites, frontend 45 tests / 1 suite.

TASK-131.

* docs(evidence): Team-Commonly#1881's before/after pair for a failed connector row (TASK-131)

Captured with `scripts/ui-evidence-shot.mjs` against the harness in
`docs/runbooks/local-ui-render-harness.md`. After side: this branch's worktree
(backend 5050, vite 3000) — `06391f11`'s page plus the working-tree copy commit
that is now `70fcaece`. Before side: `a2913955`, the revision this PR is cut from
(backend 5051, vite 3001). Same database, same token, and the pair for each width
was captured back to back so the row's relative age line does not differ between
the two.

The subject is a catalogue installation in the error state. Two rows, so one frame
carries both flag states:

- Slack, `errorMessageUserFacing: true` -> "This connector's channel is gone.
  Retry to rebuild it." in both revisions (a flagged message is already verbatim;
  this is the "user-facing reason when the flag is set" frame).
- Telegram, `errorMessageUserFacing: false`, `errorMessage` = the raw
  `connect ECONNREFUSED 10.4.4.7:443` -> before: printed in the row (the
  disclosure this PR fixes); after: "Setup didn't finish."

`diff` of the two `document.body.innerText` dumps at each width is that one line
and nothing else, which is why the `.txt` pair ships beside the PNGs — a raster is
the illustration, the text is the evidence:

    14c14
    < connect ECONNREFUSED 10.4.4.7:443
    ---
    > Setup didn't finish.

Measured, not assumed: the phone width does render the row's line (the `Team-Commonly#1757`
caveat, where `v2.css` hides a row's detail at 390, does not apply here), and both
revisions reported `non-2xx: none` and `console errors: none`.

Harness notes, because they decide whether the frame is reachable at all: the
provider readiness gate renders "Not enabled on this instance." *instead of* the
error state, so the after backend boots with the dummy `TELEGRAM_*` / `SLACK_*` /
`CONNECTOR_SECRET_*` values a local instance needs; the installation rows are
seeded directly (the install route refuses with `provider_not_configured` before
those values exist), and the flagged row's string is the reconciler's own constant,
not a string this harness produced. Source blobs are untouched by this commit.
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