feat: workflow-definitions, events, and workflow-memory CLI groups#10
Open
arnav2 wants to merge 2 commits into
Open
feat: workflow-definitions, events, and workflow-memory CLI groups#10arnav2 wants to merge 2 commits into
arnav2 wants to merge 2 commits into
Conversation
Wraps three new ksapi surfaces shipped in 1.84.0:
- `kscli workflow-definitions {create,list,describe,update,delete,invoke,runs}`
— full lifecycle for workflow definitions (WorkflowDefinitionsApi).
- `kscli events {list,append}` — audit-log events on a path part
(PathPartsApi.{list,append}_path_part_event); supports
--kind/--since/--until/--recursive filters.
- `kscli workflow-memory {list,describe,append,edit,forget}` — long-term
memory chunks attached to a workflow definition (WorkflowMemoryApi).
Bumps `ksapi>=1.84.0` and repairs collateral SDK renames so existing
commands keep working:
- `chunks`: `ChunkMetadataInput` → `ChunkMetadata`.
- `tags attach`: SDK removed `bulk_add_path_part_tags`; reimplemented as
`get_path_part_tags` → merge → `set_path_part_tags`. NOTE: this path is
now non-atomic (lost-update race possible between read and write) and
`BulkTagRequest.tag_ids` is capped at 10, so attach will fail on a path
part that already has 10 tags.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
E2E CI failure analysis — not caused by this PRCI run: 100 passed, 10 failed. All 10 failures share the same backend stderr: Why this isn't this PR's fault
Unblock path (out of scope for this PR)
Recommend landing this PR on the strength of the three new groups + the SDK-bump repair, with the checkout work tracked separately. |
The backend now requires a write lock (POST /v1/documents/{id}/checkout)
before mutating a document, its versions, sections, chunks, or lineage.
ksapi does not yet expose the checkout endpoints, so this commit adds a
small helper that calls them via the SDK's raw `param_serialize` +
`call_api` path while reusing the authenticated `ApiClient`.
The helper exposes:
- `with_document_checkout(api_client, path_part_id)` — context manager
that acquires on enter and releases on exit (release errors are
swallowed and logged; the server-side TTL will reap the lock anyway).
- `resolve_document_path_part_id` / `resolve_version_document_path_part_id`
/ `resolve_ancestor_document_path_part_id` — helpers to find the
governing document's path_part_id starting from a document id, a
version id, or any descendant path_part_id (walks parent chain until
a DOCUMENT node).
Each affected write command resolves the document and wraps its
mutation in the context manager:
- documents: `update`, `delete`
- document-versions: `create`, `update`, `delete`, `clear-contents`
- sections: `create`, `update`, `delete`
- chunks: `create`, `update`, `update-content`, `delete`
- chunk-lineages: `create`, `delete`
All 12 previously-failing Write e2e tests now pass locally.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three new top-level
kscliresource groups wrapping the new endpoints shipped inksapi 1.84.0:kscli workflow-definitions— full lifecycle:create,list,describe,update,delete,invoke,runs. Create takes--name,--runner-type, repeatable--source-path-part-id/--instruction-path-part-id/--output-path-part-id(1–20 each), plus optional--description,--runner-config(JSON),--max-run-duration-seconds,--template-path-part-id.kscli events— audit-log events scoped to a path part:events list <path_part_id>with--kind/--since/--until/--recursive/--limit/--offset, andevents append <path_part_id> --kind … [--payload '{…}'].kscli workflow-memory— long-term memory chunks scoped to a workflow definition:list,describe,append(--body, optional--kind∈ CORRECTION/PREFERENCE/EXAMPLE),edit,forget.Bumps
ksapi>=1.84.0and repairs collateral SDK renames in existing commands so the bump doesn't regress anything:chunks:ChunkMetadataInput→ChunkMetadata.tags attach: SDK removedbulk_add_path_part_tags; reimplemented asget_path_part_tags→ merge →set_path_part_tags.BulkTagRequest.tag_idsis capped at 10, so attach fails on a path part already at 10 tags. Worth a follow-up if we want to exposesetsemantics directly.agent_helpandkscli --helpauto-pick up the new groups;CLAUDE.mdresource list updated. Read-only e2e tests added for each new group, matching the existing convention.Test plan
make pre-commit— green (ruff clean, basedpyright 0 errors, 11/11 unit tests).mainbaseline — they're caused by the local e2e backend atlocalhost:28000being behind on schema migrations (document_checkouttable missing,workflow_definition.instruction_path_part_idcolumn-name mismatch) and an unrelated pre-existingPathimport bug intests/e2e/test_cli_folders.py. Not introduced by this PR.workflow-definitions list,events list, andworkflow-memory listpass against real data.workflow-definitions create+invokeend-to-end.tags attachatomicity regression in a follow-up or exposetags setdirectly.🤖 Generated with Claude Code