oliver-zehentleitner / maity

web+hub: the Why view merges the Keep the Why children into the graph (project setting, default on)

Sign in to report

tsk-13scv14k4yg4 Review

Owner decision (req-y1zb7awnyjmd, 2026-11-12): a switch in the project settings, default on.

Today the hub already reads the whole family (root plus children, keep-the-why:children, docs/api.md §11.3), and GET …/keep-the-why returns members. The web Why view (web/js/ktw-host.js, exportState) loads only the root export, so entries from hub/, cli/ and web/ are missing from the graph, the lists and the counts.

Goal:

  • With the switch on, the Why view shows the entries of every member that loaded, in one graph, with links between members kept. Each entry shows which member it comes from.
  • A member with an error (as members[].error reports it) does not break the view. The view says which members are missing and why.
  • With the switch off, the view behaves as today (root only).
  • The switch is a project setting, default on for existing and new projects. Contract first: docs/api.md (setting, default, who may change it) and the §16.11 lists in the same PR as the hub change.

Order (one PR each, review via vuur):

  1. Contract (docs/api.md).
  2. Hub: the setting, migration (revision id ≤ 32 chars; ask vuur for a migration slot first), guard tests (per_human_tables, web shapes, web check).
  3. Web: settings checkbox and the merged graph. Docs in docs/humans.md in the same PR.

Out of scope here: children in other repositories. Today the hub follows only relative directories below the file that lists them; anything else shows location_not_followed. That needs its own design and card.

Check first: does the vendored Keep the Why views library accept a merged export, or does it need one state per member? Post the finding as a note before PR 1.

Notes

  1. An agent · Nov 12, 2026, 15:25 UTC

    Step 0 finding (library check), worktree head `2112575a2`, vendored KTW dashboard 0.11.45

    Short answer: the library already accepts one merged family state. The host has to build it.

    • ktw-core.js:553-584 mergeStates(groups) (exported at :1181) turns [{member, state}] (self first) into one state with merged: true and family: [...]. A member's topic files and entry ids get its name as prefix (hub/stack.md#…). Each topic and entry carries project (null for self), origin (its group), localId and localFile. Authors and findings are summed.
    • The views read a merged state: ktw-pages.js:159-160 shows the overview's family banner with counts per member, :344 links to an entry's own repository via origin, :421 shows the member on the entry's details, and ktw-timeline.js:546 prefixes lanes with project.
    • The graph has no member layer of its own: ktw-graph.js:352-376 assemble(topics, entries) keys nodes as t:<file> and e:<id>, so it works on the merged lists as they are. See and Superseded-by links resolve by uuid (:365 through ktw-core.js:503-534 linkFamily), so links between members are kept.
    • The host today: web/js/ktw-host.js:166-180 exportState and :277-303 makeHost build the scene and graph from the root export alone (:294, :302-303). T.findEntry (:327-329) searches x.state.entries only. The family module (ktw-family.js:79-123 publicTree/publicTreeFrom, host mode export) already walks project.children through exportState(canonical, root). It returns {groups, missing:[{member, reason}]} (:124), but only search and the family page use it.

    Node probe (vm loading core, ui, scene and graph from the worktree; script kept at /workspace/ktw-probe/probe.mjs on my box):

    • Root and hub both have stack.md#use-postgres (a collision before the merge). After mergeStates the ids are stack.md#use-postgres and hub/stack.md#use-postgres, and the topics are stack.md and hub/stack.md.
    • assemble on the merged lists gives the edges e:stack.md#use-postgres -see-> e:hub/stack.md#use-postgres and t:stack.md -xtopic-> t:hub/stack.md, so the cross-member link is kept.
    • Caveat 1: when two members carry the same uuid, linkFamily's byUuid keeps the last one silently. The See resolved to web/….
    • Caveat 2: mergeStates copies the entries. Bodies filled into a member state after the merge do not reach the copies (the member has "late body", the merged copy ""). The bodies must be loaded before merging, as ktw-family.js:82 does.
    • Caveat 3: two members with the same member.name get the same prefix, and their ids collide (hub/stack.md#use-postgres twice).

    What the web PR needs (no library change):

    1. With the setting on, get groups from family.pool()/publicTree() (or from GET …/keep-the-why members[].path and exportState("", path)). Await family.bodies() per group, then K.core.mergeStates, then pass the result to scene.create({state: merged, self: rootState, scope: "family"}). Graph, lists and counts then follow.
    2. Prefix with a unique member key: the hub's members[].path (unique, "" for the root) or name plus de-dup, not the free name.
    3. List missing and members[].error reasons in the view, beside the banner. A failed member is simply not in groups.
    4. Have findEntry and entry routes look up merged.entries by uuid. A uuid that repeats across members is ambiguous: first wins, and the view flags it.
    5. With the setting off, keep today's path (root only).

    The hub reads need nothing new: §11.3 and §11.5 already serve every member export (?root=<path>). PR 2 is the setting only.

  2. Maity Test Team · Nov 21, 2026, 11:08 UTC

    Tester result (maity-test-team), hub part only (#1698 contract, #1705 hub), deployed hub, main b6d523e6b. PASS.

    • GET /projects/oliver-zehentleitner/maity shows settings.why_merge_children: true. The project never set the key, so this is the default (§6.1).
    • PATCH as an agent (me, member tester), {"settings":{"why_merge_children":true}} → 403 forbidden, reason humans_only ("whether the Why view merges the children is set by a human").
    • The same with null → 403 humans_only.
    • The same with "yes" → invalid, settings.why_merge_children: not_a_boolean. Body validation runs before the agent refusal. That's fine, since nothing is written either way.
    • After the calls, GET still reads true: nothing changed.
    • hub/tests/test_why_merge_children.py on main: 15 passed (local, uv, SQLite).

    Not tested: setting it as a human admin (false, and null restoring the default), and the project_updated event. I can't do that as an agent. Also not tested: the web part (3 of 3), which isn't merged yet, so the dashboard doesn't read the key (as docs/api.md §6.1 says).

  3. Maity Test Team · Nov 28, 2026, 14:14 UTC

    Test (maity-test-team): hub side passes; the web side (PR 3 of 3) is not on main yet, so the card's goal is not testable end to end.

    Hub part: #1705, merged as f142618d0c99567ee7c1bd8eead363449fc744be (contract #1698, fe5f84ac1). Both are ancestors of the 0.1.0a12 release commit 6adc6c8cddcfad3936f3198c02b2b636029ead8e. Prod GET /health: version 0.1.0a12, revision/head 20261124170513_org_link_check.

    Live read-only (GET only, no writes on prod):

    • GET /projects/oliver-zehentleitner/maity: settings.why_merge_children is true on this existing project, which never stored the key. That matches "a missing key reads as true, GET shows it".
    • GET …/keep-the-why: members lists root, hub, cli and web, each with error: null. That is the family the merged view would load.

    Local, at 6adc6c8 (worktree, uv run --python 3.12 --extra dev pytest tests/test_why_merge_children.py): 15 passed in 22.7 s. That covers the default, false stored / null restores it, announcements only on an effective change, no rules_version bump, not_a_boolean for non-booleans, humans_only for agents, and human admins only. I did not repeat these writes on prod.

    Not testable yet:

    • Web (PR 3: settings checkbox, merged graph, per-member origin, missing-member text, docs/humans.md). git grep why_merge_children origin/main -- web/js docs/humans.md finds nothing at 520e84d64, and docs/api.md §11.5 "The family in one view" is still marked Not built. No open or merged PR for PR 3 turned up when I searched for the card id.

    No bug filed: what is built behaves to the contract. The card should stay in review (or go back to in progress) until PR 3 lands.