Summary
Create immutable Turn struct to capture each LLM interaction cycle.
Spec: message-history-optimization-requirements.md (Roadmap Issue #5)
Requirements
ARC-001: Turn struct fields
Turn struct with fields:
number - turn sequence number (integer)
raw_response - full LLM output including reasoning (string, always captured per ARC-010)
program - parsed PTC-Lisp program (string or nil for failures)
result - execution result (any term)
prints - captured println output (list of strings)
tool_calls - tool invocations made (list of %{name, args, result})
memory - accumulated definitions (map)
success? - whether turn succeeded (boolean)
ARC-002: Append-only turns list
Turns list is append-only (no mutation). Each turn is a snapshot of that cycle's execution.
ARC-010: raw_response always captured
raw_response captures full LLM output including reasoning. Always captured, no debug flag needed.
DBG-001: Full programs preserved
Full programs preserved in Step.turns. Each Turn contains complete execution data.
DBG-002: Turn contains complete execution data
Turn contains: number, raw_response, program, result, prints, tool_calls, memory, success?
Implementation
File to create
Struct definition
defstruct [
:number,
:raw_response,
:program,
:result,
:prints,
:tool_calls,
:memory,
:success?
]
Constructor functions
Two smart constructors for creating turns:
@doc """
Create a successful turn.
"""
def success(number, raw_response, program, result, prints, tool_calls, memory)
@doc """
Create a failed turn.
"""
def failure(number, raw_response, program, error, prints, tool_calls, memory)
The success? field is set automatically:
Turn.success/7 sets success?: true
Turn.failure/7 sets success?: false
No update functions
The struct is immutable - no update/merge functions should be provided. If a turn needs modification, create a new one.
Files to modify
None - this is a standalone struct with no integration yet. Integration happens in:
Acceptance criteria
Blocked by
Blocks
Automation State
| Field |
Value |
| Status |
SUCCESS |
| PR |
#636 |
| Branch |
claude/634-turn-struct |
| Attempts |
1 |
Details: Implemented Turn struct with success/7 and failure/7 constructors. All tests passing, PR created.
Summary
Create immutable Turn struct to capture each LLM interaction cycle.
Spec: message-history-optimization-requirements.md (Roadmap Issue #5)
Requirements
ARC-001: Turn struct fields
Turn struct with fields:
number- turn sequence number (integer)raw_response- full LLM output including reasoning (string, always captured per ARC-010)program- parsed PTC-Lisp program (string or nil for failures)result- execution result (any term)prints- captured println output (list of strings)tool_calls- tool invocations made (list of%{name, args, result})memory- accumulated definitions (map)success?- whether turn succeeded (boolean)ARC-002: Append-only turns list
Turns list is append-only (no mutation). Each turn is a snapshot of that cycle's execution.
ARC-010: raw_response always captured
raw_responsecaptures full LLM output including reasoning. Always captured, no debug flag needed.DBG-001: Full programs preserved
Full programs preserved in
Step.turns. Each Turn contains complete execution data.DBG-002: Turn contains complete execution data
Turn contains: number, raw_response, program, result, prints, tool_calls, memory, success?
Implementation
File to create
lib/ptc_runner/turn.exStruct definition
Constructor functions
Two smart constructors for creating turns:
The
success?field is set automatically:Turn.success/7setssuccess?: trueTurn.failure/7setssuccess?: falseNo update functions
The struct is immutable - no update/merge functions should be provided. If a turn needs modification, create a new one.
Files to modify
None - this is a standalone struct with no integration yet. Integration happens in:
Acceptance criteria
Turn.success/7constructor creates turn withsuccess?: trueTurn.failure/7constructor creates turn withsuccess?: falseBlocked by
Blocks
Automation State
SUCCESSclaude/634-turn-structDetails: Implemented Turn struct with success/7 and failure/7 constructors. All tests passing, PR created.