|
AWK Minifier
Conservative AWK source minification
|
Accepted
The repository was created from template-bash and therefore inherited a Bash runtime baseline, Bash source files, and an executable plugin example. Issue #2 changes the product itself: AWK Minifier is an AWK source transformer whose maintained implementation must be written in portable AWK and whose public input and output are AWK source text.
The implementation guide requires modular maintained source, direct execution of that source through repeated awk -f arguments, deterministic standalone assembly, and conservative behavior when lexical or syntactic context is uncertain. The earlier template decisions remain useful where they describe explicit ordering and deterministic assembly, but a Bash runtime and automatically discovered runtime plugins no longer describe this product.
AWK Minifier SHALL be implemented in portable AWK. The implementation SHALL NOT require GNU AWK extensions unless a later ADR deliberately changes the portability baseline.
Maintained product source SHALL live under src/ as responsibility-focused AWK modules. The Makefile SHALL own an explicit ordered source list. Maintained source MUST be directly runnable by invoking the selected interpreter with the modules in that same order, for example:
Standalone artifacts SHALL be assembled deterministically from that explicit ordered list. Filesystem glob ordering, runtime plugin discovery, dynamic loading, and registration machinery are not part of the AWK Minifier runtime architecture.
The public transformer contract is:
The implementation SHALL use lexical state plus contextual recognition rather than regular-expression substitution over raw lines. Whitespace, comments, and newlines that separate tokens SHALL be treated as a pending gap whose final representation is decided only when enough context is available. If the implementation cannot prove that deleting or rewriting a gap is safe, it SHALL preserve the conservative representation or reject the transformation rather than silently change program meaning.
Slash classification SHALL be contextual. A slash MUST NOT be classified as a regular-expression delimiter or division operator solely from its character value. The recognizer SHALL track whether a primary expression is legal at the current position and use that context to distinguish regexp literals from division and assignment operators.
awk -f arguments.Rejected. Bash may remain build and test orchestration glue, but making the transformer itself a Bash program contradicts the product contract and would add a runtime dependency that the AWK implementation does not require.
Rejected. Prior Bash-minifier work is useful evidence about quoting, escaping, and continuation hazards, but AWK has different token and grammar ambiguities, most notably slash classification and newline significance. The architecture must model AWK rather than mechanically translate Bash rules.
Rejected because comments, string literals, regexp literals, division operators, continuations, and newline-sensitive grammar cannot be handled reliably by blind line substitutions.
Rejected because the minifier does not presently require runtime extensibility. The useful reusable invariant is modular maintained source plus deterministic assembly, not the starter's plugin mechanism.
The inherited Bash product source and plugin example will be removed. Build and CI shell code may remain where shell orchestration is appropriate, but product behavior and source documentation move to AWK.
Testing must exercise both the modular repeated--f form and assembled release artifacts so divergence in source order or assembly becomes observable.
This ADR supersedes ADR-002's Bash runtime and portability baseline for the AWK Minifier product.
This ADR supersedes the automatically discovered runtime-plugin portion of ADR-004. It preserves and strengthens ADR-004's explicit core source ordering.
This ADR refines ADR-014: responsibility-focused maintained source, deterministic assembly, and standalone consumer artifacts remain governing principles, while runtime registries and noop plugins are not used by this product.