Skip to content

Commit 4968e33

Browse files
authored
Merge pull request #1 from kagenti/feat/deepen-with-libraries
feat: Go context-engineering proxy/library (tree-sitter, TOON, Starlark extractor, config, metrics, real integrations)
2 parents 15165cd + ddda100 commit 4968e33

102 files changed

Lines changed: 11427 additions & 170 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-agent.yaml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build-test:
13+
runs-on: ubuntu-latest
14+
env:
15+
CGO_ENABLED: "1"
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.25'
21+
check-latest: true
22+
- name: Lint
23+
run: make lint
24+
- name: Test
25+
run: make test
26+
- name: Build
27+
run: make build
28+
29+
trivy:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Trivy filesystem scan
34+
uses: aquasecurity/trivy-action@0.28.0
35+
with:
36+
scan-type: fs
37+
ignore-unfixed: true
38+
severity: CRITICAL,HIGH
39+
exit-code: '1'

.github/workflows/weekly-docker-test.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,9 @@ cython_debug/
162162
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
163163
.idea/
164164

165+
166+
# Go / lab-context-engineering
167+
/bin/
168+
*.test
169+
*.out
170+
coverage.txt

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Run `make pre-commit` once to install these hooks (including commit-msg / DCO).
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: trailing-whitespace
7+
- id: end-of-file-fixer
8+
- id: check-yaml
9+
- id: check-added-large-files
10+
11+
- repo: https://github.com/dnephin/pre-commit-golang
12+
rev: v0.5.1
13+
hooks:
14+
- id: go-fmt
15+
- id: go-vet
16+
- id: go-mod-tidy
17+
18+
- repo: https://github.com/jorisroovers/gitlint
19+
rev: v0.19.1
20+
hooks:
21+
- id: gitlint

CLAUDE.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# CLAUDE.md
2+
3+
Guidance for working in `lab-context-engineering`, a Kagenti platform component.
4+
5+
## What this repo is
6+
7+
A single **Go** core that reduces the token cost of LLM agent traffic. It ships as a
8+
standalone proxy binary (`cmd/proxy`), an importable library (`engine`, `surfaces`), and
9+
eval-containers wiring. Its lineage is the Python `winnow` prototype (`../winnow`), which
10+
is the behavioral reference — port its *logic*, re-implement its transport in Go.
11+
12+
## Hard boundaries
13+
14+
- **No AuthBridge / kagenti-extensions code lives here.** That plugin is built in
15+
`kagenti-extensions` and depends on this repo. Keep the public API (`engine`,
16+
`surfaces`, `config`) clean and importable; never reach into another repo.
17+
- **Fail open, always.** Any error in any stage forwards the original request untouched.
18+
Reductions must be reversible (markers + rewind store). Never drop content that is only
19+
*predicted* unused — `provable_only` is on by default.
20+
21+
## Conventions
22+
23+
- Go 1.25, module `github.com/kagenti/lab-context-engineering`. `make fmt lint test build`.
24+
- Match the surrounding code's style; keep packages small and single-purpose.
25+
- **Commits: DCO sign-off is mandatory**`git commit -s`. Author as the repo owner.
26+
AI attribution uses `Assisted-By:` — never `Co-Authored-By`, never a "Generated with"
27+
line. Conventional-commit titles.
28+
- Observability follows OpenTelemetry **GenAI semantic conventions** (`gen_ai.*`).
29+
30+
## Layout
31+
32+
`cmd/proxy` (binary) · `engine` (Transform/Expand + stages) · `surfaces` (wire⇄canonical)
33+
· `internal/*` (types, extract, relevance, signals, taxonomy, actions, cache, markers,
34+
rewind, zones, session, compaction, tokens) · `config` · `observability` · `deploy` ·
35+
`docs`.

CODE_OF_CONDUCT.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Code of Conduct
2+
3+
This project adheres to the Kagenti community Code of Conduct, which is based on the
4+
[Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
5+
6+
By participating, you are expected to uphold this code. Please report unacceptable
7+
behavior to the maintainers listed in [MAINTAINERS.md](MAINTAINERS.md) or via the process
8+
described in the main [Kagenti](https://github.com/kagenti/kagenti) repository.

CONTRIBUTING.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Contributing
2+
3+
Thanks for your interest in `lab-context-engineering`, a component of the
4+
[Kagenti](https://github.com/kagenti/kagenti) platform.
5+
6+
## Developer Certificate of Origin (DCO)
7+
8+
All commits must be signed off under the [DCO](https://developercertificate.org/):
9+
10+
```sh
11+
git commit -s -m "feat: ..."
12+
```
13+
14+
This adds a `Signed-off-by:` trailer certifying you wrote or have the right to submit the
15+
patch. PRs with unsigned commits will not be merged.
16+
17+
When a commit was assisted by an AI agent, attribute it with an `Assisted-By:` trailer —
18+
do **not** use `Co-Authored-By` and do not add "Generated with" lines.
19+
20+
## Development
21+
22+
```sh
23+
make fmt # format + go mod tidy
24+
make lint # go vet + gofmt check
25+
make test # go test -race ./...
26+
make build # build ./bin/lab-cx
27+
```
28+
29+
- Go 1.25+.
30+
- Keep packages small and single-purpose; the engine core must stay transport-agnostic.
31+
- Every reduction must be reversible and fail-open. Add tests for both the happy path and
32+
the fault-injection (fail-open) path.
33+
34+
## Pull requests
35+
36+
Use conventional-commit titles (`feat:`, `fix:`, `docs:`, `refactor:`, `test:`, `chore:`).
37+
Keep PRs focused. CI (lint, test, build, Trivy) must be green.
38+
39+
## Reporting security issues
40+
41+
See [SECURITY.md](SECURITY.md). Do not open public issues for vulnerabilities.

Dockerfile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
FROM python:3.13-slim
2-
COPY --from=ghcr.io/astral-sh/uv:0.9.5 /uv /bin/uv
3-
WORKDIR /app
1+
# Build the lab-cx proxy. CGO is required (tree-sitter), so the final image is
2+
# glibc-based (distroless/base), not static.
3+
FROM golang:1.25 AS build
4+
WORKDIR /src
45
COPY . .
5-
RUN UV_COMPILE_BYTECODE=1 HOME=/tmp uv sync --no-cache --link-mode copy
6-
ENV PRODUCTION_MODE=True
7-
CMD ["/app/.venv/bin/server"]
6+
ARG VERSION=dev
7+
ARG COMMIT=none
8+
RUN CGO_ENABLED=1 go build \
9+
-ldflags "-s -w -X github.com/kagenti/lab-context-engineering/internal/buildinfo.Version=${VERSION} -X github.com/kagenti/lab-context-engineering/internal/buildinfo.Commit=${COMMIT}" \
10+
-o /out/lab-cx ./cmd/proxy
11+
12+
FROM gcr.io/distroless/base-debian12:nonroot
13+
COPY --from=build /out/lab-cx /usr/local/bin/lab-cx
14+
EXPOSE 8080
15+
ENTRYPOINT ["/usr/local/bin/lab-cx"]
16+
CMD ["proxy"]

GOVERNANCE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Governance
2+
3+
`lab-context-engineering` is a component of the
4+
[Kagenti](https://github.com/kagenti/kagenti) platform and follows Kagenti's project
5+
governance. See the Kagenti community
6+
[GOVERNANCE](https://github.com/i-am-bee/community/blob/main/GOVERNANCE.md) document for
7+
the roles, decision-making process, and the path to becoming a maintainer.
8+
9+
Maintainers of this repository are listed in [MAINTAINERS.md](MAINTAINERS.md).

0 commit comments

Comments
 (0)