dbt-cortex-agent 0.0.3__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.
- dbt_cortex_agent-0.0.3/LICENSE +201 -0
- dbt_cortex_agent-0.0.3/MANIFEST.in +4 -0
- dbt_cortex_agent-0.0.3/PKG-INFO +196 -0
- dbt_cortex_agent-0.0.3/README.md +173 -0
- dbt_cortex_agent-0.0.3/pyproject.toml +36 -0
- dbt_cortex_agent-0.0.3/setup.cfg +4 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/__init__.py +5 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/artifacts.py +26 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/cli.py +90 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/commands/__init__.py +1 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/commands/agent.py +115 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/commands/bootstrap.py +92 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/commands/common.py +62 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/commands/eval.py +143 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/commands/manifest.py +48 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/commands/skill.py +129 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/config.py +88 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/dbt_runner.py +93 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/doctor.py +204 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/eval/__init__.py +0 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/eval/baseline.py +44 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/eval/compare.py +68 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/eval/dataset.py +128 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/eval/gate.py +31 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/eval/lifecycle.py +567 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/eval/results.py +195 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/execution_context.py +136 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/identifiers.py +46 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/init.py +322 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/invoke.py +140 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/manifest.py +285 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/skills.py +181 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/snow.py +11 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/starters/orders/models/agents/orders_assistant/agent.yml +7 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/starters/orders/models/agents/orders_assistant/evals/core.yml +54 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/starters/orders/models/agents/orders_assistant/evals/orders_assistant_core.sql +50 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/starters/orders/models/agents/orders_assistant/orders_assistant.sql +54 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/starters/orders/models/semantic/sem_orders.sql +40 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/starters/orders/seeds/orders.csv +4 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent/starters/orders/seeds/orders.yml +19 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent.egg-info/PKG-INFO +196 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent.egg-info/SOURCES.txt +62 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent.egg-info/dependency_links.txt +1 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent.egg-info/entry_points.txt +2 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent.egg-info/requires.txt +12 -0
- dbt_cortex_agent-0.0.3/src/dbt_cortex_agent.egg-info/top_level.txt +1 -0
- dbt_cortex_agent-0.0.3/tests/test_ci.py +259 -0
- dbt_cortex_agent-0.0.3/tests/test_cli.py +110 -0
- dbt_cortex_agent-0.0.3/tests/test_config.py +54 -0
- dbt_cortex_agent-0.0.3/tests/test_docs.py +45 -0
- dbt_cortex_agent-0.0.3/tests/test_doctor.py +240 -0
- dbt_cortex_agent-0.0.3/tests/test_eval.py +1027 -0
- dbt_cortex_agent-0.0.3/tests/test_eval_plan_macros.py +123 -0
- dbt_cortex_agent-0.0.3/tests/test_execution_context.py +140 -0
- dbt_cortex_agent-0.0.3/tests/test_init.py +369 -0
- dbt_cortex_agent-0.0.3/tests/test_installed_wheel_verifier.py +165 -0
- dbt_cortex_agent-0.0.3/tests/test_invoke.py +184 -0
- dbt_cortex_agent-0.0.3/tests/test_live_multi_database_verifier.py +120 -0
- dbt_cortex_agent-0.0.3/tests/test_manifest.py +229 -0
- dbt_cortex_agent-0.0.3/tests/test_materialization.py +120 -0
- dbt_cortex_agent-0.0.3/tests/test_project_skill.py +43 -0
- dbt_cortex_agent-0.0.3/tests/test_public_content_policy.py +70 -0
- dbt_cortex_agent-0.0.3/tests/test_release_preflight.py +105 -0
- dbt_cortex_agent-0.0.3/tests/test_skills.py +213 -0
|
@@ -0,0 +1,201 @@
|
|
|
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 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 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 those 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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dbt-cortex-agent
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: dbt-native Snowflake Cortex Agent materialization with skill and evaluation tooling
|
|
5
|
+
Author: Jeremy Demlow
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Jeremy-Demlow/dbt-cortex-agent
|
|
8
|
+
Project-URL: Documentation, https://github.com/Jeremy-Demlow/dbt-cortex-agent/tree/v0.0.3/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/Jeremy-Demlow/dbt-cortex-agent.git
|
|
10
|
+
Project-URL: Issues, https://github.com/Jeremy-Demlow/dbt-cortex-agent/issues
|
|
11
|
+
Requires-Python: <4,>=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: PyYAML<7,>=6.0
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
Requires-Dist: build>=1.2; extra == "test"
|
|
17
|
+
Requires-Dist: Jinja2<4,>=3.1; extra == "test"
|
|
18
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
19
|
+
Requires-Dist: tomli>=2; python_version < "3.11" and extra == "test"
|
|
20
|
+
Provides-Extra: runtime
|
|
21
|
+
Requires-Dist: snowflake-connector-python<5,>=3.18; extra == "runtime"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# dbt_cortex_agent
|
|
25
|
+
|
|
26
|
+
`dbt_cortex_agent` 0.0.3 is a Snowflake-only dbt package and Python companion for
|
|
27
|
+
defining, versioning, and evaluating Cortex Agents from dbt models. A
|
|
28
|
+
`materialized='cortex_agent'` model body is the native Agent YAML specification.
|
|
29
|
+
dbt owns the complete Agent lifecycle; Python is limited to local skill files,
|
|
30
|
+
runtime smoke, and evaluation coordination.
|
|
31
|
+
|
|
32
|
+
## Install one immutable version on two surfaces
|
|
33
|
+
|
|
34
|
+
Install the Python companion from PyPI:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pipx install 'dbt-cortex-agent[runtime]==0.0.3'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For a managed Python environment, use:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
python -m pip install 'dbt-cortex-agent[runtime]==0.0.3'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
dbt does not install packages from PyPI. Pin the dbt package separately to the
|
|
47
|
+
public HTTPS `v0.0.3` Git tag in `packages.yml`:
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
packages:
|
|
51
|
+
- git: "https://github.com/Jeremy-Demlow/dbt-cortex-agent.git"
|
|
52
|
+
revision: v0.0.3
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
PyPI version `0.0.3` and Git tag `v0.0.3` identify the same immutable release
|
|
56
|
+
across the CLI and dbt surfaces. Run `dbt deps`, then
|
|
57
|
+
`dbt-cortex-agent doctor --project-dir . --json`; `doctor` verifies that the CLI,
|
|
58
|
+
declared dbt dependency, and installed consumer dbt package versions align. A
|
|
59
|
+
full immutable Git SHA is accepted only when actual installed package metadata
|
|
60
|
+
under `dbt_packages/dbt_cortex_agent` reports the matching version; a source
|
|
61
|
+
checkout's root `dbt_project.yml` is not installation evidence. The supported
|
|
62
|
+
runtime is Python `>=3.10,<4`, dbt
|
|
63
|
+
`>=1.10,<2.0`, and `dbt-snowflake`; see [compatibility](docs/reference/compatibility.md)
|
|
64
|
+
and [installation](docs/getting-started/installation.md).
|
|
65
|
+
|
|
66
|
+
The CLI also requires the Snowflake CLI (`snow`) on `PATH`; `doctor` checks both
|
|
67
|
+
the `dbt` and `snow` executables. By default, `dbt-cortex-agent init` configures an existing
|
|
68
|
+
dbt project by appending missing dependency and safety-variable entries. It does
|
|
69
|
+
not create a dbt project or scaffold Agent models, semantic views, evaluation
|
|
70
|
+
models, seeds, or skill files.
|
|
71
|
+
|
|
72
|
+
For the fixed synthetic tutorial, preview the package-owned Orders starter in an
|
|
73
|
+
existing dbt project:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
dbt-cortex-agent init --project-dir . --starter orders \
|
|
77
|
+
--package-source https://github.com/Jeremy-Demlow/dbt-cortex-agent.git --json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The preview reports the exact seed, semantic-view, Agent, optional eval, dependency, and
|
|
81
|
+
`.dbtignore` actions without writing. After review, add `--apply`. The command
|
|
82
|
+
validates every destination before writing, keeps identical files unchanged,
|
|
83
|
+
and fails closed if any generated file already has different content. It has no
|
|
84
|
+
force mode and is not a generic project or Agent wizard.
|
|
85
|
+
|
|
86
|
+
## Five-minute non-mutating quickstart
|
|
87
|
+
|
|
88
|
+
From a consumer dbt project with a full-body Agent model:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
dbt-cortex-agent doctor --project-dir . --target sandbox --json
|
|
92
|
+
dbt-cortex-agent manifest validate --project-dir . --target sandbox --json
|
|
93
|
+
dbt compile --select orders_assistant
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
These commands do not mutate Snowflake. `dbt compile` renders and validates the
|
|
97
|
+
full Agent body without invoking its materialization. Follow the
|
|
98
|
+
[quickstart](docs/getting-started/quickstart.md) to create the metadata and
|
|
99
|
+
bootstrap explicit allowlists.
|
|
100
|
+
|
|
101
|
+
For Cortex Code-guided adoption, use the project-local
|
|
102
|
+
[`dbt-cortex-agent-project` skill](.cortex/skills/dbt-cortex-agent-project/SKILL.md).
|
|
103
|
+
It discovers an existing dbt project, establishes objective/levers/data/proof,
|
|
104
|
+
and guides an existing semantic view, the fixed Orders starter, or an existing
|
|
105
|
+
Agent into dbt-owned metadata. It is script-free, shows manual 0.0.3 command
|
|
106
|
+
parity, and stops separately before local writes, Snowflake mutation/runtime,
|
|
107
|
+
paid evaluation, and baseline movement. The checked-in skill is not a claim of
|
|
108
|
+
catalog publication or live Snowflake verification.
|
|
109
|
+
|
|
110
|
+
## Controlled deploy
|
|
111
|
+
|
|
112
|
+
Upload declared skills, use an isolated target/database, then build explicitly:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
dbt-cortex-agent skill upload --project-dir . --target sandbox \
|
|
116
|
+
--agent orders_assistant --connection sandbox --database ANALYTICS_DEV \
|
|
117
|
+
--allow-target sandbox --allow-database ANALYTICS_DEV --apply
|
|
118
|
+
dbt build --select orders_assistant
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The model relation determines the physical Agent FQN. The model body is passed
|
|
122
|
+
directly to the materialization, which validates explicit orchestration, checks
|
|
123
|
+
staged skills, updates LIVE, commits immutable `VERSION$N`, and reconciles the
|
|
124
|
+
configured alias. Skill upload remains a separate Python responsibility and
|
|
125
|
+
must succeed before `dbt build`.
|
|
126
|
+
|
|
127
|
+
A target-resolved manifest may contain Agents in multiple approved databases.
|
|
128
|
+
The package carries each selected Agent's complete `database.schema.object`
|
|
129
|
+
identity through skill and runtime operations and validates every Agent, stage,
|
|
130
|
+
eval table, evaluation stage, and result database against repeatable allowlists.
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
one dbt target manifest
|
|
134
|
+
+-- FINANCE.AGENTS.FINANCE_ANALYST
|
|
135
|
+
+-- MARKETING.AGENTS.CAMPAIGN_ANALYST
|
|
136
|
+
+-- AI_FOCUS.AGENTS.ENTERPRISE_ASSISTANT
|
|
137
|
+
|
|
138
|
+
selected resource FQN -> allowlist validation -> bounded operation
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
One package invocation consumes one dbt target and its fresh manifest. Parsing
|
|
142
|
+
and coordinating several dbt targets belongs to adopter CI, where each target
|
|
143
|
+
has a separately reviewed role, warehouse, and approval boundary.
|
|
144
|
+
Read [lifecycle](docs/guides/lifecycle.md) and [Snowflake setup](docs/getting-started/snowflake-setup.md)
|
|
145
|
+
before crossing this boundary.
|
|
146
|
+
|
|
147
|
+
## CLI or dbt macros
|
|
148
|
+
|
|
149
|
+
| Need | Shipped CLI | Public dbt macro |
|
|
150
|
+
|---|---|---|
|
|
151
|
+
| Diagnose a project | `doctor` | — |
|
|
152
|
+
| Validate resolved metadata | `manifest validate` | `cortex_agent__validate` |
|
|
153
|
+
| Render the full Agent spec | — | `dbt compile --select <agent_model>` |
|
|
154
|
+
| Deploy/version an Agent | — | `dbt build --select <agent_model>` |
|
|
155
|
+
| Preview/invoke any Agent | `agent smoke` | — |
|
|
156
|
+
| Plan/upload/smoke skills | `skill plan/upload/smoke` | deploy validates staged skills |
|
|
157
|
+
| Render/run optional evaluation | `eval run` | `cortex_eval__execution_plan`, `cortex_eval__run` |
|
|
158
|
+
| Compare/gate/accept artifacts | `eval compare/gate/accept-baseline` | threshold macros only |
|
|
159
|
+
|
|
160
|
+
Use dbt for Agent render and deployment. Use Python when local file upload,
|
|
161
|
+
stable process exits/JSON, connector clients, or durable evaluation artifacts
|
|
162
|
+
are required. Python owns no Agent lifecycle operation and provisions no stage.
|
|
163
|
+
|
|
164
|
+
## Lifecycle and evaluation
|
|
165
|
+
|
|
166
|
+
The materialization validates and hashes the rendered spec plus staged skills,
|
|
167
|
+
skips unchanged versions, modifies LIVE, commits an immutable version, and
|
|
168
|
+
applies the requested alias. Promotion, rollback, grants, MCP attachment, and
|
|
169
|
+
skill smoke remain explicit operations.
|
|
170
|
+
|
|
171
|
+
Evaluation is optional and targets the same Agent selected by the model relation.
|
|
172
|
+
`eval run` is a client for that already deployed Agent, a materialized
|
|
173
|
+
eval table, and an evaluation stage; `--apply` incurs Cortex spend. It never
|
|
174
|
+
deploys or changes an Agent. It writes candidate JSON with plan identity,
|
|
175
|
+
ordered ground-truth refs, policy, and pre/post DEFAULT provenance for threshold
|
|
176
|
+
and accepted-baseline gates. See [evaluations](docs/guides/evaluations.md).
|
|
177
|
+
|
|
178
|
+
## Documentation
|
|
179
|
+
|
|
180
|
+
- Start: [installation](docs/getting-started/installation.md), [quickstart](docs/getting-started/quickstart.md), [Snowflake setup](docs/getting-started/snowflake-setup.md)
|
|
181
|
+
- Configure: [configuration model](docs/guides/configuration-model.md), [Agent metadata](docs/reference/agent-metadata.md), [eval metadata](docs/reference/eval-metadata.md), [variables](docs/reference/variables.md)
|
|
182
|
+
- Operate: [lifecycle](docs/guides/lifecycle.md), [skills](docs/guides/skills.md), [evaluations](docs/guides/evaluations.md), [CI](docs/guides/ci.md), [releasing](docs/guides/releasing.md)
|
|
183
|
+
- Reference: [CLI](docs/reference/cli.md), [macros](docs/reference/macros.md), [compatibility](docs/reference/compatibility.md), [architecture](docs/concepts/end-to-end-flow.md), [troubleshooting](docs/troubleshooting.md)
|
|
184
|
+
- Change: [changelog](CHANGELOG.md)
|
|
185
|
+
|
|
186
|
+
## Limitations and policies
|
|
187
|
+
|
|
188
|
+
- Snowflake and dbt Core with `dbt-snowflake` are the release authority; DuckDB is unsupported and Fusion is advisory.
|
|
189
|
+
- `dbt build --select <agent_model>` deploys model Agents; `dbt compile` is the non-mutating preview.
|
|
190
|
+
- Property YAML may use `target`, `var`, and `env_var`, but cannot call package macros.
|
|
191
|
+
- Skills and MCP connectors are excluded from built-in native Agent Evaluation and require separate smoke/integration proof.
|
|
192
|
+
- Live mutation, runtime smoke, and evaluation spend are never default operations.
|
|
193
|
+
- This independent, maintainer-led package is not sponsored, endorsed, supported, or maintained by Snowflake Inc.
|
|
194
|
+
|
|
195
|
+
Apache License 2.0. See [LICENSE](LICENSE), [contributing](CONTRIBUTING.md),
|
|
196
|
+
[security](SECURITY.md), [support](SUPPORT.md), and [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# dbt_cortex_agent
|
|
2
|
+
|
|
3
|
+
`dbt_cortex_agent` 0.0.3 is a Snowflake-only dbt package and Python companion for
|
|
4
|
+
defining, versioning, and evaluating Cortex Agents from dbt models. A
|
|
5
|
+
`materialized='cortex_agent'` model body is the native Agent YAML specification.
|
|
6
|
+
dbt owns the complete Agent lifecycle; Python is limited to local skill files,
|
|
7
|
+
runtime smoke, and evaluation coordination.
|
|
8
|
+
|
|
9
|
+
## Install one immutable version on two surfaces
|
|
10
|
+
|
|
11
|
+
Install the Python companion from PyPI:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pipx install 'dbt-cortex-agent[runtime]==0.0.3'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For a managed Python environment, use:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
python -m pip install 'dbt-cortex-agent[runtime]==0.0.3'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
dbt does not install packages from PyPI. Pin the dbt package separately to the
|
|
24
|
+
public HTTPS `v0.0.3` Git tag in `packages.yml`:
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
packages:
|
|
28
|
+
- git: "https://github.com/Jeremy-Demlow/dbt-cortex-agent.git"
|
|
29
|
+
revision: v0.0.3
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
PyPI version `0.0.3` and Git tag `v0.0.3` identify the same immutable release
|
|
33
|
+
across the CLI and dbt surfaces. Run `dbt deps`, then
|
|
34
|
+
`dbt-cortex-agent doctor --project-dir . --json`; `doctor` verifies that the CLI,
|
|
35
|
+
declared dbt dependency, and installed consumer dbt package versions align. A
|
|
36
|
+
full immutable Git SHA is accepted only when actual installed package metadata
|
|
37
|
+
under `dbt_packages/dbt_cortex_agent` reports the matching version; a source
|
|
38
|
+
checkout's root `dbt_project.yml` is not installation evidence. The supported
|
|
39
|
+
runtime is Python `>=3.10,<4`, dbt
|
|
40
|
+
`>=1.10,<2.0`, and `dbt-snowflake`; see [compatibility](docs/reference/compatibility.md)
|
|
41
|
+
and [installation](docs/getting-started/installation.md).
|
|
42
|
+
|
|
43
|
+
The CLI also requires the Snowflake CLI (`snow`) on `PATH`; `doctor` checks both
|
|
44
|
+
the `dbt` and `snow` executables. By default, `dbt-cortex-agent init` configures an existing
|
|
45
|
+
dbt project by appending missing dependency and safety-variable entries. It does
|
|
46
|
+
not create a dbt project or scaffold Agent models, semantic views, evaluation
|
|
47
|
+
models, seeds, or skill files.
|
|
48
|
+
|
|
49
|
+
For the fixed synthetic tutorial, preview the package-owned Orders starter in an
|
|
50
|
+
existing dbt project:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
dbt-cortex-agent init --project-dir . --starter orders \
|
|
54
|
+
--package-source https://github.com/Jeremy-Demlow/dbt-cortex-agent.git --json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The preview reports the exact seed, semantic-view, Agent, optional eval, dependency, and
|
|
58
|
+
`.dbtignore` actions without writing. After review, add `--apply`. The command
|
|
59
|
+
validates every destination before writing, keeps identical files unchanged,
|
|
60
|
+
and fails closed if any generated file already has different content. It has no
|
|
61
|
+
force mode and is not a generic project or Agent wizard.
|
|
62
|
+
|
|
63
|
+
## Five-minute non-mutating quickstart
|
|
64
|
+
|
|
65
|
+
From a consumer dbt project with a full-body Agent model:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
dbt-cortex-agent doctor --project-dir . --target sandbox --json
|
|
69
|
+
dbt-cortex-agent manifest validate --project-dir . --target sandbox --json
|
|
70
|
+
dbt compile --select orders_assistant
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
These commands do not mutate Snowflake. `dbt compile` renders and validates the
|
|
74
|
+
full Agent body without invoking its materialization. Follow the
|
|
75
|
+
[quickstart](docs/getting-started/quickstart.md) to create the metadata and
|
|
76
|
+
bootstrap explicit allowlists.
|
|
77
|
+
|
|
78
|
+
For Cortex Code-guided adoption, use the project-local
|
|
79
|
+
[`dbt-cortex-agent-project` skill](.cortex/skills/dbt-cortex-agent-project/SKILL.md).
|
|
80
|
+
It discovers an existing dbt project, establishes objective/levers/data/proof,
|
|
81
|
+
and guides an existing semantic view, the fixed Orders starter, or an existing
|
|
82
|
+
Agent into dbt-owned metadata. It is script-free, shows manual 0.0.3 command
|
|
83
|
+
parity, and stops separately before local writes, Snowflake mutation/runtime,
|
|
84
|
+
paid evaluation, and baseline movement. The checked-in skill is not a claim of
|
|
85
|
+
catalog publication or live Snowflake verification.
|
|
86
|
+
|
|
87
|
+
## Controlled deploy
|
|
88
|
+
|
|
89
|
+
Upload declared skills, use an isolated target/database, then build explicitly:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
dbt-cortex-agent skill upload --project-dir . --target sandbox \
|
|
93
|
+
--agent orders_assistant --connection sandbox --database ANALYTICS_DEV \
|
|
94
|
+
--allow-target sandbox --allow-database ANALYTICS_DEV --apply
|
|
95
|
+
dbt build --select orders_assistant
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The model relation determines the physical Agent FQN. The model body is passed
|
|
99
|
+
directly to the materialization, which validates explicit orchestration, checks
|
|
100
|
+
staged skills, updates LIVE, commits immutable `VERSION$N`, and reconciles the
|
|
101
|
+
configured alias. Skill upload remains a separate Python responsibility and
|
|
102
|
+
must succeed before `dbt build`.
|
|
103
|
+
|
|
104
|
+
A target-resolved manifest may contain Agents in multiple approved databases.
|
|
105
|
+
The package carries each selected Agent's complete `database.schema.object`
|
|
106
|
+
identity through skill and runtime operations and validates every Agent, stage,
|
|
107
|
+
eval table, evaluation stage, and result database against repeatable allowlists.
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
one dbt target manifest
|
|
111
|
+
+-- FINANCE.AGENTS.FINANCE_ANALYST
|
|
112
|
+
+-- MARKETING.AGENTS.CAMPAIGN_ANALYST
|
|
113
|
+
+-- AI_FOCUS.AGENTS.ENTERPRISE_ASSISTANT
|
|
114
|
+
|
|
115
|
+
selected resource FQN -> allowlist validation -> bounded operation
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
One package invocation consumes one dbt target and its fresh manifest. Parsing
|
|
119
|
+
and coordinating several dbt targets belongs to adopter CI, where each target
|
|
120
|
+
has a separately reviewed role, warehouse, and approval boundary.
|
|
121
|
+
Read [lifecycle](docs/guides/lifecycle.md) and [Snowflake setup](docs/getting-started/snowflake-setup.md)
|
|
122
|
+
before crossing this boundary.
|
|
123
|
+
|
|
124
|
+
## CLI or dbt macros
|
|
125
|
+
|
|
126
|
+
| Need | Shipped CLI | Public dbt macro |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| Diagnose a project | `doctor` | — |
|
|
129
|
+
| Validate resolved metadata | `manifest validate` | `cortex_agent__validate` |
|
|
130
|
+
| Render the full Agent spec | — | `dbt compile --select <agent_model>` |
|
|
131
|
+
| Deploy/version an Agent | — | `dbt build --select <agent_model>` |
|
|
132
|
+
| Preview/invoke any Agent | `agent smoke` | — |
|
|
133
|
+
| Plan/upload/smoke skills | `skill plan/upload/smoke` | deploy validates staged skills |
|
|
134
|
+
| Render/run optional evaluation | `eval run` | `cortex_eval__execution_plan`, `cortex_eval__run` |
|
|
135
|
+
| Compare/gate/accept artifacts | `eval compare/gate/accept-baseline` | threshold macros only |
|
|
136
|
+
|
|
137
|
+
Use dbt for Agent render and deployment. Use Python when local file upload,
|
|
138
|
+
stable process exits/JSON, connector clients, or durable evaluation artifacts
|
|
139
|
+
are required. Python owns no Agent lifecycle operation and provisions no stage.
|
|
140
|
+
|
|
141
|
+
## Lifecycle and evaluation
|
|
142
|
+
|
|
143
|
+
The materialization validates and hashes the rendered spec plus staged skills,
|
|
144
|
+
skips unchanged versions, modifies LIVE, commits an immutable version, and
|
|
145
|
+
applies the requested alias. Promotion, rollback, grants, MCP attachment, and
|
|
146
|
+
skill smoke remain explicit operations.
|
|
147
|
+
|
|
148
|
+
Evaluation is optional and targets the same Agent selected by the model relation.
|
|
149
|
+
`eval run` is a client for that already deployed Agent, a materialized
|
|
150
|
+
eval table, and an evaluation stage; `--apply` incurs Cortex spend. It never
|
|
151
|
+
deploys or changes an Agent. It writes candidate JSON with plan identity,
|
|
152
|
+
ordered ground-truth refs, policy, and pre/post DEFAULT provenance for threshold
|
|
153
|
+
and accepted-baseline gates. See [evaluations](docs/guides/evaluations.md).
|
|
154
|
+
|
|
155
|
+
## Documentation
|
|
156
|
+
|
|
157
|
+
- Start: [installation](docs/getting-started/installation.md), [quickstart](docs/getting-started/quickstart.md), [Snowflake setup](docs/getting-started/snowflake-setup.md)
|
|
158
|
+
- Configure: [configuration model](docs/guides/configuration-model.md), [Agent metadata](docs/reference/agent-metadata.md), [eval metadata](docs/reference/eval-metadata.md), [variables](docs/reference/variables.md)
|
|
159
|
+
- Operate: [lifecycle](docs/guides/lifecycle.md), [skills](docs/guides/skills.md), [evaluations](docs/guides/evaluations.md), [CI](docs/guides/ci.md), [releasing](docs/guides/releasing.md)
|
|
160
|
+
- Reference: [CLI](docs/reference/cli.md), [macros](docs/reference/macros.md), [compatibility](docs/reference/compatibility.md), [architecture](docs/concepts/end-to-end-flow.md), [troubleshooting](docs/troubleshooting.md)
|
|
161
|
+
- Change: [changelog](CHANGELOG.md)
|
|
162
|
+
|
|
163
|
+
## Limitations and policies
|
|
164
|
+
|
|
165
|
+
- Snowflake and dbt Core with `dbt-snowflake` are the release authority; DuckDB is unsupported and Fusion is advisory.
|
|
166
|
+
- `dbt build --select <agent_model>` deploys model Agents; `dbt compile` is the non-mutating preview.
|
|
167
|
+
- Property YAML may use `target`, `var`, and `env_var`, but cannot call package macros.
|
|
168
|
+
- Skills and MCP connectors are excluded from built-in native Agent Evaluation and require separate smoke/integration proof.
|
|
169
|
+
- Live mutation, runtime smoke, and evaluation spend are never default operations.
|
|
170
|
+
- This independent, maintainer-led package is not sponsored, endorsed, supported, or maintained by Snowflake Inc.
|
|
171
|
+
|
|
172
|
+
Apache License 2.0. See [LICENSE](LICENSE), [contributing](CONTRIBUTING.md),
|
|
173
|
+
[security](SECURITY.md), [support](SUPPORT.md), and [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dbt-cortex-agent"
|
|
7
|
+
version = "0.0.3"
|
|
8
|
+
description = "dbt-native Snowflake Cortex Agent materialization with skill and evaluation tooling"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10,<4"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
authors = [{ name = "Jeremy Demlow" }]
|
|
13
|
+
dependencies = ["PyYAML>=6.0,<7"]
|
|
14
|
+
|
|
15
|
+
[project.urls]
|
|
16
|
+
Homepage = "https://github.com/Jeremy-Demlow/dbt-cortex-agent"
|
|
17
|
+
Documentation = "https://github.com/Jeremy-Demlow/dbt-cortex-agent/tree/v0.0.3/docs"
|
|
18
|
+
Repository = "https://github.com/Jeremy-Demlow/dbt-cortex-agent.git"
|
|
19
|
+
Issues = "https://github.com/Jeremy-Demlow/dbt-cortex-agent/issues"
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
test = ["build>=1.2", "Jinja2>=3.1,<4", "pytest>=8", "tomli>=2; python_version < '3.11'"]
|
|
23
|
+
runtime = ["snowflake-connector-python>=3.18,<5"]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
dbt-cortex-agent = "dbt_cortex_agent.cli:main"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
where = ["src"]
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.package-data]
|
|
32
|
+
dbt_cortex_agent = ["starters/orders/**/*"]
|
|
33
|
+
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
testpaths = ["tests"]
|
|
36
|
+
addopts = ["--ignore=tests/test_req_013_contract.py"]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
ARTIFACT_SCHEMA_VERSION = 2
|
|
8
|
+
_SLUG = re.compile(r"^[A-Za-z0-9][A-Za-z0-9_.-]*$")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def artifact_slug(value: object, label: str) -> str:
|
|
12
|
+
text = str(value)
|
|
13
|
+
if text in {".", ".."} or not _SLUG.fullmatch(text):
|
|
14
|
+
raise ValueError(f"{label} must be a safe artifact slug: {value!r}")
|
|
15
|
+
return text
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def contained_path(root: str | Path, *components: object) -> Path:
|
|
19
|
+
base = Path(root).resolve()
|
|
20
|
+
target = base.joinpath(*(artifact_slug(value, "artifact path component") for value in components))
|
|
21
|
+
resolved = target.resolve()
|
|
22
|
+
try:
|
|
23
|
+
resolved.relative_to(base)
|
|
24
|
+
except ValueError as exc:
|
|
25
|
+
raise ValueError(f"Artifact path escapes configured root {base}: {resolved}") from exc
|
|
26
|
+
return resolved
|