Skip to content

Add user-defined translation rules (--rules)#32

Merged
stackedsax merged 2 commits into
mainfrom
feat/translation-rules
Jul 18, 2026
Merged

Add user-defined translation rules (--rules)#32
stackedsax merged 2 commits into
mainfrom
feat/translation-rules

Conversation

@stackedsax

Copy link
Copy Markdown
Contributor

What

Implements option 1 — the declarative translation-rules file — plus a small
README fix that missed the merge window.

--rules (user-defined translation rules)

Adjust a conversion without patching BAMMM. A rules file rewrites the SPLAT IR
between parse and emit, so one rule set works for any source/target pair:

bammm convert --from slurm --to pbs --rules my-rules.yaml job.sh
apiVersion: bammm.io/rules/v1alpha1
rules:
  - when: { equals: { spec.schedule.qos: debug } }
    set:  { spec.schedule.queue: debug-queue }
    warn: routed debug QoS to debug-queue
  - when: { to: pbs, has: spec.extensions.htcondor.requirements }
    remove: [ spec.extensions.htcondor.requirements ]
    warn: dropped HTCondor requirements (no PBS equivalent)
  • internal/ruleswhen matches on from/to/has/equals; actions are
    default, set, rename, remove, with an optional warn. Full SPLAT
    document paths (spec.schedule.queue); evaluated over a generic map so
    remove genuinely drops fields.
  • convert.ConvertWithRules threads the ruleset through and returns warnings
    (printed to stderr); Convert stays a thin nil-ruleset wrapper.
  • Works for single and bulk (--input-dir) conversions.
  • Worked example in examples/rules/; reference in docs/translation-rules.md
    (promoted from design → implemented).

CEL expressions and array-index paths are noted as future work.

Also: rescued README fix

Drops the internal (Partner)/(Community) tags from the scheduler table (they
track who validates each scheduler, not anything user-facing). This was
approved for #28 but pushed just after it merged, so it's cherry-picked here to
actually reach main.

Testing

  • internal/rules unit tests: match gating, set/default/rename/remove, warn,
    nil-ruleset no-op.
  • CLI tests: --rules routes a value end-to-end (slurm→pbs → #PBS -q debug-queue + stderr warning) and errors on a missing file.
  • Full suite / vet / gofmt clean.

🤖 Generated with Claude Code

stackedsax and others added 2 commits July 18, 2026 15:01
…able

Those parentheticals track who validates each scheduler against a real cluster
(a process note in CLAUDE.md), not anything user-facing — Run.ai's and LSF's
parser/emitter are first-class like every other. The Type column now just names
the paradigm.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016PnTz6Zxqa4jHocK8kCbyx
Let users adjust a conversion without patching BAMMM: a --rules file rewrites
the SPLAT IR between parse and emit, so one rule set applies regardless of the
source/target pair.

- internal/rules: a Ruleset of match → action entries. `when` matches on
  from/to/has/equals; actions are default, set, rename, remove, plus a warn
  string. Paths are full SPLAT document paths (spec.schedule.queue, ...),
  evaluated over a generic map so removes actually drop fields.
- convert.ConvertWithRules threads the ruleset through parse → apply → emit and
  returns rule warnings; Convert stays a thin wrapper (nil ruleset).
- `bammm convert --rules <file>` for single and bulk runs; warnings print to
  stderr. Worked example in examples/rules/, reference in
  docs/translation-rules.md (promoted from design to implemented).

This is option 1 (declarative rules file) from the earlier design; CEL
expressions and array-index paths remain future work.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016PnTz6Zxqa4jHocK8kCbyx
@stackedsax
stackedsax merged commit 98bd427 into main Jul 18, 2026
6 checks passed
@stackedsax
stackedsax deleted the feat/translation-rules branch July 18, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant