As of 2026-05-07, margo is still the scaffold generator and interactive
helper for margot-based workflows. The immediate design pressure comes
from private epic-models audits, especially multi-wave LMTP and three-wave
GRF workflows. Public margo notes should describe general workflow
decisions and avoid private study names, local filesystem paths, or
person-specific shorthand.
Current GRF scaffold state:
margo init grfnow generates a sharedsrc/00-preflight.Rlayer.- Generated GRF scripts should fail with clear missing-package messages.
- Generated GRF scripts should not use
qs,here_read_qs(),here_save_qs(), orpacman::p_load(). - Source data import is Arrow-based through
margot::here_read_arrow(), controlled bypaths.source_arrow_nameinstudy.toml. - Saved analysis objects use explicit
margot::here_save()/margot::here_read()calls withpaths.push_mods. - Local user config may contain private machine paths, but public repo defaults and docs should use generic placeholders and should not mention private paths.
- The GRF event-study scaffold has not yet received the same cleanup and
still needs review for
qs,pacman, output contracts, and audit outputs.
Reproducibility track:
- Treat
use_rv = trueas dependency-helper scaffolding, not as a guarantee that a generated project is fully reproducible across R versions, package deletion, system-library state, or local operating-system preferences. - Generated workflows should still expose clear package preflight errors and runnable scripts for users who manage R packages manually.
- Full reproducibility should be a later hardening track. It needs explicit
review of R version pinning,
rig, package-cache repair, system requirements, and recovery from broken local package states. - Do not let analysis generation depend on
rvbeing perfect. The analysis contract should remain visible in the scripts andstudy.toml.
Naming track:
pull_dataandpush_modsare legacymargoconfig names. Keep them backward-compatible for existing projects.- New public notes and future schemas should avoid pull/push language. Prefer direction-neutral directory names that say what the path contains.
- In future
moR functions, prefer snake-case directory-path arguments such assource_data_dir_path,output_dir_path,model_dir_path, andaudit_dir_path. - In future TOML schemas, prefer concise directory keys such as
source_data_dir,output_dir,model_dir, andaudit_dir. - When
margoeventually supports these names, accept both the new and legacy keys for a transition period and write generated files with the new names.
Workflow defaults to preserve:
- Generate sourceable R chunks with clear contracts between scripts.
- Create labels and reusable metadata once, early in the workflow.
- Prefer one canonical analysis data frame over hand-built domain-specific data frames.
- Generate human-readable audit outputs, especially missingness structure and cut-point checks before estimation.
- For GRF manuscripts, make average treatment effect and policy-tree reporting the main path; keep RATE/Qini results in appendices unless explicitly requested.
- For future publication scaffolds, generate a minimal
setup.R,manuscript.qmd, andsupplement.qmdthat read saved model/result objects and regenerate plots rather than saving plot artefacts as workflow state.
Immediate next implementation questions:
- Bring
grf-eventin line with the cleaned GRF scaffold. - Decide whether publication scaffolding is a separate command or an option
attached to
margo init grf. - Add a general study-validation command before investing in a richer TUI.
- Keep LMTP schema work in private workflow notes until the multi-wave realisation is stable enough to make public.
Checklist:
- add policy tree decision points? -- outcomes to reverse? fairness exclusions for policy trees?
- subgroup analyses?
- data checks in separate cli (for lab/ specific to data we use? or general?)
- should we let users compile projects once settings are fixed, and accept harder debugging to reduce coding? (I think not)
- Allow users to choose cut points for continuous vars when creating binary versions. (YES, this is in the script: we might need to reveal histogram for this to make sense? -- suggest it go into the validation cli)
- Plan extensibility for time-varying confounders in the framework (as part of TMLE/lmtp)
- Enable confounders from the same wave as exposure when exposure cannot affect them. (lmtp)
- Add a helper that warns when legacy
paths.pull_dataor future source-data directory fields point at a file instead of a directory. - Add
/vars export-missingto print variables with no metadata description. - Add richer
/varsmetadata support (label,scale,notes) beyond a single description field.
- Keep margo stable and plan a separate margot TUI track using the latest ratatui refactor. (consider a TUI that organizes variables left to right as confounders, exposures, time-varying confounders, time-varying outcomes, and end-of-study outcomes)
- Use a pipeline layout with baseline, exposure, and outcomes tiles moving right to left, maybe...
- For lmtp, show multiple exposure tiles with time-varying confounders on a timeline, although we can do this in a validation toml...
- Use tachyonfx for motion and draw inspiration from tek for crisp borders and typography... pretty and all, but a priority?
- Decide how much animation aids understanding without distracting from selection tasks....prob place anything like this at end -- carrot to stick
- Decide between fixed columns or flowing tiles to keep focus and keyboard navigation clear.
- Decide input style: list, search, or hybrid, and show defaults and overrides.
- Decide how selections write templates while preserving user edits and config preferences.
- Treat
margoas the single interactive editor for measures metadata used by boilerplate report workflows, and avoid new runtime coupling to bptui internals. - Define one canonical interchange schema for measures records (
name,description,reference,waves,keywords,items,standardised,standardised_date,label,scale,notes), with strict field normalisation and stable ordering. - Implement robust import adapters in
margoforboilerplate_unified.json,measures_db.json,measures_db.csv, andvariable_metadata.tsv/csv, preserving unknown fields where possible. - Add write-safe export paths in
margowith transactional save semantics (temp file + atomic replace), backup checkpoints, and deterministic formatting to reduce noisy diffs in git. - Add a
measurecommand group inmargoREPL/CLI for list, find, edit, add, delete, validate, standardise, and bulk operations targeting boilerplate-compatible files. - Add quality and completion utilities in
margo: missing description report, missing core fields report, duplicate name detection, and normalisation warnings before save. - Add schema-aware transforms for R workflows: label mapping generation, scale extraction, and notes/description harmonisation aligned with boilerplate expectations.
- Keep metadata lookup precedence in
/varsas local project files first, then boilerplate, then bptui-compatible sources, with explicit source reporting for traceability. - Migration track: provide a one-time import path from existing bptui JSON files into the canonical margo schema and document bptui deprecation for this workflow.
- Documentation and rollout: publish
margomeasure-workbench usage docs and examples showing end-to-end edit -> save -> boilerplate report generation.
/measure load [path]loads a measures source file (boilerplate_unified.json,measures_db.json,measures_db.csv,variable_metadata.tsv/csv); if omitted, use auto-discovery./measure sourceprints active source file, format, record count, and dirty state./measure list [pattern]lists measures with fuzzy filter and key fields (name, short description, scale/notes indicators)./measure show <name>prints full canonical record including passthrough fields./measure find <query>jumps/selects next matching record for iterative editing./measure add <name>creates a new canonical record scaffold./measure edit <name> <field> <value>updates one field with schema-aware coercion and validation./measure edit-batch <field> <from> <to>applies controlled replacements with preview./measure delete <name>removes one record with confirmation./measure rename <old> <new>renames a measure key while preserving content./measure validateruns completeness and schema checks (missing description, duplicate names, malformed fields)./measure standardiseapplies normalisation rules (trim, case policy, stable field order, scale extraction helpers)./measure export-missing [field]prints measures missing required fields (defaultdescription)./measure backup [label]writes timestamped checkpoint before risky operations./measure save [path]writes deterministic output using atomic replace and backup policy./measure diffshows in-session changes since load to support review before save./measure import-bptui <path>migrates legacy bptui JSON into canonical schema with migration report./measure helpprints command reference and workflow tips.
- Phase 1: schema and storage core.
- Implement canonical
MeasureRecordmodel and parser/writer adapters. - Add deterministic serialisation, passthrough-field retention, and atomic save utilities.
- Add in-memory session state (
loaded,dirty,source,history). - Phase 2: read and inspect workflow.
- Implement
/measure load,/measure source,/measure list,/measure show,/measure find. - Implement
/measure validateand/measure export-missingwith human-readable summaries. - Phase 3: edit workflow.
- Implement
/measure add,/measure edit,/measure delete,/measure rename. - Add
/measure diff,/measure backup, and/measure savewith rollback safety. - Phase 4: quality transforms.
- Implement
/measure standardiseand scale/notes harmonisation rules aligned to boilerplate expectations. - Add batch edit operation with dry-run preview mode.
- Phase 5: migration and deprecation.
- Implement
/measure import-bptuimigration path and migration diagnostics. - Document bptui deprecation timeline and margo-first migration guidance.
- Phase 6: docs and adoption.
- Add cookbook docs for
load -> edit -> validate -> save -> boilerplate report. - Add release notes and example fixtures for each supported format.