How the Albatross section docs are generated
This guide is for whoever (Claude or a person) regenerates a file in docs/sections/. Every section doc follows the same template so docs can be compared over time and diffs show real process changes.
Source of truth
- Phoenix MCP (
mcp__Phoenix-MCP__run_query) is a read-only copy of production Albatross. Use it for all docs. - stage-albatross MCP is the staging tenant and can write. Never use it for docs. Never write anything while documenting.
- Only
SELECTis allowed: noWITHclauses (use subqueries), and only thephoenixschema. - Queries live in
tools/queries/. Replace:PBwith the process block id (and edit the scope line in12-controls.sqlas described in its header).
Keeping Phoenix healthy
Phoenix is shared with other users and tools, and heavy queries slow it down for everyone. A query that times out on our side can keep running on the database. Follow these rules every time:
- One at a time. Only one agent or session queries Phoenix at once. Never run Phoenix work in parallel agents; split work across agents only when the extra agents don't touch Phoenix.
- Control history is huge (about 9.4 million rows). Only query
control_historyfor specific control ids and a date range, e.g.where control_id in (660,661) and date_created > now() - interval '30 days'. Never count or scan the whole table. - Other large tables:
project_process_block,project_status_history,communication,email_audit,notification,note, the*_audittables and anything indata_map_1. Always filter these by an id or a recent date range. - Always use
LIMITon exploratory queries (50 or fewer rows), and select only the columns you need. - Reuse what's known. Use counts already in the section docs, or ask the person, before re-counting. Configuration tables (
control,rule,process_block,object_status,field…) are small and safe to query. - If a query times out, don't retry it as is. Narrow it first (fewer ids, shorter date range) or skip it and say the number wasn't checked.
Albatross concepts
| Term | Meaning |
|---|---|
| Project | One customer job. Project types: Residential (object type 6), R&R / Roof (7), Battery Only (23). |
| Process block ("block") | A stage of work on a project, e.g. Deal Review. Has its own statuses, screen sections (fields) and controls. |
| Event | An appointment or task. Block events live under a block (e.g. Site Survey Appointment). Project-level events are tasks such as "Age Verification". |
| Status | Each block/event has statuses. Base status (ACTIVE, ON HOLD, COMPLETE, CANCELED…) is the system meaning. |
| Work queue | A team inbox. Statuses are assigned to queues; each queue has an SLA target in days. A queue row names either one status or a base status (ACTIVE, ON HOLD…), which covers every status of that block or event with that base; other rows filter by project status. 10-block-statuses.sql matches both kinds since 2026-11-16; before that, base-status queues were missed and four docs wrongly said "no queue". |
| Control | A Button (does actions), Banner (shows a message when its condition is true) or Link. Flags: auto = fires on its own when its condition becomes true; timed = evaluated on a schedule; always-on = clickable regardless of condition. An auto control fires once per block; it can't be repeatable. To let it fire again, tick Allow Reset Run Flag (control.allow_reset_triggered) and have another control run Reset Other Control on it. Until 2026-11-12 a reset auto control only fired on a later save; Red Oak fixed it, and it now fires immediately (see ZT-531). |
| When auto controls run | An automatic control is only evaluated (and run, if its condition passes) in two cases: (1) during the nightly cron, if it is also flagged timed; (2) when there is a transaction on the project: data is saved, a control is clicked, and so on. Nothing else wakes it up, so a condition that becomes true without a save on the project (for example a date passing) waits for the next save or, if timed, the nightly run. A control flagged timed but not auto does not run on the cron; it is just a button. Several Install Appointment controls ("SMS - Fresh Install (auto)", "SMS - Work Started (auto)", "No Show Detection (auto)", "Day Of (auto)") were deliberately switched to timed-not-auto because they misbehaved, so they only run when clicked. (Michael Lowry, 2026-11-02.) Exception (ZT-576, 2026-11-10): an auto doesn't fire on a save while its own block is in a COMPLETE base status (for example Permitting at All Permits Approved). Tested on 28349 (COMPLETE: no run) against 25485 (ON HOLD: fired on the first save). An auto whose condition needs a COMPLETE status must go on the completing button, or be Timed. Also, a Set OSC Value value is written as typed: now(), null and true are evaluated, but text keeps any quotes you add. Unconfirmed (ZT-577, 2026-11-10): auto + timed controls may only run on the nightly run, not on a save. Ready to Submit (auto) didn't run on a save even on a fresh block, while an auto-only control fired in the same save. Notify Permitting – On Hold After Submission (auto) behaved the same way (ZT-565). Counter-example (ZT-498, 2026-11-13): the auto + timed Scope Review Already Complete (auto) did fire on ordinary saves within an hour of being built (28736 and 28800, saved by a user), as well as on the nightly run. |
| Condition | Boolean logic over rules. Each rule checks a field, system data (status, state…) or a function. 12-controls.sql expands rule ids into rule descriptions in [brackets]. |
| Rule scope | A rule is either global (rule.origin_process_block_id is null), usable in any control, or local: created on one block (origin_process_block_id set) and usable only there. A local rule can't be reused on another block or one of its events. When a checklist reuses a rule, check its scope; if it's local to another block, tell the admin to create a global copy with the same description. Several rules can share a description, so name the global one. |
| Field placement | A field placed on a screen is an object_section_component (OSC). Rules, "Set field" actions, mirrors, integrations and stored values all point at the OSC, not the field. The admin Move button moves an OSC to another section and keeps its id, so everything keeps working. Adding the field to a section again creates a new, empty OSC that nothing points at. A moved field shows only on project types whose section list includes its new section. Rule descriptions are stored text and may still name the old section. (Michael Lowry, 2026-11-03.) |
| Conditional visibility | object_section_component_rule_group: a rule group on one OSC. Logic type 1 = Visibility (show when true), 2 = Requirement (required when true). Hiding only changes the display; rules and controls still read the value. |
| Read-only / hidden field | object_section_component.readonly and .hidden. Each flag can carry an allow/deny list of positions that can still edit it, set in the field's screen settings. That list isn't visible in Phoenix, so a read-only flag alone doesn't mean nobody can fill the field, and a hidden flag doesn't mean nobody sees it. Hidden fields are usually allowed for the positions that need them (Michael Lowry, 2026-11-03). Don't treat either flag as a finding. Ask, or test with a user in that position. |
| Action | What a button does. 12-controls.sql translates each action into text, e.g. Set block status -> Complete, Create block "Scope Review", Create task "Age Verification", Set field "Clean Sale" = true, SMS "Contract Signed -> Customer" to main-entity, Notify Deal Review Owner "…", Email "…", Send to NetSuite. |
Custom function catalog (as seen in actions): 3 = create project task, 4 = set field value, 17 = close the current event with an outcome status (param 45) and open a new copy of it at another status (param 44), copying the fields listed in param 46, 19 = send to Vivint, 20 = Enphase portal, 21 = send to NetSuite, 22 = send SMS from a template, 23 = in-app/push notification, 24 = populate sales detail, 26 = create block/event and copy fields into it, 27 = send email, 1000 = start resurvey. SMS recipients: main-entity = homeowner, closer = sales rep.
Section doc template
Write one Markdown file per section. Use exactly these headings. Keep the voice plain and specific; write for an ops director who knows the business but not the CRM internals.
# NN · Section name
> Generated from production Albatross configuration (Phoenix) on YYYY-MM-DD. Tables reflect the configuration on that date. Regenerate rather than hand-editing tables; the Overview and Notes may be edited by hand.
**Blocks in this section:** Block A · Block B · …
**Project types:** Residential, Battery Only, R&R (whichever apply)
## Overview
Two to four short paragraphs: what this part of the process is for, which teams/queues work it, how a project enters, the happy path, the main exception paths, and what it hands off to.
## Section flow
One mermaid `flowchart LR` showing how the blocks in this section connect to each other and to blocks in other sections (other sections as `[[Block]]` nodes). Block-level only.
## Block: <Block name>
| | |
|---|---|
| Used on | Residential, Battery Only… |
| Created by | control names and where they live (from 14-block-dependencies) |
| Hands off to | blocks it creates |
| Live projects in this block | sum of live_projects over non-complete statuses |
| Work queues | queue names with SLA |
### Diagram
Mermaid `flowchart LR` at the level of statuses, controls and the key fields that gate them (conventions below).
### Statuses
| Status | Base | Work queue (SLA) | Live projects |
(initial status first, marked "(initial)")
### Controls
Group in this order: **Automatic** (auto), **Timed**, **Buttons**, **Banners**, **Links**. One table per group:
| Control | When it runs / shows | What it does |
"When" is a one-sentence plain-English summary of the condition. Name the key fields and statuses. "What it does" is the action list in plain English, in order.
After the tables add a `<details><summary>Exact conditions</summary>` block listing each control's full expanded condition from the query, so nothing is lost.
### Fields
For each screen section, in display order: a heading line `**Section name**` followed by a compact table:
| Field | Type | Flags |
Mirrors read from another screen are marked "mirror". Controls placed on the screen are listed as "control". Attachments as "attachment".
### Events
Only if the block has events: | Event | Statuses | Controls |. Summarise event-level controls (from 12-controls.sql with the event scope) in a short table as above.
### Dependencies
- **Created by:** …
- **Read by (other blocks' conditions):** …
### Notes
Bullet list of things a reviewer should know: controls that look like tests or are named "test"/"ignore"/"dont touch" but are live, duplicate controls, statuses with no queue, statuses with zero live projects that may be dead, controls with no condition that are always on, hard-coded values (states, financiers, phone numbers), anything inconsistent. Facts only; say "looks like" when inferring.
Diagram conventions (mermaid)
flowchart LR
%% statuses: stadium shape, id S_<n>
S1([Ready for Verification]):::initial
S2([Complete]):::done
%% controls: hexagon, id C_<control id>; prefix ⚡ auto, ⏱ timed, 🔘 button
C202{{"⚡ Deal Review Complete<br/><small>needs: Welcome Call Passed, M0 approved, Closer set, Survey complete</small>"}}
S1 --> C202 --> S2
%% other blocks created: subroutine shape, dashed edge
C202 -.-> B5[["Scope Review"]]
%% side effects: parallelogram
C202 -.-> X1[/"Notify Deal Review Owner"/]
classDef initial fill:#e7f0f9,stroke:#1f6fb2
classDef done fill:#e6f4ec,stroke:#1e8a55
classDef other fill:#f3f5f8,stroke:#8a93a3,stroke-dasharray:3 3
- The status a control moves from comes from rules like
Process Block Object Status EQUAL/IN …on the same block. If a control has no status rule, draw it from anANY((any status))node. - The status it moves to comes from
Set block status ->actions. - Controls with no status change (set fields, SMS, notify) attach with dotted edges from the status where they apply, or from
ANY. - Put at most 4 gating items in the
needs:line; pick the ones a person would recognise (fields, other blocks' statuses, tasks). - Leave banners and links out of the diagram. Leave out controls that look like tests and say so in Notes.
- If a block has more than ~35 nodes, split it into two diagrams (e.g. "main path" and "rejections / exceptions").
- Always quote labels with
"…". Do not use"inside a label (write#quot;instead),<>other than<br/>/<small>, or|inside labels. - Check every file with:
NODE_PATH=/opt/node22/lib/node_modules:/tmp/claude-0/mmd/node_modules MERMAID_JS=/tmp/claude-0/mmd/node_modules/mermaid/dist/mermaid.min.js node tools/check-mermaid.js docs/sections/<file>.md