Skip to content

Adding things

Something enters the catalog in one of two ways:

  • A file you hand to xixo is staged, analyzed, and then placed in a resource.
  • A record that a resource already holds gets a reference to where it is. xixo never moves it.

Both ways end in an analysis.

Way in Lands as
POST /uploads a staged file
POST /share a staged file under shared/, a note, a download, or a snapshot
addNote a staged markdown file under notes/
fetchUrl a staged file under downloads/
snapshotUrl, or the resource tool’s snapshot a picture and the text of a page, written to storage
askCatalog a note keyed by the question, answered as described in asking
the resource tool’s keep a reference to one object in a resource, without a sync
a sync a reference for each object in the resource

The routes and mutations need xixo:catalog:write. keep needs xixo:resources:command, and snapshot needs that or xixo:web:keep. See the scopes reference.

A staged file waits in xixo until a resource takes it. xixo holds the bytes with Active Storage, on disk in development and in the service that XIXO_STAGING_SERVICE names in production.

POST /uploads takes a multipart file and an optional path. It answers 202 with the feed id, type, mime type, path, and analysis id before any byte reaches a resource.

  • The mime type comes from the path’s extension. xixo ignores the type the client declared.
  • A path already stored or staged reuses its feed.
  • When the same bytes are already on one of the tenant’s shared resources, or already staged, the file is not staged again. The request answers 200 with duplicate: true, the matching feed_id, and its path or title as twin. The name does not matter. An original that is gone or kept apart does not count.

The request is refused with 422 when no file was sent, when the path is empty after cleaning or longer than 900 bytes, or when no active store accepts that mime type at that size.

addNote refuses an empty body and a body over one megabyte. An untitled note takes its first line as its title.

fetchUrl checks the address, refuses when the tenant has no storage, and starts a fetch run. The download allows 100 MB, four redirects, five seconds to connect, and thirty to read. It fails on any status that is not a success. The file is named from Content-Disposition or the URL’s path, with an extension added from the content type when the name has none. The final URL is kept as the file’s source. See reaching addresses for the address checks.

POST /share takes what a phone’s share sheet sends. Files are staged like uploads. A URL is downloaded when it names a file and the tenant has storage, and otherwise snapshotted through a web resource. With neither, or with only text, xixo keeps a note. See install on a phone.

Placement decides where a staged file is stored. The candidates are the active, shared resources that serve storage, accept the file’s mime type, and allow its size. A file is placed at one of three points in its analysis:

  1. Return. Before the analyzer runs, a file already stored at this path goes back to the same resource, if that resource still accepts it. The steps that described the old bytes run again.
  2. Agent. A file that is still staged is offered to the agent, which may call feed with do: "place", a resource key, and a one-sentence reason.
  3. Default. After the agent, a file that is still staged goes to the default storage if that is a candidate, and otherwise to the first candidate by key. With no candidates, the analysis fails and the file stays staged.

Each placement records a placement step with the resource, the path, who placed it (return, agent, or default), and the reason. When another feed already holds that path, xixo adds the feed’s id to the file name so neither file is overwritten. Once the file is stored, xixo deletes the staged copy.

A snapshot needs a web resource. It renders the page in headless Chrome and stores a PNG and the page’s text under snapshots/, in the storage the web resource names or in the default storage. The window is 1280 pixels wide unless Render width says otherwise. Snapshots skip staging, because a second visit would render a different page. The reference is keyed by the URL without its fragment, and the feed takes the page’s title. See rendering pages for how the browser is locked down.

A web resource’s Watchlist holds addresses to snapshot again on every sync. A page that renders differently becomes a new version of the same item and is analyzed again. An address that fails to render is skipped, and the sync moves on. See watch pages on the web.

A sync records a reference for each object it finds. xixo analyzes the feed only when all of these are true:

  • the reference has not been analyzed since it last changed;
  • no analysis of the feed is still open;
  • no analysis of the feed failed in the last day.

After a failure, xixo waits for the bytes to change or for a day to pass, so a file that breaks the analyzer is not retried on every sync. Synced records already have a place, so xixo never places them. See syncing for how a sync walks a resource.