1---2name: architect-calculator3description: Use when an architect-partner project needs sizing or metrics math: understanding the system being sized, locking the mandatory inputs, creating or updating the input constants file, researching unknown constants, writing the human-readable justification, or rendering the final xlsx calculator. Pipeline: understand system -> lock mandatory inputs -> constants file -> research -> constants recursion -> justification -> xlsx render; the workbook is only drawn when every variable is known - math is never invented there.4---56# Architectural calculator - constants-first sizing pipeline78The calculator is the most responsible artifact of the project: its numbers drive hardware and9cost decisions. The math is NEVER invented in the workbook. It is built bottom-up through five10stages; each stage gates the next.1112## Pipeline (user orders 2026-08-25: mini-ERIR sizing session; understand-then-lock first)13140. SYSTEM UNDERSTANDING - first understand the system the calculator is made for. The agent15 states its model of the dataflow and layers (who writes what, in what order) and the user16 corrects it. A wrong mental model invalidates every downstream number - the user's17 correction here is the most valuable input of the whole pipeline. No artifacts.181. MANDATORY INPUTS LOCK - strictly fix the data without which nothing can be computed: the19 base inputs every number traces to (inflow per period, volumes per store, retention,20 ratios). Locked with the user; a missing mandatory input blocks all calculation - it is a21 question, never a filled-in guess.222. CONSTANTS FILE - the single source of truth. A python file holding constants only:23 - ONLY constants. No explanatory comments, no essay text, no argumentation - only group24 header comments (`# TIME`, `# PRODUCTION DATA`, `# RATIOS`). Argumentation lives in25 chat and in the justification stage.26 - No magic numbers: every literal is a named constant (`0.60` -> `S3_FILE_SHARE_OF_INCOME`,27 `6` -> `S3_WINDOW_MONTHS`). A number appears only as the value of a named constant.28 - Measured per-entity data goes in dicts (hashmaps); totals and ratios are COMPUTED from29 them, never re-typed.30 - User's exact variable names are honored. Python forbids identifiers starting with a31 digit (`12MONTH` -> `MONTH12`) - state that to the user, do not silently rename.32 - Derived constants reference their sources and are defined after their dependencies.33 - Dead constants (unreferenced, superseded, `None` placeholders) are removed.343. RESEARCH - fill UNKNOWN constants. Sources: measurements from prod (SQL over partitions,35 MinIO listing, counters), official vendor docs for ratio norms. Every constant gets a36 status argued in chat: measured / user-given / derived / assumption.374. CONSTANTS RECURSION - research results update the constants file; new gaps surface; loop38 until every constant that matters has a value. Two or three passes is the normal state,39 not a failure. This is where the pipeline spends most of its time.405. JUSTIFICATION - human-readable text (Telegram message, doc) drawn FROM the constants:41 every number in the text traces to a named constant. The user owns the wording; the agent42 proposes phrasing, the user edits the file. The agent NEVER full-rewrites a user-edited43 file - targeted edits only, re-read first.446. XLSX RENDER - only when every variable is known and the math is locked (stage 5 done).45 The workbook RENDERS the locked computation; it adds no math of its own.4647## HARD GATE - the workbook4849- Not started until stage 4 is done and the user has named the desired final cells.50- ALL math is prototyped as a throwaway python script in /tmp and cross-checked by a second,51 independent computation before any xlsx exists.52- xlsx formulas carry the locked constants' values; no magic numbers in formulas.53- Delivery gate: `check.py` AND `check_usage.py` AND `unwind.py` all pass, and the54 justification text's numbers match the constants (extract-and-compare).55- Nothing beyond the user's named blocks: no helper cells, no decorative text, no own56 constants block inside the workbook.5758## HARD rules (from the mini-ERIR session)5960- Units: binary (TiB = 2^40) and decimal (TB = 10^12) are different scales - name the scale61 in the variable name or state it. A TiB/TB mix is a ~10% error that survives every check62 because it is consistent.63- Replication and erasure coding are explicit named multipliers, applied per system64 according to its architecture:65 - Kafka: replication factor multiplies disk (each segment stored N times).66 - MinIO: erasure coding multiplies physical disk; the ratio is measured from the prod67 topology and does NOT transfer to a different topology.68 - ClickHouse replicas SERVE queries: disk, RAM and CPU all multiply by replica count.69 - Greenplum mirrors do NOT serve queries: disk multiplies, CPU and RAM do not.70- A number in a variable cell is measured, user-given, or derived from those - never an71 invented "realistic" value. An assumption enters only with the user's ok and is flagged in72 the justification text.73- The user edits artifacts themselves; agent edits are targeted (`edit`), never a full-file74 rewrite of a file the user touched.75- Vocabulary is locked by the user's accepted terms; introducing a synonym (e.g. "зеркала"76 instead of the user's "репликация") is a defect.7778## Scripts7980Absolute paths (all relative to this sub-skill's directory `calculator/`):8182| Script | Purpose |83|---|---|84| `~/.omp/agent/managed-skills/architect-partner/calculator/scripts/create.py` | Build the skeleton workbook from the locked spec with the palette (new books only; never re-run on an existing book). |85| `~/.omp/agent/managed-skills/architect-partner/calculator/scripts/check.py` | Evaluate every formula, fail on any error value (#N/A, #ERR, dangling references). |86| `~/.omp/agent/managed-skills/architect-partner/calculator/scripts/check_usage.py` | Fail on any numeric variable cell referenced by no formula (literals exempt; passive-by-design pass via --allow and are named in the delivery note). |87| `~/.omp/agent/managed-skills/architect-partner/calculator/scripts/unwind.py` | Print the full computation tree (label, formula, value) of final cells; no args = all true finals. |8889## Failure modes9091| Symptom | Cause | Fix |92|---|---|---|93| User's cleanup clobbered | Full-file rewrite over a user-edited file | Targeted edits only; re-read before every edit |94| Calculator built for the wrong system | Agent's mental model of the dataflow never checked | Stage 0: state the model, let the user correct it before any math |95| Numbers computed with a mandatory input missing | Calculation started before the input lock | Stage 1: lock base inputs first; a missing input is a question |96| Constants file carries essays | Argumentation written into the file | Only group headers; argumentation to chat |97| Magic numbers in formulas | No naming discipline | Every literal a named constant |98| Workbook math differs from constants | Math invented in the xlsx | Render only; prototype and cross-check in /tmp first |99| Everything ~10% off | TiB and TB mixed consistently | Name the scale; keep one everywhere |100| CPU/RAM doubled wrongly | Replication semantics not thought through | Per system: who serves queries (CH replicas yes, GP mirrors no) |101| Dead numeric variables after model change | Nothing re-checks usage | check_usage.py in the delivery gate |102| Constant used before defined | Import-order error | Define dependencies first; verify in a fresh python process |103104## Current state105106| Date | Note |107|---|---|108| 2026-08-25 | Rewritten from scratch after the mini-ERIR sizing session. The old project-specific workbook spec (parquet/codec/compression chains, fixed sheet order) is removed; the skill now encodes the constants-first pipeline (0-5) and the constants-file discipline. Scripts and the delivery gate are kept. |109110## Session mistakes111112- 2026-08-25: presented a dataflow with wrong layer shares (treated ФХ as the source of everything, ignored the highload -> Kafka -> ФХ -> ETL -> ODS Cloudberry -> DS -> CH chain); the user corrected it ("ты не понимаешь архитектуру"). Prevention: stage 0 - state the dataflow model first and get the user's correction before any percentage.113- 2026-08-25: full-file rewrite of message.txt clobbered the user's cleanup (Kafka/MinIO lines); he had to re-fix. Prevention: targeted edits only on user-edited files.114- 2026-08-25: formal-language pass changed word order and register beyond the asked orthography ("Пускай"->"Пусть", "прод"->"продакшена", "софт"->"ПО"); user reverted. Prevention: fix exactly what was asked, list the rest as options.115- 2026-08-25: introduced "зеркала" where the user's term is "репликация". Prevention: lock vocabulary from the user's accepted terms.116- 2026-08-25: constants referenced before definition; an eval kernel cached a stale module. Prevention: define dependencies first; verify with a fresh python process.117- 2026-08-25: Cloudberry segments initially computed from the mirrored disk, doubling CPU/RAM wrongly; mirrors do not serve queries. Prevention: replication semantics per system before writing formulas.