Skip to content

feat(python-harness): auto-track dict/set and nested JSON args#130

Open
mkayander wants to merge 6 commits into
mainfrom
cursor/python-collections-auto-tracking-04a1
Open

feat(python-harness): auto-track dict/set and nested JSON args#130
mkayander wants to merge 6 commits into
mainfrom
cursor/python-collections-auto-tracking-04a1

Conversation

@mkayander
Copy link
Copy Markdown
Owner

@mkayander mkayander commented Apr 23, 2026

Summary

  • Fixed tree_utils.build_tree, which had been merged accidentally into the TreeNode class (syntax/import was fragile).
  • Added solution_display.py with compose_run_output and format_python_return_value so safe_exec output includes a formatted return value (trees, lists, tracked collections, primitives) instead of only captured print text.
  • compose_run_output: when the solution returns None, only stdout is shown (no trailing None), so print-only runs stay unchanged.
  • tree_utils: binary_tree_to_display_string / linked_list_to_display_string stay the single source of truth; TreeNode, InstrumentedTreeNode, ListNode, and InstrumentedListNode implement __repr__ / __str__ using those helpers (reads go through __dict__ where needed to avoid extra blink frames).
  • Linked list display follows duck-typed val/next nodes without left when the next pointer is not a ListNode subclass.
  • Pyodide: register solution_display.py in HARNESS_FILES.
  • Tests: test_exec covers returned tracked tree/list output; test_tree_utils covers instrumented tree repr/str.

Verification

  • pnpm test (Vitest + Python harness unittest)
  • Pre-push pnpm lint (warnings only, no new errors)
Open in Web Open in Cursor 

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dstruct Error Error May 21, 2026 8:48pm

cursoragent and others added 4 commits May 20, 2026 20:24
- Add TrackedDict and TrackedSet with callstack frames (map/set arg types)
- Extend AST transformer for {}, set literals, dict/set comprehensions
- Deep-wrap array/matrix/map/object/set arguments from JSON for nested tracking
- Register collection_tracker in Pyodide harness; add unit tests

Co-authored-by: Max Kayander <mkayander@users.noreply.github.com>
…te args

- TrackedSet.add: use super().__contains__ for membership so no readArrayItem
  frame when rejecting duplicates
- _convert_arg_to_python: require each arg to be a dict (explicit TypeError)
- Remove unused os import from exec.py
- Add regression tests for duplicate add and malformed args list

Co-authored-by: Max Kayander <mkayander@users.noreply.github.com>
…PIs, docs

- Add TrackedFrozenSet and AST rewrite for frozenset(...) calls
- Deep-wrap graph args like arrays; TypeError if value is not a JSON list
- TrackedDict: setdefault, pop, popitem, clear, update with frame semantics
- TrackedSet: pop, clear; discard/remove avoid spurious read via super
- Document harness contracts in docs/PYTHON_PYODIDE.md
- Extend test_exec for frozenset, graph, dict.clear

Co-authored-by: Max Kayander <mkayander@users.noreply.github.com>
…exec args

- Restore TrackedDict class boundary broken during rebase; unify frames on
  self._add_frame; add _emit_collection_frame for TrackedFrozenSet.__new__
- exec: null array/matrix -> TrackedList; set/map require list/dict; remove
  silent wrong-type pass-through for map/object

Co-authored-by: Max Kayander <mkayander@users.noreply.github.com>
@cursor cursor Bot force-pushed the cursor/python-collections-auto-tracking-04a1 branch from 1f059d2 to a9fa558 Compare May 20, 2026 20:26
@mkayander mkayander marked this pull request as ready for review May 21, 2026 08:15
Wire safe_exec output through compose_run_output so the UI shows level-order
trees and linked-list chains instead of default object reprs. Add __repr__/
__str__ on instrumented and plain tree/list nodes; dedupe display logic via
tree_utils helpers. Register solution_display.py for Pyodide and add tests.
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.

2 participants