kestrel-feature-parametric-self 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.
- kestrel_feature_parametric_self-0.1.0/.github/workflows/ci.yml +37 -0
- kestrel_feature_parametric_self-0.1.0/.github/workflows/publish.yml +57 -0
- kestrel_feature_parametric_self-0.1.0/.gitignore +6 -0
- kestrel_feature_parametric_self-0.1.0/AGENTS.md +26 -0
- kestrel_feature_parametric_self-0.1.0/LICENSE +190 -0
- kestrel_feature_parametric_self-0.1.0/PKG-INFO +55 -0
- kestrel_feature_parametric_self-0.1.0/README.md +36 -0
- kestrel_feature_parametric_self-0.1.0/kestrel_feature_parametric_self/__init__.py +23 -0
- kestrel_feature_parametric_self-0.1.0/kestrel_feature_parametric_self/component.yaml +50 -0
- kestrel_feature_parametric_self-0.1.0/kestrel_feature_parametric_self/feature.py +118 -0
- kestrel_feature_parametric_self-0.1.0/pyproject.toml +43 -0
- kestrel_feature_parametric_self-0.1.0/tests/test_feature.py +60 -0
- kestrel_feature_parametric_self-0.1.0/uv.lock +3252 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: kestrel-feature-parametric-self CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, 'release/*', 'codex/*']
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
workflow_call:
|
|
10
|
+
inputs:
|
|
11
|
+
ref:
|
|
12
|
+
required: false
|
|
13
|
+
type: string
|
|
14
|
+
|
|
15
|
+
env:
|
|
16
|
+
PYTHON_VERSION: "3.14"
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
test:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
with:
|
|
24
|
+
ref: ${{ inputs.ref || github.ref }}
|
|
25
|
+
- uses: astral-sh/setup-uv@v3
|
|
26
|
+
- run: uv python install ${{ env.PYTHON_VERSION }}
|
|
27
|
+
- run: uv run --extra test pytest -q
|
|
28
|
+
- run: uv build
|
|
29
|
+
- name: Validate entry point
|
|
30
|
+
run: |
|
|
31
|
+
uv run --extra test python - <<'PY'
|
|
32
|
+
from importlib.metadata import entry_points
|
|
33
|
+
from kestrel_feature_parametric_self import ParametricSelfFeature
|
|
34
|
+
eps = entry_points(group="kestrel_sovereign.features")
|
|
35
|
+
assert any(ep.name == "ParametricSelfFeature" for ep in eps)
|
|
36
|
+
print(ParametricSelfFeature.__name__)
|
|
37
|
+
PY
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v[0-9]+.[0-9]+.[0-9]+']
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
ref:
|
|
9
|
+
description: 'Tag or commit to publish'
|
|
10
|
+
required: true
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
ci:
|
|
17
|
+
uses: ./.github/workflows/ci.yml
|
|
18
|
+
with:
|
|
19
|
+
ref: ${{ inputs.ref || github.ref }}
|
|
20
|
+
secrets: inherit
|
|
21
|
+
|
|
22
|
+
build:
|
|
23
|
+
needs: ci
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
with:
|
|
28
|
+
ref: ${{ inputs.ref || github.ref }}
|
|
29
|
+
- uses: astral-sh/setup-uv@v3
|
|
30
|
+
- run: uv build
|
|
31
|
+
- name: Verify tag matches package version
|
|
32
|
+
if: startsWith(inputs.ref, 'v') || startsWith(github.ref, 'refs/tags/v')
|
|
33
|
+
env:
|
|
34
|
+
INPUT_REF: ${{ inputs.ref }}
|
|
35
|
+
run: |
|
|
36
|
+
TAG_NAME="${INPUT_REF:-$GITHUB_REF_NAME}"
|
|
37
|
+
TAG_VERSION="${TAG_NAME#v}"
|
|
38
|
+
PKG_VERSION=$(uv run --no-project python -c "import tomllib; print(tomllib.loads(open('pyproject.toml').read())['project']['version'])")
|
|
39
|
+
test "$TAG_VERSION" = "$PKG_VERSION"
|
|
40
|
+
- uses: actions/upload-artifact@v4
|
|
41
|
+
with:
|
|
42
|
+
name: dist
|
|
43
|
+
path: dist/
|
|
44
|
+
if-no-files-found: error
|
|
45
|
+
|
|
46
|
+
publish:
|
|
47
|
+
needs: build
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
environment: pypi
|
|
50
|
+
permissions:
|
|
51
|
+
id-token: write
|
|
52
|
+
steps:
|
|
53
|
+
- uses: actions/download-artifact@v4
|
|
54
|
+
with:
|
|
55
|
+
name: dist
|
|
56
|
+
path: dist/
|
|
57
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# kestrel-feature-parametric-self — Agent Instructions
|
|
2
|
+
|
|
3
|
+
This repository packages the Kestrel parametric-self feature: the agent's
|
|
4
|
+
owned, nightly-finetuned local model (the "second brain").
|
|
5
|
+
|
|
6
|
+
## Key Files
|
|
7
|
+
|
|
8
|
+
- `kestrel_feature_parametric_self/feature.py` — `ParametricSelfFeature` entry point + sleep-cycle hook.
|
|
9
|
+
- `kestrel_feature_parametric_self/component.yaml` — feature manifest.
|
|
10
|
+
|
|
11
|
+
## Design
|
|
12
|
+
|
|
13
|
+
- `docs/research/TWO_BRAIN_ARCHITECTURE.md` in `kestrel-sovereign` (rationale, phases, risks).
|
|
14
|
+
- Epic #1 (this repo) tracks the phased build.
|
|
15
|
+
|
|
16
|
+
## Conventions
|
|
17
|
+
|
|
18
|
+
- Depends on `kestrel-feature-reflection` as its corpus source (P1); does not live inside it.
|
|
19
|
+
- The MLX trainer is Apple-Silicon only and imported lazily — never at module import — so the package installs and CI-validates on Linux.
|
|
20
|
+
- This is the *parametric* self (weights), distinct from reflection's *symbolic* self-model. It is not memory.
|
|
21
|
+
|
|
22
|
+
## Running Tests
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv run --extra test pytest
|
|
26
|
+
```
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright
|
|
52
|
+
owner or by an individual or Legal Entity authorized to submit on behalf
|
|
53
|
+
of 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
|
+
Copyright 2024-2026 Kestrel Sovereign AI Project
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kestrel-feature-parametric-self
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Owned parametric self for Kestrel Sovereign agents — a per-agent local model nightly-finetuned on the agent's own experience
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Requires-Python: <3.15,>=3.11
|
|
12
|
+
Requires-Dist: kestrel-sovereign-sdk<1,>=0.14.1
|
|
13
|
+
Requires-Dist: kestrel-sovereign<1,>=0.13.1
|
|
14
|
+
Provides-Extra: test
|
|
15
|
+
Requires-Dist: pytest-asyncio>=1.1.0; extra == 'test'
|
|
16
|
+
Requires-Dist: pytest-timeout>=2.3.1; extra == 'test'
|
|
17
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# kestrel-feature-parametric-self
|
|
21
|
+
|
|
22
|
+
The agent's **owned parametric self** for Kestrel Sovereign.
|
|
23
|
+
|
|
24
|
+
A per-agent local model (target: Gemma 4 31B, 4-bit MLX) that is
|
|
25
|
+
nightly-finetuned during the sleep cycle on the agent's own experience, and —
|
|
26
|
+
once proven — consulted in the agent's reasoning loop as a disposition prior
|
|
27
|
+
and on-demand oracle alongside the frontier model.
|
|
28
|
+
|
|
29
|
+
Slogan: **rent intelligence, own identity.** This is the *parametric*
|
|
30
|
+
counterpart to reflection's *symbolic* self-model (the weights, not a trait
|
|
31
|
+
dict). It is **not** memory — RAG remains the factual layer.
|
|
32
|
+
|
|
33
|
+
Design: `docs/research/TWO_BRAIN_ARCHITECTURE.md` in `kestrel-sovereign`.
|
|
34
|
+
Build plan: epic #1.
|
|
35
|
+
|
|
36
|
+
> **Status: P0 scaffold.** The feature loads and registers; the MLX trainer,
|
|
37
|
+
> reflection-derived corpus, fidelity gate, and in-loop integration land in
|
|
38
|
+
> later phases. The Apple-Silicon trainer is imported lazily, so the package
|
|
39
|
+
> installs and CI-validates on any platform.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
uv pip install kestrel-feature-parametric-self
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The package registers `ParametricSelfFeature` through the
|
|
48
|
+
`kestrel_sovereign.features` entry point group.
|
|
49
|
+
|
|
50
|
+
## Development
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv sync --extra test
|
|
54
|
+
uv run --extra test pytest
|
|
55
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# kestrel-feature-parametric-self
|
|
2
|
+
|
|
3
|
+
The agent's **owned parametric self** for Kestrel Sovereign.
|
|
4
|
+
|
|
5
|
+
A per-agent local model (target: Gemma 4 31B, 4-bit MLX) that is
|
|
6
|
+
nightly-finetuned during the sleep cycle on the agent's own experience, and —
|
|
7
|
+
once proven — consulted in the agent's reasoning loop as a disposition prior
|
|
8
|
+
and on-demand oracle alongside the frontier model.
|
|
9
|
+
|
|
10
|
+
Slogan: **rent intelligence, own identity.** This is the *parametric*
|
|
11
|
+
counterpart to reflection's *symbolic* self-model (the weights, not a trait
|
|
12
|
+
dict). It is **not** memory — RAG remains the factual layer.
|
|
13
|
+
|
|
14
|
+
Design: `docs/research/TWO_BRAIN_ARCHITECTURE.md` in `kestrel-sovereign`.
|
|
15
|
+
Build plan: epic #1.
|
|
16
|
+
|
|
17
|
+
> **Status: P0 scaffold.** The feature loads and registers; the MLX trainer,
|
|
18
|
+
> reflection-derived corpus, fidelity gate, and in-loop integration land in
|
|
19
|
+
> later phases. The Apple-Silicon trainer is imported lazily, so the package
|
|
20
|
+
> installs and CI-validates on any platform.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv pip install kestrel-feature-parametric-self
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The package registers `ParametricSelfFeature` through the
|
|
29
|
+
`kestrel_sovereign.features` entry point group.
|
|
30
|
+
|
|
31
|
+
## Development
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uv sync --extra test
|
|
35
|
+
uv run --extra test pytest
|
|
36
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Parametric Self feature for Kestrel Sovereign.
|
|
2
|
+
|
|
3
|
+
The owned parametric self: a per-agent local model (target: Gemma 4 31B,
|
|
4
|
+
4-bit MLX) that is nightly-finetuned during the sleep cycle on the agent's
|
|
5
|
+
own experience, and — once proven — consulted in the agent's reasoning loop
|
|
6
|
+
as a disposition prior and on-demand oracle.
|
|
7
|
+
|
|
8
|
+
This is the *parametric* counterpart to reflection's *symbolic* self-model
|
|
9
|
+
(``kestrel_feature_reflection.SelfModelManager``): the weights, not a trait
|
|
10
|
+
dict. It is **not** memory — RAG remains the factual layer.
|
|
11
|
+
|
|
12
|
+
See ``docs/research/TWO_BRAIN_ARCHITECTURE.md`` in kestrel-sovereign and
|
|
13
|
+
epic #1 for the design and phased build.
|
|
14
|
+
|
|
15
|
+
P0 is a scaffold: the feature loads and registers, the sleep-hook surface is
|
|
16
|
+
stubbed, and the MLX trainer + reflection corpus land in P1/P2.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from .feature import ParametricSelfFeature
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"ParametricSelfFeature",
|
|
23
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Parametric Self Feature Component Manifest
|
|
2
|
+
# The agent's owned parametric self — nightly-finetuned, in-the-loop.
|
|
3
|
+
|
|
4
|
+
name: parametric_self
|
|
5
|
+
version: 0.1.0
|
|
6
|
+
description: |
|
|
7
|
+
Owned parametric self: a per-agent local model (target Gemma 4 31B, 4-bit
|
|
8
|
+
MLX) nightly-finetuned during the sleep cycle on the agent's own experience,
|
|
9
|
+
and consulted in the reasoning loop as a disposition prior and on-demand
|
|
10
|
+
oracle. The parametric counterpart to reflection's symbolic self-model.
|
|
11
|
+
|
|
12
|
+
# Feature class location
|
|
13
|
+
module: kestrel_feature_parametric_self.feature
|
|
14
|
+
class: ParametricSelfFeature
|
|
15
|
+
|
|
16
|
+
# Dependencies
|
|
17
|
+
requires:
|
|
18
|
+
- storage # For reading the training corpus and adapter pointers
|
|
19
|
+
|
|
20
|
+
optional:
|
|
21
|
+
- reflection # Corpus source (insights + per-turn facts); P1
|
|
22
|
+
- llm_service # For serving / oracle consultation; P3
|
|
23
|
+
- security # Constitutional gating — sovereign agents only (P2)
|
|
24
|
+
|
|
25
|
+
# Tools provided
|
|
26
|
+
tools:
|
|
27
|
+
- name: parametric-self-status
|
|
28
|
+
description: Report base model, current adapter, and live build phase
|
|
29
|
+
command: "!parametric-self"
|
|
30
|
+
|
|
31
|
+
# Integration hooks
|
|
32
|
+
hooks:
|
|
33
|
+
- event: post_consolidation
|
|
34
|
+
method: on_post_consolidation
|
|
35
|
+
description: Nightly LoRA training on the night's consolidated reflections (P2)
|
|
36
|
+
|
|
37
|
+
# Configuration
|
|
38
|
+
config:
|
|
39
|
+
# Apple-Silicon only; the trainer no-ops elsewhere.
|
|
40
|
+
enable_nightly_training: false # Off until P2 lands the real trainer
|
|
41
|
+
base_model: "gemma-4-31B-it-mlx-4bit"
|
|
42
|
+
# In-loop integration is path-first; promotion to always-on prior is gated.
|
|
43
|
+
in_loop: false
|
|
44
|
+
|
|
45
|
+
# Tags for discovery
|
|
46
|
+
tags:
|
|
47
|
+
- cognitive
|
|
48
|
+
- parametric-self
|
|
49
|
+
- sovereignty
|
|
50
|
+
- local-model
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""Parametric Self feature — owned, nightly-finetuned, in-the-loop second brain.
|
|
2
|
+
|
|
3
|
+
P0 scaffold. The feature loads, registers through the
|
|
4
|
+
``kestrel_sovereign.features`` entry point, exposes a status tool, and
|
|
5
|
+
declares the sleep-cycle hook surface it will use for nightly training. The
|
|
6
|
+
actual MLX LoRA trainer, the reflection-derived corpus, the fidelity gate,
|
|
7
|
+
and the in-loop conditioning/oracle integration land in later phases
|
|
8
|
+
(see epic #1 and ``docs/research/TWO_BRAIN_ARCHITECTURE.md``).
|
|
9
|
+
|
|
10
|
+
Design boundary: this is the *parametric* self (weights). Reflection keeps
|
|
11
|
+
the *symbolic* self-model (a trait dict). This feature depends on reflection
|
|
12
|
+
as its corpus source but does not live inside it, because it is active in the
|
|
13
|
+
runtime reasoning loop, not only during sleep.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import logging
|
|
17
|
+
from typing import Any, Dict
|
|
18
|
+
|
|
19
|
+
from kestrel_sdk.features.base import Feature, tool
|
|
20
|
+
from kestrel_sdk.tools.base import ToolCategory
|
|
21
|
+
from kestrel_sdk.tools.result import ToolResult
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ParametricSelfFeature(Feature):
|
|
27
|
+
"""The agent's owned parametric self.
|
|
28
|
+
|
|
29
|
+
A per-agent local model nightly-finetuned on the agent's own experience
|
|
30
|
+
and (once proven) consulted in the reasoning loop. P0 wires the feature
|
|
31
|
+
into the platform; behaviour arrives in P1+ per epic #1.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def tool_description(self) -> str:
|
|
36
|
+
return (
|
|
37
|
+
"Owned parametric self — a per-agent local model nightly-finetuned "
|
|
38
|
+
"on the agent's own experience, consulted as a disposition prior and "
|
|
39
|
+
"on-demand oracle alongside the frontier model"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
async def initialize(self) -> None:
|
|
43
|
+
"""Initialize the parametric-self feature.
|
|
44
|
+
|
|
45
|
+
P0 holds the slots the later phases fill: the MLX training adapter
|
|
46
|
+
(P1), the fidelity gate (P2), and the served-adapter pointer (P3).
|
|
47
|
+
They are ``None`` here so the feature loads cleanly on any platform —
|
|
48
|
+
the Apple-Silicon trainer is imported lazily in P1, never at module
|
|
49
|
+
import, so Linux installs and CI stay green.
|
|
50
|
+
"""
|
|
51
|
+
self._adapter = None # P1: LocalMLXAdapter (lazy, darwin/arm64 only)
|
|
52
|
+
self._fidelity_gate = None # P2: held-out promotion check
|
|
53
|
+
self._active_adapter_path = None # P3: currently served LoRA adapter
|
|
54
|
+
|
|
55
|
+
@tool(
|
|
56
|
+
name="parametric-self-status",
|
|
57
|
+
description="Report the parametric-self feature state: configured base model, current adapter, and which build phase is live",
|
|
58
|
+
category=ToolCategory.SYSTEM,
|
|
59
|
+
command_prefix="!parametric-self",
|
|
60
|
+
)
|
|
61
|
+
async def parametric_self_status(self) -> ToolResult:
|
|
62
|
+
"""Report scaffold state.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
ToolResult describing the current (P0) state. Replaced with real
|
|
66
|
+
adapter/training status in later phases.
|
|
67
|
+
"""
|
|
68
|
+
data = {
|
|
69
|
+
"phase": "P0 — scaffold",
|
|
70
|
+
"trained_adapter": self._active_adapter_path,
|
|
71
|
+
"trainer_available": False,
|
|
72
|
+
"in_loop": False,
|
|
73
|
+
}
|
|
74
|
+
return ToolResult.ok(
|
|
75
|
+
confirmation=(
|
|
76
|
+
"Parametric-self is scaffolded (P0). Nightly training, the "
|
|
77
|
+
"fidelity gate, and in-loop conditioning arrive in later phases "
|
|
78
|
+
"(epic #1)."
|
|
79
|
+
),
|
|
80
|
+
data=data,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
async def on_post_consolidation(
|
|
84
|
+
self,
|
|
85
|
+
consolidation_result: Dict[str, Any],
|
|
86
|
+
) -> Dict[str, Any]:
|
|
87
|
+
"""Feature-layer sleep hook: nightly adapter training (stub).
|
|
88
|
+
|
|
89
|
+
Signature mirrors ``ReflectionFeature.on_post_consolidation`` exactly.
|
|
90
|
+
The sleep cycle does NOT call feature methods directly — it invokes a
|
|
91
|
+
``*SleepHook`` wrapper (cf. reflection's ``ReflectionSleepHook``, whose
|
|
92
|
+
``on_post_consolidation(self, agent, consolidation_result)`` is the
|
|
93
|
+
method ``sleep.py`` calls), and the wrapper delegates here with just
|
|
94
|
+
``consolidation_result``. So there is no sleep-context argument at this
|
|
95
|
+
layer; this is the delegate target.
|
|
96
|
+
|
|
97
|
+
P1/P2 add parametric-self's own SleepHook wrapper and resolve how it
|
|
98
|
+
attaches: ``sleep.py`` currently exposes a single
|
|
99
|
+
``agent.reflection_hook`` slot that reflection owns, so a second
|
|
100
|
+
feature's nightly hook needs either a core change (hook list) or
|
|
101
|
+
chaining through reflection — tracked in epic #1 (P2).
|
|
102
|
+
|
|
103
|
+
Fires after memory consolidation — the point at which reflection has
|
|
104
|
+
produced the night's insights, the corpus this feature trains on. P0 is
|
|
105
|
+
a no-op that records intent; P2 trains a LoRA adapter here and promotes
|
|
106
|
+
it only if it clears the fidelity gate. Returns the legacy sleep-hook
|
|
107
|
+
result dict shape so it slots in beside reflection's hook.
|
|
108
|
+
"""
|
|
109
|
+
logger.debug(
|
|
110
|
+
"parametric-self on_post_consolidation: training deferred to P2 "
|
|
111
|
+
"(episodes_created=%s)",
|
|
112
|
+
consolidation_result.get("episodes_created", 0),
|
|
113
|
+
)
|
|
114
|
+
return {
|
|
115
|
+
"trained": False,
|
|
116
|
+
"promoted": False,
|
|
117
|
+
"reason": "scaffold — nightly training lands in P2 (epic #1)",
|
|
118
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "kestrel-feature-parametric-self"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Owned parametric self for Kestrel Sovereign agents — a per-agent local model nightly-finetuned on the agent's own experience"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
requires-python = ">=3.11,<3.15"
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Programming Language :: Python :: 3.11",
|
|
10
|
+
"Programming Language :: Python :: 3.12",
|
|
11
|
+
"Programming Language :: Python :: 3.13",
|
|
12
|
+
"Programming Language :: Python :: 3.14",
|
|
13
|
+
]
|
|
14
|
+
dependencies = [
|
|
15
|
+
# P0 scaffold: the Feature base class and ToolResult contract come from
|
|
16
|
+
# the SDK; the sleep-hook surface comes from core. The reflection
|
|
17
|
+
# dependency (corpus source) and the Apple-Silicon MLX trainer land in
|
|
18
|
+
# P1 — see epic #1 — so this scaffold installs and CI-validates on
|
|
19
|
+
# Linux without pulling a darwin-only wheel.
|
|
20
|
+
"kestrel-sovereign>=0.13.1,<1",
|
|
21
|
+
"kestrel-sovereign-sdk>=0.14.1,<1",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
test = [
|
|
26
|
+
"pytest>=8.0.0",
|
|
27
|
+
"pytest-asyncio>=1.1.0",
|
|
28
|
+
"pytest-timeout>=2.3.1",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.entry-points."kestrel_sovereign.features"]
|
|
32
|
+
ParametricSelfFeature = "kestrel_feature_parametric_self:ParametricSelfFeature"
|
|
33
|
+
|
|
34
|
+
[build-system]
|
|
35
|
+
requires = ["hatchling"]
|
|
36
|
+
build-backend = "hatchling.build"
|
|
37
|
+
|
|
38
|
+
[tool.hatch.build.targets.wheel]
|
|
39
|
+
packages = ["kestrel_feature_parametric_self"]
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
asyncio_mode = "auto"
|
|
43
|
+
asyncio_default_fixture_loop_scope = "function"
|