Skip to content

Move LocalThought setup/sync onto the reflector read path (PlatformReader) - #76

Closed
michielbdejong wants to merge 3 commits into
mainfrom
claude/issue-52-localthought-on-reflector
Closed

michielbdejong wants to merge 3 commits into
mainfrom
claude/issue-52-localthought-on-reflector

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

Closes #52 (last commit; see "Merge order").

What

The WASM describe/fetchRecords/validateConnection bridge is gone from both repos. Per the maintainer's decision on #52, this replaces it on the reflector path instead of restoring it.

  • integrations/localthought/reflector-read.ts (new): reflector's read path ported to the browser, with no imports outside the folder. It covers:

    • resource discovery from crudResources, after reflector's discoverResourceModel;
    • nested collections via identity bindings;
    • the pageNumber/pageToken/nextLink pagination schemes, after syncables/src/pagination;
    • the ontology the removed Rust derive_ontology produced (FetchedPlatform).

    Its only transport is BrowserIntegrations.request(); in reflector the transport is authorizedFetch(). PlatformReader exposes describe/check/read, which is everything the data-browser needs. There is no per-platform code.

  • browser.ts stays transport-only. It adds catalogDocument() (JSON, falling back to .yaml-as-JSON) and catalogSelection(). request() now returns response headers, still without x-connection-code. isLoopbackHost is exported again for the data-browser's pluginCatalogUrl.ts.

  • integration-proxy + mock-proxy serve /catalog/<platform>.json, so the browser needs no YAML parser. The proxy test used to assert that this route 404s; it now asserts it returns the same document.

  • pets e2e: the spec now expects capitalized column names. It was quarantined when schema.ts started capitalizing them (atomic-server 5dc880bf1). The last commit un-quarantines the tier.

  • Docs: the LocalThought section of integrations/README.md, localthought/README.md, integration-proxy/README.md.

Decisions for the maintainer

  • This is a port, not an import, of syncables/reflector. atomic-server only gets integrations/, and the published syncables@0.17.1 entry point imports node:http/node:fs. The alternative is a browser-safe syncables subpath export (e.g. syncables/client). That needs a publish, and publishing is blocked on the Trusted Publisher re-point. The duplication is about 1,100 lines, with provenance in the file header.
  • Not ported: standalone x-crud reads and cross-collection links from the Rust engine. The Web Lock is now held per proxy request rather than for the whole walk. localThoughtSync.ts still locks the whole fetch/map/apply cycle per installation.
  • New .json catalog route. localthought.io needs a redeploy to serve it. Until then only JSON-bodied .yaml documents work, and a YAML-only proxy fails with an explicit error.

Verified

  • vitest (integrations/localthought, 41 tests), tsc -p integrations/localthought/tsconfig.json, oxlint/oxfmt on integrations/, and the tooling node --test suite (43).
  • cargo test + clippy + fmt for integration-proxy.
  • node integrations/tooling/run-lane.mjs pets --tier e2e passed twice (about 5s each). It ran against an atomic-server e2e build of claude/localthought-on-reflector (the companion atomic-server PR), using the recipe from the Follow-ups after the per-plugin CI lane split (#37, #38) #43 handoff.

Not verified: other platforms (google-calendar, clockify, github-issues) end to end. The unit tests only cover their document shapes. I didn't test against live localthought.io either.

Merge order

  1. The atomic-server PR (claude/localthought-on-reflector → feat/plugin-debug).
  2. Bump .atomic-server-ref to that merge.
  3. This PR's last commit (lanes: un-quarantine the pets e2e tier). Before step 2, the pets e2e lane fails at the current pin (50cf5151c). So either land this PR after the bump, or drop that commit and land it with the bump. The first two commits are safe to land at the current pin.

Notion (#68)

Nothing here is pets-specific. A proxy:notion platform would need:

Notion lists databases with POST /v1/search and /v1/databases/{id}/query, with the cursor in the request body. reflector-read.ts is GET-only and puts cursors in the query string, so it would need POST list operations and body-field cursors (request.bodyFields). The read-only Notion Devonian lens (#66) would apply as a projection after read(), the way clockifyProjection does.

🤖 Generated with Claude Code

Michiel de Jong and others added 3 commits September 23, 2026 12:26
The WASM describeIntegration/fetchIntegration bridge is gone from both
repos (atomic-server#1618, this repo's 3640748). So atomic-server's
data-browser had nothing to call for setup (describe), the install-time
access check (validateConnection) or imports (fetchRecords), and the pets
e2e lane was quarantined. Per the maintainer's decision on #52, this moves
those onto the reflector path instead of restoring the bridge.

- integrations/localthought/reflector-read.ts (new): reflector's read
  path ported to the browser, with no imports outside this folder:
  - resource discovery from crudResources, after reflector's
    discoverResourceModel;
  - the pagination-schemes subset (pageNumber, pageToken, nextLink),
    after syncables/src/pagination;
  - the ontology the removed Rust derive_ontology produced, as the
    FetchedPlatform that schema.ts and the data-browser consume.
  Its only transport is BrowserIntegrations.request(); in reflector it is
  authorizedFetch(). PlatformReader exposes describe/check/read, and
  nothing in it is platform-specific. It is a port rather than an import
  because atomic-server only gets integrations/, and the published
  syncables entry point imports node:http and node:fs.
- browser.ts stays transport-only. It adds catalogDocument() (JSON, with a
  .yaml-as-JSON fallback) and catalogSelection(), returns response headers
  from request() for Link pagination (x-connection-code is still withheld),
  and exports isLoopbackHost again, which the data-browser's
  pluginCatalogUrl.ts imports.
- integration-proxy and mock-proxy.mjs serve /catalog/<platform>.json, so
  the browser needs no YAML parser. The proxy test used to assert that this
  route 404s; it now asserts the route returns the same document.
- Docs: integrations/README.md (LocalThought section),
  localthought/README.md, integration-proxy/README.md.

Refs #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The spec was quarantined when localthought/schema.ts started
capitalizing column names (atomic-server 5dc880bf1: `updated_at` ->
`Updated at`), so its datatype check still looked up `age`/`updated at`.
Found by running the lane against the reflector-path build (#52). With
this change it passes twice in a row locally.

Refs #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pets setup dialog works again now that LocalThought setup and sync use
PlatformReader (#52). Against an atomic-server build of
claude/localthought-on-reflector, run-lane.mjs pets --tier e2e passes, twice
in a row.

This needs the atomic-server change merged into feat/plugin-debug and
.atomic-server-ref bumped to it first. At the current pin (50cf5151c), the
data-browser still calls the removed WASM bridge, and this tier fails.

Closes #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michielbdejong

Copy link
Copy Markdown
Contributor Author

Closing along with ontola/atomic-server#1647. The data-browser's LocalThought code is being removed in ontola/atomic-server#1549, so a browser-side PlatformReader copy of syncables isn't needed. #52 is redirected: pets becomes an iframe plugin that bundles syncables (via a browser-safe syncables npm entry point) and proxies through the host. The branch stays for reference; its catalog-JSON route, fixture regex fix and pets spec column-name fix may be salvaged.

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.

Move LocalThought setup/sync onto reflector (pets e2e is blocked until then)

1 participant