weft-kernel 0.1.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.
- weft_kernel-0.1.0/.gitignore +85 -0
- weft_kernel-0.1.0/LICENSE +21 -0
- weft_kernel-0.1.0/NOTICE +77 -0
- weft_kernel-0.1.0/PKG-INFO +88 -0
- weft_kernel-0.1.0/README.md +76 -0
- weft_kernel-0.1.0/pyproject.toml +13 -0
- weft_kernel-0.1.0/src/weft_kernel/__init__.py +178 -0
- weft_kernel-0.1.0/src/weft_kernel/blocking.py +370 -0
- weft_kernel-0.1.0/src/weft_kernel/context.py +250 -0
- weft_kernel-0.1.0/src/weft_kernel/discovery.py +1181 -0
- weft_kernel-0.1.0/src/weft_kernel/errors.py +73 -0
- weft_kernel-0.1.0/src/weft_kernel/fallback.py +159 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/__init__.py +43 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/applicability.py +298 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/ext.py +172 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/ids.py +22 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/lineage.py +90 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/media_type.py +18 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/node.py +260 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/outcome.py +40 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/property.py +60 -0
- weft_kernel-0.1.0/src/weft_kernel/payload/vector.py +28 -0
- weft_kernel-0.1.0/src/weft_kernel/pipeline.py +748 -0
- weft_kernel-0.1.0/src/weft_kernel/py.typed +0 -0
- weft_kernel-0.1.0/src/weft_kernel/registry.py +692 -0
- weft_kernel-0.1.0/src/weft_kernel/resolution.py +1582 -0
- weft_kernel-0.1.0/src/weft_kernel/runner.py +1436 -0
- weft_kernel-0.1.0/src/weft_kernel/seam.py +725 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# A sibling checkout, reachable for reading only.
|
|
2
|
+
# Never a build input: see CLAUDE.md and docs/README.md.
|
|
3
|
+
/_external-src
|
|
4
|
+
|
|
5
|
+
# Python
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
.venv/
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
*.egg-info/
|
|
12
|
+
|
|
13
|
+
# Tooling
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.ruff_cache/
|
|
16
|
+
.pyright/
|
|
17
|
+
|
|
18
|
+
# `uv.lock` was here, filed between two caches. It is not a cache: `ci.yml` runs
|
|
19
|
+
# `uv sync --frozen` in three of its four jobs, and every one of them died at that step
|
|
20
|
+
# the first time CI ever ran. It is tracked now — the resolution CI installs and the
|
|
21
|
+
# resolution a developer installs must be one artefact, which is the same argument
|
|
22
|
+
# `docs/README.md` makes about single-sourcing anything two readers can disagree about.
|
|
23
|
+
#
|
|
24
|
+
# It constrains nobody downstream. A lockfile is not a dependency bound; what a consumer
|
|
25
|
+
# resolves is decided by each distribution's `pyproject.toml`.
|
|
26
|
+
|
|
27
|
+
# Session-local attempt counter for the guard_quality_gates.py PreToolUse hook — per-session
|
|
28
|
+
# scratch, not a record anyone should read later. See the hook's module docstring.
|
|
29
|
+
.claude/.gate-attempts.json
|
|
30
|
+
|
|
31
|
+
# Secrets. `.env` holds live provider keys; only the documented, valueless
|
|
32
|
+
# example is tracked. Listed before any tooling rule so a stray `git add -A`
|
|
33
|
+
# cannot reach it.
|
|
34
|
+
.env
|
|
35
|
+
.env.*
|
|
36
|
+
!.env.example
|
|
37
|
+
|
|
38
|
+
# Corpus payload. Every subdirectory of /corpus is a materialised document set and
|
|
39
|
+
# is deliberately untracked; `corpus/manifest.toml` and `scripts/fetch_corpus.py`
|
|
40
|
+
# are the tracked artefact. `09` §4 V1 permits exactly this:
|
|
41
|
+
# a corpus is "either redistributable or fetched by a pinned, checksummed script",
|
|
42
|
+
# and the mRMR papers are published under publisher copyright, so committing them
|
|
43
|
+
# would be redistribution this repository has no right to perform. The manifest
|
|
44
|
+
# carries a sha256 per document, which is what makes the set reproducible without
|
|
45
|
+
# the bytes being here. The pattern is a directory glob rather than a list of names
|
|
46
|
+
# so that scaling the corpus up cannot silently start tracking a paper.
|
|
47
|
+
/corpus/*/
|
|
48
|
+
|
|
49
|
+
# Where a baseline run stages the corpus it indexes and writes the `weft.toml` it measures
|
|
50
|
+
# through (`eval/run_baseline.py`). The staged copies are the same untracked papers one
|
|
51
|
+
# directory over, and the configuration is reproduced by the harness rather than kept — what
|
|
52
|
+
# is tracked is the run it produced, under `eval/baselines/`.
|
|
53
|
+
/.baseline-run/
|
|
54
|
+
|
|
55
|
+
# Working artefacts of a build session — a generated map of the codebase and a design
|
|
56
|
+
# record produced while planning. Untracked on purpose: `docs/README.md` routes every
|
|
57
|
+
# document this project owns, and a design that matters belongs in the `docs/` file
|
|
58
|
+
# that owns its content, not in a root-level file nothing points at.
|
|
59
|
+
/.phase2-*.md
|
|
60
|
+
/.phase3-*.md
|
|
61
|
+
/.phase4-*.md
|
|
62
|
+
|
|
63
|
+
# Gate-session preparation: the Bring lists of `docs/05-grilling-sessions.md`, measured on the day
|
|
64
|
+
# a session is about to run. Untracked for the same reason — the session's outcome belongs in
|
|
65
|
+
# `docs/README.md`'s decision log and in the reference document the decision changes, never here.
|
|
66
|
+
/.gate-brief-*.md
|
|
67
|
+
|
|
68
|
+
# Claude Code local state
|
|
69
|
+
.claude/settings.local.json
|
|
70
|
+
|
|
71
|
+
.DS_Store
|
|
72
|
+
|
|
73
|
+
# The build harness driving Phase 2, alongside its brief, findings and design record.
|
|
74
|
+
/.phase2-build.js
|
|
75
|
+
|
|
76
|
+
# Transient: harvested subagent findings, promoted into docs/lessons.md by implement-ll.
|
|
77
|
+
# Never committed — its content belongs in the queue or nowhere.
|
|
78
|
+
.claude/lessons-spool.md
|
|
79
|
+
|
|
80
|
+
# Reading material and design records about codebases this project does not own.
|
|
81
|
+
# Kept on disk, deliberately outside version control: nothing tracked here refers to
|
|
82
|
+
# them, and a write to any of them would leave no trace in a diff.
|
|
83
|
+
/docs/_external-reading/
|
|
84
|
+
|
|
85
|
+
/tmp/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Adam Krysztopa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
weft_kernel-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Weft
|
|
2
|
+
Copyright (c) 2026 Adam Krysztopa
|
|
3
|
+
|
|
4
|
+
This product is licensed under the MIT License. See the LICENSE file at the root
|
|
5
|
+
of this repository.
|
|
6
|
+
|
|
7
|
+
--------------------------------------------------------------------------------
|
|
8
|
+
Original work
|
|
9
|
+
--------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
**Weft carries no third party's source text.** Every line of this project's own
|
|
12
|
+
code is written for it, against its own contracts. Nothing here depends on a
|
|
13
|
+
licence granted by anyone else.
|
|
14
|
+
|
|
15
|
+
That is a rule, not a description: no file may be copied or adapted from another
|
|
16
|
+
project's source, and no third-party source text may be pasted into this
|
|
17
|
+
repository. Where a prior system informed a design, what was carried across is
|
|
18
|
+
understanding — an approach, an ordering, a measurement, a reason a guard exists
|
|
19
|
+
— restated in this project's own words and implemented fresh. Copyright does not
|
|
20
|
+
reach any of that.
|
|
21
|
+
|
|
22
|
+
What was learned from prior work, and what was deliberately not taken, is a
|
|
23
|
+
design record kept outside version control. Nothing in it authorises a copy of a
|
|
24
|
+
third party's text, because that is not permitted here at all.
|
|
25
|
+
|
|
26
|
+
--------------------------------------------------------------------------------
|
|
27
|
+
Three cases, because the sentence above used to be absolute and was not accurate
|
|
28
|
+
--------------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
This section was added on 2026-09-05. It previously read "Weft contains no source
|
|
31
|
+
text from any other codebase", and two separate things made that literally false
|
|
32
|
+
while nothing about the project's substance had changed. Both are stated here
|
|
33
|
+
rather than left for a reader to discover, because a founding claim that is
|
|
34
|
+
almost true is worse than a narrower one that is exactly true.
|
|
35
|
+
|
|
36
|
+
1. **A third party's code — never.** Somebody else's work is somebody else's:
|
|
37
|
+
not a file, a function body, a docstring, a comment, a prompt string, a word
|
|
38
|
+
list or a test fixture. Read to understand, then closed. This is the rule
|
|
39
|
+
above and it has not moved.
|
|
40
|
+
|
|
41
|
+
2. **The copyright holder's own prior work — permitted, and marked.** Material
|
|
42
|
+
written by this project's own author before this project began carries no
|
|
43
|
+
third party's rights. Copying it violates nobody's licence, and forbidding it
|
|
44
|
+
would be a rule about tidiness dressed as a rule about ownership. Where such
|
|
45
|
+
material is carried across, the file carrying it says so, naming the source
|
|
46
|
+
work — so a reader can always tell the two origins apart without asking.
|
|
47
|
+
|
|
48
|
+
**How it says so, because "says so" was a sentence and not a convention until
|
|
49
|
+
2026-09-09.** The carried lines are delimited in place, by a comment in
|
|
50
|
+
whatever syntax the file is written in: `weft-prior-work begin: <source work>`
|
|
51
|
+
opens the span and names the source work it came from, and
|
|
52
|
+
`weft-prior-work end` closes it and takes no argument. Spans do not nest — a
|
|
53
|
+
span inside a span makes *which lines are that work* answerable two ways,
|
|
54
|
+
which is the one question this convention exists to answer. Every source work
|
|
55
|
+
carried this way is enumerated on the repository's own README.md, where a
|
|
56
|
+
reader looks first, and tests/architecture/test_release_licensing.py fails
|
|
57
|
+
the build when the marked spans and that enumeration disagree. The obligation
|
|
58
|
+
falls in the same commit as the copied line and never after it, which is why
|
|
59
|
+
the check exists before the first copy rather than behind it.
|
|
60
|
+
|
|
61
|
+
3. **Short attributed quotation of a stated rationale — permitted, and bounded.**
|
|
62
|
+
A handful of docstrings in this repository quote a sentence of a third party's
|
|
63
|
+
*reasoning* — why one cleaning stage must run before another — attributed with
|
|
64
|
+
a path and a line number, immediately beside this project's own restatement of
|
|
65
|
+
the same reasoning. Nothing executable was ever carried this way: no
|
|
66
|
+
expression, no algorithm, no data. This is ordinary attributed quotation of a
|
|
67
|
+
published rationale, of the kind a comment citing a paper makes, and the
|
|
68
|
+
previous absolute wording forbade it in words while the repository practised
|
|
69
|
+
it. It is bounded rather than open: a quotation must be a sentence or two, it
|
|
70
|
+
must be attributed at the point of use, and it must sit next to the project's
|
|
71
|
+
own words on the same point — never stand in for them.
|
|
72
|
+
|
|
73
|
+
The distinction that matters, and it is the same test the rest of this project
|
|
74
|
+
uses: **if you could not have written it without the other file open, it is a
|
|
75
|
+
copy.** Case 1 forbids that outright. Case 2 permits it because the other file is
|
|
76
|
+
the author's own. Case 3 is not that at all — it is quoting someone, with their
|
|
77
|
+
name on it, beside your own argument.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: weft-kernel
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The Weft kernel: registry, discovery, pipeline model, payload types.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Requires-Dist: opentelemetry-api>=1.28
|
|
10
|
+
Requires-Dist: pydantic>=2.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# weft-kernel
|
|
14
|
+
|
|
15
|
+
The kernel of Weft, a RAG engine built as a microkernel. This distribution is the registry a pack
|
|
16
|
+
registers into, the entry-point discovery that finds packs, the pipeline model a pipeline document
|
|
17
|
+
resolves against, the payload types every stage signature names, and the registration seam every
|
|
18
|
+
stage's execution passes through. It contains no RAG capability of any kind.
|
|
19
|
+
|
|
20
|
+
## The one thing that makes it unusual
|
|
21
|
+
|
|
22
|
+
**The kernel names no capability.** There is no `Extractor`, `Chunker`, `Store`, `Retriever` or
|
|
23
|
+
`LLM` in this package — those contracts are published by the first-party packs that own them, in
|
|
24
|
+
`weft-rag`, on exactly the same public entry point a third party's pack would use. What ships here
|
|
25
|
+
is the mechanism a contract is expressed and run through, never a contract itself.
|
|
26
|
+
|
|
27
|
+
This is not a design intention stated in a docstring; it is checked. `weft-kernel` is a separate
|
|
28
|
+
installable distribution for exactly one reason: `poe kernel-isolated` installs it alone into a
|
|
29
|
+
clean environment and imports it, so if anything reached outside what it ships, the import fails.
|
|
30
|
+
A static counterpart walks every import in the source tree against the same declared dependency
|
|
31
|
+
set. Both are fitness function 1, in `tests/architecture/test_ff1_boundary.py`.
|
|
32
|
+
|
|
33
|
+
## Dependencies
|
|
34
|
+
|
|
35
|
+
Exactly `pydantic` and `opentelemetry-api` — that is `packages/weft-kernel/pyproject.toml`'s whole
|
|
36
|
+
`dependencies` list, and a third dependency is a decision-log entry, not a line in a pyproject.
|
|
37
|
+
`opentelemetry-api` is the no-op-without-an-SDK API; anything that actually exports a span is a
|
|
38
|
+
pack's concern (`weft-otel`), not this one's.
|
|
39
|
+
|
|
40
|
+
## Async only
|
|
41
|
+
|
|
42
|
+
Every contract method this kernel's types describe is `async def`. There is no sync protocol and
|
|
43
|
+
no sync facade anywhere in this package — a stage runs on the event loop, and a categorical
|
|
44
|
+
detector installed at the registration seam (`weft_kernel.blocking`) fails the build on a blocking
|
|
45
|
+
call made on that thread rather than tolerating one behind a synchronous-looking signature.
|
|
46
|
+
|
|
47
|
+
## What is actually in here
|
|
48
|
+
|
|
49
|
+
Twenty modules under `weft_kernel`, none of them a plugin:
|
|
50
|
+
|
|
51
|
+
- `registry.py` — where a pack's `register()` adds what it provides, and where an unresolvable
|
|
52
|
+
name fails loudly, naming what was wanted and what is registered.
|
|
53
|
+
- `discovery.py` — entry-point discovery and the trust model: which installed distributions get
|
|
54
|
+
imported, what a pack may disclose about itself, and the `[packs] allow` pin that refuses an
|
|
55
|
+
import before it happens rather than after.
|
|
56
|
+
- `pipeline.py` / `resolution.py` / `runner.py` — the pipeline as authored data, the pipeline
|
|
57
|
+
resolved to a frozen explicit form, and the linear runner that executes a resolved chain.
|
|
58
|
+
- `seam.py` — `wrap`, the one seam every stage's call passes through: spans, error attribution,
|
|
59
|
+
`__transient__` stripping and the blocking-call detector attach here, automatically, so no
|
|
60
|
+
author has to remember any of the four.
|
|
61
|
+
- `context.py` — the passport every stage receives: tenant, run and trace ids, cancellation,
|
|
62
|
+
locale, and `require()` for an ambient service.
|
|
63
|
+
- `payload/` — the domain model a stage signature names: `Node`, `NodeId`, `Lineage`, `MediaType`,
|
|
64
|
+
`Vector`, `Outcome`, `ExtModel`/`ExtMap` (a pack's own namespaced, validated extension data), and
|
|
65
|
+
the `Property` and `Applies` markers a plugin class declares itself against.
|
|
66
|
+
- `errors.py` / `fallback.py` / `blocking.py` — the `WeftError` root every pack raises against, the
|
|
67
|
+
fallback-chain combinator that composes plugins over any contract without inspecting them, and
|
|
68
|
+
the blocking-call detector above.
|
|
69
|
+
|
|
70
|
+
The kernel is also held to a size ceiling: `uv run pytest tests/architecture/test_ff3_kernel_budget.py -s`
|
|
71
|
+
measures 3,300 non-blank, non-comment, non-docstring lines against a 3,500-line fail and a
|
|
72
|
+
2,800-line review trigger — a stated budget rather than an unstated one, so growth is on the agenda
|
|
73
|
+
before it is a crisis.
|
|
74
|
+
|
|
75
|
+
## You probably do not want this package
|
|
76
|
+
|
|
77
|
+
If you want to index a directory and ask a question about it, install `weft-rag`, not this. It
|
|
78
|
+
depends on `weft-kernel` and brings the packs that do the actual work — extraction, chunking,
|
|
79
|
+
embedding, storage, retrieval, generation — plus the `weft` command:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
uvx --from weft-rag weft --help
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`weft-kernel` exists as its own installable distribution so that fitness function 1 can be a fact
|
|
86
|
+
about a clean install rather than a claim about the source tree. Install it directly only if you
|
|
87
|
+
are writing a pack against its registry and discovery mechanism and want nothing else on the
|
|
88
|
+
import path while you do it.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# weft-kernel
|
|
2
|
+
|
|
3
|
+
The kernel of Weft, a RAG engine built as a microkernel. This distribution is the registry a pack
|
|
4
|
+
registers into, the entry-point discovery that finds packs, the pipeline model a pipeline document
|
|
5
|
+
resolves against, the payload types every stage signature names, and the registration seam every
|
|
6
|
+
stage's execution passes through. It contains no RAG capability of any kind.
|
|
7
|
+
|
|
8
|
+
## The one thing that makes it unusual
|
|
9
|
+
|
|
10
|
+
**The kernel names no capability.** There is no `Extractor`, `Chunker`, `Store`, `Retriever` or
|
|
11
|
+
`LLM` in this package — those contracts are published by the first-party packs that own them, in
|
|
12
|
+
`weft-rag`, on exactly the same public entry point a third party's pack would use. What ships here
|
|
13
|
+
is the mechanism a contract is expressed and run through, never a contract itself.
|
|
14
|
+
|
|
15
|
+
This is not a design intention stated in a docstring; it is checked. `weft-kernel` is a separate
|
|
16
|
+
installable distribution for exactly one reason: `poe kernel-isolated` installs it alone into a
|
|
17
|
+
clean environment and imports it, so if anything reached outside what it ships, the import fails.
|
|
18
|
+
A static counterpart walks every import in the source tree against the same declared dependency
|
|
19
|
+
set. Both are fitness function 1, in `tests/architecture/test_ff1_boundary.py`.
|
|
20
|
+
|
|
21
|
+
## Dependencies
|
|
22
|
+
|
|
23
|
+
Exactly `pydantic` and `opentelemetry-api` — that is `packages/weft-kernel/pyproject.toml`'s whole
|
|
24
|
+
`dependencies` list, and a third dependency is a decision-log entry, not a line in a pyproject.
|
|
25
|
+
`opentelemetry-api` is the no-op-without-an-SDK API; anything that actually exports a span is a
|
|
26
|
+
pack's concern (`weft-otel`), not this one's.
|
|
27
|
+
|
|
28
|
+
## Async only
|
|
29
|
+
|
|
30
|
+
Every contract method this kernel's types describe is `async def`. There is no sync protocol and
|
|
31
|
+
no sync facade anywhere in this package — a stage runs on the event loop, and a categorical
|
|
32
|
+
detector installed at the registration seam (`weft_kernel.blocking`) fails the build on a blocking
|
|
33
|
+
call made on that thread rather than tolerating one behind a synchronous-looking signature.
|
|
34
|
+
|
|
35
|
+
## What is actually in here
|
|
36
|
+
|
|
37
|
+
Twenty modules under `weft_kernel`, none of them a plugin:
|
|
38
|
+
|
|
39
|
+
- `registry.py` — where a pack's `register()` adds what it provides, and where an unresolvable
|
|
40
|
+
name fails loudly, naming what was wanted and what is registered.
|
|
41
|
+
- `discovery.py` — entry-point discovery and the trust model: which installed distributions get
|
|
42
|
+
imported, what a pack may disclose about itself, and the `[packs] allow` pin that refuses an
|
|
43
|
+
import before it happens rather than after.
|
|
44
|
+
- `pipeline.py` / `resolution.py` / `runner.py` — the pipeline as authored data, the pipeline
|
|
45
|
+
resolved to a frozen explicit form, and the linear runner that executes a resolved chain.
|
|
46
|
+
- `seam.py` — `wrap`, the one seam every stage's call passes through: spans, error attribution,
|
|
47
|
+
`__transient__` stripping and the blocking-call detector attach here, automatically, so no
|
|
48
|
+
author has to remember any of the four.
|
|
49
|
+
- `context.py` — the passport every stage receives: tenant, run and trace ids, cancellation,
|
|
50
|
+
locale, and `require()` for an ambient service.
|
|
51
|
+
- `payload/` — the domain model a stage signature names: `Node`, `NodeId`, `Lineage`, `MediaType`,
|
|
52
|
+
`Vector`, `Outcome`, `ExtModel`/`ExtMap` (a pack's own namespaced, validated extension data), and
|
|
53
|
+
the `Property` and `Applies` markers a plugin class declares itself against.
|
|
54
|
+
- `errors.py` / `fallback.py` / `blocking.py` — the `WeftError` root every pack raises against, the
|
|
55
|
+
fallback-chain combinator that composes plugins over any contract without inspecting them, and
|
|
56
|
+
the blocking-call detector above.
|
|
57
|
+
|
|
58
|
+
The kernel is also held to a size ceiling: `uv run pytest tests/architecture/test_ff3_kernel_budget.py -s`
|
|
59
|
+
measures 3,300 non-blank, non-comment, non-docstring lines against a 3,500-line fail and a
|
|
60
|
+
2,800-line review trigger — a stated budget rather than an unstated one, so growth is on the agenda
|
|
61
|
+
before it is a crisis.
|
|
62
|
+
|
|
63
|
+
## You probably do not want this package
|
|
64
|
+
|
|
65
|
+
If you want to index a directory and ask a question about it, install `weft-rag`, not this. It
|
|
66
|
+
depends on `weft-kernel` and brings the packs that do the actual work — extraction, chunking,
|
|
67
|
+
embedding, storage, retrieval, generation — plus the `weft` command:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
uvx --from weft-rag weft --help
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`weft-kernel` exists as its own installable distribution so that fitness function 1 can be a fact
|
|
74
|
+
about a clean install rather than a claim about the source tree. Install it directly only if you
|
|
75
|
+
are writing a pack against its registry and discovery mechanism and want nothing else on the
|
|
76
|
+
import path while you do it.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "weft-kernel"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "The Weft kernel: registry, discovery, pipeline model, payload types."
|
|
5
|
+
requires-python = ">=3.12"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
dependencies = ["pydantic>=2.9", "opentelemetry-api>=1.28"]
|
|
10
|
+
|
|
11
|
+
[build-system]
|
|
12
|
+
requires = ["hatchling"]
|
|
13
|
+
build-backend = "hatchling.build"
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"""The Weft kernel.
|
|
2
|
+
|
|
3
|
+
What belongs here is settled in G1 and specified in `docs/01-high-level-plan.md`
|
|
4
|
+
under *The kernel boundary*: the kernel is what is required to express, load and
|
|
5
|
+
run contracts it knows nothing about, plus the domain types those signatures
|
|
6
|
+
unavoidably name — and nothing in the kernel performs RAG work.
|
|
7
|
+
|
|
8
|
+
Its two dependencies, `pydantic` and `opentelemetry-api`, are declared and
|
|
9
|
+
enforced by fitness function 1.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from weft_kernel.blocking import BlockingCallError
|
|
13
|
+
from weft_kernel.context import (
|
|
14
|
+
Context,
|
|
15
|
+
DuplicateServiceError,
|
|
16
|
+
ServiceRegistry,
|
|
17
|
+
ServiceRole,
|
|
18
|
+
UnresolvedServiceError,
|
|
19
|
+
)
|
|
20
|
+
from weft_kernel.discovery import (
|
|
21
|
+
ENTRY_POINT_GROUP,
|
|
22
|
+
Disclosure,
|
|
23
|
+
EntryPointLike,
|
|
24
|
+
EnvInterpolationError,
|
|
25
|
+
PackRegistrar,
|
|
26
|
+
PackReport,
|
|
27
|
+
PackSettingsError,
|
|
28
|
+
PackStatus,
|
|
29
|
+
PipelineResource,
|
|
30
|
+
allow_list_from_config,
|
|
31
|
+
discover,
|
|
32
|
+
interpolate_env,
|
|
33
|
+
)
|
|
34
|
+
from weft_kernel.errors import UnresolvedNameError, WeftError
|
|
35
|
+
from weft_kernel.fallback import Attempt, try_in_order
|
|
36
|
+
from weft_kernel.payload import (
|
|
37
|
+
SCHEMA_VERSION_KEY,
|
|
38
|
+
ExtMap,
|
|
39
|
+
ExtModel,
|
|
40
|
+
Failed,
|
|
41
|
+
Lineage,
|
|
42
|
+
MediaType,
|
|
43
|
+
Node,
|
|
44
|
+
NodeId,
|
|
45
|
+
NothingToProduce,
|
|
46
|
+
Outcome,
|
|
47
|
+
Produced,
|
|
48
|
+
Property,
|
|
49
|
+
SchemaVersionRefusedError,
|
|
50
|
+
SourceId,
|
|
51
|
+
SyntheticOrigin,
|
|
52
|
+
Vector,
|
|
53
|
+
)
|
|
54
|
+
from weft_kernel.pipeline import (
|
|
55
|
+
InsertOperator,
|
|
56
|
+
Pipeline,
|
|
57
|
+
SetOperator,
|
|
58
|
+
SlotDeclaration,
|
|
59
|
+
StageDeclaration,
|
|
60
|
+
)
|
|
61
|
+
from weft_kernel.registry import (
|
|
62
|
+
DuplicateRegistrationError,
|
|
63
|
+
MissingDestroysDeclarationError,
|
|
64
|
+
MissingRequiredDeclarationError,
|
|
65
|
+
Registry,
|
|
66
|
+
RegistryEntry,
|
|
67
|
+
UnknownPluginError,
|
|
68
|
+
)
|
|
69
|
+
from weft_kernel.resolution import (
|
|
70
|
+
Contribution,
|
|
71
|
+
InvalidStageConfigError,
|
|
72
|
+
OperatorIdCollisionError,
|
|
73
|
+
PipelineCycleError,
|
|
74
|
+
ResolvedPipeline,
|
|
75
|
+
ResolvedStage,
|
|
76
|
+
SlotOrderConflictError,
|
|
77
|
+
StageNotConfigurableError,
|
|
78
|
+
StaleOperatorTargetError,
|
|
79
|
+
UndefinedVarError,
|
|
80
|
+
UnknownParentPipelineError,
|
|
81
|
+
resolve,
|
|
82
|
+
)
|
|
83
|
+
from weft_kernel.runner import (
|
|
84
|
+
FlushError,
|
|
85
|
+
IntactViolationError,
|
|
86
|
+
Lifetime,
|
|
87
|
+
PipelineResolutionError,
|
|
88
|
+
RunnablePipeline,
|
|
89
|
+
Runner,
|
|
90
|
+
RunSummary,
|
|
91
|
+
Stage,
|
|
92
|
+
StageCompositionError,
|
|
93
|
+
StageSpec,
|
|
94
|
+
TenantMismatchError,
|
|
95
|
+
UnknownFallbackError,
|
|
96
|
+
UnmetRequiresError,
|
|
97
|
+
)
|
|
98
|
+
from weft_kernel.seam import Deprecation, wrap, wrap_flush
|
|
99
|
+
|
|
100
|
+
__all__ = [
|
|
101
|
+
"ENTRY_POINT_GROUP",
|
|
102
|
+
"SCHEMA_VERSION_KEY",
|
|
103
|
+
"Attempt",
|
|
104
|
+
"BlockingCallError",
|
|
105
|
+
"Context",
|
|
106
|
+
"Contribution",
|
|
107
|
+
"Deprecation",
|
|
108
|
+
"Disclosure",
|
|
109
|
+
"DuplicateRegistrationError",
|
|
110
|
+
"DuplicateServiceError",
|
|
111
|
+
"EntryPointLike",
|
|
112
|
+
"EnvInterpolationError",
|
|
113
|
+
"ExtMap",
|
|
114
|
+
"ExtModel",
|
|
115
|
+
"Failed",
|
|
116
|
+
"FlushError",
|
|
117
|
+
"InsertOperator",
|
|
118
|
+
"IntactViolationError",
|
|
119
|
+
"InvalidStageConfigError",
|
|
120
|
+
"Lifetime",
|
|
121
|
+
"Lineage",
|
|
122
|
+
"MediaType",
|
|
123
|
+
"MissingDestroysDeclarationError",
|
|
124
|
+
"MissingRequiredDeclarationError",
|
|
125
|
+
"Node",
|
|
126
|
+
"NodeId",
|
|
127
|
+
"NothingToProduce",
|
|
128
|
+
"OperatorIdCollisionError",
|
|
129
|
+
"Outcome",
|
|
130
|
+
"PackRegistrar",
|
|
131
|
+
"PackReport",
|
|
132
|
+
"PackSettingsError",
|
|
133
|
+
"PackStatus",
|
|
134
|
+
"Pipeline",
|
|
135
|
+
"PipelineCycleError",
|
|
136
|
+
"PipelineResolutionError",
|
|
137
|
+
"PipelineResource",
|
|
138
|
+
"Produced",
|
|
139
|
+
"Property",
|
|
140
|
+
"Registry",
|
|
141
|
+
"RegistryEntry",
|
|
142
|
+
"ResolvedPipeline",
|
|
143
|
+
"ResolvedStage",
|
|
144
|
+
"RunnablePipeline",
|
|
145
|
+
"Runner",
|
|
146
|
+
"RunSummary",
|
|
147
|
+
"SchemaVersionRefusedError",
|
|
148
|
+
"ServiceRegistry",
|
|
149
|
+
"ServiceRole",
|
|
150
|
+
"SetOperator",
|
|
151
|
+
"SlotDeclaration",
|
|
152
|
+
"SlotOrderConflictError",
|
|
153
|
+
"SourceId",
|
|
154
|
+
"Stage",
|
|
155
|
+
"StageCompositionError",
|
|
156
|
+
"StageDeclaration",
|
|
157
|
+
"StageNotConfigurableError",
|
|
158
|
+
"StageSpec",
|
|
159
|
+
"StaleOperatorTargetError",
|
|
160
|
+
"SyntheticOrigin",
|
|
161
|
+
"TenantMismatchError",
|
|
162
|
+
"UndefinedVarError",
|
|
163
|
+
"UnknownFallbackError",
|
|
164
|
+
"UnknownParentPipelineError",
|
|
165
|
+
"UnknownPluginError",
|
|
166
|
+
"UnmetRequiresError",
|
|
167
|
+
"UnresolvedNameError",
|
|
168
|
+
"UnresolvedServiceError",
|
|
169
|
+
"Vector",
|
|
170
|
+
"WeftError",
|
|
171
|
+
"allow_list_from_config",
|
|
172
|
+
"discover",
|
|
173
|
+
"interpolate_env",
|
|
174
|
+
"resolve",
|
|
175
|
+
"try_in_order",
|
|
176
|
+
"wrap",
|
|
177
|
+
"wrap_flush",
|
|
178
|
+
]
|