oficina / fichas Public

Design draft: the stepped type designer, describe-it, links and folders

For Paul's sign-off (2026-11-12). Rulings so far: rail; folders; the
assistant drafts and Paul reviews.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev cf6bf745586759f9624a207846d96c7d24dde1b0 parent 0e2e8fd
1 file changed, +212 −0
  • docs/superpowers/specs/2026-11-12-type-designer-design.md +212 −0

CI passed — run details

CI log
=== vet ===
go vet ./...
go vet -tags browser ./internal/fichastest/
=== fmt ===
=== test ===
go test ./...
?   	amadan.net/oficina/fichas/cmd/fichas	[no test files]
ok  	amadan.net/oficina/fichas/internal/fichas	2.008s
?   	amadan.net/oficina/fichas/internal/fichas/icons	[no test files]
ok  	amadan.net/oficina/fichas/internal/fichas/seal	0.019s
ok  	amadan.net/oficina/fichas/internal/fichastest	1.174s
?   	amadan.net/oficina/fichas/scripts/mockups	[no test files]
?   	amadan.net/oficina/fichas/scripts/preview	[no test files]
?   	amadan.net/oficina/fichas/scripts/writeestilo	[no test files]
=== migration-check ===
go tool rastrillo migration check
rastrillo migration check: models and migrations agree
diff --git a/docs/superpowers/specs/2026-11-12-type-designer-design.md b/docs/superpowers/specs/2026-11-12-type-designer-design.md
new file mode 100644
index 0000000..d978b0a
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-12-type-designer-design.md
@@ -0,0 +1,212 @@
+# Fichas: building a data model — the stepped type designer, "describe it", links and folders
+
+Status: draft 1, 2026-11-12, for Paul's sign-off before anything is built.
+Builds on the base spec, `2026-09-19-fichas-design.md`; nothing here changes its sealing rules.
+
+## Why
+
+Paul, 2026-11-12, after a full UX review of Fichas:
+
+> The new type flow should be step by step and be really easy to create a rich data model ... maybe we also offer the ability to type what you need and have a TensorX model (Deepseek?) create what's required? e.g. "I need a way to track all the products I'm working on". And should there be a way to group different "tables" together?
+
+Today a new type is one form with two questions (singular and plural names). It lands on a fields table with one row and no next step. Every type shares one icon. There is no way to relate one type to another, so a "rich" model cannot be built at all.
+
+## Rulings already made
+
+| # | Question | Ruling (Paul, 2026-11-12) |
+|---|---|---|
+| R1 | The frame | The rail stays (Bar was rejected). |
+| R2 | How types are grouped | **Folders.** Each type is in at most one group. The rail shows group headings you can collapse. |
+| R3 | What the assistant may do | **It drafts and you review.** Its draft opens in the stepped flow, and nothing exists until you press Create. |
+
+## What this adds, in the order it would be built
+
+1. **Folders and icons.** The rail lists types under groups, each type with its own icon.
+2. **The stepped designer.** Each step is a page with its own URL, and every step works with scripts off.
+3. **Links.** A new field kind, "Link to …", points at a card of another type. The card it points at shows what links to it.
+4. **"Describe what you need".** DeepSeek V4 on TensorX writes a draft from one sentence, and the draft opens in step 2.
+
+Steps 1 and 2 are useful without the other two. Step 4 is much better once step 3 exists, because most real models need a link: Products ↔ Customers, Releases → Products.
+
+## 1. Folders and icons
+
+### Model
+
+- A new table, `type_groups`, with these columns:
+ - `id`;
+ - `key`, opaque, like `g_` + hex;
+ - `sealed_label`;
+ - `ordinal`;
+ - timestamps.
+- Labels are sealed, as type labels are (§4.2): there is no DDL and no plaintext vocabulary.
+- A new nullable column, `card_types.group_id`. A type with no group sits at the top of the rail, above the folders.
+- A new column, `card_types.icon`, holding a Lucide slug from a curated list of about 40.
+ - It is plaintext, because it is structural and not the user's words: the slug is chosen from our own list, never typed.
+ - Built-ins: Customers is `users` and Call log is `phone`.
+- Every change is logged in `events` with an actor, as every schema change is (§5). This covers creating, renaming, reordering and deleting a group, and moving a type between groups.
+
+### Rail
+
+```
+Fichas
+ [icon] Customers
+ ▾ Sales
+ [icon] Deals
+ [icon] Quotes
+ ▾ Products
+ [icon] Products
+ [icon] Releases
+ ─────
+ + New type
+```
+
+- A group heading is a `<details>` element, so it collapses with no script.
+ - Its open state is remembered per person, in a cookie, as the list's density is.
+ - A heading holding the current type is always open.
+- "New type" moves out of the list of types. It becomes a quieter row below a separator. (UX review: a creation action was styled as a navigation item.)
+- Groups are managed at `/groups`: rename, reorder (move up and down with submit buttons, no dragging), and delete.
+ - Deleting a group keeps its types, which move to the top. It has its own confirm page.
+- A type's own settings gain "Group" and "Icon".
+
+## 2. The stepped designer
+
+Every step is a server-rendered page at its own URL, with Back, a progress line ("Step 2 of 4") and the busy rule. In-progress work lives in a **draft**, so a reload, Back, a phone going to sleep or a script being off loses nothing.
+
+### Draft
+
+- A new table, `type_drafts`, with these columns:
+ - `id`;
+ - `member_id`;
+ - `sealed_payload`: a JSON document, sealed under a new purpose, `draft.payload`;
+ - `created_at`;
+ - `updated_at`.
+- One person can have several drafts. A draft is private to the person who made it, and is deleted on Create or Discard, or after 14 days.
+- The payload is a **model**: one or more types, the links between them, and an optional new group. The assistant writes this same structure, so "describe it" and "start from a template" both feed the same steps.
+
+### Step 1 — Start (`/types/new`)
+
+There are three ways in, as three large cards:
+
+- **Describe what you need.** A textarea: "What do you want to keep track of?", with examples underneath. This card appears only when the assistant is configured (see §4).
+- **Start from a template.** Five templates:
+ - **People:** name, email, phone, organisation, role, notes;
+ - **Organisations:** name, web address, email, phone, stage, next action, notes;
+ - **Projects:** name, status, owner, start, due, notes;
+ - **Products:** name, status, category, price, launch date, notes;
+ - **Things:** name, category, date, number, notes.
+- **Start blank.** Just a name.
+
+### Step 2 — Name and look (`/types/drafts/{id}/name`)
+
+- **Singular** ("Product") and **plural** ("Products"). The plural is filled in from a simple rule, and you can edit it.
+- **Icon**: a grid of the curated icons, as radio buttons, so it works with no script.
+- **Group**: "None", an existing group, or "New group…" with a name field.
+- **A one-line description**, shown in the type's empty state.
+
+In a draft with several types, this step and the next show one type at a time, with tabs across the top: Products | Releases.
+
+### Step 3 — Fields (`/types/drafts/{id}/fields`)
+
+One editable list, not one page per field.
+
+- **Each row holds:**
+ - a label;
+ - a kind: Text, Long text, Number, Date, Choice, Email, Phone, Web address, or **Link to…**;
+ - **Required**;
+ - optional **help text**, shown under the input on the card form;
+ - for a Choice, the options, one per line, each with an optional tone (the colour of its pill);
+ - for a Link, the type it points at, and whether it holds one card or several.
+- **Add a field** is a submit button that redraws the page with one more row. **Remove** and **Move up / Move down** on each row are submit buttons too. No dragging is needed, though a script may add it later.
+- **The title field** is fixed first, marked as the card's name, and always required.
+- **Findability** follows the kind (`DefaultTier`, shipping in feat/ux-fixes). It shows as one quiet line, with an Advanced override.
+- **Sections** ("Contact", "Pipeline") can be named between rows. On the card form they become headed groups. (UX review: the forms were "seven identical full-width boxes".)
+
+### Step 4 — Status and card (`/types/drafts/{id}/card`)
+
+- **Status**: which Choice field (if any) is the status, shown as the pill on the card and in the table.
+- **Card face**: up to three fields shown on the cards view, with a live sample card built from the field labels. A new type has no real cards to preview yet; the review showed the empty preview.
+- **Default sort** for the list: newest first, or by a field.
+
+### Step 5 — Review and create (`/types/drafts/{id}/review`)
+
+- A summary of every type in the draft: fields, links, status, face and group.
+- One sentence states once what cannot be changed later: a field's kind.
+- **Create** makes everything in one transaction, with every row logged as an event. It lands on the first type's empty list, whose first action is "Add a product".
+- **Discard** has its own confirm page.
+
+### Afterwards
+
+The fields page that exists today becomes the same Step 3 editor, working on the live type instead of on a draft. Ordering, required, help text and sections can then be changed at any time; a kind still cannot.
+
+## 3. Links ("Link to …")
+
+`KindRef` and a `Ref` table already exist, for references to other suite apps (§9). A link between Fichas cards is a new, separate kind, **`link`**, so that the existing rules for `ref` stay as they are.
+
+- **Value**: the target card's id, or ids for a field that holds several. It is sealed like any value (tier `sealed`; never `print`, because a print would publish who links to whom).
+- **Index**: the in-memory index (index.go) resolves each id to the target's title and builds **backlinks**. Card titles are already open in the index; the event log feeds it as it feeds everything else.
+- **Input**: a select listing the target type's cards by title, which works with scripts off. `select.js` makes it searchable, as rastrillo's searchable select already does. A type with more than about 200 cards needs a search-as-you-type picker, which is a progressive enhancement over a plain "search, then pick" page.
+- **On the card**: the value is a chip that links to the target card. The target card gets a **"Linked here"** section: "3 Products link to this customer", listed by title.
+- **In the table**: the linked card's title, which is sortable and filterable.
+- **Deleting a target**: the card is soft-deleted, as every card is (cards are never hard-deleted). The link stays and shows "deleted card". Nothing cascades.
+- **Field kind is permanent** (as for every kind). The target type cannot change once the field exists.
+
+## 4. "Describe what you need"
+
+### What it does
+
+The person types a sentence: "I need a way to track all the products I'm working on". The assistant returns a **model**, the same structure a draft holds, and Fichas opens it at step 2.
+
+For that example, a good answer would be:
+- a group called Products;
+- a type Product with name, status (Idea, Designing, Building, Launched, Retired), category, owner, price, launch date and notes;
+- possibly a second type, Release, with a link to Product.
+
+The person edits the draft. Nothing exists until they press Create (R3).
+
+### Provider and model
+
+- **Provider:** TensorX, which is zero data retention and treated as local (Paul, 2026-09-19).
+- **Client:** reuse Slides' client, `internal/slides/assist/provider.go`, which has the base URL pinned and no way to point it elsewhere in production.
+- **Model:** `deepseek/deepseek-v4-flash-0731`. It is fast, and a draft should come back in a few seconds. Seapointish and Slides use the same identifier.
+ - If Flash's drafts are thin, the same call can use `deepseek/deepseek-v4-pro-0813` instead. That is one setting.
+- **Configuration:** off unless `FICHAS_TENSORX_KEY` is set on the app. Without it the "Describe" card is simply not offered.
+
+### What is sent
+
+- The person's sentence, up to 1,000 characters.
+- The names of the person's existing types and groups, with their field labels, so the draft can link to an existing type ("Products used by which Customers?").
+- **Never any card values**, and never anything from another person's drafts.
+- No suite data (memoria, Docs and the rest) is involved.
+
+### What comes back, and how it is trusted
+
+The model is asked for JSON that matches a schema. Fichas then treats the answer as **untrusted input**:
+
+- **Validation:** kinds and icons must come from the allowed lists. There are limits:
+ - at most 5 types per draft;
+ - at most 25 fields per type;
+ - at most 30 options per Choice;
+ - name lengths as the forms already enforce.
+ - Anything outside these is dropped, and a note says so: "2 fields were left out".
+- **No actions:** the answer can only ever become a draft. It calls no tools and touches no data. The review step is the person's control.
+- **Failure:** on a timeout (20 seconds), an error or an empty draft, the page says "Couldn't draft that" and offers the templates. The person's sentence is kept.
+- **Log:** one line per call: member, model, duration, outcome, and the number of types and fields. Never the sentence or the answer. One `events` row records that a draft came from the assistant.
+- **Rate limit:** per person, for example 20 drafts an hour.
+
+## Order of work and review
+
+| Slice | Contents | Depends on |
+|---|---|---|
+| A | Folders, icons, the rail, `/groups` | — |
+| B | Drafts and steps 1, 2, 3 and 5 (templates and blank) | A |
+| C | Step 4; the fields editor reused on live types (order, required, help, sections) | B |
+| D | The link kind, backlinks and its picker | B |
+| E | Describe it | B; best after D |
+
+Each slice is its own branch with a Fable review, mock-ups of the new screens in the preview before it is built (Paul, 2026-09-29: "mockups before implementing"), and a deploy.
+
+## Open questions for Paul
+
+1. **Templates.** Are People, Organisations, Projects, Products and Things the right five? Should any be a pair with a link, for example Organisations + People?
+2. **Links in Customers.** Should the built-in Customer type gain anything once links exist, such as a "Contacts" link to People?
+3. **The assistant key.** Should Fichas use its own TensorX key, or the one Seapointish uses? The recommendation is its own key, so usage can be told apart and revoked separately.