Map front door + notebook code

Delegated run·Sep 13, 2026  19:29·Prompted by Fable·Run by Sonnet 5Sonnet 5 xhigh
Ctrl + F
Show

Transcript

Fable·19:29:26·Sep 13, 2026Prompter

You are mapping code in the a327ex.com site renderer (Lua on the Anchor engine) at C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer. Read-only. Return CONCLUSIONS with file:line references and exact function names/signatures, not file dumps. Search breadth: very thorough within the files named.

Context: under the opt-in "Reading" theme (site_next in code) the front door at route / is drawn by collections.lua; the notebook (the untitled posts) is built by notebook.lua; the unified feed under the default Dark theme is homepage.lua. Read renderer/REDESIGN.md sections 5 and 6 first for orientation, then the code. The PLAN.md top three sections are implementer notes and may help.

Answer these, each with where-in-code evidence:

  1. FRONT DOOR STRUCTURE (collections.lua, plus its hooks in main.lua): the entry point that builds the front door, how the page is laid out (works column 38% / notebook column 62%), the function that draws it each frame, how it scrolls (is the front door one tall scrolling view? where is the scroll offset kept, who draws the scrollbar), and what state table it keeps. List the top-level functions with one-line purposes.
  2. HOW ENTRY BODIES ARE DRAWN AT AN OFFSET: the front door's notebook column draws the newest entries' whole bodies. Find exactly how an entry's document is built (entry_doc_new in notebook.lua or wherever), laid out to a given width, and drawn at an (x, y) position; how links inside those bodies are hit-tested on click and hover (column coordinates vs screen coordinates; any translate/offset mechanism); whether several documents can be laid out and drawn side by side in one frame today. Name the functions in elements.lua / canvas.lua involved (layout, draw, hit-test), with signatures.
  3. THE ENTRY HEADER + WORK ROWS: the entry header element (gold mono id, date, tags) — which function makes it and what it draws; the typographic cover component (64x96) and the work row drawing in collections.lua — function names, what each row shows (title, kind/year, action link), and how the action link resolves (Read/Steam/Play).
  4. THE CONTINUE BAND: where remembered positions come from (positions.lua / web storage), which function reads them for the band, what an entry looks like (slug, page, label).
  5. THE NOTEBOOK SEQUENCE: how notebook.lua selects entries (untitled flag, from which index), the ordering, the count, what fields an index item has (id number, slug, date, tags, untitled, title), and whether TITLED posts (essays) also carry an id number. Also: what the Dark-theme unified feed in homepage.lua includes (posts + messages? titled + untitled?) so we know what "all posts" would mean.
  6. ROUTING + VIEWS in main.lua: how nav_to_path dispatches / under site_next, how the current view is represented (the view() in site_debug), how the front door receives input (wheel, keys, clicks) — the input dispatch function(s) and how a view registers for them; the mobile breakpoints (widths) and what the front door does below them; the note about main.lua sitting at Lua's 200-local ceiling (where new state gets grouped).
  7. Anything in collections.lua or notebook.lua that is clearly a reusable piece for a "book spread" layout (a component that draws N pages side by side), or clearly an obstacle.

Report format: numbered sections matching the questions; each conclusion followed by file:line; a final "obstacles / surprises" list. Keep it under ~1500 words.

Sonnet 5xhigh·19:29:32·Sep 13, 2026Worked for 6m 1s
Thinking19:29:32

I should look into the renderer directory to see how it's structured.

Bashcd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && ls -la && echo "---RE...19:29:32Output not recorded
Input
cd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && ls -la && echo "---RE...
Bashcd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && wc -l collections.lua...19:29:32Output not recorded
Input
cd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && wc -l collections.lua...
Thinking19:29:37

I should check REDESIGN.md sections 5 and 6 along with the relevant top sections of PLAN.md.

Bashcd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && grep -n "^#" REDESIGN...19:29:38Output not recorded
Input
cd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && grep -n "^#" REDESIGN...
Bashcd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && grep -n "^#" PLAN.md ...19:29:38Output not recorded
Input
cd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && grep -n "^#" PLAN.md ...
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\REDESIGN.md19:29:38Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\REDESIGN.md
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\PLAN.md19:29:38Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\PLAN.md

Now let's dig into the actual code files.

Grep^local function |^function |^collections_|^front_door_|^local FD_|^front_door\b19:29:46Output not recorded
Input
^local function |^function |^collections_|^front_door_|^local FD_|^front_door\b
Grep^local function |^function |^notebook_19:29:46Output not recorded
Input
^local function |^function |^notebook_
Thinking19:29:51

I got matches but not the actual content, so I need to re-run with the content output mode to see the full results.

Grep^local function |^function |^collections_|^front_door_|^local FD_|^front_door\b19:29:51Output not recorded
Input
^local function |^function |^collections_|^front_door_|^local FD_|^front_door\b
Grep^local function |^function |^notebook_19:29:51Output not recorded
Input
^local function |^function |^notebook_

Now let's read the full notebook.lua (it's short) and the key parts of collections.lua.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\notebook.lua19:29:56Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\notebook.lua
Thinking19:30:01

I notice `entry_doc_new` is called from notebook.lua but the comment suggests it's actually defined in homepage.lua for loading and stripping ::solo—I should track down its real definition there. I also need to find where `notebook_entries()` is defined, likely in works.lua or main.lua.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua19:30:01Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua
Grepfunction notebook_entries|function entry_doc_new|function entry_info19:30:01Output not recorded
Input
function notebook_entries|function entry_doc_new|function entry_info

Now let's read the notebook_column, front_items, front_modules, continue_band, entry_header, work_row, draw_cover, and collections_front functions in detail.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua19:30:06Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua19:30:06Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua
Thinking19:30:19

This is helpful — collections_front applies a single shared scroll offset to both columns when drawing, confirming the whole page scrolls together as one view rather than the works and notebook columns scrolling independently. That settles the scroll behavior question and feeds into the side-by-side layout question too.

Now I want to trace where `scroll` actually comes from — who owns that state, who calls collections_front, and where the scrollbar itself gets drawn, since it's likely main.lua holds the scroll variable and routes it in. I should grep main.lua for collections_front, collections_draw, nav_to_path, and any scroll-related state.

Grepcollections_front|collections_draw|collections_enter|collections_invalidate|collections_hot19:30:19Output not recorded
Input
collections_front|collections_draw|collections_enter|collections_invalidate|collections_hot
Grepfunction canvas_layout|function canvas_draw|function canvas_link_at|function canvas_clickable_at|function canvas_hover|function elements_set_band|function elements_band_19:30:19Output not recorded
Input
function canvas_layout|function canvas_draw|function canvas_link_at|function canvas_clickable_at|function canvas_hover|function elements_set_band|function elements_band_
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua19:30:19Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua
Thinking19:30:29

So scroll_y is a single shared global scroll variable used across all views, not a per-view state. I need to track down where it's defined, where the wheel input handler updates it, and where the scrollbar rendering reads it.

Grepscroll_y\s*=|local scroll_y|max_scroll\s*=|local max_scroll19:30:29Output not recorded
Input
scroll_y\s*=|local scroll_y|max_scroll\s*=|local max_scroll
Grepscrollbar|draw_scrollbar|sb_thumb|scroll_thumb19:30:29Output not recorded
Input
scrollbar|draw_scrollbar|sb_thumb|scroll_thumb
Thinking19:30:37

This confirms the scrollbar is a single page-wide right-edge element drawn generically in main.lua, shared across all views via scroll_y/max_scroll — so it's main.lua's generic scrollbar logic, not anything in collections.lua.

Now I want to check how collections_enter sets `kind` around line 1253 and how it interacts with top-level state, so let me look at main.lua around 1240-1290 for the collections_enter/nav dispatch logic and search for `nav_to_path`.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua19:30:37Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua
Grepfunction nav_to_path19:30:37Output not recorded
Input
function nav_to_path
Thinking19:30:42

I notice the notebook uses view='article' rather than 'collection', tying it to reader machinery instead of the front door/collections which use view='home'/'collection'. Now I want to read through nav_to_path in full.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua19:30:42Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua
Thinking19:30:47

I see that `show_home` is where view='home' gets set, so I should check that function along with site_debug.view() to trace this further.

Grepfunction show_home\b|site_debug\s*=|site_debug\.view|function view\(\)|view = function|\.view = function|view =\s*'home'19:30:47Output not recorded
Input
function show_home\b|site_debug\s*=|site_debug\.view|function view\(\)|view = function|\.view = function|view =\s*'home'
Grepsite_debug\s*=\s*\{|^site_debug|SITE_DEBUG19:30:47Output not recorded
Input
site_debug\s*=\s*\{|^site_debug|SITE_DEBUG
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua19:30:47Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua19:30:47Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua
Thinking19:30:58

That covers Q1 and Q6 sufficiently. Next I want to check input dispatch functions for wheel, keys, and clicks, the main update() structure, mobile breakpoints, and that 200-local ceiling note, so I'll search PLAN.md, REDESIGN.md, and main.lua comments for references to "local ceiling" or "200 local".

Grep200.local|local.*ceiling|too many local|local variable limit19:30:58Output not recorded
Input
200.local|local.*ceiling|too many local|local variable limit
Grep200.local|ceiling|local variable limit|too many local19:30:58Output not recorded
Input
200.local|ceiling|local variable limit|too many local
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua19:30:58Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua
Thinking19:31:09

Confirmed the mobile and split breakpoints, and how new shell state gets grouped into tables like NAV, shell, hp rather than new locals, similar to how the CL table groups state in collections.lua. Now I want to trace the wheel-handling code around lines 3106-3260 back to its enclosing function to identify the main input dispatch function.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua19:31:09Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua
Thinking19:31:18

I see now that there's no separate registration system for views—it's all one big update function with conditionals checking the view string throughout. I'm noticing that view=='home' seems to be reused for both the old homepage feed and the new front door, so I need to check whether the front door actually sets view to 'home' too.

Grep^function update|^local function update19:31:18Output not recorded
Input
^function update|^local function update
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua19:31:18Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\main.lua
Thinking19:31:26

I see the update function is one monolithic dispatch with no per-view registration—views are handled through if-checks throughout, which fully answers that question. Now I'm moving to canvas_layout, canvas_draw, canvas_link_at, and canvas_clickable_at, looking at their signatures and how hit testing handles column versus screen coordinates, plus whether multiple documents can be laid out side by side.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\canvas.lua19:31:26Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\canvas.lua
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\canvas.lua19:31:26Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\canvas.lua
Thinking19:31:36

I'm digging into how canvas_link_at and canvas_clickable_at work, and checking how layout_list positions elements — specifically that x/y coordinates get baked in absolutely at layout time, with only the vertical offset applied separately during drawing and hit-testing. This matters for figuring out how multiple documents could be displayed side by side, since the column position would need to be fixed when canvas_layout runs.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\canvas.lua19:31:36Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\canvas.lua
Thinking19:31:53

I've confirmed that canvas_link_at uses the element's x coordinate directly since it's baked in at layout time, only adding the vertical offset oy dynamically. So the horizontal position is fixed by the column_x layout parameter rather than being adjustable at runtime like the vertical offset is.

This differs from reader.lua's page mechanism, which translates the x-axis externally via layer_push around canvas_draw calls (per REDESIGN.md section 5) rather than inside canvas.lua itself. That means multiple docs could theoretically lay out side-by-side using different column_x values, but nothing currently does this — front_items/notebook_column stacks entries in a single vertical queue rather than placing documents side-by-side. I should check reader.lua directly to confirm how it wraps canvas_draw with layer_push for x-translation.

For Q3, I've already found entry_header, draw_cover, and work_row in collections.lua; now I need to check works.lua to see how the action field (Read/Steam/Play) resolves for each work entry.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\works.lua19:31:53Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\works.lua
Grepaction\s*=|action\.label|action\.route|action\.url|work_kind_label|function works_all|function works_by_slug|WORKS\s*=\s*\{" 19:31:53Output not recorded
Input
action\s*=|action\.label|action\.route|action\.url|work_kind_label|function works_all|function works_by_slug|WORKS\s*=\s*\{" 
Thinking19:32:00

I've confirmed the action structure differs for in-app versus external links, resolved through text_link which likely calls hit() and follow() to route based on whether the target starts with '/'. I should check the follow function around line 75 in collections.lua to verify this routing logic.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua19:32:00Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua
Thinking19:32:07

This confirms how Q3's action-link resolution works: internal routes starting with '/' go through go(path), which sets ACT and propagates up through collections_front/collections_draw to main.lua's site_go call, while external URLs open in the browser instead. Now I'm moving to Q4 and checking positions.lua's reader_positions() function.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\positions.lua19:32:07Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\positions.lua
Grepfunction reader_positions|function pos_remember|function pos_save|function pos_load|a327ex_positions19:32:07Output not recorded
Input
function reader_positions|function pos_remember|function pos_save|function pos_load|a327ex_positions
Thinking19:32:16

This confirms positions.lua stores a Lua table keyed by slug, with each record holding element index, line index, page, page count, title, and place label plus timestamp. I trace how continue_items() in collections.lua pulls this via reader_positions(), which wraps pos_load to read either the desktop file or the web storage key.

Now I want to check reader.lua around lines 305-380 for pos_remember, since that's likely what triggers saving positions (probably on reader_leave), to cite where remembered positions actually come from.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\reader.lua19:32:16Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\reader.lua

Now let's look at homepage.lua entry_doc_new, and the untitled feed to compare with notebook selection logic, plus works.lua notebook_entries/entry_info for index item fields.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\homepage.lua19:32:21Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\homepage.lua
Grepfunction works_init|W\.entries|W\.entry\[|untitled|function notebook_entries|function entry_info19:32:21Output not recorded
Input
function works_init|W\.entries|W\.entry\[|untitled|function notebook_entries|function entry_info
Thinking19:32:28

Confirmed entry_doc_new is defined at homepage.lua:380 as the shared loader used by the front door, collections, and notebook — one function serving three consumers, which directly answers how an entry's document gets built. Now I want to check works.lua:240-300 for the full index item fields, id numbering scheme, untitled flag detection, and whether titled posts still get numbered ids.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\works.lua19:32:28Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\works.lua
Thinking19:32:39

This confirms notebook_entries comes from filtering the index for posts, stories, or prototypes marked untitled, preserving the index's original newest-first order when building W.entries.

Each entry record stores slug, id, date, tags, words, and title, with newer/older links determined purely by array position rather than any stored flag. I notice essays (titled posts) don't include an id field in their W.essays row — just slug, title, date, and words — which raises the question of whether titled posts even carry an id in the underlying index data, so I need to check main.lua or the content converter for where `.id` gets assigned.

Grep\.id\s*=|entry_info\(|for i, e in ipairs\(index\)|assign.*id|\bid\s*=\s*i\b19:32:39Output not recorded
Input
\.id\s*=|entry_info\(|for i, e in ipairs\(index\)|assign.*id|\bid\s*=\s*i\b
Grep\bid\b19:32:39Output not recorded
Input
\bid\b
Thinking19:32:48

I see that `e.id` comes straight from the index entries built by the converter rather than being computed in main.lua or works.lua. Now I want to check homepage.lua around lines 480-560 to see how it builds the unified feed model, since that's where I can confirm whether the dark-theme feed includes both messages and posts, titled and untitled alike.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\homepage.lua19:32:48Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\homepage.lua
ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\homepage.lua19:32:48Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\homepage.lua
Thinking19:33:07

This confirms the homepage builds its unified feed from the entire index — every item type (posts, untitled posts/messages, stories, logs) — with the `untitled` flag controlling inline vs row display rather than excluding anything, and each item's id maps directly from `e.id`.

But this raises the question of whether titled posts (essays) actually carry an id in the underlying data, or if that field is only populated for untitled ones. I should check data/index.lua for a titled entry to see if it has an id field.

Bashcd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && grep -n "untitled" to...19:33:07Output not recorded
Input
cd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer" && grep -n "untitled" to...
Bashcd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\data" && head -c 2000 ind...19:33:07Output not recorded
Input
cd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\data" && head -c 2000 ind...
Thinking19:33:13

I see the id field is actually global across the whole index, not just for untitled posts—log entries have ids too. Now I want to check whether titled posts (type=post, not untitled) also carry an id alongside their title.

Bashcd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\data" && grep -o '{sectio...19:33:13Output not recorded
Input
cd "C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\data" && grep -o '{sectio...
Thinking19:33:27

So titled essays also carry an id in the index, meaning ids are shared globally across all item types rather than being exclusive to untitled entries — a solid finding for Q5. Now I'm looking at how works.lua builds the W.essays rows to see how this interacts with that logic.

I want to check the mobile stacking behavior more closely — in narrow non-mobile mode covers appear as a row using larger 140x196 thumbnails, while true mobile stacks the work_row full width. Let me read further into collections.lua, from around line 527 to 560, to nail down this distinction.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua19:33:27Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua
Thinking19:33:37

Below the split breakpoint, covers render in a single row that clips extra items when they overflow the width rather than wrapping — a quirk worth flagging — with the notebook column full-width beneath. On mobile it switches to a full-width stacked row layout instead.

Now I want to check elements.lua for the pick_text_font/pick_text_color functions and canvas.lua's layout_list signature, since Q2 specifically asks for the exact functions and signatures involved in layout, draw, and hit-testing.

Grep^local function layout_list|^function layout_list|^local function layout_el|^function layout_el19:33:37Output not recorded
Input
^local function layout_list|^function layout_list|^local function layout_el|^function layout_el
Grepfunction pick_text_font|function pick_text_color|kind == 'meta'|kind == 'title'|mono = true|current = true19:33:37Output not recorded
Input
function pick_text_font|function pick_text_color|kind == 'meta'|kind == 'title'|mono = true|current = true
Thinking19:33:58

I've traced layout_list as the actual per-element layout recursion invoked by canvas_layout, and identified pick_text_font and pick_text_color as the functions resolving mono/meta/tag/current run styles used by header_el and entry_header.

Checking the "documents side by side" question now — reader.lua's spread rendering is one document split across two windows, not two separate documents, and neither collections.lua nor notebook.lua currently lays out multiple docs side-by-side (front_items stacks them vertically at one x). Mechanically it looks feasible since canvas_layout/canvas_draw/canvas_link_at take explicit column_x/doc parameters with no shared state blocking multiple calls per frame, but this path isn't currently exercised.

Actually, digging into canvas.lua, I find a real obstacle: spoiler_reveal_doc is a module-global overwritten on every canvas_draw call, so drawing doc A then doc B in the same frame leaves it pointing at doc B, meaning a spoiler-reveal click test afterward would target the wrong document for A. That's worth flagging as a genuine blocker for side-by-side multi-doc rendering. I'm also checking elements_set_band/elements_band_hits, reader.lua's page-culling band mechanism which is global rather than per-document — that could conflict for a two-doc spread, but since it's only invoked by reader.lua and not by collections.lua's plain scroll draw, it's likely not relevant here.

Other module-level globals like hover_link look fine since they're per-frame single values, and I confirm main.lua's `doc` singleton used for hit-testing in update() is specific to the article view, not to collections.lua's own per-item hit-testing via canvas_link_at(it.doc, ...), which already works correctly across multiple docs in a vertical list.

So a side-by-side layout should work similarly to the existing precedent of drawing multiple docs in sequence — just need distinct x-offsets per doc's column, since layout already bakes x. The real obstacle remains the spoiler_reveal_doc singleton at line 537, so I should check canvas.lua for any other similar "= doc" module-level assignments before draw functions.

Grep^spoiler_reveal_doc|^local spoiler_reveal_doc|spoiler_reveal_doc\b19:33:58Output not recorded
Input
^spoiler_reveal_doc|^local spoiler_reveal_doc|spoiler_reveal_doc\b
Thinking19:34:09

I've confirmed spoiler_reveal_doc is a genuine global variable, not local, which creates a real singleton-per-frame issue for side-by-side multi-doc rendering—a "reveal all" click in one doc's spoiler would flip the flag based on whichever doc was drawn last that frame.

I also verified the front door's input handling has no formal registration system, just an if/elseif chain baked into the monolithic update and draw functions. I think I have enough material now, though I want to quickly check the collections_invalidate and collections_enter functions to understand the cache invalidation mechanism and what state the front door keeps.

ReadC:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua19:34:09Output not recorded
Input
C:\Users\a327e\Desktop\a327ex\a327ex-site\renderer\collections.lua

I now have thorough coverage of all seven questions. Let me compile the final report.

ccd session: mark_chapter{"title": "Writing final report"}19:34:13Output not recorded
Input
{"title": "Writing final report"}

Front door / notebook / collections map

1. Front door structure

  • Entry point: collections_front(scroll) — collections.lua:483-550. Called from main.lua:3811 only when view == 'home' and prose.treat.next (i.e. Reading theme); the plain-theme view == 'home' branch (main.lua:3818-3822) instead calls homepage_build/homepage_draw. So the front door literally rides the same view state as the old feed homepage, gated by the theme flag — there's no separate view value for it.
  • Layout split: collections.lua:489-512. split = (cssw >= SPLIT_BP) and not mobile with SPLIT_BP = 1024 (collections.lua:35). When split: lw = floor((w-GAP)*0.38), rw = w-GAP-lw, rx = x+lw+GAP — works column 38%, notebook column 62%, GAP = px(32) (collections.lua:34,494-496).
  • Below 1024 (collections.lua:514-549): one column; ≥768 (mobile==false) shows a single row of 140×196 covers (clipped, not wrapped, when it overflows — if cx+cw > x+w then break at collections.lua:532) then the notebook column below; below 768 (mobile) work rows stack full-width, then the notebook column.
  • Scrolling: it is ONE tall scrolling view. Both columns receive the identical oy = -(scroll or 0) (collections.lua:488,498,509,510) — there is no independent per-column scroll. The offset itself is the single global scroll_y local in main.lua:360, shared by every scrolling view (home/collection/article); collections_front(scroll_y) is simply called with it (main.lua:3811). Max extent is written back to the shared max_scroll (main.lua:3813). The scrollbar is not drawn by collections.lua at all — it's the site-wide right-edge bar: scrollbar_geom() (main.lua:2457) + draw at main.lua:3881-3882 and drag/click handling at main.lua:3217-3227, all keyed off the same scroll_y/max_scroll.
  • State table: CL (collections.lua:24-32) — kind, slug (current collection page), chip/cell (experiments/logs filters), hot (clickable-under-cursor flag main.lua reads for the hand cursor, main.lua:3136), fd = {w, items} (front-door notebook-column item cache), ch (per-work chapter-list cache).
  • Top-level functions (one-line purposes), collections.lua:
    • collections_hot() (51) — a clickable is under the cursor this frame.
    • entry_header(rec,x,y,w) (227) — draws a notebook entry's id/date/tags header line.
    • work_row(w0,x,y,w) (258) — one Works-column row (cover, title, meta, action).
    • continue_items() (291) / continue_band(x,y,w,items) (312) — gather and draw the Continue band.
    • front_modules(x,y,w) (351) — Essays/Experiments/AI Logs "newest two" modules.
    • front_items(rx,rw) (418) — cached slice of the newest FRONT_N=60 notebook entries.
    • notebook_column(x,y,w,oy) (429) — draws the notebook column (headers + lazily-built bodies).
    • collections_front(scroll) (483) — builds/draws the whole front door, returns route, bottom.
    • draw_works/draw_work/draw_essays/draw_experiments/draw_logs (564,611,723,764,836) — the five collection pages.
    • collections_enter(kind,slug) (943), collections_kind() (948), collections_draw(scroll) (950), collections_invalidate() (968).

2. How entry bodies are drawn at an offset

  • Building: entry_doc_new(slug) — homepage.lua:380-392. Loads data/<slug>.lua via canvas_load, strips ::solo elements. Comment at homepage.lua:377-379: "GLOBAL because the front door and the notebook (collections.lua / notebook.lua) build the same entries at their own widths — one loader, three consumers."
  • Layout to a width: canvas_layout(doc, column_x, column_w, top_y) — canvas.lua:374-380, which calls layout_list(doc.elements, column_x, w, top_y or 0, nil) (canvas.lua:231 is layout_list's definition). column_x is baked into every element's .x at layout time — there is no runtime x-parameter afterward.
  • Drawing at (x,y): canvas_draw(layer, doc, oy) — canvas.lua:536-539. Only a vertical offset oy is a draw-time parameter; horizontal position comes solely from the .x baked in during layout. notebook_column calls this per entry: canvas_layout(d, x, w, 0) then canvas_draw(ui_layer, it.doc, cs) where cs = y + oy (collections.lua:452,459).
  • Hit-testing: canvas_link_at(doc, oy, px, py) (canvas.lua:732-750) and canvas_clickable_at(doc, oy, px, py) (canvas.lua:638) both compare the mouse's screen px,py directly against el.x (absolute/baked) plus el.y + oy. There is no separate column→screen translate step for x, and oy is the only offset argument — same pattern canvas_code_at, canvas_details_at, canvas_details_body_at use. notebook_column calls canvas_link_at(it.doc, cs, mx, my) with raw mouse coords (collections.lua:465).
  • Contrast with the reader: REDESIGN.md §5 (reader.lua) additionally translates the x axis via layer_push per page and shifts hit-tests by subtracting dx (reader_mouse), because it shows several windows onto one document. Plain canvas.lua has no such x-translate primitive — canvas.lua's oy covers only vertical shift.
  • Side-by-side today: mechanically possible, not exercised. Nothing in canvas_layout/canvas_draw/canvas_link_at/canvas_clickable_at prevents laying out two different docs at two different column_x values and drawing/hit-testing each with its own oy in one frame (notebook_column already loops and lays out/draws multiple different documents per frame today, just stacked vertically at one x, budgeted at budget = 2 new layouts/frame — collections.lua:441,449-457). The one real obstacle: canvas_draw sets a module-global spoiler_reveal_doc = doc (canvas.lua:537, no local) — drawing doc A then doc B in the same frame leaves spoiler_reveal_doc pointing at B, so a spoiler "reveal all" hit-test (canvas.lua:460-462) after both draws would target the wrong document if A also has spoilers.

3. Entry header + work rows

  • Notebook entry header: entry_header(rec,x,y,w) — collections.lua:227-251 (front-door instance) draws the gold-mono #id link (hit+follow to /posts/<slug>), a middot, the date, and truncated tags. The notebook's own paginated-document version is header_el(rec) — notebook.lua:29-41, which returns a text element with runs styled {mono=true, current=true} (id), {meta=true, dim=true} (date), {tag=true, dim=true} (tags) — resolved by pick_text_font/pick_text_color (elements.lua:90,119).
  • Typographic cover: draw_cover(x,y,w,h,title) — collections.lua:171-223. No cover art exists; picks the largest font from {h1,h2,ITEM,UIB,META} that fits the box, falls back to a character-level word-break for narrow covers (the 64×96 work-row size), and draws a centered gold rule under the title. Used at COVER_W,COVER_H = px(64),px(96) in work_row (collections.lua:256,266).
  • Work row: work_row(w0,x,y,w) — collections.lua:258-286. Draws the 64×96 cover, title (truncated), work_kind_label(w0.kind) .. ' / ' .. year, and the action link via text_link(a.label, tx, ty, a.route or a.url) (collections.lua:279). The whole row is also a click target to /works/<slug>, tested with over_rect after the inner action link's own hit() has first refusal (comment collections.lua:261-262).
  • Action resolution (Read/Steam/Play): the work's action field in works.lua is either {label, route} (in-app, e.g. It Follows {label='Read', route='/stories/it_follows'} at works.lua:42, Horse Game/Skyland {label='Play', route='/posts/...'} at works.lua:64,69) or {label, url} (external, e.g. SNKRX/BYTEPATH {label='Steam', url='https://store.steampowered.com/...'} at works.lua:47,52). text_link→hit→follow(url) (collections.lua:75-78) decides: url:sub(1,1)=='/' → go(url) (in-app route, returned as ACT and dispatched by main.lua via site_go); otherwise open_link(url) (external browser).

4. The continue band

  • Source: reader_positions() — reader.lua:376, wrapping pos_load() (reader.lua:311-327), which reads renderer/positions.lua (desktop, gitignored per REDESIGN.md §5) or web_store_get('a327ex_positions') on web. Positions are written by pos_remember() (reader.lua:361-373) on every page turn, debounced by pos_save (reader.lua:329-344, SAVE_DEBOUNCE).
  • Reader for the band: continue_items() — collections.lua:291-305. Iterates reader_positions(), keeps records with v.t (title), sorts newest (ts) first, keeps at most 3.
  • Item shape: {slug, title = v.t, place = v.c (chapter/month label) or nil, page = v.p, pages = v.n, ts}. On disk each record is {e=<element idx>, l=<line idx>, p=<page>, n=<page count>, t=<title>, c=<place label>, ts=<unix time>} (see positions.lua and reader.lua:336-337,369-372). resume_route(slug) (collections.lua:307-310) maps slug=='notebook' → /notebook, else url_for_slug(slug) or /posts/<slug>.

5. The notebook sequence

  • Selection: works_init(index) — works.lua:278-295 — walks the whole index (newest-first) and, for type in {post, story, prototype} with e.untitled truthy, appends {slug, id=e.id, date, tags, words, title} to W.entries (works.lua:283-287); exposed as notebook_entries() (works.lua:184, returns W.entries). Titled posts of type post (not in NOT_ESSAY) instead go into W.essays grouped by year with only {slug, title, date, words} — no id field carried on that row, even though the underlying index item has one (see below).
  • Ordering/count: newest first (index order), REDESIGN.md §6: "182 untitled posts as ONE document"; notebook.lua:47-65 walks notebook_entries() in that order, inserting a month _chapter h1 (works_month_label) whenever rec.date:sub(1,7) changes, and an hr between same-month entries.
  • Index-item fields: from data/index.lua (converter output), every entry — titled or not — carries {section, slug, title, date, untitled(true|nil), words, type, tags, id}, e.g. an untitled post: {..., untitled = true, ..., id = 540} and a titled essay: {slug="what-predicts-indie-success", title="...", ..., id = 454} with no untitled key. So id numbering is global across the whole index (posts, logs, stories) and titled essays DO carry an id number, even though collections.lua's Essays page/module doesn't surface it (works.lua's essay row drops id).
  • Dark-theme unified feed (homepage.lua): homepage_build(index,...) (homepage.lua:522-546) builds feed from the entire index, every section (kind_for(e.section)), with inline = e.untitled or nil deciding whole-body vs title-row rendering (comment homepage.lua:7-19,528-530: "posts, messages, stories and logs are one kind of thing... TITLED = a ROW... UNTITLED = INLINE"). So "all posts" under Dark = every index item (titled essays/logs/stories as rows + untitled posts inline), unfiltered by kind.

6. Routing + views in main.lua

  • nav_to_path(path, push) — main.lua:1296-1339. For /: show_home(np) (1302). For collection paths (COLLECTION_ROUTE table at main.lua:1234-1235, or ^/works/): gated by prose.treat.next — falls back to show_home under any other theme (main.lua:1306); /notebook → show_notebook(np) (rides the reader, view='article', not 'collection' — main.lua:1266-1289); /works/<slug> → show_collection('work', slug, np); the other four → show_collection(COLLECTION_ROUTE[path], nil, np).
  • View representation: a single top-level local view string ('home' | 'collection' | 'article' | 'search' | 'settings' | 'admin' | 'loading'), reported by site_debug.view() → return view, (doc and doc.slug) or active_slug (main.lua:1712); site_debug.state() (main.lua:1740-1745) adds theme/top_nav/collection-kind. Front door and old feed share view=='home', distinguished at draw time only by prose.treat.next (main.lua:3809,3818).
  • Input dispatch: there is no per-view registration mechanism. Everything funnels through one monolithic function update(dt) (main.lua:2612) with if view == 'article' ..., view == 'home' ... branches inline (e.g. wheel routing main.lua:3143-3148, text-selection drag main.lua:3092-3107, cursor affordance including collections_hot() at main.lua:3136, page-scrollbar drag main.lua:3217-3227, keys main.lua:3230-3250). The front door gets input "for free" because it reuses the view=='home' branches.
  • Mobile breakpoints: MOBILE_BP = 768 (CSS px, main.lua:133, compared as width < MOBILE_BP*UI_S in compute_layout, main.lua:176) — below this the top nav collapses to the 44px TOPBAR_H bar + hamburger and content goes full-width (main.lua:179-182). Collections-specific SPLIT_BP = 1024 (collections.lua:35) governs only the front door's two-column vs one-column switch, and is checked in CSS px (cssw, collections.lua:489-490) independent of MOBILE_BP.
  • 200-local ceiling: noted explicitly at main.lua:141-142 ("the main chunk is at Lua's 200-local ceiling, so new shell values ride these instead of taking a slot") next to the NAV table (main.lua:143-168), and again at main.lua:204 for why reader_env() is a global function rather than a local. New state for the redesign is grouped the same way collections.lua does with CL — a single table rather than new top-level locals.

7. Reusable pieces / obstacles for a "book spread" layout

  • Reusable: canvas_layout(doc, column_x, column_w, top_y) / canvas_draw(layer, doc, oy) / canvas_link_at / canvas_clickable_at (all canvas.lua) already take an explicit per-doc x at layout time and an independent per-doc vertical oy at draw/hit-test time, with no shared mutable layout state between docs — this is the load-bearing precedent for a two/N-document side-by-side spread. notebook_column (collections.lua:429-481) is already a working "N documents laid out and drawn per frame, budgeted, cached on it.doc" loop — it would need to place items at different x columns instead of stacking them at one x + increasing y.
  • Reusable: entry_doc_new(slug) (homepage.lua:380) is explicitly the single shared loader for "the front door and the notebook... at their own widths" — safe to call again for a spread's per-page slice.
  • Obstacle: spoiler_reveal_doc global singleton in canvas_draw (canvas.lua:537) — breaks correctness if two different docs with spoilers are drawn in the same frame.
  • Obstacle: front door's shared single scroll_y/oy (collections.lua:488) means both columns — and any new side-by-side column — currently scroll in lockstep; independent per-column/per-page scrolling would need new state outside the shared scroll_y.
  • Obstacle: front_items/CL.fd cache keys only on w (collections.lua:418-427) — a spread with multiple simultaneous widths (e.g. two half-width pages) would collide on that cache key as written.
  • Obstacle: the narrow-viewport cover row (collections.lua:528-542) silently clips overflowing covers (if cx+cw > x+w then break) rather than wrapping/scrolling — a pattern to avoid copying into a spread layout.

Obstacles / surprises

  1. spoiler_reveal_doc is a module-global in canvas.lua, not per-document — a latent bug for any simultaneous multi-doc draw (front door already draws several docs/frame vertically, so this may already be live).
  2. Front door and the old feed homepage share one view=='home' state, branching only on prose.treat.next — there's no dedicated "front door" view value.
  3. The notebook itself does NOT use collections.lua's draw path at all — /notebook sets view='article' and hands a synthetic document to the paginated reader (show_notebook, main.lua:1266-1289); only the front door's preview of notebook entries lives in collections.lua.
  4. Ids are global across the whole content index (titled and untitled), but works.lua's essay-row builder drops the id field, so collections.lua's Essays page can't currently show an essay's id even though the data has one.
  5. The <1024px cover row hard-clips extra works instead of wrapping/scrolling them off-screen.
  6. Horizontal position in canvas.lua is baked in at layout time (no runtime x offset like reader.lua's layer_push), so any spread implementation must re-layout (not just re-draw) a document if its column x changes.
Back to Website Redesign 2

Settings