Manifest and rules redesign¶
Status: Implemented 2026-11-07; see the user guide (Rules, The manifest).
Deviations from this note¶
The implementation differs from the design below in these points:
viewhas no filter or output options; it takes a target or log file,--plugin,--fail-on,--manifestand--rootonly.Plugin listing and inspection moved to
sawmill plugins listandsawmill plugins info NAME.The TUI has no separate waived or hidden tabs.
vtoggles waived and hidden rows into the table, marked in a status column (W,H).Refresh keys are
r(re-read manifest and rules) andR(also re-read logs), notRandshift+R.When a rule’s
max_countis exhausted, the excess is unwaived; later rules are not tried for that message.The project-level
config.tomlis removed. Only the user config~/.config/sawmill/config.tomlremains.report --outputgiven without a path writes to the manifest’sreportkey.
This note replaced the earlier waiver and suppression design. There is no backwards compatibility requirement; the project is pre-release.
Motivation¶
The current design grew out of single-block lint flows: one log, one plugin, one waiver file found in the current directory. It does not fit multi-stage flows such as an FPGA build that produces several lint logs and eight parallel Vivado jobs per run. Specific problems:
one log per invocation, so CI needs shell loops and exit-code merging;
waivers and suppressions are discovered relative to the current working directory, which is arbitrary in CI;
a waiver has no scope, so a waiver written for one job applies to all;
waivers and suppressions are two file formats and two matchers with nearly identical semantics;
no way to say “this message is expected at most N times”;
no channel for passing flow mode or other options to a plugin.
Decisions¶
Taken in discussion on 2026-11-06.
One rule format. There is no separate suppression file and no
actionkey. A rule is a waiver; which file lists it decides where it applies.No personal or per-user rule file. Everything that affects what a user sees is checked in, so there is no “works for me” drift. Session-only hiding in the TUI is the only non-persistent filter.
All configuration lives under a
.sawmill/directory: the manifest at.sawmill/manifest.tomland rule files under.sawmill/rules/.Discovery walks down from one or more roots looking for
.sawmilldirectories, as FuseSoC does for core files. Each manifest has a uniquename.Subcommands replace the flat flag set:
check,view,report,rules,init.sawmill <logfile>remains a shortcut forviewwithout a manifest.Unused rules produce a warning, never a failure.
Rules never depend on line numbers.
The TUI adds rules; editing and deleting is done in a text editor. A refresh key re-reads the manifest and rule files.
Layout¶
soc/
.sawmill/
manifest.toml
rules/
vivado.toml
vivado-pnr.toml
slang.toml
build/
lint/top.log sub_a.log sub_b.log
pnr/job_0/vivado.log ... job_7/vivado.log
The directory containing .sawmill/ is the project root. Log globs are
relative to the project root. Rule file names are relative to
.sawmill/rules/.
Manifest¶
[manifest]
name = "soc"
rules = ["vivado.toml", "slang.toml"] # plugin-wide, see rule header
report = "build/sawmill-report.json" # default for `report`
fail_on = "warning" # default for all targets
[[target]]
name = "lint"
plugin = "slang"
logs = ["build/lint/*.log"]
[[target]]
name = "pnr"
plugin = "vivado"
logs = ["build/pnr/job_*/vivado.log"]
rules = ["vivado-pnr.toml"]
fail_on = "critical_warning"
unused_rules = "warn" # warn (default) | ignore
[target.plugin_options]
mode = "implementation"
Keys:
[manifest]name(required, unique across discovered manifests),rules,report,fail_on.[[target]]name(required, unique within the manifest),plugin(required),logs(required, list of globs),rules,fail_on,unused_rules,plugin_options(table passed to the plugin’sconfigurehook).
A target with no matching logs is an error in check and shown as empty
in view.
Rule files¶
[rules]
plugin = "vivado" # required; the file only applies to this plugin
[[rule]] # every Vivado log in every target
id = "Vivado 12-3523"
comment = "Attempt to change param, harmless. BER-123"
[[rule]] # one job only
id = "Synth 8-7080"
regex = "u_dbg_.*"
logs = ["build/pnr/job_3/vivado.log"]
max_count = 2
comment = "Debug core only present in job 3; remove after 2027-01"
[[rule]] # by referenced source file, as in the Slang lint waivers
id = "Synth 8-3331"
file = "**/ip/snps_pcie/**/*.v"
comment = "Vendor IP, not ours to fix"
Match keys, all optional but at least one of id, regex or file
is required:
idExact match on the plugin’s message ID.
regexPython regex searched over the message’s raw text,
DOTALL.fileGlob matched against the path in the message’s file reference.
**is supported. Matched against the path as written in the log and, if that is relative, also against it resolved from the project root.logsList of globs relative to the project root. The rule applies only to logs whose resolved path matches. Absent means every log the file applies to.
severityRestrict to one severity id. Mostly useful with
regex.
Limits and metadata:
max_countMaximum matches per log (default) before the rule stops waiving and the excess counts as unwaived.
per = "target"counts across the target.commentRequired free text. Tickets, expiry and rationale go here.
author,dateWritten by the TUI when it adds a rule. Optional when hand-written.
nameOptional stable identifier so reports and
rulesoutput can refer to the rule by something other than file and index.
Matching: for each message, rules from the plugin-wide files are tried first, then the target’s files, in file order and then rule order. The first rule whose every present key matches wins. A rule counts as used when it matches at least one message in the run.
Scope hierarchy¶
Listed in |
Applies to |
Used by |
|---|---|---|
|
every target with that plugin |
yes |
|
that target |
yes |
rule |
the matching logs only |
yes |
TUI session hide |
current session |
no |
Discovery¶
sawmill looks for manifests by walking down from each root. Roots are,
in order of precedence: --manifest PATH (no walk, exactly one manifest),
--root DIR (repeatable), roots in ~/.config/sawmill/config.toml,
the current directory. Hidden directories other than .sawmill and
directories named .git are skipped. Targets are addressed as
manifest:target, or target alone when unique across all discovered
manifests. Duplicate manifest names are an error.
CLI¶
sawmill check [TARGET...] [--all] [--fail-on SEV] [--report PATH]
sawmill view [TARGET | LOGFILE] [--plugin NAME]
sawmill report [TARGET...] [--format json|text|junit]
sawmill rules list [TARGET...]
sawmill rules unused [TARGET...]
sawmill rules generate TARGET [--min-level N]
sawmill init [--name NAME]
sawmill init --target NAME GLOB [--plugin NAME]
sawmill LOGFILE # alias for `view LOGFILE`
check exits 1 when any selected target has an unwaived message at or
above its fail_on level, or when a target has no matching logs. Unused
rules and max_count overflows are listed in the output. With no target
and no --all, check runs every target of the single discovered
manifest and errors if more than one manifest was found.
init with no arguments writes .sawmill/manifest.toml with every key
present and commented, and creates .sawmill/rules/. With --target
it appends a target, detects the plugin from the first log matching the
glob unless --plugin is given, and scaffolds rules/<name>.toml with
the [rules] header.
Plugin API additions¶
configure(options: dict) -> NoneOptional hook, called once per target before any log is parsed, with the target’s
plugin_optionstable. Plugins without the hook ignore options andcheckwarns if options were given.
No other plugin changes. The log column and per-log counts in the TUI are a base-app concern.
TUI¶
Opened with sawmill view TARGET or sawmill view for all targets of
the discovered manifest.
- Overview tab
One row per target, with one row per log beneath it: counts per severity, waived, hidden, pass or fail against
fail_on. Enter opens the target’s tab filtered to that log.- Target tabs
One tab per target. The table is merged across the target’s logs with a log column, and group-by message ID shows per-log counts. Filtering by log is a filter on the log column, not a separate mode.
- Waive modal
Opened on a message or a message-ID group. Fields: scope (this log, this target, all targets using this plugin), match (id only, id plus substring, id plus regex, prefilled from the message and editable),
max_countand per log or per target, comment, destination file. The destination defaults from the scope: plugin-wide scope offers the manifest’s files for that plugin, target scope the target’s files, and the last file in the list is preselected. Author and date are filled in. Saving appends one[[rule]]block to the file usingtomlkitso existing content and comments are untouched, then re-applies rules so counts update live.- Keys
hhides the selected message ID for the session.Rre-reads the manifest and rule files and re-applies them, keeping the cursor.shift+Ralso re-reads the logs.- No manifest
sawmill view LOGFILEis a single target tab with no overview. The waive modal prompts once per session for a rules file path, defaulting to.sawmill/rules/<plugin>.tomlbeside the log, and offers to runinitto create the manifest.
Report¶
report and check --report write one JSON document covering every
selected target: per target and per log, counts per severity, waived,
unwaived, rules used, rules unused, max_count overflows, and the pass or
fail result. A JUnit XML format is a thin view over the same data, one test
case per log, for CI systems that render it.
Build variables¶
Added 2026-11-07. A flow that builds into run.<make-target> has one
build directory per invocation, chosen by the Makefile. The manifest cannot
name it statically, and one target per make target duplicates the target
list. Instead a manifest declares variables and the command line supplies
their values.
A top-level
[vars]table holds default values. Keys are identifiers ([A-Za-z_][A-Za-z0-9_]*); values are strings. The table is optional.${name}is expanded in everylogsentry and inreport. It is not expanded inrules,nameorplugin. A$not followed by{is literal; an unterminated${is a manifest error.--var NAME=VALUE(repeatable) oncheck,report,rules unused,rules generateandviewoverrides or supplies a value. A malformed argument is a usage error (exit 2).--varneed not name a key in[vars]; the table only provides defaults.Resolution is
[vars]overlaid by--var, per manifest. A reference to a name with no value is a configuration error (exit 2) naming the target, the key and the variable. Validation happens when the target is run or the report path is resolved, sorules listneeds no values.A
--varthat no selected manifest references is ignored.The resolved variables are recorded: the
checkandreporttext header gains[build=sub]afterfail_onwhen any variable is set; the JSON report gains a per-target"vars"object; JUnit gains onevars.<name>property per variable.The TUI keeps the command-line overrides across
randRso a refresh re-reads the manifest’s defaults but not the overrides.No environment-variable expansion and no escaping syntax.
Example:
[manifest]
name = "fpga"
report = "run.${build}/sawmill-report.json"
[vars]
build = "top"
[[target]]
name = "pnr"
plugin = "vivado"
logs = ["run.${build}/pnr/job_*/vivado.log"]
$ sawmill check --var build=$(TARGET)
Stage E tasks
- E1
Manifest.vars,[vars]parsing and validation,expand()withVariableError, andvarsparameters onTarget.resolve_logsandManifest.report_path.- E2
TargetRef.overridesandTargetRef.vars;resolve_targetstakes overrides; the runner resolves logs throughref.varsand mapsVariableErrortoRunnerError; report, JUnit and the text header record the variables.- E3
--varoption on the CLI commands,run_selectedplumbing, barereport --outputthrough the resolved report path, TUI refresh keeps overrides,inittemplate documents[vars].- E4
User guide and reference pages.
Open questions¶
Whether
fileshould also accept a plugin-provided label (for example a Vivado run name) as an alternative to path globs. Deferred until globs prove insufficient.Whether
expiresdeserves enforcement as a first-class key. Deferred; today it is a convention incomment.Whether the overview should be a tab or a separate screen. Try tabs first.
Implementation plan¶
Each task is independently testable and small enough for one subagent on a worktree. Order matters within a stage; stages are sequential.
Stage A, data model and loading
- A1
RuleandRuleFilemodels plus a loader with validation and line numbers in errors. Replacesmodels/waiver.py,core/waiver.pyloader andcore/suppress.py.- A2
ManifestandTargetmodels plus loader. Relative path resolution for logs and rules. Glob expansion.- A3
Discovery: walk roots for
.sawmill/manifest.toml, address targets bymanifest:target, detect duplicates.- A4
RuleMatcher: ordering, all match keys,logsscoping,max_countper log and per target, used and unused tracking.
Stage B, CLI
- B1
Subcommand skeleton with
click.Group;sawmill LOGFILEalias. Move existing options underview. Remove the flat flags.- B2
check: run targets, apply rules, exit code, text output including unused rules and overflows.- B3
report: JSON then JUnit.- B4
rules list,rules unused,rules generate.- B5
initboth forms.- B6
configurehook in the hookspec and base plugin; wireplugin_optionsthroughcheckandview.
Stage C, TUI
- C1
Multi-log model: a target loads N logs, messages carry their source log, aggregation groups by ID with per-log counts.
- C2
Target tab with log column and log filter.
- C3
Overview tab.
- C4
Waive modal rewrite: scope, match, count, comment, destination; append with
tomlkit.- C5
Randshift+Rrefresh;hsession hide.- C6
No-manifest path: prompt for rules file, offer
init.
Stage D, docs
- D1
Rewrite
user-guide/waivers.rst,sawmill-directory.rst,ci-integration.rst,reference/cli-reference.rstandreference/file-formats.rst. Remove the stale workflow table fromCLAUDE.md.