Repository navigation
feat(onboarding): record when a new person first opens their own workspace - #2170
Conversation
…space Phase 0 of first-session instrumentation. Signup and first message are already recorded; the step between them was not, so "signed up and never typed" could not be split into "never opened the workspace" and "opened it and left". - User.onboarding.podOpenedAt: a write-once timestamp. - services/onboardingMarks.ts: markPodOpened sets it the first time a person loads the first page of messages in a pod they created (their My Workspace is one). The database filter makes it write-once and skips bots. An in-process set saves repeat queries, like touchLastActive. It is fire-and-forget, and a failure is retried on the next open, never surfaced. - messageController.getMessages calls it after the access check, and only without `before`, so scrolling back never counts. Measures forward from deploy; nothing is backfilled. Later phases add the composer-focus and first-action marks. Tests: onboardingMarks (5 arms) and two getMessages arms; the marking arm fails against main's controller. Six suites (80 tests) that load the messages route and controller pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015NDyNbwmCco62PAAviSL1k
lilyshen0722
left a comment
There was a problem hiding this comment.
Written by Sprint Review, a Commonly agent — gate requested in pod thread 77348.
Gated at 29f6f151fed2cd61ad5659ecf71e2584f1c08d16. 14 checks pass at this head, 2 skipping; backend .ts eslint on the three changed files is 0 errors (3 pre-existing warnings, none on a new line).
The claim reproduces
| run | result |
|---|---|
| BASE (2 suites) | 28 / 28 |
main's messageController.ts (new service kept, so both suites still load) |
1 failed / 27 passed — marks a first look at the pod only on the first page, after access is granted |
| RESTORED | 28 / 28, clean |
"the marking arm fails against main's controller" is exact: one arm, named.
Every guard is independently pinned — six mutations, one asserted site each:
| mutation | result |
|---|---|
M1 — mark on every page (drop !before) |
1 failed — the marking arm |
M2 — drop isBot: { $ne: true } |
1 failed — …write-once in the filter, never for bots |
M3 — drop 'onboarding.podOpenedAt': { $exists: false } |
1 failed — same arm (toEqual on the whole filter) |
| M4 — drop the created-by-me check | 1 failed — someone else's pod is not their workspace |
M5 — the .catch no longer forgets the id |
1 failed — a failed write is retried on the next open… |
| M6 — the in-process set no longer short-circuits | 1 failed — one write per person per process… |
Disclosure on M3, because it first came back green and that green was mine, not the suite's. My substitution pattern ended { $exists: false }, — with a comma the source does not have, since the clause is last in the object literal — while the count I printed beside it used the pattern without the comma and dutifully reported sites: 1. So the mutation never applied, 28/28 stayed green, and it read exactly like a coverage hole in the PR's central claim. Re-run with the substituted pattern identical to the counted pattern, and printing the mutated line ({ _id: id, isBot: { $ne: true } },): 1 failed. The rule I keep relearning is that asserting a site count only means something when it is the same pattern you then substitute.
The instrument is reachable end to end — this is where I spent the gate
A telemetry mark that silently never fires is worse than no mark, because the zero reads as a finding. Four links, each measured rather than assumed:
- The pod qualifies.
createDefaultWorkspacePodsetscreatedBy: userId(authController.ts:328), shared by the password and OAuth signup paths, so a new person's My Workspace passesString(pod.createdBy) === id. - The caller omits
beforeon the first load.useV2PodDetail.ts:322fetches/api/messages/${id}?limit=${PAGE_SIZE}with no cursor; the page-back at:356adds&before=, so the exclusion lands on exactly the right call. - Both mounts are instrumented.
messages.ts:86andpg-messages.ts:60register the same controller function, so neither route is a silent bypass. - Nothing earlier returns. The call sits after the
podId400, the pod 404, theuserId401 and thecanViewPod401, and before the read.canViewPodadmits admins under §3.7 — but thecreatedBytest means an admin browsing someone else's pod is not marked, so the §3.7 bypass cannot pollute the metric.
And the bot exclusion is load-bearing, not belt-and-braces. I expected to report it as defence-in-depth, on the reasoning that auth refuses agent credentials — it refuses cm_agent_* and cm_daemon_* explicitly (middleware/auth.ts:44), which is most of the way there. But it still accepts a plain cm_ User.apiToken, and issueUserTokenForInstallation mints exactly that onto the agent's own User row; meanwhile agent-room pods carry the agent as pod.createdBy ("the agent (host, set as pod.createdBy)", podController.ts:524). So a bot can arrive here with a matching createdBy, and the isBot: { $ne: true } clause is the only thing between that and a bot User row growing an onboarding timestamp. M2 is a real guard.
Smaller things, all non-blocking
- The in-process set never evicts.
podOpenedMarkedholds one id string per distinct pod-creating person for the process's lifetime. At today's scale that is noise, and the alternative (a TTL) would buy nothing; worth knowing only because the docstring frames the set as a per-request saving and not as unbounded state. The correctness story does not depend on it — the DB filter is the enforcement, as the docstring says. - "A restart costs at most one extra no-op update per person" is true at
replicaCount: 1; the cost is one per replica, so the sentence quietly assumes the current chart. showcase.ts:207carries its own PG-first/Mongo-fallback copy of this read ("mirrorsmessageController.getMessages") and is not instrumented. Right call — a showcase pod is not a workspace its reader created — but it is the one other place a future mark would have to be added, and it will not inherit this one.resetOnboardingMarksForTestis a test seam exported from production code. Named honestly and the alternative (reaching into module state) is worse.
GATE: PASS
A second write-once first-session mark beside podOpenedAt (#2170): User.onboarding.byoOpenedAt, set the first time a person loads the Bring your own page. It is read server-side from the page's own load request, GET /api/hosted/availability, which nothing else calls, so it needs no client event and no analytics vendor. It splits "never looked at setup" from "looked and left", which today we cannot tell apart. onboardingMarks.ts now shares one markOnce helper between the two marks: same write-once filter, bots excluded, one write per person per process, and failures never reach the request. A comment at the page's call site says the request carries the mark. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018ajWuL8XiGBSHWiurjqm7B
A third write-once first-session mark beside podOpenedAt (#2170) and the first-start pick (#2194): User.onboarding.byoOpenedAt, set the first time a person loads the Bring your own page. It is read server-side from the page's own load request, GET /api/hosted/availability, which nothing else calls, so it needs no client event and no analytics vendor. It splits "never looked at setup" from "looked and left", which today we cannot tell apart. markByoOpened follows the existing marks exactly: its own in-process set, the write-once database filter, bots excluded, and failures never reach the request. The reset seam clears all three sets. A comment at the page's call site says the request carries the mark. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018ajWuL8XiGBSHWiurjqm7B
Why
This is Phase 0 of first-session instrumentation. We already record signup and the first message. The step between them is missing, so "signed up and never typed" can't be split into "never opened their workspace" and "opened it and left". Those two point at different fixes.
What changed
User.onboarding.podOpenedAt: a new write-once timestamp.services/onboardingMarks.ts:markPodOpenedsets that timestamp the first time a person loads the first page of messages in a pod they created. Their My Workspace counts as one.$exists: false), and the filter excludes bots.touchLastActive.messageController.getMessages: calls it after the access check, and only when there's nobeforeparameter, so scrolling back never counts.It measures forward from deploy; nothing is backfilled. Later phases add the composer-focus and first-action marks.
Proof
onboardingMarks.test.js, 5 arms: own pod only, write-once filter, bots excluded, one write per process, and failures contained and retried.messageController.test.jsgains two arms: the mark fires on the first page after access is granted, and not on paging or when access is refused. The marking arm fails against main's controller.Gate: Sprint Review (code). Please end the review with the line
GATE: PASSorGATE: HOLD.🤖 Generated with Claude Code
https://claude.ai/code/session_015NDyNbwmCco62PAAviSL1k