Context
Issue #828 introduces <capabilities> as natural-language contracts. This sub-issue creates the foundational parsing layer that compiles <capabilities> tag text into a language-neutral effect IR, independent of any target backend.
Scope
Create a new capability_ir module at pdd/prompts/capability_ir_python.prompt.
The module must:
- Accept a
<capabilities> block (raw text or parsed tag content).
- Parse each bullet into a normalized
EffectItem dataclass/model with fields: modal (MAY | MUST_NOT), action (verb, e.g. read, write, call, send, log, modify), resource (normalized noun phrase, e.g. payment_records, email, secrets).
- Return a
ContractEffectIR object containing a list of EffectItems and metadata (capabilities_present: bool, effect_count: int).
- Be entirely independent of Python AST analysis — no imports of
ast, pylint, or code-inspection libraries.
Example input
<capabilities>
- MAY read payment records.
- MAY write refund records.
- MUST NOT send emails.
- MUST NOT log provider secrets, bearer tokens, card PAN, or CVV.
</capabilities>
Expected output (Python dataclass / Pydantic model)
ContractEffectIR(
capabilities_present=True,
effect_count=4,
effects=[
EffectItem(modal='MAY', action='read', resource='payment_records'),
EffectItem(modal='MAY', action='write', resource='refund_records'),
EffectItem(modal='MUST_NOT', action='send', resource='email'),
EffectItem(modal='MUST_NOT', action='log', resource='secrets'),
]
)
Files to create/modify
pdd/prompts/capability_ir_python.prompt (NEW — prompt spec for capability_ir module)
Acceptance criteria
- Parsing a well-formed
<capabilities> block produces EffectItem objects with correct modal, action, and resource values.
- A prompt with no
<capabilities> tag returns ContractEffectIR(capabilities_present=False, effect_count=0, effects=[]).
- The module has no imports of Python AST or code-analysis libraries.
- Unit tests cover: basic MAY/MUST_NOT parsing, multi-line capabilities, empty/missing tag, compound resource phrases.
PDD Command Hint
change, sync
Split Contract
Command sequence: change → sync
Allowed write set:
pdd/prompts/capability_ir_python.prompt
Acceptance criteria:
- capability_ir.py exists and exports EffectItem and ContractEffectIR
- Parsing a block with MAY/MUST_NOT bullets returns correct EffectItem list
- Missing/empty tag returns capabilities_present=False
- No Python AST or code-analysis imports in capability_ir.py
- Unit tests for parsing pass
Independently mergeable: True
Scope rule: Do not expand beyond this contract or implement sibling sub-issue work. If the contract is insufficient, report the gap instead.
PDD Command Hint: This is a new feature. Use change → sync (modify prompts, then generate and validate code).
Parent: #1370
Parent issue: #1370
Context
Issue #828 introduces
<capabilities>as natural-language contracts. This sub-issue creates the foundational parsing layer that compiles<capabilities>tag text into a language-neutral effect IR, independent of any target backend.Scope
Create a new
capability_irmodule atpdd/prompts/capability_ir_python.prompt.The module must:
<capabilities>block (raw text or parsed tag content).EffectItemdataclass/model with fields:modal(MAY|MUST_NOT),action(verb, e.g.read,write,call,send,log,modify),resource(normalized noun phrase, e.g.payment_records,email,secrets).ContractEffectIRobject containing a list ofEffectItems and metadata (capabilities_present: bool,effect_count: int).ast,pylint, or code-inspection libraries.Example input
Expected output (Python dataclass / Pydantic model)
Files to create/modify
pdd/prompts/capability_ir_python.prompt(NEW — prompt spec forcapability_irmodule)Acceptance criteria
<capabilities>block producesEffectItemobjects with correctmodal,action, andresourcevalues.<capabilities>tag returnsContractEffectIR(capabilities_present=False, effect_count=0, effects=[]).PDD Command Hint
change, sync
Split Contract
Command sequence: change → sync
Allowed write set:
pdd/prompts/capability_ir_python.promptAcceptance criteria:
Independently mergeable: True
Scope rule: Do not expand beyond this contract or implement sibling sub-issue work. If the contract is insufficient, report the gap instead.
PDD Command Hint: This is a new feature. Use
change → sync(modify prompts, then generate and validate code).Parent: #1370
Parent issue: #1370