@agent-native/core 0.164.12 → 0.164.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/netlify.toml +4 -0
  3. package/corpus/templates/clips/actions/request-transcript.ts +10 -6
  4. package/corpus/templates/content/actions/_database-source-utils.ts +25 -2
  5. package/corpus/templates/content/actions/_database-utils.ts +2 -0
  6. package/corpus/templates/content/actions/_local-folder-source.ts +186 -2
  7. package/corpus/templates/content/actions/connect-local-folder-source.ts +23 -8
  8. package/corpus/templates/content/actions/disconnect-local-folder-source.ts +3 -3
  9. package/corpus/templates/content/actions/resolve-local-folder-conflict.ts +2 -2
  10. package/corpus/templates/content/actions/sync-local-folder-source.ts +130 -12
  11. package/corpus/templates/content/app/components/LocalFolderLiveSync.tsx +77 -0
  12. package/corpus/templates/content/app/components/editor/BubbleToolbar.tsx +298 -3
  13. package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +354 -8
  14. package/corpus/templates/content/app/components/editor/DocumentToolbar.tsx +23 -1
  15. package/corpus/templates/content/app/components/editor/VisualEditor.tsx +81 -1
  16. package/corpus/templates/content/app/components/editor/database/sidebar.tsx +36 -0
  17. package/corpus/templates/content/app/components/editor/extensions/NotionExtensions.tsx +18 -4
  18. package/corpus/templates/content/app/components/editor/local-source-write-state.ts +52 -0
  19. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +244 -6
  20. package/corpus/templates/content/app/components/sidebar/local-source-hierarchy.ts +189 -0
  21. package/corpus/templates/content/app/hooks/use-create-page.ts +26 -4
  22. package/corpus/templates/content/app/hooks/use-documents.ts +83 -0
  23. package/corpus/templates/content/app/i18n-data.ts +239 -0
  24. package/corpus/templates/content/app/lib/desktop-content-files.ts +57 -1
  25. package/corpus/templates/content/app/lib/local-content-source-files.ts +210 -34
  26. package/corpus/templates/content/app/lib/local-folder-live-sync.ts +191 -0
  27. package/corpus/templates/content/app/root.tsx +2 -1
  28. package/corpus/templates/content/app/routes/_app.local-files.tsx +103 -38
  29. package/corpus/templates/content/docs/product/capabilities/content.source.file-folder.md +2 -2
  30. package/corpus/templates/content/docs/product/features/content.feature.bring-your-local-work.md +3 -3
  31. package/corpus/templates/content/docs/product/roadmap.md +2 -2
  32. package/corpus/templates/content/docs/solutions/2026-08-18-colored-text-highlighting-shape.md +693 -0
  33. package/corpus/templates/content/docs/solutions/2026-08-18-content-navigation-coherence-shape.md +482 -0
  34. package/corpus/templates/content/package.json +1 -0
  35. package/corpus/templates/content/shared/api.ts +25 -0
  36. package/corpus/templates/content/shared/nfm.ts +14 -3
  37. package/corpus/templates/factory/AGENTS.md +24 -29
  38. package/corpus/templates/factory/actions/get-slack-feedback-context.ts +8 -28
  39. package/corpus/templates/factory/actions/get-triage-config.ts +1 -0
  40. package/corpus/templates/factory/actions/govern-agent-native-pull-request.ts +67 -59
  41. package/corpus/templates/factory/actions/list-triage-items.ts +6 -1
  42. package/corpus/templates/factory/actions/reconcile-triage-run.ts +7 -1
  43. package/corpus/templates/factory/actions/save-triage-config.ts +27 -7
  44. package/corpus/templates/factory/actions/start-builder-for-item.ts +113 -31
  45. package/corpus/templates/factory/actions/view-screen.ts +12 -0
  46. package/corpus/templates/factory/app/components/factory/FactorySettingsView.tsx +457 -0
  47. package/corpus/templates/factory/app/components/factory/FactoryWorkspaceActions.tsx +53 -0
  48. package/corpus/templates/factory/app/components/layout/Layout.tsx +2 -0
  49. package/corpus/templates/factory/app/components/layout/Sidebar.tsx +3 -1
  50. package/corpus/templates/factory/app/hooks/use-navigation-state.ts +10 -7
  51. package/corpus/templates/factory/app/i18n/en-US.ts +3 -0
  52. package/corpus/templates/factory/app/routes/agents.tsx +22 -1
  53. package/corpus/templates/factory/app/routes/factory-settings.tsx +34 -0
  54. package/corpus/templates/factory/app/routes/factory.tsx +33 -323
  55. package/corpus/templates/factory/server/connectors/slack.ts +62 -0
  56. package/corpus/templates/factory/server/db/schema.ts +1 -0
  57. package/corpus/templates/factory/server/lib/slack-feedback-prompt.ts +30 -0
  58. package/corpus/templates/factory/server/plugins/agent-chat.ts +9 -8
  59. package/corpus/templates/factory/server/plugins/factory-migrations.ts +7 -0
  60. package/corpus/templates/factory/server/plugins/factory-scheduler-job.ts +43 -25
  61. package/corpus/templates/factory/server/triage/ai-services-git.ts +2 -0
  62. package/corpus/templates/factory/server/triage/pr-monitor.ts +2 -1
  63. package/corpus/templates/factory/server/triage/pr-policy.ts +197 -19
  64. package/corpus/templates/factory/server/triage/review-skill-alignment.ts +127 -0
  65. package/corpus/templates/factory/server/triage/slack-client.ts +79 -6
  66. package/dist/app-config/auth.d.ts +4 -0
  67. package/dist/app-config/auth.js +7 -0
  68. package/dist/app-config/schema.d.ts +3 -0
  69. package/dist/app-config/schema.js +2 -0
  70. package/dist/cli/code-agent-executor.js +6 -1
  71. package/dist/cli/code-agent-mcp-config.d.ts +2 -2
  72. package/dist/cli/code-agent-mcp-config.js +34 -9
  73. package/dist/client/MultiTabAssistantChat.js +28 -1
  74. package/dist/client/org/OrgSwitcher.js +8 -4
  75. package/dist/client/use-chat-threads.d.ts +1 -0
  76. package/dist/client/use-chat-threads.js +13 -3
  77. package/dist/collab/awareness.d.ts +2 -2
  78. package/dist/collab/routes.d.ts +1 -1
  79. package/dist/mcp-client/config.d.ts +11 -0
  80. package/dist/mcp-client/config.js +33 -26
  81. package/dist/notifications/routes.d.ts +3 -3
  82. package/dist/observability/routes.d.ts +5 -5
  83. package/dist/progress/routes.d.ts +1 -1
  84. package/dist/resources/handlers.d.ts +2 -2
  85. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  86. package/dist/server/auth.js +17 -3
  87. package/dist/server/realtime-token.d.ts +1 -1
  88. package/dist/server/transcribe-voice.d.ts +1 -1
  89. package/dist/vite/client.js +2 -0
  90. package/package.json +1 -1
@@ -0,0 +1,482 @@
1
+ # Content navigation coherence: ordered cache-boundary repairs
2
+
3
+ ## Summary
4
+
5
+ Four durable reports describe navigation that temporarily disagrees with
6
+ committed Content state: the tree blanks after page creation, an MCP-created
7
+ file does not appear without reload, a deleted page remains briefly, and a new
8
+ pin takes seconds to appear. They are related as user experience, but current
9
+ repository evidence does **not** support one four-symptom implementation lane.
10
+
11
+ Creation, deletion, and cross-surface MCP creation all converge on the complete
12
+ `list-documents` action query that supplies the document tree. Pinning does not:
13
+ the visible Pinned section is rendered from the Favorites system database's
14
+ `get-content-database` query. The current code already contains partial or
15
+ complete-looking repairs for each path, so historical reports cannot establish
16
+ that any particular failure still reproduces on current head.
17
+
18
+ The smallest compatible first slice is therefore one document-list coherence
19
+ lane, beginning with a current-head successful-user-story reproduction matrix.
20
+ It may repair only the first demonstrated failure at the existing query/cache
21
+ ownership boundary. Pinning stays a separately ordered repair after that lane;
22
+ it must not be folded into a generic navigation store or broad invalidation
23
+ helper.
24
+
25
+ ## Durable task cluster
26
+
27
+ - `ab8d5f7f-2fc7-438a-8c63-74a5e1b42b55` — **Fix Content navigation tree
28
+ flicker after page creation**. Two reporter flows and Clips show the entire
29
+ tree disappearing temporarily after creation.
30
+ - `7438346b-c717-4e2f-b581-a90cb2c91ab8` — **Refresh Content navigation after
31
+ MCP-created files**. A reporter says supported MCP creation remains absent
32
+ until reload.
33
+ - `50c4a2d7-2525-4fa3-8260-6ae3e4beb6f7` — **Remove stale Content navigation
34
+ after page deletion**. A reporter Clip shows confirmed deletion leaving a
35
+ stale entry briefly.
36
+ - `a185e193-28fb-4d0d-a014-e79d4ddcb6c3` — **Make Content pinning update the
37
+ sidebar immediately**. The report says pinning takes about three seconds
38
+ while unpinning is nearly immediate.
39
+
40
+ These are historical reporter observations. This Shape did not replay the
41
+ Clips or mutate a live Content runtime, and it does not claim a fresh
42
+ reproduction.
43
+
44
+ ## Product context
45
+
46
+ - Feature: `content.feature.find-your-place-again` (partially implemented).
47
+ - Capability: `content.navigation.sidebar` (approved shape).
48
+ - User workflow: while Content is open, create, externally create, delete, pin,
49
+ or unpin a Page and continue navigating without the sidebar blanking, lagging,
50
+ or presenting stale success.
51
+ - Product contract preserved: the sidebar is a personal navigation projection,
52
+ not object parentage or a second source of truth. Personal pins must not
53
+ reparent Pages or alter Database membership beyond the Favorites reference.
54
+ - Change classification: contract repair if a current-head reproduction fails;
55
+ verification-only closure for any historical symptom that current evidence
56
+ proves already repaired.
57
+
58
+ ## Current architecture and demonstrated callers
59
+
60
+ ### Document-tree projection
61
+
62
+ `DocumentSidebar` calls `useDocuments()`. That hook owns the stable
63
+ `["action", "list-documents", undefined]` query and refuses to return a clipped
64
+ paginated list as complete. The sidebar derives local-file and database trees
65
+ from that one complete document list.
66
+
67
+ Demonstrated callers entering this projection:
68
+
69
+ 1. **Sidebar page creation.** `handleCreatePage` calls the shared
70
+ `create-document` Action. Ordinary SQL creation and local-file creation
71
+ backed by a Files database insert a temporary document into
72
+ `LIST_DOCUMENTS_QUERY_KEY`; direct local-file creation without that
73
+ database waits for write-back before navigation.
74
+ 2. **Sidebar deletion.** `handleDelete` computes the deleted subtree, removes
75
+ those rows from `LIST_DOCUMENTS_QUERY_KEY`, removes per-document queries,
76
+ and chooses a safe remaining route before calling `delete-document` or
77
+ `delete-content-database`. Success and failure both refetch the list; failure
78
+ does not restore a captured list snapshot directly.
79
+ 3. **MCP/tool creation.** Mutating Action execution emits a durable
80
+ action-change marker. Root `useDbSync()` receives action events and the core
81
+ sync hook invalidates active `["action"]` queries, including
82
+ `list-documents`, while preserving a trailing refresh when an older read is
83
+ already in flight. The framework already intends this to be the cross-tab,
84
+ agent, script, and MCP convergence seam.
85
+
86
+ ### Pinned projection
87
+
88
+ `DocumentSidebar` obtains `favoritesDatabaseId` from `list-content-spaces`,
89
+ reads the Pinned section through `useContentDatabaseById(favoritesDatabaseId)`,
90
+ and renders its `ContentDatabaseItem` rows. Pin/unpin calls `update-document`
91
+ with `isFavorite`.
92
+
93
+ `useUpdateDocument` optimistically patches per-document, `list-documents`, and
94
+ every cached `get-content-database` response and restores captured snapshots on
95
+ error. For a Favorites database, setting `isFavorite: false` removes an
96
+ existing row immediately. Setting it to `true` can only patch an item already
97
+ present; it cannot synthesize the missing Favorites membership row. This
98
+ directly predicts the reported asymmetry—unpin is immediate while pin waits for
99
+ the database query to refetch—but remains an inference until reproduced on
100
+ current head.
101
+
102
+ ### Navigation and application state
103
+
104
+ Route selection (`activeDocumentId`, React Router navigation, selected Content
105
+ space, expanded nodes, and persisted sidebar expansion) controls which existing
106
+ projection is open. It does not own document-list membership or Favorites
107
+ membership. No evidence supports moving these four repairs into application
108
+ state or creating a new navigation store.
109
+
110
+ ## Architecture grounding and fit
111
+
112
+ ### Direct evidence
113
+
114
+ - `templates/content/app/components/sidebar/DocumentSidebar.tsx` renders the
115
+ tree from `useDocuments`, optimistically removes deleted subtrees, and renders
116
+ Pinned from the Favorites `get-content-database` response.
117
+ - `templates/content/app/hooks/use-documents.ts` owns the complete-list query,
118
+ document cache patches, optimistic favorite updates, rollback snapshots, and
119
+ explicit document/list/database invalidation.
120
+ - `templates/content/app/hooks/use-content-database.ts` owns database response
121
+ caches and existing optimistic database-item movement.
122
+ - `templates/content/app/hooks/use-db-sync.ts` installs the Content root's core
123
+ database/action synchronization.
124
+ - `packages/core/src/client/use-db-sync.ts`, action routes, CLI runner, and
125
+ production-agent paths establish action-change events as the intended
126
+ cross-surface invalidation seam.
127
+ - The four Bowerbird notes preserve the reporter observations, distinct outcome
128
+ boundaries, and done conditions.
129
+
130
+ ### Inferences to test
131
+
132
+ - The creation report may arise from a loading-state transition or list-cache
133
+ replacement around ordinary SQL creation, but invalidation alone does not
134
+ prove that cause.
135
+ - The deletion report may reflect an older implementation, a refetch race, a
136
+ content-database deletion path, or rollback behavior; current optimistic
137
+ removal means the historical Clip is not current-head proof.
138
+ - MCP visibility should converge through action-change invalidation; if it does
139
+ not, the first missing boundary may be marker publication, delivery/cursor
140
+ replay, event scoping, or the list refetch—not necessarily React Query.
141
+ - Pin latency is likely the absent optimistic Favorites membership row, not the
142
+ document-list query or navigation state.
143
+
144
+ ### Ownership boundaries
145
+
146
+ - Actions and SQL own committed Page and Favorites membership state.
147
+ - `useDocuments` and `LIST_DOCUMENTS_QUERY_KEY` own the complete document-list
148
+ client projection.
149
+ - `get-content-database` caches own Favorites rows and order.
150
+ - Core `useDbSync` plus action-change markers own cross-surface freshness
151
+ signaling; Content may configure or narrowly consume that seam but must not
152
+ add an MCP-only refresh channel.
153
+ - React Router and Content sidebar state own route, selection, and expansion,
154
+ not object membership.
155
+
156
+ ### Legacy contracts that must remain unchanged
157
+
158
+ - `list-documents` exhaustion remains explicit; absent, unreadable, clipped,
159
+ and successfully empty results stay distinguishable.
160
+ - The dedicated `get-document` response remains authoritative for editable
161
+ bodies; list/database snapshots must not seed a body as fresh.
162
+ - Local-file optimistic creation and write-back behavior remain intact.
163
+ - Deletes navigate safely, remove the full subtree, and roll back visibly on
164
+ failure.
165
+ - Pinning remains personal and access-scoped, with truthful persistence,
166
+ rollback, and no Page reparenting.
167
+ - Action-change sync remains generic across browser, MCP, agent, CLI, and other
168
+ supported Action callers; no provider- or MCP-specific twin path is added.
169
+ - Broad bare-action invalidation is not added to high-volume paths that already
170
+ own narrow invalidation.
171
+
172
+ ### Smallest compatible delta
173
+
174
+ First, characterize all three document-list flows against one mounted sidebar
175
+ and the real supported interfaces. If a document-list symptom fails, fix only
176
+ the earliest demonstrated break in the existing Action -> action-change or
177
+ mutation lifecycle -> `LIST_DOCUMENTS_QUERY_KEY` -> derived tree chain. Preserve
178
+ the previous successful list while a replacement read is pending and use exact
179
+ optimistic patch/rollback only where the failing flow requires it.
180
+
181
+ Do not design a generic `navigation-coherence` cache, an application-state copy,
182
+ or a new subscription. Existing ownership is already specific enough.
183
+
184
+ ### Deferred capabilities
185
+
186
+ - Optimistic construction of a new Favorites `ContentDatabaseItem` and its
187
+ exact rollback/reconciliation strategy.
188
+ - Dynamic Recent/Shared sections, generalized personal References, and the
189
+ complete `content.navigation.sidebar` Capability.
190
+ - Session restoration, view-instance state, local-folder watch behavior, and
191
+ provider-source hydration.
192
+ - Refactoring every mutation to a generalized normalized entity cache.
193
+
194
+ ### Reversibility
195
+
196
+ The first slice is restricted to current query keys, mutation callbacks, sync
197
+ configuration, and focused regression coverage. It adds no schema, route,
198
+ protocol, source-of-truth, or product vocabulary and can be reverted without
199
+ data migration.
200
+
201
+ ### Unresolved owner questions
202
+
203
+ None. Current code and product records settle the public boundaries; the
204
+ remaining uncertainty is empirical current-head behavior for Work to establish.
205
+
206
+ ## Implementation-lane decision
207
+
208
+ Use **two separately ordered repair lanes**, not one four-symptom lane:
209
+
210
+ 1. **Document-list coherence lane (first).** Treat creation, deletion, and MCP
211
+ creation as one investigation/proof lane because they share the same rendered
212
+ query boundary. Within it, repair only symptoms that reproduce, in this
213
+ order: creation flicker, deletion success/rollback, then MCP cross-surface
214
+ convergence. One fix may close siblings only when the complete acceptance
215
+ matrix proves that exact shared delta.
216
+ 2. **Favorites membership lane (second).** Shape/implement immediate pin and
217
+ unpin behavior at the Favorites database cache boundary. It may reuse
218
+ existing database-cache helpers, but it is not coupled to the first lane's
219
+ document-list or sync repair and should not delay it.
220
+
221
+ This ordering puts the highest-confidence shared boundary first while avoiding
222
+ a four-task PR whose mechanism and proof surface would be ambiguous.
223
+
224
+ ## Explicit exclusions
225
+
226
+ - No shipping-code edit, dependency, schema, migration, branch operation,
227
+ commit, push, pull request, deployment, feature-flag change, merge, or
228
+ Bowerbird status mutation is authorized by this Shape.
229
+ - No new navigation store, event bus, subscription, raw REST endpoint, or MCP-
230
+ specific refresh action.
231
+ - No redesign of the sidebar, hierarchy, Content spaces, Home, Recent, Shared,
232
+ session restore, or database Views.
233
+ - No claim that historical reports reproduce on current head.
234
+ - No automatic consolidation or completion of the four Bowerbird tasks; Work
235
+ must reconcile each only from exact current proof.
236
+
237
+ ## Successful-user-story acceptance plan
238
+
239
+ Story `content-navigation-document-list-coherence-v1`:
240
+
241
+ > With an existing populated Content sidebar open, a person can create and
242
+ > delete a Page while a supported Content MCP caller can create another Page;
243
+ > throughout those changes the existing tree never blanks, committed additions
244
+ > appear without reload, confirmed deletions disappear immediately with safe
245
+ > navigation, failed deletion restores the prior truthful state, and incomplete
246
+ > reads never masquerade as an empty workspace.
247
+
248
+ Required assertions:
249
+
250
+ 1. Starting from at least two visible Pages, ordinary UI page creation keeps the
251
+ pre-existing rows visible continuously and adds/navigates to exactly one new
252
+ Page after success.
253
+ 2. Failed UI creation restores the exact prior tree and route with an explicit
254
+ error; it leaves no optimistic row or stale page query.
255
+ 3. Supported MCP creation in the same workspace appears in the already-open
256
+ sidebar without manual reload and without duplicate rows.
257
+ 4. A confirmed UI deletion removes the Page and descendants immediately and
258
+ selects a deterministic safe remaining destination.
259
+ 5. A failed deletion restores the exact prior tree and active route and exposes
260
+ the failure instead of presenting deletion success.
261
+ 6. During slow/in-flight replacement reads, the last complete successful list
262
+ stays visible; unavailable, unauthorized, inconsistent-pagination, and
263
+ successfully empty results remain distinct.
264
+ 7. The same flows do not regress local-file creation, per-document body
265
+ authority, access scoping, or full-list pagination.
266
+
267
+ Acceptance policy:
268
+
269
+ - Modality: `real-interface` joined with focused automated regression coverage.
270
+ - Independence: `preferred`.
271
+ - Custody: `same-context-allowed`.
272
+ - Interface: the real Content UI for UI create/delete plus the supported
273
+ Content MCP Action surface for cross-surface creation, against an isolated
274
+ local or branch-preview workspace with task-owned disposable Pages.
275
+ - Rationale: the defect is interaction timing across two real callers, so unit
276
+ tests alone are insufficient. Alice did not require tester-owned independent
277
+ custody; same-context evidence is proportionate, with technical review and
278
+ automated failure/rollback coverage.
279
+
280
+ Work must declare exact disposable Page IDs and baseline tree state before
281
+ mutation, delete every created Page, and prove independent absence before
282
+ acceptance can be satisfied.
283
+
284
+ The second Favorites lane retains its own acceptance story from Bowerbird:
285
+ pin and unpin update immediately, success reconciles to persisted Favorites
286
+ membership, failure restores the prior state with an explicit error, and
287
+ focused plus real-interface coverage exercises both directions. That story is
288
+ not part of the first Work grant.
289
+
290
+ ## Architecture fingerprint — frozen five
291
+
292
+ ```yaml
293
+ authoritySchemaVersion: 3
294
+ stage: shape
295
+ authority-source: >-
296
+ Delegated request from Codex thread 01a00f83-f02d-7b42-9a31-ff18c5a5eded:
297
+ shape the four named Content navigation tasks only; implementation is not
298
+ authorized.
299
+ authorized-scope:
300
+ repositories:
301
+ - /Users/alicemoore/.codex/worktrees/e19d/agent-native
302
+ product-surfaces:
303
+ - Content document-tree navigation
304
+ outcome: >-
305
+ Prove and repair current-head coherence for UI-created, UI-deleted, and
306
+ MCP-created Pages at the existing complete document-list boundary without
307
+ coupling the separate Favorites membership repair.
308
+ allowed-mutations:
309
+ - artifact-write
310
+ write-targets:
311
+ artifacts:
312
+ - templates/content/docs/solutions/2026-08-18-content-navigation-coherence-shape.md
313
+ governing-artifact:
314
+ path: templates/content/docs/solutions/2026-08-18-content-navigation-coherence-shape.md
315
+ revision: shape-v1-2026-08-18
316
+ architecture-fingerprint:
317
+ outcome: >-
318
+ Existing Content navigation remains truthful and continuously usable while
319
+ UI and MCP Page mutations converge through the document-list projection.
320
+ shipping-surfaces:
321
+ - id: content-document-list-navigation
322
+ repository: builderio/agent-native
323
+ product-surface: templates/content document-tree sidebar and Action sync
324
+ constituency: authorized Content users using UI and supported MCP callers
325
+ durable-destination: agent-native origin/main Content template
326
+ integration-action: merge
327
+ governing-architecture: >-
328
+ Actions and SQL remain authoritative; UI-local mutation lifecycles and the
329
+ existing core action-change sync seam converge the complete
330
+ LIST_DOCUMENTS_QUERY_KEY projection, while route/application state owns
331
+ selection only and Favorites remains a separate database projection.
332
+ acceptance-story:
333
+ id: content-navigation-document-list-coherence-v1
334
+ summary: >-
335
+ A populated open sidebar stays visible and converges without reload across
336
+ UI create, UI delete success and rollback, and supported MCP creation.
337
+ required-assertions:
338
+ - UI creation preserves existing rows and adds exactly one committed Page.
339
+ - Creation failure restores the exact prior tree and route.
340
+ - Supported MCP creation appears without reload or duplication.
341
+ - Deletion removes the subtree and selects a safe destination immediately.
342
+ - Deletion failure restores the exact prior tree and active route.
343
+ - Slow, failed, unreadable, clipped, and empty reads remain distinguishable.
344
+ - Local-file behavior, body authority, access scope, and pagination remain intact.
345
+ acceptance-policy:
346
+ modality: real-interface
347
+ independence: preferred
348
+ custody: same-context-allowed
349
+ interface: >-
350
+ Real Content UI plus supported Content MCP Actions in an isolated local
351
+ or branch-preview workspace with declared disposable Pages.
352
+ rationale: >-
353
+ Timing and cross-caller convergence require real interfaces; Alice did
354
+ not make independent tester custody part of the story.
355
+ risk-strategy:
356
+ kind: system-ready
357
+ production-validation-after-merge: false
358
+ architecture-grounding:
359
+ applicability: required
360
+ reason: >-
361
+ The lane crosses Content mutation hooks and the shared framework
362
+ action-change synchronization seam.
363
+ status: grounded
364
+ demonstrated-callers:
365
+ - DocumentSidebar UI create through create-document.
366
+ - DocumentSidebar UI delete through delete-document or delete-content-database.
367
+ - Supported Content MCP/tool create through the same mutating Action surface.
368
+ existing-primitives:
369
+ - useDocuments and LIST_DOCUMENTS_QUERY_KEY complete-list cache.
370
+ - DocumentSidebar optimistic local-file create and subtree delete patches.
371
+ - useUpdateDocument cache snapshots and rollback.
372
+ - core useDbSync action-change invalidation with trailing refresh.
373
+ ownership-boundaries:
374
+ - SQL and Actions own committed objects and memberships.
375
+ - list-documents owns the complete tree projection.
376
+ - get-content-database owns Favorites membership rows.
377
+ - action-change sync owns cross-surface freshness delivery.
378
+ - Router and sidebar state own selection and expansion only.
379
+ legacy-contracts:
380
+ - Complete-list pagination fails loudly rather than returning a clipped success.
381
+ - get-document remains authoritative for editable bodies.
382
+ - Local-file optimistic creation and write-back remain intact.
383
+ - Delete success, rollback, and safe navigation remain truthful.
384
+ - Action-change stays caller-generic and access-scoped.
385
+ shared-vocabulary:
386
+ - document-list projection
387
+ - Favorites membership projection
388
+ - action-change sync seam
389
+ smallest-compatible-delta: >-
390
+ Reproduce the three document-list flows on current head, then repair only
391
+ the earliest demonstrated break inside the existing mutation/action-change
392
+ to LIST_DOCUMENTS_QUERY_KEY chain, preserving the last complete list and
393
+ adding exact rollback where the failed story requires it.
394
+ deferred-capabilities:
395
+ - Immediate optimistic Favorites membership creation and rollback.
396
+ - Full personal References and dynamic sidebar sections.
397
+ - Session restoration, Home, Recent, Shared, and provider/local-source sync.
398
+ reversibility: >-
399
+ No schema or public contract changes; the slice stays within existing query
400
+ keys, mutation callbacks, sync configuration, and regression coverage.
401
+ direct-evidence:
402
+ - templates/content/app/components/sidebar/DocumentSidebar.tsx
403
+ - templates/content/app/hooks/use-documents.ts
404
+ - templates/content/app/hooks/use-content-database.ts
405
+ - templates/content/app/hooks/use-db-sync.ts
406
+ - packages/core/src/client/use-db-sync.ts
407
+ - templates/content/docs/product/capabilities/content.navigation.sidebar.md
408
+ - the four named Bowerbird task notes
409
+ inferences:
410
+ - Pin asymmetry likely comes from inability to add an absent optimistic Favorites row.
411
+ - Historical creation, deletion, and MCP failures may have changed on current head.
412
+ unresolved-owner-questions: []
413
+ delegation-ceiling: []
414
+ product-boundary-gates:
415
+ agent-native-public-constituency: >-
416
+ Content is a public template surface for authorized end users and supported
417
+ MCP callers; the repository evidence names both callers and one shared Action contract.
418
+ bowerbird-product-boundary: >-
419
+ Four existing tasks remain separate durable outcomes; this artifact orders
420
+ their repair and does not mutate or collapse their status.
421
+ acceptance-state:
422
+ status: satisfied
423
+ summary: >-
424
+ Work preserves the complete list-cache shape during optimistic creation,
425
+ removes only the failed creation's temporary Page, and restores exact list
426
+ and document snapshots on failed deletion. Sixty-two focused tests,
427
+ typecheck, all 55 guards, a
428
+ production build, real UI creation/deletion, and open-UI Action refresh are
429
+ green. Every declared disposable Page is independently absent after cleanup.
430
+ blockers: []
431
+ last-land-packet: null
432
+ ledger-revision: content-navigation-coherence-work-v1
433
+ status: review-ready
434
+ ```
435
+
436
+ ## Work evidence — 2026-08-18
437
+
438
+ - Exact branch: `codex/content-navigation-coherence` from
439
+ `origin/main@39383b558b881269a1387d7cfcc94eba8826250b`.
440
+ - Smallest delta: preserve the existing list-cache envelope during optimistic
441
+ creation; remove only the failed creation's temporary Page so concurrent
442
+ creates survive; restore deletion list/per-document snapshots and the exact
443
+ prior URL synchronously on mutation failure; remove the optimistic list query
444
+ when no prior snapshot existed.
445
+ - Cross-surface result: two Action-created Pages appeared in the already-open
446
+ real sidebar without reload or duplication, so no new MCP channel or core
447
+ sync change was necessary.
448
+ - Real UI result: with `nav-baseline-a` and `nav-baseline-b` visible, creating
449
+ `nav-ui-create` kept both baseline rows visible and navigated to exactly one
450
+ new Page. Confirmed deletion removed it immediately and navigated to the
451
+ surviving `Dev's workspace` surface while both baseline rows remained.
452
+ - Automated result: 62 focused Content tests pass, including concurrent and
453
+ absent-list creation rollback, exact prior-URL restoration, complete-list
454
+ pagination, and deleted list/per-document snapshot restoration. The 44
455
+ focused core sync tests also pass.
456
+ - Repository result: Content typecheck, `git diff --check`, all 55 guards, and
457
+ the Content production build pass. The build reports pre-existing doctor and
458
+ local-production-configuration warnings but completes successfully.
459
+ - Review result: an independent read-only review found two rollback holes
460
+ (prior-route restoration and absent-snapshot semantics) plus weak deletion
461
+ coverage; all three were corrected and covered before acceptance.
462
+ - Cleanup receipt: `nav-baseline-a`, `nav-baseline-b`, and
463
+ `thmKsbqMzOAJ` (`nav-ui-create`) were permanently deleted. The open sidebar
464
+ reported zero matching rows, SQLite reported zero matching records, port
465
+ `8086` had no listener after shutdown, and
466
+ `/tmp/content-nav-coherence.CFh4Jg` was moved to Trash.
467
+ - Compute receipt: framework remote preflight could not run because Tailscale
468
+ was stopped, so the supported Mac fallback was used; no remote workload or
469
+ manifest was created.
470
+
471
+ ## Precise Work handoff
472
+
473
+ Invoke:
474
+
475
+ `/work templates/content/docs/solutions/2026-08-18-content-navigation-coherence-shape.md`
476
+
477
+ Work is authorized only after that explicit invocation. It should begin with
478
+ the document-list acceptance matrix, preserve the exact frozen fingerprint,
479
+ and stop rather than absorbing the deferred Favorites lane. When the first lane
480
+ is proven and review-ready, reconcile each of the three document-list Bowerbird
481
+ tasks independently from its evidence; leave the pinning task open for its
482
+ separate ordered repair.
@@ -35,6 +35,7 @@
35
35
  "@tiptap/core": "catalog:",
36
36
  "@tiptap/extension-blockquote": "catalog:",
37
37
  "@tiptap/extension-bubble-menu": "catalog:",
38
+ "@tiptap/extension-code": "3.30.1",
38
39
  "@tiptap/extension-code-block-lowlight": "catalog:",
39
40
  "@tiptap/extension-collaboration": "catalog:",
40
41
  "@tiptap/extension-collaboration-caret": "catalog:",
@@ -612,6 +612,28 @@ export interface ContentDatabaseSourceCapabilities {
612
612
  canUseLocalComponents?: boolean;
613
613
  }
614
614
 
615
+ export interface ContentRepositoryIdentity {
616
+ localId: string;
617
+ providerBinding?: { provider: "github"; repositoryId: string };
618
+ }
619
+
620
+ export interface ContentWorkingCopyIdentity {
621
+ id: string;
622
+ repositoryId?: string;
623
+ kind: "persistent" | "temporary";
624
+ name: string;
625
+ branch?: string;
626
+ commit?: string;
627
+ deviceId: string;
628
+ localOnly: boolean;
629
+ shareable: boolean;
630
+ }
631
+
632
+ export interface ContentLocalSourceIdentity {
633
+ repository?: ContentRepositoryIdentity;
634
+ workingCopy: ContentWorkingCopyIdentity;
635
+ }
636
+
615
637
  export interface ContentDatabaseSourceFieldMapping {
616
638
  id: string;
617
639
  propertyId: string | null;
@@ -782,6 +804,9 @@ export interface ContentDatabaseSource {
782
804
  connectionId?: string | null;
783
805
  connectionLabel?: string | null;
784
806
  truthPolicy?: ContentDatabaseSourceTruthPolicy;
807
+ syncPolicy?: "manual" | "keep_in_sync";
808
+ liveBridgeEnabled?: boolean;
809
+ localIdentity?: ContentLocalSourceIdentity;
785
810
  liveReadConfigured?: boolean;
786
811
  lastReadEntryCount?: number;
787
812
  lastReadMatchedRowCount?: number;
@@ -363,8 +363,13 @@ function serializeInlineNode(node: PMNode): string {
363
363
  const a = span?.attrs || {};
364
364
  const underlined =
365
365
  a.underline === "true" || a.underline === true || plainUnderline;
366
+ const foregroundColor =
367
+ isColor(a.color) && !a.color.endsWith("_bg") ? a.color : null;
368
+ const backgroundColor =
369
+ isColor(a.bgColor) && a.bgColor.endsWith("_bg") ? a.bgColor : null;
366
370
  const attrStr = serializeAttrs([
367
- ["color", a.color || a.bgColor || null],
371
+ ["color", foregroundColor || backgroundColor],
372
+ ["bg_color", foregroundColor ? backgroundColor : null],
368
373
  ["underline", underlined ? "true" : null],
369
374
  ]);
370
375
  if (attrStr) out = `<span${attrStr}>${out}</span>`;
@@ -397,9 +402,15 @@ function addMark(nodes: PMNode[], mark: PMMark): void {
397
402
  function mergeSpanMark(nodes: PMNode[], attrs: Record<string, string>): void {
398
403
  const color = attrs.color;
399
404
  const isBg = color ? color.endsWith("_bg") : false;
405
+ const explicitBackground = attrs.bg_color;
400
406
  const spanAttrs: Record<string, any> = {
401
- color: color && !isBg ? color : null,
402
- bgColor: color && isBg ? color : null,
407
+ color: isColor(color) && !isBg ? color : null,
408
+ bgColor:
409
+ isColor(explicitBackground) && explicitBackground.endsWith("_bg")
410
+ ? explicitBackground
411
+ : isColor(color) && isBg
412
+ ? color
413
+ : null,
403
414
  underline: attrs.underline === "true" ? "true" : null,
404
415
  href: attrs.href || null,
405
416
  attrsJson: "{}",
@@ -21,21 +21,22 @@ decisions, feedback, agent runs, and provider audit records.
21
21
  reconciliation is not success; preserve typed failure or
22
22
  `reconciliation_required` state.
23
23
  - Deduplicate by Factory item and rule/run identity, not provider comment ID.
24
- - Use the generic Slack adapter: clear-bug automations add 👀 and tag
25
- `@builder.io`, ask Builder to run `/address-feedback`, and group repeated
26
- reports into one Builder thread; GitHub/Sentry clear bugs use the Builder run
27
- API. Clips, Design, and Content stay owner-managed outside autonomous
28
- dispatch and PR governance.
29
- - PR governance follows `review-prs`: verify current BuilderIO membership and
30
- the complete diff/review/check evidence, never approve external or
31
- unverified authors, and keep ultra-scary security, auth, tenant-isolation,
32
- secrets, data-loss, execution, payment, and deployment risks manual. The
33
- verified internal-author evidence does not waive ordinary failed or
34
- unresolved checks or feedback; those gates remain required and their exact
35
- states must stay visible. It never waives membership or the ultra-scary
36
- gate.
37
- Product/UX ownership still needs the verified owner, with the documented Sid
38
- exception. Auto-merge also requires a verified Factory Builder run.
24
+ - Slack clear bugs go through `start-builder-for-item` (👀 and a Slack user
25
+ mention for `/address-feedback`); never post Slack messages or `@handles`.
26
+ Group repeats into one Builder thread. GitHub/Sentry use the Builder run
27
+ API. Follow `review-latest-feedback` for full-thread evidence, existing
28
+ reaction and owner checks, answered-clarification priority, one-question
29
+ clarification limits, durable rechecks, and the required `@agent-native`
30
+ disposition after every actionable 👀. Clips, Design, and Content stay
31
+ owner-managed outside autonomous dispatch and PR governance.
32
+ - PR governance follows `review-prs`: verify BuilderIO membership and complete
33
+ diff/review/check evidence; skip drafts/current approvals and never approve
34
+ external authors. Keep ultra-scary security, auth, tenant-isolation,
35
+ secrets, data-loss, execution, payment, and deployment risks manual.
36
+ Verified members may pass ordinary uncertain checks or review feedback, but
37
+ record exact states and never call them clean. Apply the Alice/Content,
38
+ Nick/Slides, Enzo/Factory, Sid/Design, and docs-only exceptions only after
39
+ membership and the ultra-scary gate. Never auto-merge.
39
40
  - Graph edits create immutable blueprint versions. AI proposes with `source=ai`;
40
41
  a person reviews and publishes through the same action surface.
41
42
  - Provider credentials belong to Dispatch/shared workspace integrations, never
@@ -45,10 +46,10 @@ decisions, feedback, agent runs, and provider audit records.
45
46
 
46
47
  ## Application state
47
48
 
48
- - `navigation.view` is `factory` or `agents`; `factoryId`, `factoryTab`,
49
- `factoryAuditRunId`, `factoryNodeId`, and `factoryEdgeId` hold the selected
50
- Factory context. Read `view-screen` before explaining a route, changing the
51
- selected Factory, or answering about the `/agents` inventory.
49
+ - `navigation.view` is `factory`, `agents`, or `factory-settings`.
50
+ Observation settings are workspace-scoped at `/factory-settings`.
51
+ `factoryId`, `factoryTab`, `factoryAuditRunId`, `factoryNodeId`, and
52
+ `factoryEdgeId` hold Factory context. Read `view-screen` first.
52
53
 
53
54
  ## Action contract
54
55
 
@@ -80,17 +81,11 @@ decisions, feedback, agent runs, and provider audit records.
80
81
  | `import-agent` / `import-agent-pack` / `list-agent-pack` | Import profiles or agent packs. |
81
82
  | `start-workspace-app-creation` | Promote an agent and its pack into an app handoff. |
82
83
 
83
- Rules start in shadow mode; hard guards always apply. Organization automations
84
- execute stored prompts, and every external mutation needs a durable run,
85
- idempotency key, and provider confirmation. The legacy observer ends once org
86
- automations are seeded. Use the visual editor for graph changes and agent chat
84
+ Rules start in shadow mode; hard guards apply. Organization automations use
85
+ stored prompts; external mutations require durable, idempotent runs and
86
+ provider confirmation. Use the visual editor for graph changes and agent chat
87
87
  for proposals; persist complete graphs with `save-factory-graph`. Change rules
88
- through triage rule actions, never graph JSON.
89
-
90
- The Slack, GitHub, and Sentry pollers are bounded ingestion adapters for the
91
- legacy default triage queue. They do not define the complete tool surface.
92
- Interactive and scheduled agents may discover additional connected provider or
93
- MCP tools through the shared workspace context.
88
+ through triage actions, never graph JSON.
94
89
 
95
90
  ## Source Changes
96
91