weevr-core 1.18.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.
Files changed (54) hide show
  1. weevr_core-1.18.0/LICENSE +201 -0
  2. weevr_core-1.18.0/PKG-INFO +39 -0
  3. weevr_core-1.18.0/README.md +14 -0
  4. weevr_core-1.18.0/pyproject.toml +39 -0
  5. weevr_core-1.18.0/src/weevr/config/__init__.py +265 -0
  6. weevr_core-1.18.0/src/weevr/config/audit_templates.py +314 -0
  7. weevr_core-1.18.0/src/weevr/config/duration.py +5 -0
  8. weevr_core-1.18.0/src/weevr/config/inheritance.py +402 -0
  9. weevr_core-1.18.0/src/weevr/config/locations.py +492 -0
  10. weevr_core-1.18.0/src/weevr/config/macros.py +71 -0
  11. weevr_core-1.18.0/src/weevr/config/parser.py +213 -0
  12. weevr_core-1.18.0/src/weevr/config/resolver.py +750 -0
  13. weevr_core-1.18.0/src/weevr/config/validation.py +312 -0
  14. weevr_core-1.18.0/src/weevr/config/warp.py +223 -0
  15. weevr_core-1.18.0/src/weevr/duration.py +48 -0
  16. weevr_core-1.18.0/src/weevr/engine/formatting.py +23 -0
  17. weevr_core-1.18.0/src/weevr/engine/planner.py +513 -0
  18. weevr_core-1.18.0/src/weevr/errors/__init__.py +43 -0
  19. weevr_core-1.18.0/src/weevr/errors/exceptions.py +422 -0
  20. weevr_core-1.18.0/src/weevr/model/__init__.py +168 -0
  21. weevr_core-1.18.0/src/weevr/model/audit.py +29 -0
  22. weevr_core-1.18.0/src/weevr/model/base.py +13 -0
  23. weevr_core-1.18.0/src/weevr/model/column_set.py +343 -0
  24. weevr_core-1.18.0/src/weevr/model/connection.py +29 -0
  25. weevr_core-1.18.0/src/weevr/model/dimension.py +377 -0
  26. weevr_core-1.18.0/src/weevr/model/execution.py +38 -0
  27. weevr_core-1.18.0/src/weevr/model/export.py +143 -0
  28. weevr_core-1.18.0/src/weevr/model/fact.py +67 -0
  29. weevr_core-1.18.0/src/weevr/model/failure.py +26 -0
  30. weevr_core-1.18.0/src/weevr/model/hooks.py +227 -0
  31. weevr_core-1.18.0/src/weevr/model/keys.py +98 -0
  32. weevr_core-1.18.0/src/weevr/model/load.py +209 -0
  33. weevr_core-1.18.0/src/weevr/model/lookup.py +95 -0
  34. weevr_core-1.18.0/src/weevr/model/loom.py +134 -0
  35. weevr_core-1.18.0/src/weevr/model/naming.py +78 -0
  36. weevr_core-1.18.0/src/weevr/model/params.py +44 -0
  37. weevr_core-1.18.0/src/weevr/model/pipeline.py +1085 -0
  38. weevr_core-1.18.0/src/weevr/model/seed.py +44 -0
  39. weevr_core-1.18.0/src/weevr/model/source.py +184 -0
  40. weevr_core-1.18.0/src/weevr/model/sub_pipeline.py +42 -0
  41. weevr_core-1.18.0/src/weevr/model/target.py +217 -0
  42. weevr_core-1.18.0/src/weevr/model/thread.py +242 -0
  43. weevr_core-1.18.0/src/weevr/model/types.py +12 -0
  44. weevr_core-1.18.0/src/weevr/model/validation.py +132 -0
  45. weevr_core-1.18.0/src/weevr/model/variable.py +27 -0
  46. weevr_core-1.18.0/src/weevr/model/warp.py +182 -0
  47. weevr_core-1.18.0/src/weevr/model/weave.py +187 -0
  48. weevr_core-1.18.0/src/weevr/model/write.py +73 -0
  49. weevr_core-1.18.0/src/weevr/reserved_words.py +442 -0
  50. weevr_core-1.18.0/src/weevr/result.py +637 -0
  51. weevr_core-1.18.0/src/weevr/telemetry/events.py +79 -0
  52. weevr_core-1.18.0/src/weevr/telemetry/results.py +181 -0
  53. weevr_core-1.18.0/src/weevr/telemetry/span.py +65 -0
  54. weevr_core-1.18.0/src/weevr/telemetry/trace.py +66 -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,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: weevr-core
3
+ Version: 1.18.0
4
+ Summary: Pure-Python validation, planner, and telemetry contracts for weevr.
5
+ Keywords: weevr,pydantic,fabric,etl,data-pipeline,yaml,configuration
6
+ Author: Pierre LaFromboise
7
+ Author-email: Pierre LaFromboise <44212292+DataInsightPro@users.noreply.github.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Topic :: Database
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Typing :: Typed
17
+ Requires-Dist: pydantic>=2.0,<3.0
18
+ Requires-Dist: pyyaml>=6.0,<7.0
19
+ Requires-Python: >=3.11, <3.12
20
+ Project-URL: Documentation, https://ardent-data.github.io/weevr/
21
+ Project-URL: Repository, https://github.com/ardent-data/weevr
22
+ Project-URL: Issues, https://github.com/ardent-data/weevr/issues
23
+ Project-URL: Changelog, https://github.com/ardent-data/weevr/blob/main/CHANGELOG.md
24
+ Description-Content-Type: text/markdown
25
+
26
+ # weevr-core
27
+
28
+ Pure-Python validation, planner, and telemetry contracts for weevr.
29
+
30
+ Install this wheel when you need weevr's Pydantic model layer, configuration
31
+ resolver, planner graph, or telemetry schemas without paying for PySpark
32
+ — for example, in a CLI that validates `.weevr` projects in CI.
33
+
34
+ For execution capability (running a loom, weave, or thread end-to-end), see
35
+ the companion [`weevr`](../weevr) wheel; it depends on `weevr-core` so a plain
36
+ `pip install weevr` installs both transparently.
37
+
38
+ See the [project README](../../README.md) and the
39
+ [documentation](https://ardent-data.github.io/weevr/).
@@ -0,0 +1,14 @@
1
+ # weevr-core
2
+
3
+ Pure-Python validation, planner, and telemetry contracts for weevr.
4
+
5
+ Install this wheel when you need weevr's Pydantic model layer, configuration
6
+ resolver, planner graph, or telemetry schemas without paying for PySpark
7
+ — for example, in a CLI that validates `.weevr` projects in CI.
8
+
9
+ For execution capability (running a loom, weave, or thread end-to-end), see
10
+ the companion [`weevr`](../weevr) wheel; it depends on `weevr-core` so a plain
11
+ `pip install weevr` installs both transparently.
12
+
13
+ See the [project README](../../README.md) and the
14
+ [documentation](https://ardent-data.github.io/weevr/).
@@ -0,0 +1,39 @@
1
+ [project]
2
+ name = "weevr-core"
3
+ version = "1.18.0" # x-release-please-version
4
+ description = "Pure-Python validation, planner, and telemetry contracts for weevr."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ authors = [
9
+ { name = "Pierre LaFromboise", email = "44212292+DataInsightPro@users.noreply.github.com" }
10
+ ]
11
+ requires-python = ">=3.11,<3.12"
12
+ keywords = ["weevr", "pydantic", "fabric", "etl", "data-pipeline", "yaml", "configuration"]
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Intended Audience :: Developers",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Topic :: Database",
19
+ "Topic :: Software Development :: Libraries :: Python Modules",
20
+ "Typing :: Typed",
21
+ ]
22
+ dependencies = [
23
+ "pydantic>=2.0,<3.0",
24
+ "pyyaml>=6.0,<7.0",
25
+ ]
26
+
27
+ [project.urls]
28
+ Documentation = "https://ardent-data.github.io/weevr/"
29
+ Repository = "https://github.com/ardent-data/weevr"
30
+ Issues = "https://github.com/ardent-data/weevr/issues"
31
+ Changelog = "https://github.com/ardent-data/weevr/blob/main/CHANGELOG.md"
32
+
33
+ [build-system]
34
+ requires = ["uv_build>=0.10.0,<0.11.0"]
35
+ build-backend = "uv_build"
36
+
37
+ [tool.uv.build-backend]
38
+ module-name = "weevr"
39
+ namespace = true
@@ -0,0 +1,265 @@
1
+ """Configuration loading and validation."""
2
+
3
+ from pathlib import Path
4
+ from typing import Any
5
+
6
+ from pydantic import ValidationError
7
+
8
+ from weevr.config.inheritance import apply_inheritance
9
+ from weevr.config.locations import ConfigLocation, LocalConfigLocation, make_location
10
+ from weevr.config.macros import expand_foreach
11
+ from weevr.config.parser import (
12
+ detect_config_type,
13
+ detect_config_type_from_extension,
14
+ extract_config_version,
15
+ parse_yaml,
16
+ validate_config_version,
17
+ )
18
+ from weevr.config.resolver import (
19
+ build_param_context,
20
+ resolve_declared_params,
21
+ resolve_references,
22
+ resolve_variables,
23
+ validate_params,
24
+ )
25
+ from weevr.config.validation import validate_schema
26
+ from weevr.errors import ConfigError, ModelValidationError
27
+ from weevr.model import Loom, Thread, Weave
28
+
29
+
30
+ def _derive_config_name(path: ConfigLocation) -> str:
31
+ """Derive the component name from a config location.
32
+
33
+ Returns the filename stem — the filename without the typed extension.
34
+ For example, ``dim_customer.thread`` returns ``'dim_customer'``.
35
+ """
36
+ return path.stem
37
+
38
+
39
+ def load_config(
40
+ path: str | Path | ConfigLocation,
41
+ runtime_params: dict[str, Any] | None = None,
42
+ project_root: Path | ConfigLocation | None = None,
43
+ ) -> Thread | Weave | Loom | dict[str, Any]:
44
+ """Load and validate a weevr configuration file.
45
+
46
+ This function orchestrates the full config loading pipeline:
47
+ 1. Parse YAML file
48
+ 2. Extract and validate config_version
49
+ 3. Detect config type (extension-based for components, content-based for params)
50
+ 4. Validate schema with Pydantic
51
+ 5. Build parameter context (runtime > defaults)
52
+ 6. Resolve variable references (${var} and ${var:-default})
53
+ 7. Resolve references to child configs (threads, weaves)
54
+ 8. Apply inheritance cascade (loom -> weave -> thread)
55
+ 9. Validate name against filename stem
56
+ 10. Hydrate into typed domain model (thread, weave, loom only)
57
+
58
+ Args:
59
+ path: Path or :class:`ConfigLocation` for the config file (thread,
60
+ weave, or loom). Local paths are wrapped automatically; remote
61
+ URIs must be supplied as a :class:`RemoteConfigLocation` so the
62
+ caller can attach a SparkSession.
63
+ runtime_params: Optional runtime parameter overrides.
64
+ project_root: The ``.weevr`` project directory. Required for configs
65
+ that reference other files. Accepts a :class:`ConfigLocation` or
66
+ a bare :class:`pathlib.Path`.
67
+
68
+ Returns:
69
+ A frozen, typed domain model instance (Thread, Weave, or Loom) for
70
+ thread/weave/loom config types. Returns a plain dict for params configs.
71
+
72
+ Raises:
73
+ ConfigParseError: YAML syntax errors, file not found
74
+ ConfigVersionError: Unsupported config version
75
+ ConfigSchemaError: Schema validation failures
76
+ ConfigError: Extension or name validation failures
77
+ VariableResolutionError: Unresolved variables without defaults
78
+ ReferenceResolutionError: Missing referenced files, circular dependencies
79
+ ModelValidationError: Semantic validation failures during model hydration
80
+ """
81
+ file_path = make_location(path)
82
+
83
+ # Step 1: Parse YAML
84
+ raw = parse_yaml(file_path)
85
+
86
+ # Step 2: Extract and validate version
87
+ version = extract_config_version(raw)
88
+
89
+ # Step 3: Detect config type — extension-based for typed files, content-based for .yaml
90
+ ext_type = detect_config_type_from_extension(file_path)
91
+ config_type = ext_type if ext_type is not None else detect_config_type(raw)
92
+
93
+ # Step 4: Validate schema
94
+ validate_config_version(version, config_type)
95
+ validated = validate_schema(raw, config_type)
96
+ config_dict = validated.model_dump(exclude_unset=True)
97
+
98
+ # Step 5: Build parameter context (no more param_file)
99
+ declared_param_specs = config_dict.get("params")
100
+ resolved_declared_params = resolve_declared_params(
101
+ declared_param_specs,
102
+ runtime_params,
103
+ file_path=str(file_path),
104
+ )
105
+ # Type validation only — required-missing already raised above.
106
+ validate_params(declared_param_specs, resolved_declared_params)
107
+ context = build_param_context(
108
+ runtime_params,
109
+ config_dict.get("defaults"),
110
+ entry_params=resolved_declared_params or None,
111
+ )
112
+
113
+ # Step 6: Resolve variables
114
+ resolved = resolve_variables(config_dict, context)
115
+
116
+ # Step 7: Resolve references to child configs
117
+ if project_root is None:
118
+ effective_root: ConfigLocation = file_path.parent
119
+ elif isinstance(project_root, ConfigLocation):
120
+ effective_root = project_root
121
+ else:
122
+ effective_root = LocalConfigLocation(Path(project_root))
123
+ resolved_with_refs = resolve_references(
124
+ resolved,
125
+ config_type,
126
+ effective_root,
127
+ runtime_params,
128
+ )
129
+
130
+ # Step 8: Apply inheritance for child configs
131
+ if config_type == "loom" and "_resolved_weaves" in resolved_with_refs:
132
+ loom_defaults = resolved_with_refs.get("defaults")
133
+ loom_audit_templates = resolved_with_refs.get("audit_templates")
134
+ loom_connections = resolved_with_refs.get("connections")
135
+ for weave in resolved_with_refs["_resolved_weaves"]:
136
+ if "_resolved_threads" in weave:
137
+ weave_defaults = weave.get("defaults")
138
+ weave_audit_templates = weave.get("audit_templates")
139
+ weave_connections = weave.get("connections")
140
+ for i, thread in enumerate(weave["_resolved_threads"]):
141
+ merged = apply_inheritance(
142
+ loom_defaults,
143
+ weave_defaults,
144
+ thread,
145
+ loom_audit_templates=loom_audit_templates,
146
+ weave_audit_templates=weave_audit_templates,
147
+ loom_connections=loom_connections,
148
+ weave_connections=weave_connections,
149
+ )
150
+ weave["_resolved_threads"][i] = merged
151
+
152
+ elif config_type == "weave" and "_resolved_threads" in resolved_with_refs:
153
+ weave_defaults = resolved_with_refs.get("defaults")
154
+ weave_audit_templates = resolved_with_refs.get("audit_templates")
155
+ weave_connections = resolved_with_refs.get("connections")
156
+ for i, thread in enumerate(resolved_with_refs["_resolved_threads"]):
157
+ merged = apply_inheritance(
158
+ None,
159
+ weave_defaults,
160
+ thread,
161
+ weave_audit_templates=weave_audit_templates,
162
+ weave_connections=weave_connections,
163
+ )
164
+ resolved_with_refs["_resolved_threads"][i] = merged
165
+
166
+ # Step 8b: Expand foreach macros in thread steps
167
+ if config_type == "thread" and isinstance(resolved_with_refs.get("steps"), list):
168
+ resolved_with_refs["steps"] = expand_foreach(resolved_with_refs["steps"])
169
+
170
+ # Step 9: Name validation and injection
171
+ if config_type in ("thread", "weave", "loom") and ext_type is not None:
172
+ stem = _derive_config_name(file_path)
173
+ declared_name = resolved_with_refs.get("name", "")
174
+ if declared_name and declared_name != stem:
175
+ raise ConfigError(
176
+ f"Declared name '{declared_name}' does not match filename stem '{stem}'",
177
+ file_path=str(file_path),
178
+ )
179
+ if not declared_name:
180
+ resolved_with_refs["name"] = stem
181
+
182
+ # Compute qualified key for standalone files
183
+ if project_root is not None and ext_type is not None:
184
+ if file_path.is_relative_to(effective_root):
185
+ # Strip the project_root prefix to produce a relative key.
186
+ # For local locations this matches the previous Path.resolve()
187
+ # / Path.relative_to behavior; for remote locations it is a
188
+ # normalized URI prefix strip.
189
+ if isinstance(file_path, LocalConfigLocation) and isinstance(
190
+ effective_root, LocalConfigLocation
191
+ ):
192
+ rel = file_path.path.resolve().relative_to(effective_root.path.resolve())
193
+ resolved_with_refs["qualified_key"] = str(rel)
194
+ else:
195
+ file_str = str(file_path)
196
+ root_str = str(effective_root).rstrip("/")
197
+ resolved_with_refs["qualified_key"] = (
198
+ file_str[len(root_str) + 1 :]
199
+ if file_str.startswith(root_str + "/")
200
+ else file_str
201
+ )
202
+ else:
203
+ resolved_with_refs["qualified_key"] = str(file_path)
204
+ elif not resolved_with_refs.get("name"):
205
+ resolved_with_refs["name"] = file_path.stem
206
+
207
+ # Step 10: Hydrate into typed domain model
208
+ model_map: dict[str, type[Thread | Weave | Loom]] = {
209
+ "thread": Thread,
210
+ "weave": Weave,
211
+ "loom": Loom,
212
+ }
213
+ if config_type in model_map:
214
+ try:
215
+ return model_map[config_type].model_validate(resolved_with_refs)
216
+ except ValidationError as exc:
217
+ raise ModelValidationError(
218
+ f"Model hydration failed for {config_type}: {exc}",
219
+ cause=exc,
220
+ file_path=str(path),
221
+ ) from exc
222
+
223
+ # params config type returns a plain dict
224
+ return resolved_with_refs
225
+
226
+
227
+ # Federated namespace: weevr.config splits across two wheels — pure
228
+ # parser/resolver/validation/inheritance modules in weevr-core (which
229
+ # ships this __init__.py) and Spark-bound config helpers (fabric.py,
230
+ # paths.py) contributed by the weevr engine wheel. In editable workspace
231
+ # installs each wheel's src/ is a separate sys.path entry, so we extend
232
+ # __path__ to pull engine-side contributions into the import-time view.
233
+ # In a real install both wheels' files merge into a single
234
+ # site-packages/weevr/config/ directory and the loop is a no-op. The
235
+ # basename(p) == "src" gate scopes the scan to src-layout package roots.
236
+ def _extend_namespace_path() -> None:
237
+ """Append sibling weevr.config/ directories on sys.path to ``__path__``."""
238
+ import os.path as osp
239
+ import sys
240
+
241
+ components = __name__.split(".")
242
+ src_entries_seen = 0
243
+ candidates_added = 0
244
+ for entry in sys.path:
245
+ if not entry or osp.basename(entry) != "src":
246
+ continue
247
+ src_entries_seen += 1
248
+ candidate = osp.join(entry, *components)
249
+ if osp.isdir(candidate) and candidate not in __path__:
250
+ __path__.append(candidate)
251
+ candidates_added += 1
252
+ if src_entries_seen > 0 and candidates_added == 0:
253
+ import warnings
254
+
255
+ warnings.warn(
256
+ f"weevr federated namespace {__name__!r}: no sibling "
257
+ "contributor found on sys.path. If this is an editable "
258
+ "workspace install, run `uv sync --dev` from the repo root "
259
+ "to install both wheels.",
260
+ stacklevel=2,
261
+ )
262
+
263
+
264
+ _extend_namespace_path()
265
+ del _extend_namespace_path