pawc-kit 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pawc_kit-0.5.0/LICENSE +190 -0
- pawc_kit-0.5.0/PKG-INFO +430 -0
- pawc_kit-0.5.0/README.md +403 -0
- pawc_kit-0.5.0/pyproject.toml +117 -0
- pawc_kit-0.5.0/setup.cfg +4 -0
- pawc_kit-0.5.0/src/pawc_kit/__init__.py +27 -0
- pawc_kit-0.5.0/src/pawc_kit/_fs_atomic.py +16 -0
- pawc_kit-0.5.0/src/pawc_kit/_sentinel.py +14 -0
- pawc_kit-0.5.0/src/pawc_kit/_session_config.py +108 -0
- pawc_kit-0.5.0/src/pawc_kit/_time.py +10 -0
- pawc_kit-0.5.0/src/pawc_kit/_versioning.py +65 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/__init__.py +41 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/always_continue.py +20 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/factory.py +68 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/fs/__init__.py +24 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/fs/_io.py +7 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/fs/artifact_store.py +169 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/fs/context.py +159 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/fs/runtime.py +95 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/fs/state_store.py +134 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/local_invoker.py +130 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/logging.py +98 -0
- pawc_kit-0.5.0/src/pawc_kit/adapters/otel.py +382 -0
- pawc_kit-0.5.0/src/pawc_kit/async_session.py +206 -0
- pawc_kit-0.5.0/src/pawc_kit/config/__init__.py +5 -0
- pawc_kit-0.5.0/src/pawc_kit/config/loader.py +92 -0
- pawc_kit-0.5.0/src/pawc_kit/context.py +488 -0
- pawc_kit-0.5.0/src/pawc_kit/contracts/__init__.py +131 -0
- pawc_kit-0.5.0/src/pawc_kit/contracts/artifacts.py +114 -0
- pawc_kit-0.5.0/src/pawc_kit/contracts/config.py +215 -0
- pawc_kit-0.5.0/src/pawc_kit/contracts/context.py +54 -0
- pawc_kit-0.5.0/src/pawc_kit/contracts/discovery.py +114 -0
- pawc_kit-0.5.0/src/pawc_kit/contracts/errors.py +53 -0
- pawc_kit-0.5.0/src/pawc_kit/contracts/events.py +217 -0
- pawc_kit-0.5.0/src/pawc_kit/contracts/execution.py +86 -0
- pawc_kit-0.5.0/src/pawc_kit/contracts/state.py +101 -0
- pawc_kit-0.5.0/src/pawc_kit/layout.py +58 -0
- pawc_kit-0.5.0/src/pawc_kit/llm/__init__.py +62 -0
- pawc_kit-0.5.0/src/pawc_kit/llm/backend.py +102 -0
- pawc_kit-0.5.0/src/pawc_kit/llm/compressor.py +355 -0
- pawc_kit-0.5.0/src/pawc_kit/llm/mock.py +139 -0
- pawc_kit-0.5.0/src/pawc_kit/llm/prompts.py +548 -0
- pawc_kit-0.5.0/src/pawc_kit/llm/roles.py +621 -0
- pawc_kit-0.5.0/src/pawc_kit/llm/structured.py +355 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/__init__.py +50 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/artifacts.py +157 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/clock.py +22 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/compressor.py +23 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/context.py +64 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/controller.py +47 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/invoker.py +48 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/observers.py +46 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/prompts.py +58 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/runtime.py +88 -0
- pawc_kit-0.5.0/src/pawc_kit/ports/state.py +75 -0
- pawc_kit-0.5.0/src/pawc_kit/py.typed +1 -0
- pawc_kit-0.5.0/src/pawc_kit/session.py +245 -0
- pawc_kit-0.5.0/src/pawc_kit/validators.py +71 -0
- pawc_kit-0.5.0/src/pawc_kit/workflow/__init__.py +33 -0
- pawc_kit-0.5.0/src/pawc_kit/workflow/engine.py +1460 -0
- pawc_kit-0.5.0/src/pawc_kit/workflow/graph.py +300 -0
- pawc_kit-0.5.0/src/pawc_kit/workflow/roles.py +111 -0
- pawc_kit-0.5.0/src/pawc_kit.egg-info/PKG-INFO +430 -0
- pawc_kit-0.5.0/src/pawc_kit.egg-info/SOURCES.txt +66 -0
- pawc_kit-0.5.0/src/pawc_kit.egg-info/dependency_links.txt +1 -0
- pawc_kit-0.5.0/src/pawc_kit.egg-info/requires.txt +11 -0
- pawc_kit-0.5.0/src/pawc_kit.egg-info/top_level.txt +1 -0
- pawc_kit-0.5.0/tests/test_public_api.py +238 -0
pawc_kit-0.5.0/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 pawc-kit contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
pawc_kit-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pawc-kit
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: PAWC Core: shared SDK for workflow models, state, layout, and orchestration
|
|
5
|
+
Author-email: agsuy <37564412+agsuy@users.noreply.github.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/agsuy/pawc-kit
|
|
8
|
+
Project-URL: Issues, https://github.com/agsuy/pawc-kit/issues
|
|
9
|
+
Keywords: workflow,orchestration,llm,sdk
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.12
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: pydantic>=2.0
|
|
18
|
+
Requires-Dist: pyyaml>=6.0
|
|
19
|
+
Requires-Dist: semver<4,>=3.0
|
|
20
|
+
Requires-Dist: toon-formatter>=1.0
|
|
21
|
+
Provides-Extra: otel
|
|
22
|
+
Requires-Dist: opentelemetry-api>=1.28.0; extra == "otel"
|
|
23
|
+
Requires-Dist: opentelemetry-sdk>=1.28.0; extra == "otel"
|
|
24
|
+
Provides-Extra: semantic
|
|
25
|
+
Requires-Dist: semantic-text-splitter>=0.18; extra == "semantic"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# pawc-kit
|
|
29
|
+
|
|
30
|
+
`pawc-kit` is a Python library for **multi-phase execution and review workflows**: execution graphs from native `config.yaml`, **discovery** graphs from `DiscoveryConfig`, filesystem-backed default adapters, and a stable **LLM** integration layer (backends, structured output, prompt assembly, LLM roles). Sync and **async** engines and sessions are both first-class.
|
|
31
|
+
|
|
32
|
+
The supported public surface is:
|
|
33
|
+
|
|
34
|
+
- `pawc_kit` (slim: version, `utc_now`, config loaders, `WorkflowSession`, `AsyncWorkflowSession`)
|
|
35
|
+
- `pawc_kit.config`
|
|
36
|
+
- `pawc_kit.contracts`
|
|
37
|
+
- `pawc_kit.workflow`
|
|
38
|
+
- `pawc_kit.ports`
|
|
39
|
+
- `pawc_kit.adapters` (built-in adapters; submodules like `adapters.fs` remain valid)
|
|
40
|
+
- `pawc_kit.context`
|
|
41
|
+
- `pawc_kit.llm`
|
|
42
|
+
|
|
43
|
+
Example YAML by schema (`RootConfig`, `DiscoveryConfig`, `RoleConfig`) lives under [`templates/`](templates/) — see [`templates/README.md`](templates/README.md). Field-by-field native `config.yaml` reference: [`docs/workflow-config-reference.md`](docs/workflow-config-reference.md). **How the library is layered** (contracts → ports → workflow → adapters): [`docs/architecture.md`](docs/architecture.md). For the HTTP control plane and server-side deployment, see the **pawc-server** repository (`docs/architecture.md`, `templates/README.md`).
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
Using `uv`:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uv sync --dev
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Core dependencies include [**semver**](https://pypi.org/project/semver/) for SemVer 2.0 validation of skill/role and session version fields.
|
|
54
|
+
|
|
55
|
+
Optional extras:
|
|
56
|
+
|
|
57
|
+
- **OpenTelemetry** — metrics and tracing: `uv sync --dev --extra otel` or `pip install -e .[otel]`
|
|
58
|
+
- **Semantic compression** — [semantic-text-splitter](https://github.com/benbrandt/text-splitter) for chunk-based prompt compression: `uv sync --dev --extra semantic` or `pip install -e .[semantic]`
|
|
59
|
+
|
|
60
|
+
Requires Python 3.12+.
|
|
61
|
+
|
|
62
|
+
## Releases
|
|
63
|
+
|
|
64
|
+
The repo includes [python-semantic-release](https://python-semantic-release.readthedocs.io/)
|
|
65
|
+
configuration for SemVer bumps, [`CHANGELOG.md`](CHANGELOG.md), and `v*`
|
|
66
|
+
release tags based on conventional commits (see
|
|
67
|
+
[`CONTRIBUTING.md`](CONTRIBUTING.md)).
|
|
68
|
+
|
|
69
|
+
## Quick Start (config-driven)
|
|
70
|
+
|
|
71
|
+
The recommended way to run a workflow is via `WorkflowSession`, which reads
|
|
72
|
+
`config.yaml` and builds the workflow graph, engine policy, and directory
|
|
73
|
+
layout from it. Only role bindings and optional runtime objects (observer,
|
|
74
|
+
clock) are supplied in code.
|
|
75
|
+
|
|
76
|
+
**config.yaml**
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
skill:
|
|
80
|
+
name: my-skill
|
|
81
|
+
version: "1.0.0"
|
|
82
|
+
state_directory: sessions
|
|
83
|
+
|
|
84
|
+
workflow:
|
|
85
|
+
phases:
|
|
86
|
+
- phase_id: work
|
|
87
|
+
role_id: worker
|
|
88
|
+
kind: executor
|
|
89
|
+
on_complete: [review]
|
|
90
|
+
- phase_id: review
|
|
91
|
+
role_id: reviewer
|
|
92
|
+
kind: review
|
|
93
|
+
can_request_changes_from: [work]
|
|
94
|
+
confidence_threshold: 85
|
|
95
|
+
max_iterations: 10
|
|
96
|
+
max_feedback_rounds: 3
|
|
97
|
+
run_directory: sessions/execution
|
|
98
|
+
state_filename: state.json
|
|
99
|
+
|
|
100
|
+
observability:
|
|
101
|
+
observer: otel # "otel" | "logging" | "none" (default: none)
|
|
102
|
+
meter_name: pawc_kit.workflow # for otel; ignored when observer != "otel"
|
|
103
|
+
tracer_name: pawc_kit.workflow # for otel; ignored when observer != "otel"
|
|
104
|
+
logger_name: pawc_kit.workflow # for logging; ignored when observer != "logging"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Python**
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from pawc_kit import WorkflowSession
|
|
111
|
+
|
|
112
|
+
session = WorkflowSession.from_config("config.yaml")
|
|
113
|
+
session.register_role("worker", my_worker)
|
|
114
|
+
session.register_role("reviewer", my_reviewer)
|
|
115
|
+
|
|
116
|
+
state = session.run(session_id="run-001")
|
|
117
|
+
print(state.status)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Any `workflow.*` value can be overridden in code when needed:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
session = WorkflowSession.from_config(
|
|
124
|
+
"config.yaml",
|
|
125
|
+
confidence_threshold=90, # override config value
|
|
126
|
+
run_directory="sessions/custom",
|
|
127
|
+
)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`WorkflowSession.run()` is resumable — calling it again with the same
|
|
131
|
+
`session_id` picks up where it left off.
|
|
132
|
+
|
|
133
|
+
Async equivalent (`from_config` is synchronous; `run` is async):
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from pawc_kit import AsyncWorkflowSession
|
|
137
|
+
|
|
138
|
+
session = AsyncWorkflowSession.from_config("config.yaml")
|
|
139
|
+
session.register_role("worker", my_async_worker)
|
|
140
|
+
session.register_role("reviewer", my_async_reviewer)
|
|
141
|
+
state = await session.run(session_id="run-001")
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Low-level engine usage
|
|
145
|
+
|
|
146
|
+
For full control over stores and paths, use `WorkflowEngine` directly:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from pathlib import Path
|
|
150
|
+
from pawc_kit.adapters.fs import FsArtifactStore, FsStateStore
|
|
151
|
+
from pawc_kit.workflow import WorkflowEngine
|
|
152
|
+
|
|
153
|
+
run_dir = Path(".tmp") / "demo-run"
|
|
154
|
+
engine = WorkflowEngine(graph, FsStateStore(run_dir), FsArtifactStore(run_dir))
|
|
155
|
+
engine.register_role("worker", my_worker)
|
|
156
|
+
engine.register_role("reviewer", my_reviewer)
|
|
157
|
+
|
|
158
|
+
state = engine.run(
|
|
159
|
+
session_id="session-1",
|
|
160
|
+
skill_name="demo-skill",
|
|
161
|
+
skill_version="0.1.0",
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`WorkflowEngine` keeps the active session state in memory and only persists at commit points:
|
|
166
|
+
|
|
167
|
+
- run start
|
|
168
|
+
- phase transition
|
|
169
|
+
- iteration commit
|
|
170
|
+
- review commit
|
|
171
|
+
- finalize
|
|
172
|
+
|
|
173
|
+
You can pass a `ContextPack` into `session.run(context_pack=pack)` or `engine.run(context_pack=pack)`. The engine scopes it per phase via `PhaseDefinition.context_sources` and injects it into `ExecutionContext.context` and `ReviewContext.context` for roles.
|
|
174
|
+
|
|
175
|
+
## Stable API
|
|
176
|
+
|
|
177
|
+
### Config Infrastructure
|
|
178
|
+
|
|
179
|
+
- `load_yaml_config`, `load_root_config`, `load_role_config`
|
|
180
|
+
- `RootConfig`, `SkillConfig`, `ContextConfig`, `EfficiencyConfig`, `RoleConfig`
|
|
181
|
+
- `ContextInjectionConfig`, `CompressionConfig`, `ChunkPolicyConfig`
|
|
182
|
+
- `WorkflowSession`, `AsyncWorkflowSession`
|
|
183
|
+
- `LayoutManager`
|
|
184
|
+
- `ContextPack`, `load_context_pack`, `accessible_packs`
|
|
185
|
+
- `check_quality_gates`, `validate_composition`
|
|
186
|
+
|
|
187
|
+
### Contracts
|
|
188
|
+
|
|
189
|
+
- `SessionState`, `IterationEntry`, `ReviewEntry`, `ArtifactRef`
|
|
190
|
+
- `DecisionPayload`, `HandoffContext`, handoff artifact types (`HandoffArtifact`, …)
|
|
191
|
+
- **Discovery:** `DiscoveryConfig`, `DiscoveryPhaseConfig`, `QuestionEntry`, …
|
|
192
|
+
- **Events:** `RunStarted`, `RunCompleted`, `PhaseStarted`, `IterationCommitted`, `ReviewCommitted`, … plus `event_to_dict` / `event_from_dict` helpers
|
|
193
|
+
- **Errors:** `PawcError`, `LLMError`, `ConcurrencyError`, …
|
|
194
|
+
|
|
195
|
+
### Workflow
|
|
196
|
+
|
|
197
|
+
- `PhaseDefinition`, `PhaseGraph` (including discovery-shaped graphs when built from `DiscoveryConfig`)
|
|
198
|
+
- `ExecutionContext`, `ReviewContext`
|
|
199
|
+
- `ExecutionResult`, `ReviewDecision`, `ReviewResult`
|
|
200
|
+
- `WorkflowEngine`, `AsyncWorkflowEngine`
|
|
201
|
+
- `Executor`, `Reviewer`, `AsyncExecutor`, `AsyncReviewer`
|
|
202
|
+
|
|
203
|
+
### Ports
|
|
204
|
+
|
|
205
|
+
- `StateStore`, `AsyncStateStore`
|
|
206
|
+
- `ArtifactStore`, `AsyncArtifactStore`
|
|
207
|
+
- `WorkflowObserver`, `AsyncWorkflowObserver`
|
|
208
|
+
- `Clock`, `AsyncClock`
|
|
209
|
+
- `ContextCompressor` — pluggable text compression for prompt injection
|
|
210
|
+
|
|
211
|
+
### Filesystem Adapters
|
|
212
|
+
|
|
213
|
+
- `FsStateStore`, `AsyncFsStateStore`
|
|
214
|
+
- `FsArtifactStore`, `AsyncFsArtifactStore`
|
|
215
|
+
|
|
216
|
+
## Generic Config Loading
|
|
217
|
+
|
|
218
|
+
The `config/` subpackage provides a generic YAML loader so that no consumer
|
|
219
|
+
needs to implement its own config processing:
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
from pydantic import BaseModel
|
|
223
|
+
from pawc_kit import load_yaml_config
|
|
224
|
+
|
|
225
|
+
class RunnerConfig(BaseModel):
|
|
226
|
+
max_retries: int = 3
|
|
227
|
+
|
|
228
|
+
# Flat config
|
|
229
|
+
cfg = load_yaml_config("my-config.yaml", RunnerConfig)
|
|
230
|
+
|
|
231
|
+
# Keyed config (e.g. runner-config.yaml with top-level "runner:" key)
|
|
232
|
+
cfg = load_yaml_config("runner-config.yaml", RunnerConfig, root_key="runner")
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Convenience wrappers for PAWC-defined config types:
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
from pawc_kit import load_root_config, load_role_config
|
|
239
|
+
|
|
240
|
+
root = load_root_config("config.yaml") # -> RootConfig
|
|
241
|
+
role = load_role_config("worker/config.yaml") # -> RoleConfig
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## LLM Integrations
|
|
245
|
+
|
|
246
|
+
LLM helpers are available under the stable namespace:
|
|
247
|
+
|
|
248
|
+
```python
|
|
249
|
+
from pawc_kit.llm import (
|
|
250
|
+
MockBackend,
|
|
251
|
+
LLMExecutorRole,
|
|
252
|
+
LLMReviewerRole,
|
|
253
|
+
StructuredOutput,
|
|
254
|
+
AsyncStructuredOutput,
|
|
255
|
+
)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Backends implement `LLMBackend` / `AsyncLLMBackend` (`complete(..., max_tokens: int | None = None)`). `StructuredOutput` / `AsyncStructuredOutput` call the backend, parse JSON into Pydantic models (trying multiple fenced blocks / extractions), and retry on validation failure; async structured output supports optional exponential backoff between retries (`retry_delay` on `AsyncStructuredOutput`).
|
|
259
|
+
|
|
260
|
+
### Context injection and compression
|
|
261
|
+
|
|
262
|
+
Context pack data (request files, discovery handoff, child packs) is injected into executor and reviewer prompts according to `RootConfig.context_injection` (`ContextInjectionConfig`). You control:
|
|
263
|
+
|
|
264
|
+
- **What to include** — `include_request_files`, `include_discovery`, `include_children`
|
|
265
|
+
- **Filtering** — `file_allowlist`, `file_blocklist`, `max_file_chars`, `discovery_sections`
|
|
266
|
+
- **Compression** — `compression.mode`: `"simple"` (default regex-based `MarkdownCompressor`), `"semantic"` (chunk → classify → policy → reassemble, requires `pawc-kit[semantic]`), or `"none"` (`PassthroughCompressor`)
|
|
267
|
+
|
|
268
|
+
With `mode: "semantic"`, per-chunk-type policies are configurable in YAML (`compression.policies`): `heading`, `paragraph`, `list`, `code`, `table`, `diagram`, each with `action` (`keep` / `truncate` / `collapse` / `strip`) and optional limits (`max_sentences`, `max_items`, `max_lines`, `max_rows`). The semantic pipeline uses [semantic-text-splitter](https://github.com/benbrandt/text-splitter) as the boundary oracle, then a heuristic classifier and your policies.
|
|
269
|
+
|
|
270
|
+
Implementations: `MarkdownCompressor`, `PassthroughCompressor`, `SemanticCompressor`; all implement the `ContextCompressor` protocol. The prompt builder resolves the compressor from config when building request and discovery sections; an explicit `compressor` argument overrides.
|
|
271
|
+
|
|
272
|
+
## Observability
|
|
273
|
+
|
|
274
|
+
`pawc_kit` emits immutable workflow events through the `WorkflowObserver` port. Built-in adapters are available for standard-library logging and OpenTelemetry.
|
|
275
|
+
|
|
276
|
+
### Config-driven observer selection
|
|
277
|
+
|
|
278
|
+
Set `observability.observer` in `config.yaml` to auto-construct an observer without writing any wiring code. The session resolves the observer with the following precedence:
|
|
279
|
+
|
|
280
|
+
1. Explicit `observer=SomeObserver()` kwarg wins.
|
|
281
|
+
2. Explicit `observer=None` suppresses the observer (even if config says `otel`).
|
|
282
|
+
3. Omitted kwarg -- auto-constructed from `config.observability` (default: `"none"`).
|
|
283
|
+
|
|
284
|
+
```yaml
|
|
285
|
+
observability:
|
|
286
|
+
observer: otel # "otel" | "logging" | "none"
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The `otel` value requires `pawc-kit[otel]`. An explicit `observer=` kwarg on `WorkflowSession` / `AsyncWorkflowSession` always takes precedence.
|
|
290
|
+
|
|
291
|
+
### Logging adapter
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
import logging
|
|
295
|
+
|
|
296
|
+
from pawc_kit.adapters import LoggingWorkflowObserver
|
|
297
|
+
|
|
298
|
+
logging.basicConfig(level=logging.INFO)
|
|
299
|
+
logging.getLogger("pawc_kit.workflow").setLevel(logging.DEBUG)
|
|
300
|
+
|
|
301
|
+
observer = LoggingWorkflowObserver()
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Level selection follows normal Python library conventions:
|
|
305
|
+
|
|
306
|
+
- configure `pawc_kit.workflow` to request lifecycle logs at `DEBUG`, `INFO`, `WARNING`, or `ERROR`
|
|
307
|
+
- configure `pawc_kit.llm` to include structured-output retry and failure logs
|
|
308
|
+
- the library installs a `NullHandler` on `pawc_kit` and never calls `basicConfig()`
|
|
309
|
+
|
|
310
|
+
Default logging adapter level mapping:
|
|
311
|
+
|
|
312
|
+
- `INFO`: `RunStarted`, `RunResumed`, successful `RunCompleted`
|
|
313
|
+
- `DEBUG`: `PhaseStarted`, `PhaseTransitioned`, `IterationCommitted`, approved `ReviewCommitted`
|
|
314
|
+
- `WARNING`: `ReviewCommitted` with `REQUEST_CHANGES`, abandoned `RunCompleted`
|
|
315
|
+
- `ERROR`: `RunFailed`
|
|
316
|
+
|
|
317
|
+
### OpenTelemetry adapter
|
|
318
|
+
|
|
319
|
+
Requires `pawc-kit[otel]`. Handles all 8 workflow event types with **metrics** (counters and histograms) and **traces** (nested spans).
|
|
320
|
+
|
|
321
|
+
```python
|
|
322
|
+
from pawc_kit.adapters import OpenTelemetryWorkflowObserver
|
|
323
|
+
|
|
324
|
+
observer = OpenTelemetryWorkflowObserver(
|
|
325
|
+
meter_name="pawc_kit.workflow",
|
|
326
|
+
tracer_name="pawc_kit.workflow",
|
|
327
|
+
)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Span hierarchy (parent → child): **run** → **phase** → **iteration** / **review**.
|
|
331
|
+
|
|
332
|
+
| Span name | Created on | Ended on | Typical attributes |
|
|
333
|
+
|---|---|---|---|
|
|
334
|
+
| `pawc.workflow.run` | `RunStarted`, `RunResumed` | `RunCompleted`, `RunFailed` | `session_id`, `phase_id`, `resumed`, `skill_name` (when `RunStarted`); on completion: `run.status`, `run.feedback_loops` or `error.type` / `error.message` |
|
|
335
|
+
| `pawc.workflow.phase` | `PhaseStarted` | `PhaseTransitioned`, run end | `session_id`, `phase_id`, `role_id`, `phase_kind` |
|
|
336
|
+
| `pawc.workflow.iteration` | `IterationCommitted` | same event (duration from event timestamps) | `session_id`, `phase_id`, `iteration`, `confidence_score` |
|
|
337
|
+
| `pawc.workflow.review` | `ReviewCommitted` | same event (duration from event timestamps) | `session_id`, `phase_id`, `review`, `decision`, `confidence_score` |
|
|
338
|
+
|
|
339
|
+
Metrics emitted:
|
|
340
|
+
|
|
341
|
+
| Instrument | Type | Attributes | Event |
|
|
342
|
+
|---|---|---|---|
|
|
343
|
+
| `pawc.workflow.runs` | counter | `phase_id`, `outcome` | `RunStarted`, `RunCompleted` |
|
|
344
|
+
| `pawc.workflow.run_failures` | counter | `phase_id` | `RunFailed` |
|
|
345
|
+
| `pawc.workflow.iterations` | counter | `phase_id`, `outcome` | `IterationCommitted` |
|
|
346
|
+
| `pawc.workflow.reviews` | counter | `phase_id`, `outcome` | `ReviewCommitted` |
|
|
347
|
+
| `pawc.workflow.phases` | counter | `phase_id`, `phase_kind` | `PhaseStarted` |
|
|
348
|
+
| `pawc.workflow.transitions` | counter | `from_phase`, `to_phase` | `PhaseTransitioned` |
|
|
349
|
+
| `pawc.workflow.resumes` | counter | `phase_id`, `phase_kind` | `RunResumed` |
|
|
350
|
+
| `pawc.workflow.run.duration.seconds` | histogram | `outcome` | `RunCompleted` |
|
|
351
|
+
| `pawc.workflow.iteration.duration.seconds` | histogram | `phase_id` | `IterationCommitted` |
|
|
352
|
+
| `pawc.workflow.review.duration.seconds` | histogram | `phase_id` | `ReviewCommitted` |
|
|
353
|
+
|
|
354
|
+
Design notes:
|
|
355
|
+
|
|
356
|
+
- **Metrics:** low-cardinality attributes only; `session_id` is never included in metric labels.
|
|
357
|
+
- **Traces:** `session_id` is included on spans (expected for request-scoped traces and distinct from the metrics policy).
|
|
358
|
+
- **Threading:** the observer assumes single-threaded event delivery per session (same model as the default filesystem stores); span state is not locked.
|
|
359
|
+
- **Defensive behavior:** if events arrive without a parent span (e.g. `PhaseStarted` before `RunStarted`), child spans are still recorded as roots; duplicate `RunStarted` for the same session ends the previous run span before opening a new one.
|
|
360
|
+
- `AsyncOpenTelemetryWorkflowObserver` delegates to the sync observer (OTEL SDK calls are CPU-bound)
|
|
361
|
+
|
|
362
|
+
## Architecture
|
|
363
|
+
|
|
364
|
+
**Narrative and diagrams:** [`docs/architecture.md`](docs/architecture.md) (execution vs discovery config, async vs sync, related docs).
|
|
365
|
+
|
|
366
|
+
The public architecture is split into layers:
|
|
367
|
+
|
|
368
|
+
```mermaid
|
|
369
|
+
flowchart TD
|
|
370
|
+
contracts["contracts<br/>models, events, errors"]
|
|
371
|
+
ports["ports<br/>abstract interfaces"]
|
|
372
|
+
workflow["workflow<br/>graph, roles, engine"]
|
|
373
|
+
adapters["adapters<br/>filesystem, logging, OpenTelemetry"]
|
|
374
|
+
config["config<br/>YAML loading and validation"]
|
|
375
|
+
llm["llm<br/>backends, prompts, roles, structured output, compressors"]
|
|
376
|
+
session["session.py / async_session.py<br/>config-driven orchestration"]
|
|
377
|
+
context["context.py<br/>context pack loading and scoping"]
|
|
378
|
+
layout["layout.py<br/>run directory management"]
|
|
379
|
+
validators["validators.py<br/>composition and quality gates"]
|
|
380
|
+
|
|
381
|
+
contracts --> ports
|
|
382
|
+
contracts --> workflow
|
|
383
|
+
contracts --> adapters
|
|
384
|
+
contracts --> config
|
|
385
|
+
contracts --> llm
|
|
386
|
+
ports --> workflow
|
|
387
|
+
ports --> adapters
|
|
388
|
+
workflow --> llm
|
|
389
|
+
config --> session
|
|
390
|
+
config --> context
|
|
391
|
+
config --> llm
|
|
392
|
+
workflow --> session
|
|
393
|
+
workflow --> llm
|
|
394
|
+
adapters --> session
|
|
395
|
+
context --> workflow
|
|
396
|
+
validators --> context
|
|
397
|
+
validators --> llm
|
|
398
|
+
layout --> session
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Execution wiring follows the same direction: config/session code builds the graph and
|
|
402
|
+
adapters, then hands execution to the workflow engine and role implementations.
|
|
403
|
+
|
|
404
|
+
1. `contracts` — pure data models and error types
|
|
405
|
+
2. `ports` — abstract interfaces (state, artifacts, observers, clock)
|
|
406
|
+
3. `workflow` — engine, phase graph, role protocols
|
|
407
|
+
4. `adapters` — filesystem and observability implementations
|
|
408
|
+
5. `config` — YAML config loading and validation infrastructure
|
|
409
|
+
6. `llm` — LLM backend integration (roles, structured output, prompts, context injection, compressors: `MarkdownCompressor`, `SemanticCompressor`, `PassthroughCompressor`)
|
|
410
|
+
|
|
411
|
+
Top-level modules bridge config with the engine:
|
|
412
|
+
|
|
413
|
+
- `session.py` — `WorkflowSession` orchestrator (config -> layout -> stores -> engine)
|
|
414
|
+
- `context.py` — context pack loading, resolution, scoping
|
|
415
|
+
- `layout.py` — run directory structure management
|
|
416
|
+
- `validators.py` — composition and quality-gate validation
|
|
417
|
+
|
|
418
|
+
## Development
|
|
419
|
+
|
|
420
|
+
Primary local workflow:
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
./scripts/verify.sh # lint (fix), test, lint-check, type-check, test
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
Or run individual steps: `./scripts/lint.sh`, `./scripts/test.sh`, `./scripts/lint-check.sh`, `./scripts/type-check.sh`. Use `./scripts/commit.sh "type(scope): subject"` for commit message validation.
|
|
427
|
+
|
|
428
|
+
## License
|
|
429
|
+
|
|
430
|
+
Apache-2.0
|