Skip to content

Phase 1: context-attention walking skeleton (contract + get_context harness + APM wrap) - #4

Closed
FScholPer wants to merge 68 commits into
mainfrom
context-attention-phase1-walking-skeleton
Closed

FScholPer wants to merge 68 commits into
mainfrom
context-attention-phase1-walking-skeleton

Conversation

@FScholPer

Copy link
Copy Markdown
Contributor

Summary

Phase 1 walking skeleton for the Agent Context Attention Layer. Makes the contract and harness ideas concrete and runnable end-to-end, kept minimal but real (no stubs).

Stacked on the Phase 0 branch (context-attention-phase0-schema) so this diff is Phase 1 only.

The thread it demonstrates

git graph fragment -> compose -> get_context (attention) -> Lane A gate proves it -> APM delivers it

A task seeds a single node (pr__mcp_servers__42); get_context reaches the affected contract (via affects) and the relevant dec_rec (via discussed_in) by traversing typed edges — nothing hardcoded. The empty BaselineHarness fails the gate; the ContextHarness candidate passes. That contrast is the point.

Contract (stable operating surface)

  • Vendored, pinned copies of upstream draft schemas from eclipse-score/docs-as-code@4bc0fbf (docs-as-code#628): repo-manifest.schema.json, agent-card.schema.json, adapter_contract_v0_1.{md,schema.json}. Provenance recorded in .github/references/README.md and harness/contract/README.md.
  • Real instances for this repo: .github/score/repo-manifest.json (python; build uv sync, test uv run pytest, lint uv run ruff check ., typecheck uv run pyright; mcp.tools: [search]) and .github/score/agent-card.json, both validated against the vendored schemas in tests.

Harness (deterministic evaluation seam)

  • AssuranceHarness.get_context(task_spec) -> str mirrored from upstream; BaselineHarness (returns "") + ContextHarness (calls the engine).
  • Deterministic Lane A natural-key gate: pass iff every expected node id is surfaced.
  • adapter.py implements the validate | run | report envelope from adapter_contract_v0.1: issue-first (issue_id), artifacts under .stage/ISSUE-<n>/…, iso26262 profile, full error-code set. CLI: uv run python -m score_context.harness harness/spec/request_run.json.

Engine slice (libs/score-context, still MCP-free)

  • graph.py: fragment loader + deterministic compose with natural-key conflict detection, on the Phase 0 Node/Edge models.
  • context.py: get_context(task, repo, role, top_n) returns structured output (selected / decisions / contracts / repositories / blocking_tasks) + rendered text. Scoring = seeds + relation weights + neighbor degree + provenance freshness. Explicitly marked a first-cut placeholder for personalized PageRank; the seam and output shape are stable, the ranking math is not.

APM wrap (first real example)

  • packages/context/.apm/context/attention-task-001.md regenerated from a real candidate run; packages/context/.apm/skills/query-context/SKILL.md is now a real skill. apm pack --offline stays ok: true.

Impact Analysis

  • Additive; no change to Phase 0 schema semantics. .stage/ and generated APM output are gitignored.

Validation

  • reuse lint compliant (54/54 files)
  • uv run ruff check . / ruff format --check . clean
  • uv run pyright — 0 errors
  • uv run pytest — 9 passed
  • apm pack --offline --json — ok: true
  • Real harness run: candidate verdict pass, baseline verdict fail; artifact written to .stage/ISSUE-1/harness/run.json

actionlint was unavailable in the environment and skipped.

FScholPer and others added 6 commits July 23, 2026 07:27
Signed-off-by: frank.scholter_peres <frank.scholter_peres@mercedes-benz.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ed lib

Signed-off-by: frank.scholter_peres <frank.scholter_peres@mercedes-benz.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: frank.scholter_peres <frank.scholter_peres@mercedes-benz.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: frank.scholter_peres <frank.scholter_peres@mercedes-benz.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: frank.scholter_peres <frank.scholter_peres@mercedes-benz.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: frank.scholter_peres <frank.scholter_peres@mercedes-benz.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@FScholPer
FScholPer marked this pull request as draft July 23, 2026 13:15
@FScholPer
FScholPer marked this pull request as ready for review July 23, 2026 13:15
@FScholPer
FScholPer marked this pull request as draft July 23, 2026 13:16
Base automatically changed from context-attention-phase0-schema to main July 27, 2026 12:38
FScholPer and others added 20 commits August 5, 2026 09:04
- Remove the agent-observation subsystem (local_observation.py,
  schema/observation.py, and its tests) to collapse to one mental model.
- Persist an append-only experiences.jsonl and one derived weights.json
  instead of a per-run file tree; gitignore runtime artifacts/.
- Key learning on edge classes (relation, source_type, target_type) so
  signals generalize across repositories instead of memorizing node ids.
- Centralize every scoring/learning knob in harness/policy.yml (no magic
  numbers left in code); load via a validated Policy model.
- Add a single score-ctx CLI (run / aggregate / demo). 'demo' shows a
  deterministic before/after where a decision record moves into the
  selection and the Lane A gate flips fail -> pass.
- Make README self-contained (drop the dead design-doc link).

Signed-off-by: frank.scholter_peres <frank.scholter_peres@mercedes-benz.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Packages:
- graphify-codegraph: Code structure queries (wraps graphify CLI)
- context-discipline: Working memory + local learning (MCP server)

Changes:
- Simplify README (350→150 lines) for quick start
- Create AGENTS.md for AI-generated packages
- Create CONTRIBUTING.md for contributors
- Create setup-context-discipline wizard
- Fix setup-graphify with idempotent .gitignore handling
- Fix initialize_session() to accept list + dict assumptions
- Remove all context7-docs references (cloud service)
- Add validation script for pre-commit checks

Features:
- Two independent setup wizards (./do setup-<pkg>)
- Local-only observations (.score-local/)
- Interactive setup with --verify and --help
- All SPDX license headers in place

Testing:
- context-discipline: 6/6 integration tests passed
- setup wizards: Tested in fresh repos
- validation script: 29/29 checks passed
- Register graphify-codegraph and context-discipline in apm.yml marketplace
- Update README with correct apm marketplace add workflow
- Show two install paths: GitHub marketplace and local development
- Clarify setup wizard usage post-compilation
- Create marketplace.json with package metadata
- Register graphify-codegraph, context-discipline, context packages
- Update README with correct marketplace add URL (https://)
- Enable APM CLI to discover and install packages
APM CLI checks multiple paths:
- marketplace.json (root)
- .github/plugin/marketplace.json
- .claude-plugin/marketplace.json

Using -f to override gitignore for APM discovery.
APM should use the root marketplace.json file.
Simplified configuration.
- Remove CONTRIBUTING.md
- Update README references to point to CONTRIBUTION.md
- Standardized naming convention
APM checks these locations:
- marketplace.json (root)
- .github/plugin/marketplace.json
- .claude-plugin/marketplace.json

All three must be present for APM to discover packages.
Changed name from 'Eclipse S-CORE APM Packages' to 'eclipse-score-packages'
APM requires marketplace names to match [a-zA-Z0-9._-]+ pattern.
Use #local_harness_apm ref to specify the branch.
APM now successfully discovers packages.
APM finds marketplace.json in the repository root.
No need for duplicate copies.
- Show simple marketplace add command
- Keep local path option for development
- Removed confusing #ref pinning explanation
Removed packages array - APM finds packages from:
- packages/*/apm.yml files in the repository
- Not from marketplace.json package declarations

This matches APM's expected marketplace discovery mechanism.
- Use package@marketplace syntax
- Show marketplace name check command
- APM discovers packages from apm.yml files in package directories
Changed name from 'Eclipse S-CORE' to 'eclipse-score'
APM validates marketplace names with [a-zA-Z0-9._-]+
- Add packages array to marketplace.json with apm paths
- Update README to use correct marketplace name 'mcp-servers'
- Ensures APM can discover and browse all 3 packages
- Install command: apm install graphify-codegraph@mcp-servers context-discipline@mcp-servers
@FScholPer FScholPer closed this Sep 18, 2026
FScholPer added a commit that referenced this pull request Oct 21, 2026
Fixes all 4 issues from PR #49 review:

Issue #1 (P1 - HIGH): Windows platform compatibility
- Move fcntl import to try/except with graceful fallback
- Add platform-compatible locking for Windows support
- Update build() to handle missing fcntl module

Issue #2 (P2 - MEDIUM): Extraction output directory
- Clear GRAPHIFY_OUT env var in graphify subprocess
- Prevents interference with --out flag
- Ensures correct output location

Issue #3 (P2 - MEDIUM): Cache path sharing with context-discipline
- Add resolve_graph_path() public function
- Update MergedGraph.build() to check user cache
- Update _graph_setup_status() to check user cache
- Both consumers now find cached graphs

Issue #4 (P2 - MEDIUM): Registry seeding race condition
- Add locking around registry seeding in prepare()
- Recheck graph existence after lock acquisition
- Prevents concurrent cold starts from corrupting cache

Add comprehensive test coverage:
- 7 new tests for resolve_graph_path()
- Test for GRAPHIFY_OUT env clearing
- Test for locking race condition prevention
- Total: 19 tests passing

Update documentation:
- Add resolve_graph_path() usage example to README
- Document programmatic access API

All code passes:
- Ruff linter (clean)
- Pyright type checker (0 errors)
- Pytest test suite (19/19 passing)
FScholPer added a commit that referenced this pull request Oct 22, 2026
* Serve graphify from a user cache seeded by central graphs

graphify-codegraph now prepares the graph before starting the server:
an existing graphify-out in the repository is used as is, otherwise the
graph lives under ~/.local/share/score-agent. For eclipse-score repos an
empty cache is seeded from ghcr.io/eclipse-score/mcp-servers/graphs
(merge-base, then main) with sha256 digest check, and a locked code-only
build refreshes it in the background when HEAD moved.

Co-Authored-By: frank.scholter_peres <frank.scholter_peres@mercedes-benz.com>

* fix(graphify-codegraph): address PR review issues

Fixes all 4 issues from PR #49 review:

Issue #1 (P1 - HIGH): Windows platform compatibility
- Move fcntl import to try/except with graceful fallback
- Add platform-compatible locking for Windows support
- Update build() to handle missing fcntl module

Issue #2 (P2 - MEDIUM): Extraction output directory
- Clear GRAPHIFY_OUT env var in graphify subprocess
- Prevents interference with --out flag
- Ensures correct output location

Issue #3 (P2 - MEDIUM): Cache path sharing with context-discipline
- Add resolve_graph_path() public function
- Update MergedGraph.build() to check user cache
- Update _graph_setup_status() to check user cache
- Both consumers now find cached graphs

Issue #4 (P2 - MEDIUM): Registry seeding race condition
- Add locking around registry seeding in prepare()
- Recheck graph existence after lock acquisition
- Prevents concurrent cold starts from corrupting cache

Add comprehensive test coverage:
- 7 new tests for resolve_graph_path()
- Test for GRAPHIFY_OUT env clearing
- Test for locking race condition prevention
- Total: 19 tests passing

Update documentation:
- Add resolve_graph_path() usage example to README
- Document programmatic access API

All code passes:
- Ruff linter (clean)
- Pyright type checker (0 errors)
- Pytest test suite (19/19 passing)

* fix: resolve CI formatting and type checking issues

- Apply ruff formatting to 4 Python files
- Fix unused variable warnings (document, graph1, graph2)
- Add type annotation for seeded list

* fix: prioritize in-repo graph over cache and report correct path

When no graph exists, report the in-repo path (graphify-out/graph.json)
instead of the user cache path. This matches user expectations and the
graphify-codegraph prepare() behavior.

Fixes test failures in test_initialize_session_reports_missing_graph_setup
and test_query_graph_reports_missing_graph_setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant