From 653e18ee285b1d57a4b237fd70b3468a0362e9d7 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 25 Jul 2026 11:59:41 -0400 Subject: [PATCH] remove code related to dry run and dep graph rendering (ps1 meta) --- scripts/passes/annotation.lua | 2 -- scripts/passes/atoms_source_map.lua | 15 ++++-------- scripts/passes/components.lua | 7 ------ scripts/passes/emission_model.lua | 2 +- scripts/passes/offsets.lua | 7 ++---- scripts/passes/report.lua | 9 +++---- scripts/passes/scan_source.lua | 1 - scripts/passes/static_analysis.lua | 2 -- scripts/passes/word_count_eval.lua | 1 - scripts/ps1_meta.lua | 37 ----------------------------- 10 files changed, 11 insertions(+), 72 deletions(-) diff --git a/scripts/passes/annotation.lua b/scripts/passes/annotation.lua index 1137710..42937e0 100644 --- a/scripts/passes/annotation.lua +++ b/scripts/passes/annotation.lua @@ -45,7 +45,6 @@ local ensure_dir = duffle.ensure_dir --- @field project_root string --- @field upstream table --- @field flags table ---- @field dry_run boolean --- @field verbose boolean --- @class PassResult @@ -640,7 +639,6 @@ end --- Render `.errors.h` with `#error` directives for every error found across all sources in the directory. --- Empty directories (no errors, no atoms) produce no file. local function emit_module_errors_h(ctx, dir_basename, atoms_count, errors, sources) - if ctx.dry_run then return nil end if atoms_count == 0 and #errors == 0 then return nil end diff --git a/scripts/passes/atoms_source_map.lua b/scripts/passes/atoms_source_map.lua index 0e1c1bf..85bdda3 100644 --- a/scripts/passes/atoms_source_map.lua +++ b/scripts/passes/atoms_source_map.lua @@ -65,7 +65,6 @@ local FORMAT_VERSION = 1 --- @field shared.corpus table -- canonical source-order corpus --- @field shared.word_counts table --- @field out_root string -- output root (e.g. "build/gen") ---- @field dry_run boolean -- if true, compute but don't write --- @field flags table -- `ctx.flags`; reads `flags.gdb_runtime` + `flags.elf_path` -- ════════════════════════════════════════════════════════════════════════════ @@ -464,10 +463,8 @@ local function emit_gdb_runtime(ctx) lines[#lines + 1] = 'printf "[gdb_tape_atoms] runtime loaded %d atoms from %s\\n", $__atom_count, $__elf_path' local out_path = ctx.out_root .. "/gdb_tape_atoms_runtime.gdb" - if not ctx.dry_run then - duffle.ensure_dir(duffle.dirname(out_path)) - duffle.write_file_lf(out_path, table.concat(lines, "\n") .. "\n") - end + duffle.ensure_dir(duffle.dirname(out_path)) + duffle.write_file_lf(out_path, table.concat(lines, "\n") .. "\n") io.stderr:write(string.format( "[atoms_source_map] wrote %s (%d atoms)\n", out_path, #matched)) end @@ -528,11 +525,9 @@ function M.run(ctx) local prov_path = ctx.out_root .. "/" .. basename .. ".atoms.provenance.txt" local prov_body = render_provenance(src, wc) - if not ctx.dry_run then - duffle.ensure_dir(duffle.dirname(sourcemap_path)) - duffle.write_file_lf(sourcemap_path, sourcemap_body) - duffle.write_file_lf(prov_path, prov_body) - end + duffle.ensure_dir(duffle.dirname(sourcemap_path)) + duffle.write_file_lf(sourcemap_path, sourcemap_body) + duffle.write_file_lf(prov_path, prov_body) outputs[#outputs + 1] = { kind = "report", path = sourcemap_path } outputs[#outputs + 1] = { kind = "report", path = prov_path } diff --git a/scripts/passes/components.lua b/scripts/passes/components.lua index 6e17842..97b5fac 100644 --- a/scripts/passes/components.lua +++ b/scripts/passes/components.lua @@ -64,7 +64,6 @@ local GEN_SUBDIR = "gen" --- @field project_root string -- project root (e.g. "code/") --- @field upstream table -- per-pass upstream outputs --- @field flags table -- CLI flags ---- @field dry_run boolean -- if true, compute but don't write --- @field verbose boolean -- log diagnostic info --- @class PassResult @@ -535,7 +534,6 @@ end --- Emit a per-source `.macs.h` header with the `mac_X` macros + `WORD_COUNT` entries. --- Writes in BINARY mode so LF line endings are preserved (the git blob is LF; Windows text-mode would emit CRLF and break the byte-identical diff). ---- Honors `ctx.dry_run`: prints the intended path but does not write the file. --- @param ctx PassCtx --- @param src SourceFile --- @param components Component[] @@ -553,11 +551,6 @@ local function emit_component_macros_h(ctx, src, components, counts) end local content = table.concat(lines, "\n") .. "\n" - if ctx.dry_run then - print(string.format(" -> %s (dry-run)", out_path)) - return out_path - end - duffle.ensure_dir(out_dir) duffle.write_file_lf(out_path, content) print(string.format(" -> %s", out_path)) diff --git a/scripts/passes/emission_model.lua b/scripts/passes/emission_model.lua index be26c9e..352411f 100644 --- a/scripts/passes/emission_model.lua +++ b/scripts/passes/emission_model.lua @@ -123,7 +123,7 @@ end -- Run the emission-model pass. -- ───────────────────────────────────────────────────────────────────────── ---- @param ctx PassCtx -- { shared = { corpus = ... }, out_root, dry_run, ... } +--- @param ctx PassCtx -- { shared = { corpus = ... }, out_root, ... } --- @return PassResult function M.run(ctx) local outputs = {} diff --git a/scripts/passes/offsets.lua b/scripts/passes/offsets.lua index 348d594..003fb65 100644 --- a/scripts/passes/offsets.lua +++ b/scripts/passes/offsets.lua @@ -50,7 +50,6 @@ local OFFSET_MACRO_COL = 44 --- @field shared.corpus table -- canonical corpus projection --- @field shared.word_counts table --- @field out_root string -- output root (e.g. "build/gen") ---- @field dry_run boolean -- if true, compute but don't write --- @class PassResult --- @field outputs table[] -- {kind=, path=} entries describing emit files @@ -220,10 +219,8 @@ local function process_source(ctx, src) if #atoms_data == 0 then return nil end local out_path = src.dir .. "/gen/" .. duffle.basename_no_ext(src.dir) .. ".offsets.h" - if not ctx.dry_run then - duffle.ensure_dir(duffle.dirname(out_path)) - duffle.write_file(out_path, generate_header(src.path:gsub("/", "\\"), atoms_data)) - end + duffle.ensure_dir(duffle.dirname(out_path)) + duffle.write_file(out_path, generate_header(src.path:gsub("/", "\\"), atoms_data)) return out_path end diff --git a/scripts/passes/report.lua b/scripts/passes/report.lua index 4405684..3aae6ed 100644 --- a/scripts/passes/report.lua +++ b/scripts/passes/report.lua @@ -76,7 +76,6 @@ local PASS_NAME = "report" --- @field project_root string -- project root (e.g. "code/") --- @field upstream table -- per-pass upstream outputs --- @field flags table -- CLI flags + per-pass stash ---- @field dry_run boolean -- if true, compute but don't write --- @field verbose boolean -- if true, log diagnostic info --- @class PassResult @@ -447,7 +446,7 @@ function M.run(ctx) local corpus = ctx.shared and ctx.shared.corpus local by_dir = (corpus and corpus.sources_by_dir) or {} - if not ctx.dry_run then duffle.ensure_dir(ctx.out_root) end + duffle.ensure_dir(ctx.out_root) local all_results_for_summary = {} for dir, dir_sources in pairs(by_dir) do @@ -462,9 +461,7 @@ function M.run(ctx) if module_has_content(module_results) then local out_path = ctx.out_root .. "/" .. dir_basename .. ".annotations.txt" - if not ctx.dry_run then - duffle.write_file(out_path, render_module_report(dir, dir_sources, module_results)) - end + duffle.write_file(out_path, render_module_report(dir, dir_sources, module_results)) outputs[#outputs + 1] = { annotations_txt = out_path } else debug_log(" -> no content; skipping\n") @@ -472,7 +469,7 @@ function M.run(ctx) end end - if not ctx.dry_run and #all_results_for_summary > 0 then + if #all_results_for_summary > 0 then local summary_path = ctx.out_root .. "/annotation_validation.txt" duffle.write_file(summary_path, render_project_report(all_results_for_summary)) outputs[#outputs + 1] = { summary_txt = summary_path } diff --git a/scripts/passes/scan_source.lua b/scripts/passes/scan_source.lua index 3cb398d..6196416 100644 --- a/scripts/passes/scan_source.lua +++ b/scripts/passes/scan_source.lua @@ -117,7 +117,6 @@ local parse_enum_int_literal --- @field project_root string --- @field upstream table --- @field flags table ---- @field dry_run boolean --- @field verbose boolean --- @class PassResult diff --git a/scripts/passes/static_analysis.lua b/scripts/passes/static_analysis.lua index c216dc0..3784f23 100644 --- a/scripts/passes/static_analysis.lua +++ b/scripts/passes/static_analysis.lua @@ -109,7 +109,6 @@ local OUTPUT_EXTENSION = ".static_analysis.txt" --- @field project_root string --- @field upstream table --- @field flags table ---- @field dry_run boolean --- @field verbose boolean --- @class PassResult @@ -2197,7 +2196,6 @@ local function emit_module_static_analysis_txt(ctx, dir, dir_sources, atoms, fin -- Module basename = last component of `dir` ("code/duffle" -> "duffle"). local dir_basename = dir:match("([^/\\]+)$") or dir local out_path = ctx.out_root .. "/" .. dir_basename .. ".static_analysis.txt" - if ctx.dry_run then return out_path end duffle.ensure_dir(ctx.out_root) local lines = {} diff --git a/scripts/passes/word_count_eval.lua b/scripts/passes/word_count_eval.lua index 5e27b28..4fffcea 100644 --- a/scripts/passes/word_count_eval.lua +++ b/scripts/passes/word_count_eval.lua @@ -49,7 +49,6 @@ local duffle = dofile(_bootstrap_dir .. "../duffle_paths.lua") --- @field project_root string -- project root (e.g. "code/") --- @field upstream table -- per-pass upstream outputs --- @field flags table -- CLI flags ---- @field dry_run boolean -- if true, compute but don't write --- @field verbose boolean -- if true, log diagnostic info --- @class PassResult diff --git a/scripts/ps1_meta.lua b/scripts/ps1_meta.lua index 6a242cd..0269c49 100644 --- a/scripts/ps1_meta.lua +++ b/scripts/ps1_meta.lua @@ -77,7 +77,6 @@ local PASS_FLAG_DISPATCH_KEY = "__pass__" --- @field out_root string -- output root (e.g. "build/gen") --- @field project_root string -- PS1 repository root --- @field flags table -- CLI flags + per-pass stash ---- @field dry_run boolean -- if true, compute but don't write --- @field verbose boolean -- if true, log diagnostic info --- @class Finding @@ -96,7 +95,6 @@ local PASS_FLAG_DISPATCH_KEY = "__pass__" --- @field metadata string -- --metadata value --- @field out_root string -- --out-root value (default "build/gen") --- @field project_root string -- PS1 repository root (derived from metadata by default) ---- @field dry_run boolean -- if true, compute but don't write --- @field verbose boolean -- if true, log diagnostic info -- ════════════════════════════════════════════════════════════════════════════ @@ -299,7 +297,6 @@ COMMON_FLAGS: /code/duffle/word_count.metadata.h) --gdb-runtime Also emit /gdb_tape_atoms_runtime.gdb (post-link, requires --elf) --elf PATH Path to linked .elf (for --gdb-runtime / --dwarf-injection) - --dry-run Print dep order (alphabetical); exit 0 without running --verbose Print per-pass debug output --help Show this help and exit @@ -345,7 +342,6 @@ FLAG_HANDLERS["--help"] = function(args) os.exit(0) end -FLAG_HANDLERS["--dry-run"] = function(args) args.dry_run = true end FLAG_HANDLERS["--verbose"] = function(args) args.verbose = true end FLAG_HANDLERS["--source"] = function(args, argv, arg_idx) local value, value_idx = require_flag_value(argv, arg_idx, "--source") @@ -430,7 +426,6 @@ local function parse_args(argv) metadata = nil, out_root = DEFAULT_OUT_ROOT, project_root = nil, - dry_run = false, verbose = false, } @@ -611,7 +606,6 @@ local function build_ctx(args) out_root = args.out_root, project_root = corpus.project_root, flags = args.flags or {}, - dry_run = args.dry_run, verbose = args.verbose, } @@ -709,28 +703,6 @@ local function topo_sort(passes, requested_set) return order end --- ════════════════════════════════════════════════════════════════════════════ --- ASCII dep graph renderer (Decision 6 in the spec) --- ════════════════════════════════════════════════════════════════════════════ - --- ════════════════════════════════════════════════════════════════════════════ --- Topological dep-order printer (used by --dry-run). --- Re-render the PASSES graph manually in `docs/guide_metaprogram_ssdl.md` if you need an updated visual; --- The canonical ASCII view there is regenerated by hand whenever PASSES rows change. --- ════════════════════════════════════════════════════════════════════════════ -local function render_dep_order(passes, closed) - local lines = {} - lines[#lines + 1] = "[ps1_meta] Resolved dependency order (closed under deps):" - for pass_idx, name in ipairs(closed) do - local p = passes[name] - local deps_str = (#p.deps == 0) and "(no deps)" or - "(deps: " .. table.concat(p.deps, ", ") .. ")" - lines[#lines + 1] = string.format(" %d. %-22s %-45s [%s]", - pass_idx, name, deps_str, p.kind) - end - return table.concat(lines, "\n") .. "\n" -end - -- ════════════════════════════════════════════════════════════════════════════ -- Main Orchestrator -- ════════════════════════════════════════════════════════════════════════════ @@ -777,13 +749,6 @@ local function main(argv) local requested = args.requested_set local closed = topo_sort(PASSES, requested) - -- --dry-run: print the closed dep order and exit OK. - -- (The hand-rendered PASSES graph lives in docs/guide_metaprogram_ssdl.md; see Decision 6.) - if args.dry_run then - io.write(render_dep_order(PASSES, closed)) - os.exit(EXIT_OK) - end - local had_errors = dispatch_passes(ctx, closed) if had_errors then os.exit(EXIT_VALIDATION_ERRORS) end end) @@ -797,11 +762,9 @@ local function main(argv) end -- Module export for in-process consumers (tests that dofile this script). --- The closed dep-order printer + the `PASSES` table are exposed so a test can observe the resolved dep order for synthetic PASSES tables without spawning a subprocess. -- The conditional `main(...)` call below only fires when this file is invoked as the entry script (arg[0] ends in "ps1_meta.lua"); -- in dofile() mode (test's arg[0] does not match), main() is skipped and the chunk returns `_M` to the caller. local _M = { - render_dep_order = render_dep_order, PASSES = PASSES, PASS_KIND_STOP_ON_ERROR = PASS_KIND_STOP_ON_ERROR, parse_args = parse_args,