Skip to content

Agent Script codegen backend: flat n-ary guard ladder for the requirement-dag Space - #29

Closed
jdonaldson wants to merge 3 commits into
mainfrom
agentscript-backend
Closed

Agent Script codegen backend: flat n-ary guard ladder for the requirement-dag Space#29
jdonaldson wants to merge 3 commits into
mainfrom
agentscript-backend

Conversation

@jdonaldson

Copy link
Copy Markdown
Owner

What

Adds a second codegen target to the requirement-dag HF Space: the recognized decision table now compiles to a Salesforce Agent Script .agent file alongside the Burr state machine.

The finding that shaped the emitter

Agent Script has no elif, and its shipped linter also rejects nested if ("Combine conditions with 'and'/'or'") — contradicting the repo's own SPEC.md §5.8, which recommends nesting. So an n-ary conditional must be emitted as a flat ladder of mutually-exclusive guards, row i carrying its full path conjunction (if not f1 and f2:). That is the decision-table normal form — exactly the object the probe recognizes, so the recognized table maps 1:1 onto Agentforce's reviewable artifact.

Validation

  • All 5 non-abstain demo examples emit scripts that parse + compile 0-diagnostic against Salesforce's published toolchain (@sf-agentscript/agentforce 2.5.34 with language overridden to 2.18.0 — the published pin is internally inconsistent and won't import otherwise; packages live under the @sf-agentscript/* npm scope, not @agentscript/* as their README says).
  • Negative controls: elif → syntax error; minimal nested-if → the no-nesting lint. The validator has teeth.
  • Antonym-negation polarity survives the new backend: "on track" routes notify to the not is_late world.
  • Burr path regression-checked (unchanged output); abstain path abstains on both code panes.

emit_ladder() is n-ary — k-check elif chains plug in unchanged when the recognizer grows past one check (the Stefan requirement thread); today's single-check tables are the two-row special case.

🤖 Generated with Claude Code

Second emit target next to burr_source(): the recognized decision table
compiles to a Salesforce Agent Script .agent file. Key finding baked into
the emitter: Agent Script has no elif AND its shipped linter rejects
nested if (contradicting SPEC.md §5.8's own advice), so n-ary choice must
compile to a FLAT ladder of mutually-exclusive guards carrying full path
conjunctions — the decision-table normal form the probe already recognizes.

emit_ladder() is n-ary (k-check chains plug in when the recognizer grows);
today's single-check tables are the two-row special case. All 5 non-abstain
demo examples validate 0-diagnostic against @sf-agentscript/agentforce
(language 2.18.0 override needed — published pin is internally broken);
elif and nested-if controls are rejected by the same toolchain.
The real stakeholder requirement that motivated the n-ary work: two
out-of-library checks (VIP, repeat-customer) + an unenrolled action
(free gift) + a chain structure past the single-check recognizer.
Routes to the abstain path; intro explains why and what's open.
…eam derived

Enroll CheckVIP / CheckRepeatCustomer / SendFreeGift as mock actions (no
probe heads — the recognizer cannot demand them) and, for the ONE bundled
VIP example, follow the honest abstain banner with a clearly-labeled MOCK
preview: a hand-supplied 3-row decision table from which the n-ary DAG,
Burr program (elif via ordered when() transitions), and Agent Script flat
guard ladder are all derived symbolically. render_svg generalized to take
n-ary guard edges/lanes (legacy single-check path untouched). Mock Agent
Script validates 0-diagnostic with @sf-agentscript/agentforce; examples
0-5 regression-checked.
@jdonaldson

Copy link
Copy Markdown
Owner Author

Closing unmerged by design: this branch is the HF Space / Agentforce demo source, kept separate from main. The Space at hf.co/spaces/jdonaldson/requirement-dag deploys directly from this branch's experiments/agentforce_space/ via hf upload; future Space work continues here.

@jdonaldson jdonaldson closed this Jul 6, 2026
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