Cover transaction rollback, stale state, permissions, cache invalidation, batch deletion, and concurrent writes across all three database drivers.
Reject nil attachment bindings and enforce effective lifecycle policies before memo mutations reach the driver.
The MCP catalog survived the recent API changes because it is derived
from OpenAPI, but three things drifted around it, and fixing them
surfaced a fourth.
- mcp: the adapter built each in-process API request with httptest,
whose fixed peer address (192.0.2.1) overrode the caller's resolved
address on the client-address middleware's second pass. Every
anonymous MCP caller shared one rate-limit bucket. The adapter now
presents the address resolved for the /mcp request as the peer.
- mcp: the full SpaceService is curated as space_* tools. Space and
member updates drop path-bound fields and rely on the gateway's
update-mask inference; accepting and declining an invitation no
longer require an empty body for a body: "*" binding whose only
field comes from the path.
- mcp/evals: answers re-pinned to the current seed (four users,
22 top-level memos, 35 reactions, four spaces) and extended with
space questions.
- store/sqlite: transactions begin IMMEDIATE. Token authentication
records the token's last-used time asynchronously on every request,
and the space drivers read before they write in a deferred
transaction; when the background commit landed in between, SQLite
refused the upgrade with SQLITE_BUSY without consulting the busy
timeout. Roughly half of space creates over MCP failed. Taking the
write lock up front keeps the parent-delete serialization the design
relies on, so the SQLite stale-snapshot test now asserts that a
concurrent delete waits for the open transaction instead.
An active application ADMIN now passes every memo-local authorization
check on named operations: authorship, audience, Space membership and
participation, attachment and reaction ownership. Structural validity
still applies, an archived admin holds no privilege, and collection
listings keep the audience predicate so feeds never surface other users'
private memos.
- core/access: admin bypass in the read policy; CanManageMemo and
CanManageAttachment as the shared author-level predicates.
- store: drivers read the actor's role alongside its lifecycle state in
the mutation transaction; validators accept an admin where they
required the author or a member; shared attachment binding and
removal predicates.
- api: handlers use the shared predicates; admins may place memos in
any existing Space and see a memo's Space by name.
- web: one canManageMemo helper replaces the ad hoc creator checks.
- docs: multi-spaces design revised in place; share RPC comments
updated.
Drop the D1 store driver, its migrations, emulator, design doc, filter
dialect, and test-harness wiring. Memos supports SQLite, MySQL, and
PostgreSQL only.
Bound work an anonymous or low-privilege caller can force:
- Bound thumbnail decoding by declared pixel count before decoding and
remember images that cannot be thumbnailed (over the bound or not
decodable), so a small image declaring billions of pixels is served
as-is instead of decoded on every request. Transient storage read
errors are not remembered. The bound lives in internal/imagelimit and
is shared with EXIF stripping.
- Cap request bodies at 16 MiB for procedures that carry no file bytes;
only inline attachment creation, transcription, and chunked uploads
keep their larger caps.
- Digest over-long submitted usernames before using them as sign-in
limiter keys, add header and idle timeouts to the HTTP server, limit
filter expression size, and cap the SQLite regexp cache.
Close correctness gaps:
- Delete the thumbnail the file server actually writes (.v2.jpeg), its
failure marker, and the legacy name when an attachment is removed.
- Decide EXIF stripping from the sniffed content as well as the declared
type, so a mislabeled JPEG keeps no metadata.
- Revoke every other session when a password changes; an admin reset
revokes all of the target's sessions. Prune expired refresh tokens.
- Enforce the 2 MiB avatar limit the web client already applies.
- Keep S3 object keys unique when the path template has no {uuid}.
- Reject negative attachment page tokens.
- Charge memo archive imports against the write and upload budgets,
charge repeated validate-only plans, discard only attachments an
import actually stored, and refuse archives that declare far more
bytes than they hold.
- Load database-stored attachment bytes only after authorization.
- Remove the unused, unguarded linkmeta.GetImage fetcher.
Frontend: send no referrer when loading external images in memos and
link previews, and drop picture/source from the sanitizer so every
remote image goes through the https-only src rule.
Dependencies: grpc 1.83.1 and x/crypto 0.56.0 for reported advisories.
layout
Review follow-up for the D1 driver.
- LATEST.sql kept two index statements in one paragraph; the bridge
sends a
paragraph as one prepared statement, which D1 refuses. Separate them,
and
join buffered scripts in the sql adapter with a blank line so several
migration files commit over the bridge.
- List lookups by id, uid, and username bound one parameter per value
and
failed above D1's 100-parameter limit for pages larger than 100 rows.
Bind
the whole list as one JSON array through json_each instead, which also
replaces the uid resolution threshold and the chunk-and-resort paths.
- Write-policy validation now returns the memo state it read, and every
policy-checked write guards on exactly that state: memo update, memo
mutation, share creation, and attachment creation, update, and
deletion,
including the expected memo content and attachment bindings. Memo,
user,
and space deletion guard their pre-read row sets on count plus highest
id
so a row swapped for a newer one is caught.
- A 429 is no longer retried; the API rate limit that produces it blocks
the
caller for minutes.
- The reference Worker defaults a null result set to an empty array, and
the
comments claiming a batch never reads its own writes are corrected.
The emulator now judges statement boundaries with sqlite3_complete: a
bridge
entry or a parameterized REST entry holding two statements is refused
with
D1's message, and a parameter-free REST entry runs as a script. New
tests
interpose on the transport to change the database between a method's
reads
and its batch, apply the real schema over both transports, pin the
one-statement rule, and list by 250-entry id lists on every driver.
Calendar day cells drop the printed count and carry activity as a
GitHub-style background instead: four primary-tinted levels keyed to the
same all-time ceiling the sidebar heatmap uses, so a day reads alike in
both. Today and the open day share one 22px rounded badge on the
numeral,
primary for today and a quiet foreground wash for the open day, nested
in
a halo when both coincide. The cell type follows the sidebar row
grammar:
13px on 18px lines from the column axis, weight only for the open day,
and a strip of 36px photo marks under the excerpt.
The floating memo panel gets a popover surface and a new float shadow
token in every theme, and its resize trigger becomes a grip pill that
appears only while the pointer is over the edge strip.
The sidebar was recently tightened onto one grammar: 28px rows on a
shared
rail, two chrome type tokens (13px and 11px), quiet kit controls,
outline
focus, and accent fill reserved for the one thing that is on. The memo
card
and editor still mixed 32px and 24px controls, 12px and 14px chrome
type,
bordered "slab" sections, ring focus, and hand-rolled control looks.
Memo card
- The header is a fixed 24px row; time and creator are 13px, the creator
collapses to one line with a 20px avatar.
- Attachments are part of the memo, not a labelled section: media
renders as
the bare gallery, and audio, files, relations and the location are one
list
of 28px rows whose glyphs sit on the memo's text edge and whose
details sit
on one trailing rail. A file row reveals its download arrow on hover;
an
audio row plays from its slot and opens a small player from its name.
- Relations carry their direction as trailing detail instead of a header
and
tabs. Reactions are pills, since they are tokens on the memo rather
than
controls; your own reaction and the add control take the accent while
on.
- The comment strip is a titled row list with a View all action.
Memo editor
- Every toolbar control is 28px: quiet formatting segments with
aria-pressed,
an outline insert square matching the sidebar's compose control, a
quiet
visibility chip built like the scope pill, a quiet Cancel and a small
Save.
- Attachment, relation and location rows share the metadata row grammar;
their controls overlay the trailing edge on hover so the detail rail
never
moves. The tag autocomplete matches the small dropdown.
The row grammar lives in MetadataSection.tsx with its own helpers (icon
slot,
detail rail, remove control, list container) and stays deliberately
separate
from the sidebar's. Every Lucide glyph in these views draws at stroke
1.8, and
the last ring-based focus sites move to the outline constant.
Pasting an image went through the inline-image path and wrote its
markdown
into the text immediately; the file only surfaced in the attachment list
once that markdown was deleted. A paste carries no placement gesture, so
pasted files now join the attachment list like the + menu's upload, and
the list's own Insert action is how a pasted image becomes inline. Drop
keeps inlining images at the drop point.
The CodeMirror handler reports the gesture as an EditorFileOrigin
through
the single onFiles callback, and MemoEditor owns one ingest function
with a
placement argument that the + menu, paste and drop all share.
createBlobUrl
is memoized so the ingest callback's dependencies hold.
The calendar's day panel and the map's location panel were two
implementations of the same surface: a resizable side panel that reads a
selection of memos as ordinary cards and ends with a quiet row that
becomes the editor in place. Fold both into components/MemoPanel.
MemoPanel is the map's floating, non-modal card generalized: a fixed
card at the end edge from md, a bottom sheet below it, with one
persisted
width shared by every host like the sidebar's. It owns the header, close
control, resize rail, internal scroll, busy lock and the exit-animation
snapshot. The width lives in a custom property on the document root so a
resize drag reflows the page beside the card live and commits once on
release; the panel measures its committed size for hosts that need
numbers. The rail stops short of the card's corners.
The calendar drops its docked aside and its modal mid-tier sheet for the
shared card. At xl the grid gives way to it so every column stays
legible; below xl it floats over the trailing columns; the phone tier
stays inline under the compact grid. The hand-rolled Escape listener
goes, since the dialog handles it.
MemoPanelList is the shared content block with the compose row keyed to
the selection, so a half-written memo never moves days or places.
Panel strings move to common keys; the calendar and map copies are
removed from every locale that carried them.
The primary navigator gained a fifth square with the map page, which
left
the current page's label truncated at the default sidebar width. The
label
now opens through a container query on the row instead of eating
whatever
width is left: below a 230px row the current page stays a filled square
with its tooltip, and above it the whole word shows. Tighter gaps and
lead-
in make the default width the threshold.
Sidebar rows also adopt the kit's outline focus treatment in place of
the
last ring-based one.
Replace the profile's map tab with a /map route (also under Spaces) that
shows every located memo on a Positron vector basemap with clustering,
falling back to raster tiles when the vector style cannot load.
Selecting a pin or a cluster opens a side rail (a bottom sheet on
phones)
with the memos at that place; "Write here" expands into the editor in
place, seeded with the location. Selection and viewport live in the URL.
The sidebar's tag counts are scoped to located memos on this route, and
the editor draft cache now remembers a memo's location.
Add UploadAttachment, a unary RPC that accepts a file in bounded chunks
and streams it to a temp file instead of holding the whole blob in one
request body and in memory. A call carrying a spec starts an upload and
returns an opaque upload_id; later calls carry that id with
write_offset,
data, and finish_write, following the Cloud Storage WriteObject shape.
Retrying the last chunk after a lost response is idempotent, uploads are
bound to their owner, and they expire after 30 minutes of inactivity.
CreateAttachment and the chunked finalize now share one processing
pipeline for motion-photo detection, EXIF stripping, and storage. The
motion-photo detector works over an io.ReaderAt so large JPEGs are never
loaded whole, and the request body cap is a single per-procedure lookup.
The web editor uploads through the new RPC in 2 MiB chunks with bounded
concurrency under the server's per-user limit.
The "all" / "preserve" origin scope existed to decide whether returning
from a memo detail should clear the remembered Space. With the Space now
part of the origin URL itself, nothing branches on it any more; it was only
computed, serialized into router state as fromScope, and threaded through
props as parentScope.
Router state is now just { from }, createMemoNavigationState takes one
argument, and resolveMemoDetailOrigin / resolveMemoParentPage return the
origin page as a string. The archived-memo fallback to /archived stays.
The selected Space used to live in sessionStorage and ride along invisibly
with every collection route. It now lives in the URL: collection pages exist
both globally and beneath /spaces/:spaceUid, and the Space context derives
its scope from the current location.
- Add a Space route branch (Home, Explore, Calendar, Attachments) guarded by
a SpaceRoute that shows loading, unavailable, and retry states.
- Resolve collection routes through one matchPath-based helper built from the
route constants; build Space-scoped paths with buildCollectionPath.
- Fetch the route Space directly, seeded from the switcher list so pages are
not held behind a second round-trip.
- Turn the Space switcher into plain links that preserve the current
collection view and query.
- Drop the remembered-Space machinery: clearSelectedSpace/selectMemos,
the compose-placement policy, routeSupportsCollectionScope, and the
quick-find switchToAll flag are all implied by the URL now.
- Return from memo details to the full origin URL, including its Space.
- Add space.unavailable and space.back-to-memos strings; align the
Azerbaijani catalog with English.