Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions composer/cvl/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from composer.ui.tool_display import tool_display_of, CommonTools, ToolDisplay, suppress_ack

from graphcore.graph import tool_state_update
from graphcore.serial_tools import serialize_writes

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -162,6 +163,16 @@ def put_cvl_raw(
"""Put a CVL file using raw surface syntax."""
return maybe_update_cvl(tool_call_id=tool_call_id, pp=cvl_file, reset_read=DEFAULT_READ_KEY, spec_key=DEFAULT_SPEC_KEY)


# Every tool that rewrites the spec buffer belongs to one serialization group: a
# turn containing two of them runs them in sequence, each editing the buffer the
# previous one produced (see graphcore.serial_tools).
_SPEC_WRITES = (DEFAULT_SPEC_KEY, DEFAULT_READ_KEY)

serialize_writes(put_cvl, *_SPEC_WRITES)
serialize_writes(put_cvl_raw, *_SPEC_WRITES)


class WithCurrSpec(TypedDict):
curr_spec: str | None

Expand Down Expand Up @@ -228,7 +239,10 @@ def get_cvl(
**update
)
return spec
return get_cvl
# Only the did_read-stamping variant writes state, and `did_read` is the same
# plain channel the spec writers reset — so it joins their serialization
# group. The plain reader returns a string and needs no declaration.
return serialize_writes(get_cvl, DEFAULT_READ_KEY) if set_did_read else get_cvl


edit_cvl_description = """
Expand Down Expand Up @@ -280,4 +294,4 @@ def edit_cvl(**args) -> str | Command:
spec_key=DEFAULT_SPEC_KEY,
reset_read=DEFAULT_READ_KEY,
)
return edit_cvl
return serialize_writes(edit_cvl, *_SPEC_WRITES)
2 changes: 1 addition & 1 deletion graphcore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the graphcore PR is done and merged I'll update this to pint at the "real" master.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ authors = [
]

dependencies = [
"graphcore @ git+ssh://git@github.com/Certora/graphcore.git@5b295139242ba81ecc98ef986deb0ea31a240b68",
"graphcore @ git+ssh://git@github.com/Certora/graphcore.git@dedcb9abb914508d9dcc9426fb4a010abb0f702c",
"aiohttp>=3.13",
"attrs>=26.1",
"Jinja2>=3.1",
Expand Down
Loading