ctxlineage 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.
- ctxlineage-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +29 -0
- ctxlineage-0.1.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
- ctxlineage-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +20 -0
- ctxlineage-0.1.0/.github/dependabot.yml +12 -0
- ctxlineage-0.1.0/.github/labels.yml +37 -0
- ctxlineage-0.1.0/.github/pull_request_template.md +13 -0
- ctxlineage-0.1.0/.github/workflows/release.yml +30 -0
- ctxlineage-0.1.0/.github/workflows/sync-labels.yml +16 -0
- ctxlineage-0.1.0/.github/workflows/test.yml +51 -0
- ctxlineage-0.1.0/.gitignore +39 -0
- ctxlineage-0.1.0/CHANGELOG.md +41 -0
- ctxlineage-0.1.0/CLAUDE.md +51 -0
- ctxlineage-0.1.0/CONTRIBUTING.md +40 -0
- ctxlineage-0.1.0/LICENSE +202 -0
- ctxlineage-0.1.0/PKG-INFO +142 -0
- ctxlineage-0.1.0/README.md +117 -0
- ctxlineage-0.1.0/SECURITY.md +21 -0
- ctxlineage-0.1.0/assets/avatar.png +0 -0
- ctxlineage-0.1.0/assets/avatar.svg +12 -0
- ctxlineage-0.1.0/assets/logo-dark.svg +11 -0
- ctxlineage-0.1.0/assets/logo.svg +11 -0
- ctxlineage-0.1.0/assets/wordmark.svg +14 -0
- ctxlineage-0.1.0/codecov.yml +11 -0
- ctxlineage-0.1.0/docs/PLAN.md +204 -0
- ctxlineage-0.1.0/docs/assets/report-calls.png +0 -0
- ctxlineage-0.1.0/docs/assets/report-graph.png +0 -0
- ctxlineage-0.1.0/docs/assets/report-tour.gif +0 -0
- ctxlineage-0.1.0/docs/design/m2-mockups/README.md +42 -0
- ctxlineage-0.1.0/docs/design/m2-mockups/build.py +41 -0
- ctxlineage-0.1.0/docs/design/m2-mockups/call-anatomy.template.html +244 -0
- ctxlineage-0.1.0/docs/design/m2-mockups/chain.template.html +292 -0
- ctxlineage-0.1.0/docs/design/m3-lineage-graph/README.md +41 -0
- ctxlineage-0.1.0/docs/design/m3-lineage-graph/build.py +39 -0
- ctxlineage-0.1.0/docs/design/m3-lineage-graph/lineage-graph.template.html +300 -0
- ctxlineage-0.1.0/docs/plans/2026-06-12-m1-capture.md +393 -0
- ctxlineage-0.1.0/docs/plans/2026-06-12-m2-report.md +86 -0
- ctxlineage-0.1.0/docs/plans/2026-07-16-m2-frontend.md +22 -0
- ctxlineage-0.1.0/docs/plans/2026-07-16-m3-phase-a-span-tag.md +39 -0
- ctxlineage-0.1.0/docs/plans/2026-07-16-m3-phase-b-matching.md +49 -0
- ctxlineage-0.1.0/docs/plans/2026-07-16-m3-phase-c-edges.md +46 -0
- ctxlineage-0.1.0/docs/plans/2026-07-16-m3-phase-e-graph.md +46 -0
- ctxlineage-0.1.0/docs/plans/2026-07-16-m4-anthropic-capture.md +348 -0
- ctxlineage-0.1.0/docs/plans/2026-07-16-m4-examples-skill.md +123 -0
- ctxlineage-0.1.0/docs/plans/2026-07-16-m4-mcp.md +108 -0
- ctxlineage-0.1.0/docs/plans/2026-07-16-redact.md +81 -0
- ctxlineage-0.1.0/docs/positioning.md +153 -0
- ctxlineage-0.1.0/docs/vision/context-contract-testing.md +242 -0
- ctxlineage-0.1.0/examples/agent_app.py +225 -0
- ctxlineage-0.1.0/examples/anthropic_app.py +248 -0
- ctxlineage-0.1.0/examples/generate_demo_events.py +351 -0
- ctxlineage-0.1.0/examples/rag_app.py +186 -0
- ctxlineage-0.1.0/org-profile.png +0 -0
- ctxlineage-0.1.0/pyproject.toml +66 -0
- ctxlineage-0.1.0/schema/events.v1.schema.json +179 -0
- ctxlineage-0.1.0/skills/ctxlineage-instrument/SKILL.md +181 -0
- ctxlineage-0.1.0/src/ctxlineage/__init__.py +5 -0
- ctxlineage-0.1.0/src/ctxlineage/_cli.py +84 -0
- ctxlineage-0.1.0/src/ctxlineage/_events.py +66 -0
- ctxlineage-0.1.0/src/ctxlineage/_instrument/__init__.py +29 -0
- ctxlineage-0.1.0/src/ctxlineage/_instrument/_common.py +190 -0
- ctxlineage-0.1.0/src/ctxlineage/_instrument/anthropic_patch.py +221 -0
- ctxlineage-0.1.0/src/ctxlineage/_instrument/openai_patch.py +171 -0
- ctxlineage-0.1.0/src/ctxlineage/_redact.py +34 -0
- ctxlineage-0.1.0/src/ctxlineage/_report/__init__.py +0 -0
- ctxlineage-0.1.0/src/ctxlineage/_report/assets/app.js +704 -0
- ctxlineage-0.1.0/src/ctxlineage/_report/assets/style.css +205 -0
- ctxlineage-0.1.0/src/ctxlineage/_report/assets/template.html +36 -0
- ctxlineage-0.1.0/src/ctxlineage/_report/html.py +26 -0
- ctxlineage-0.1.0/src/ctxlineage/_report/matching.py +106 -0
- ctxlineage-0.1.0/src/ctxlineage/_report/normalize.py +447 -0
- ctxlineage-0.1.0/src/ctxlineage/_report/redact.py +63 -0
- ctxlineage-0.1.0/src/ctxlineage/_report/tokens.py +60 -0
- ctxlineage-0.1.0/src/ctxlineage/_span.py +81 -0
- ctxlineage-0.1.0/src/ctxlineage/_stack.py +33 -0
- ctxlineage-0.1.0/src/ctxlineage/_state.py +111 -0
- ctxlineage-0.1.0/src/ctxlineage_mcp/__init__.py +5 -0
- ctxlineage-0.1.0/src/ctxlineage_mcp/server.py +273 -0
- ctxlineage-0.1.0/tests/coexistence/langfuse_openai_scenario.py +190 -0
- ctxlineage-0.1.0/tests/conftest.py +309 -0
- ctxlineage-0.1.0/tests/test_anthropic_messages.py +88 -0
- ctxlineage-0.1.0/tests/test_anthropic_messages_async.py +169 -0
- ctxlineage-0.1.0/tests/test_anthropic_messages_stream.py +185 -0
- ctxlineage-0.1.0/tests/test_cli.py +47 -0
- ctxlineage-0.1.0/tests/test_coexistence_langfuse.py +81 -0
- ctxlineage-0.1.0/tests/test_demo_generator.py +46 -0
- ctxlineage-0.1.0/tests/test_events.py +54 -0
- ctxlineage-0.1.0/tests/test_examples.py +236 -0
- ctxlineage-0.1.0/tests/test_hardening.py +187 -0
- ctxlineage-0.1.0/tests/test_html.py +94 -0
- ctxlineage-0.1.0/tests/test_init.py +55 -0
- ctxlineage-0.1.0/tests/test_matching.py +153 -0
- ctxlineage-0.1.0/tests/test_mcp_server.py +343 -0
- ctxlineage-0.1.0/tests/test_normalize.py +874 -0
- ctxlineage-0.1.0/tests/test_openai_chat.py +86 -0
- ctxlineage-0.1.0/tests/test_openai_chat_async.py +68 -0
- ctxlineage-0.1.0/tests/test_openai_chat_stream.py +96 -0
- ctxlineage-0.1.0/tests/test_openai_responses.py +109 -0
- ctxlineage-0.1.0/tests/test_redact.py +309 -0
- ctxlineage-0.1.0/tests/test_schema.py +67 -0
- ctxlineage-0.1.0/tests/test_smoke.py +5 -0
- ctxlineage-0.1.0/tests/test_span.py +181 -0
- ctxlineage-0.1.0/tests/test_stack.py +33 -0
- ctxlineage-0.1.0/tests/test_tokens.py +49 -0
- ctxlineage-0.1.0/uv.lock +1982 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Bug report
|
|
2
|
+
description: Something broke or captured/rendered incorrectly
|
|
3
|
+
labels: [bug]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: what
|
|
7
|
+
attributes:
|
|
8
|
+
label: What happened?
|
|
9
|
+
description: Include the command or code you ran and what went wrong.
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: expected
|
|
14
|
+
attributes:
|
|
15
|
+
label: What did you expect?
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
- type: textarea
|
|
19
|
+
id: repro
|
|
20
|
+
attributes:
|
|
21
|
+
label: Minimal reproduction
|
|
22
|
+
description: Smallest snippet / events.jsonl excerpt that shows the problem (redact prompts!).
|
|
23
|
+
- type: input
|
|
24
|
+
id: version
|
|
25
|
+
attributes:
|
|
26
|
+
label: Versions
|
|
27
|
+
placeholder: ctxlineage 0.1.0 / openai 2.41.1 / Python 3.12 / macOS
|
|
28
|
+
validations:
|
|
29
|
+
required: true
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Feature request
|
|
2
|
+
description: Suggest an improvement
|
|
3
|
+
labels: [enhancement]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: problem
|
|
7
|
+
attributes:
|
|
8
|
+
label: Problem
|
|
9
|
+
description: What are you trying to see or do that you currently cannot?
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: solution
|
|
14
|
+
attributes:
|
|
15
|
+
label: Proposed solution
|
|
16
|
+
- type: textarea
|
|
17
|
+
id: alternatives
|
|
18
|
+
attributes:
|
|
19
|
+
label: Alternatives considered
|
|
20
|
+
description: Note the roadmap lives in the milestone issues; off-roadmap requests may be closed per the maintenance policy.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Source of truth for repo labels (synced by .github/workflows/sync-labels.yml)
|
|
2
|
+
- name: bug
|
|
3
|
+
color: d73a4a
|
|
4
|
+
description: Something is broken
|
|
5
|
+
- name: enhancement
|
|
6
|
+
color: a2eeef
|
|
7
|
+
description: Feature or improvement
|
|
8
|
+
- name: documentation
|
|
9
|
+
color: 0075ca
|
|
10
|
+
description: Docs only
|
|
11
|
+
- name: dependencies
|
|
12
|
+
color: 0366d6
|
|
13
|
+
description: Dependency updates
|
|
14
|
+
- name: good first issue
|
|
15
|
+
color: 7057ff
|
|
16
|
+
description: Small, well-scoped, newcomer-friendly
|
|
17
|
+
- name: help wanted
|
|
18
|
+
color: 008672
|
|
19
|
+
description: Community contribution welcome
|
|
20
|
+
- name: wontfix
|
|
21
|
+
color: ffffff
|
|
22
|
+
description: Out of scope / off-roadmap
|
|
23
|
+
- name: duplicate
|
|
24
|
+
color: cfd3d7
|
|
25
|
+
description: Already tracked elsewhere
|
|
26
|
+
- name: milestone
|
|
27
|
+
color: 1FBFAE
|
|
28
|
+
description: v1 milestone tracking issue
|
|
29
|
+
- name: human-action
|
|
30
|
+
color: D93F0B
|
|
31
|
+
description: Requires the maintainer (accounts, uploads, announcements)
|
|
32
|
+
- name: backlog
|
|
33
|
+
color: C5DEF5
|
|
34
|
+
description: Post-v1 ideas, not scheduled
|
|
35
|
+
- name: discussion
|
|
36
|
+
color: 8250DF
|
|
37
|
+
description: Discussion topic for a dedicated session with the maintainer
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## What
|
|
2
|
+
|
|
3
|
+
<!-- one or two sentences -->
|
|
4
|
+
|
|
5
|
+
## Related
|
|
6
|
+
|
|
7
|
+
<!-- issue number, e.g. part of #4 / closes #12 -->
|
|
8
|
+
|
|
9
|
+
## Checklist
|
|
10
|
+
|
|
11
|
+
- [ ] Tests added/updated (`uv run pytest`)
|
|
12
|
+
- [ ] Lint clean (`uv run ruff check . && uv run ruff format --check .`)
|
|
13
|
+
- [ ] Commits signed off (`git commit -s`, DCO)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
# Tag-driven PyPI release via OIDC Trusted Publishing (no API token secrets).
|
|
3
|
+
# Requires: PyPI pending publisher configured for this repo/workflow, and a
|
|
4
|
+
# GitHub environment named `pypi`. Inert until a v* tag is pushed.
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
tags: ["v*"]
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
jobs:
|
|
11
|
+
verify:
|
|
12
|
+
if: github.repository == 'ctxlineage/ctxlineage'
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
- uses: astral-sh/setup-uv@v7
|
|
17
|
+
- run: uv sync
|
|
18
|
+
- run: uv run ruff check .
|
|
19
|
+
- run: uv run pytest -q
|
|
20
|
+
publish:
|
|
21
|
+
needs: verify
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
environment: pypi
|
|
24
|
+
permissions:
|
|
25
|
+
id-token: write
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v7
|
|
28
|
+
- uses: astral-sh/setup-uv@v7
|
|
29
|
+
- run: uv build
|
|
30
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: sync-labels
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
paths: [.github/labels.yml]
|
|
6
|
+
permissions:
|
|
7
|
+
issues: write
|
|
8
|
+
jobs:
|
|
9
|
+
sync:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v7
|
|
13
|
+
- uses: crazy-max/ghaction-github-labeler@v6
|
|
14
|
+
with:
|
|
15
|
+
yaml-file: .github/labels.yml
|
|
16
|
+
skip-delete: true
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
schedule:
|
|
8
|
+
# Weekly run against the latest SDK versions (PLAN.md §12: catch upstream
|
|
9
|
+
# openai/anthropic changes early).
|
|
10
|
+
- cron: "0 6 * * 1"
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
lint:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v7
|
|
17
|
+
- uses: astral-sh/setup-uv@v7
|
|
18
|
+
- run: uv sync
|
|
19
|
+
- run: uv run ruff check .
|
|
20
|
+
- run: uv run ruff format --check .
|
|
21
|
+
- name: Package builds
|
|
22
|
+
run: uv build
|
|
23
|
+
|
|
24
|
+
test:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
strategy:
|
|
27
|
+
fail-fast: false
|
|
28
|
+
matrix:
|
|
29
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v7
|
|
32
|
+
- uses: astral-sh/setup-uv@v7
|
|
33
|
+
with:
|
|
34
|
+
python-version: ${{ matrix.python-version }}
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: |
|
|
37
|
+
if [ "${{ github.event_name }}" = "schedule" ]; then
|
|
38
|
+
uv sync --upgrade
|
|
39
|
+
else
|
|
40
|
+
uv sync
|
|
41
|
+
fi
|
|
42
|
+
- name: Run tests
|
|
43
|
+
run: uv run pytest -v --cov=ctxlineage --cov-report=term-missing --cov-report=xml
|
|
44
|
+
# Coverage upload only once per matrix (drt pattern); tokenless upload
|
|
45
|
+
# via the org-installed Codecov app (#12).
|
|
46
|
+
- name: Upload coverage
|
|
47
|
+
if: matrix.python-version == '3.13'
|
|
48
|
+
uses: codecov/codecov-action@v7
|
|
49
|
+
with:
|
|
50
|
+
files: coverage.xml
|
|
51
|
+
fail_ci_if_error: true
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Local working drafts (Japanese planning doc — canonical English version: docs/PLAN.md)
|
|
2
|
+
base_plan.md
|
|
3
|
+
|
|
4
|
+
# ctxlineage's own capture output
|
|
5
|
+
.ctxlineage/
|
|
6
|
+
|
|
7
|
+
# Python
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.py[cod]
|
|
10
|
+
*.egg-info/
|
|
11
|
+
.eggs/
|
|
12
|
+
dist/
|
|
13
|
+
build/
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
.pytest_cache/
|
|
17
|
+
.mypy_cache/
|
|
18
|
+
.ruff_cache/
|
|
19
|
+
.coverage
|
|
20
|
+
htmlcov/
|
|
21
|
+
|
|
22
|
+
# Node / frontend
|
|
23
|
+
node_modules/
|
|
24
|
+
frontend/dist/
|
|
25
|
+
|
|
26
|
+
# Tooling / editors
|
|
27
|
+
.serena/
|
|
28
|
+
.claude/
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
.DS_Store
|
|
32
|
+
.coverage
|
|
33
|
+
|
|
34
|
+
# Playwright MCP artifacts
|
|
35
|
+
.playwright-mcp/
|
|
36
|
+
|
|
37
|
+
# Generated report artifacts
|
|
38
|
+
ctxlineage-report.html
|
|
39
|
+
coverage.xml
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versioning:
|
|
5
|
+
[SemVer](https://semver.org/spec/v2.0.0.html) (pre-1.0: breaking changes may
|
|
6
|
+
land in minor versions).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-07-17
|
|
11
|
+
|
|
12
|
+
First public release.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- Capture core: `ctxlineage.init()` auto-instruments the **openai** (Chat
|
|
16
|
+
Completions + Responses API) and **anthropic** (Messages) SDKs — sync,
|
|
17
|
+
async, and streaming — into append-only `.ctxlineage/events.jsonl`
|
|
18
|
+
(versioned JSON Schema).
|
|
19
|
+
- Explicit **span/tag API**: `with ctxlineage.span(...) as sp: sp.tag(name,
|
|
20
|
+
content, source=..., transform=...)` for context provenance.
|
|
21
|
+
- **Report** (`ctxlineage report`): one self-contained HTML file with four
|
|
22
|
+
views — Overview, Calls (context-window anatomy), Chain (session flow),
|
|
23
|
+
Graph (sources → elements → calls lineage with impact tracing) — plus
|
|
24
|
+
client-side search, light/dark themes, i18n-safe rendering.
|
|
25
|
+
- Segment matching (exact → partial → honest untagged) with a visible tag
|
|
26
|
+
match rate; lineage edge inference (output→input, same-span) computed in
|
|
27
|
+
the report backend.
|
|
28
|
+
- Coexistence test matrix with the Langfuse OpenAI drop-in.
|
|
29
|
+
- **Redaction**: `ctxlineage report --redact PATTERN` (repeatable regex;
|
|
30
|
+
applied after matching so stats stay honest, disclosed in the report) and
|
|
31
|
+
capture-side `ctxlineage.init(redact_fields=[...])` field masking (secrets
|
|
32
|
+
never reach `events.jsonl`).
|
|
33
|
+
- Read-only **MCP server** (`ctxlineage[mcp]` extra, `ctxlineage-mcp` entry
|
|
34
|
+
point): list_sessions / get_call / get_lineage / generate_report over the
|
|
35
|
+
same JSONL.
|
|
36
|
+
- Anthropic Messages rendered honestly in the report: top-level `system`
|
|
37
|
+
prompt, `tool_use` / `tool_result` blocks, thinking-block markers, streamed
|
|
38
|
+
assembly, and cache-token folding into the window figures.
|
|
39
|
+
- Runnable examples (`examples/rag_app.py`, `examples/agent_app.py`,
|
|
40
|
+
`examples/anthropic_app.py`, all with a keyless `--mock` mode) and a
|
|
41
|
+
`ctxlineage-instrument` agent skill.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
ctxlineage: a local-first Python library that records every LLM call (OpenAI / Anthropic SDKs, auto-instrumented via monkey-patch) to an append-only `.ctxlineage/events.jsonl`, then renders a **single static HTML report** (Call Anatomy + Lineage Graph views). Zero server, zero DB, no external data transmission — ever.
|
|
8
|
+
|
|
9
|
+
**Current state: v0.1.0 (first public release).** All of M1–M4 shipped: capture (openai + anthropic, sync/async/streaming), the four-view report, the span/tag lineage pipeline, the MCP server, redaction, and runnable examples. Build/test: `uv sync --all-extras`, `uv run pytest`, `uv run ruff check . && uv run ruff format .`. Next: v0.2 = context contract testing (#14) + coding-agent session import (#57).
|
|
10
|
+
|
|
11
|
+
## Required workflow
|
|
12
|
+
|
|
13
|
+
- [docs/PLAN.md](docs/PLAN.md) is the canonical spec. Read it before implementing anything.
|
|
14
|
+
- Before coding a feature, write a detailed implementation plan under `docs/plans/YYYY-MM-DD-<feature>.md`.
|
|
15
|
+
- **Non-Goals (PLAN.md §5) are hard guardrails** — do not implement: SaaS/hosting/accounts, evals, prompt versioning, persistent DBs (incl. SQLite; JSONL is the store), non-Python SDKs, LLM proxying (never rewrite/forward requests).
|
|
16
|
+
- TODOs live in GitHub issues (`ctxlineage/ctxlineage`), not in local files. Milestones M1–M4 are issues #1–#4; each milestone must be independently demoable.
|
|
17
|
+
- TDD with pytest; SDK patches are tested against mocked HTTP (respx).
|
|
18
|
+
|
|
19
|
+
## Maintainer commands (`.claude/commands/`)
|
|
20
|
+
|
|
21
|
+
Repo-scoped slash commands for the maintainer's own workflow (not end-user
|
|
22
|
+
features), adapted from the drt-hub operations playbook:
|
|
23
|
+
|
|
24
|
+
- `/ctxlineage-release-check` — version/doc consistency sweep, then the
|
|
25
|
+
tag → Trusted Publishing flow.
|
|
26
|
+
- `/ctxlineage-review-pr` — PR review keyed on ctxlineage's load-bearing rules
|
|
27
|
+
(host-app safety, no proxying, honest data, self-contained report, Non-Goals).
|
|
28
|
+
- `/ctxlineage-triage` — open PR/issue triage and release-readiness check.
|
|
29
|
+
|
|
30
|
+
## Conventions
|
|
31
|
+
|
|
32
|
+
- **Everything in the repo is English** (code, comments, docs, issues, commits) even when the conversation with the user is in Japanese.
|
|
33
|
+
- `base_plan.md` (Japanese) is a local, gitignored draft — never commit it; docs/PLAN.md is the source of truth.
|
|
34
|
+
- Commits use the personal identity `K.Masuda <me@masukai.dev>` (already set in repo-local git config). License is Apache-2.0 with DCO; never copy-paste external code — take it as a dependency instead.
|
|
35
|
+
- Keep the public API surface and the SDK patch layer minimal (low-maintenance is an explicit design goal); unknown SDK fields pass through into `payload` rather than being modeled.
|
|
36
|
+
|
|
37
|
+
## Architecture (planned, PLAN.md §6)
|
|
38
|
+
|
|
39
|
+
Three loosely-coupled layers sharing one artifact, the JSONL event log:
|
|
40
|
+
|
|
41
|
+
1. **Capture** — `ctxlineage.init()` monkey-patches openai/anthropic SDKs (wrapt); optional explicit `span()`/`tag()` API adds metadata. Writes 1 event per line to `.ctxlineage/events.jsonl`. Streaming support is mandatory.
|
|
42
|
+
2. **Report builder** — `ctxlineage report` CLI parses the JSONL, normalizes sessions/calls/elements/edges, runs segment matching (exact → partial → "untagged" fallback, match rate shown honestly) and lineage edge inference, then injects JSON into a prebuilt HTML template.
|
|
43
|
+
3. **MCP server** (`src/ctxlineage_mcp/`, FastMCP/stdio) — read-only tools over the same JSONL.
|
|
44
|
+
|
|
45
|
+
The event schema (`schema/`, versioned JSON Schema) is language-agnostic by design — it is the contract between all layers and future non-Python SDKs.
|
|
46
|
+
|
|
47
|
+
The report frontend is **server-rendered by Python** (decided 2026-07-16 — no React/Vite, no node toolchain): templates, vanilla JS, and a single CSS-token block live as package resources under `src/ctxlineage/_report/`; the lineage graph is emitted as static SVG whose colors reference CSS custom properties. Light and dark mode are both mandatory (default follows `prefers-color-scheme`, manual toggle persisted). The HTML must open offline (no CDN references). Design reference: the maintainer's drt-hub/drt `drt docs` (deterministic layout engine, reserved-gutter edge routing) and the agreed mockups in `docs/design/m2-mockups/`. Report UI palette: Ink `#252B33` × Lineage Teal `#1FBFAE`.
|
|
48
|
+
|
|
49
|
+
## Stack
|
|
50
|
+
|
|
51
|
+
Python 3.10+, `uv` + `hatchling`, src layout. Minimal runtime deps: `wrapt`, `tiktoken` (prefer real `usage` values over estimates). CLI ships as `ctxlineage` with alias `ctxl`.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for your interest! ctxlineage is a deliberately low-maintenance,
|
|
4
|
+
single-maintainer project — small, focused contributions land fastest.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/ctxlineage/ctxlineage && cd ctxlineage
|
|
10
|
+
uv sync # installs everything (Python 3.10+)
|
|
11
|
+
uv run pytest # tests (hermetic — no network)
|
|
12
|
+
uv run ruff check . && uv run ruff format . # lint / format
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Useful while hacking on the report UI:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
uv run python examples/generate_demo_events.py /tmp/demo
|
|
19
|
+
CTXLINEAGE_DIR=/tmp/demo uv run ctxlineage report --open
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Ground rules
|
|
23
|
+
|
|
24
|
+
- **DCO, not CLA.** Sign off every commit: `git commit -s`
|
|
25
|
+
(adds `Signed-off-by`, certifying [developercertificate.org](https://developercertificate.org/)).
|
|
26
|
+
- **Never copy-paste external code** — take it as a dependency instead.
|
|
27
|
+
- **TDD**: changes come with tests; SDK patches are tested against mocked HTTP
|
|
28
|
+
(respx). The suite must stay hermetic (no network).
|
|
29
|
+
- Everything in the repo is English.
|
|
30
|
+
- Pre-1.0, minor versions may contain breaking changes (CLI output, public
|
|
31
|
+
API, event schema constraints). The event schema (`schema/`) is the
|
|
32
|
+
versioned contract — additive changes only within a schema version.
|
|
33
|
+
|
|
34
|
+
## Scope
|
|
35
|
+
|
|
36
|
+
The roadmap lives in the milestone issues. Non-Goals
|
|
37
|
+
([docs/PLAN.md](docs/PLAN.md) §5) are hard guardrails: no SaaS, no evals, no
|
|
38
|
+
prompt management, no persistent DBs, no LLM proxying. Off-roadmap issues and
|
|
39
|
+
PRs may be closed without much ceremony — please open an issue before large
|
|
40
|
+
changes.
|
ctxlineage-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|