Skip to content

Monorepo scaffold + Phase 0 schema for the Agent Context Attention Layer - #2

Closed
FScholPer wants to merge 1 commit into
mainfrom
devin/context-attention-phase0-schema
Closed

FScholPer wants to merge 1 commit into
mainfrom
devin/context-attention-phase0-schema

Conversation

@FScholPer

@FScholPer FScholPer commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

First step of the Agent Context Attention Layer. Turns this repo into a uv monorepo and lands Phase 0 only: the schema / data model. No adapters, graph composition, ranking, apm.yml generation, or MCP server logic yet — those are later phases; placeholder dirs mark where they go.

The layer's job is to turn "trace everything" across S-CORE's 80+ repos into "surface what matters for my current context". Everything becomes a typed, provenance-bearing graph node/edge; later phases rank them per (task, repo, role) and project the top-N into a generated APM manifest that compiles to AGENTS.md.

Layout

mcp-servers/
  pyproject.toml            # uv workspace root
  apm.yml / apm-policy.yml  # Microsoft APM manifest + starter (tighten-only) policy
  packages/score-context/   # engine LIBRARY — MCP-free, importable, CI-runnable
    src/score_context/schema/{nodes,edges,provenance}.py, context.jsonld
    src/score_context/delta.py
  servers/context/          # placeholder: Phase 6 get_context MCP server
  apm-packages/             # placeholder: authored vs generated APM packages

Schema (the substance)

Design principle: sphinx-needs is one signal source, not the foundation. Node vocabulary is split into two families:

  • Needs-model nodes — IDs reused verbatim from score_metamodel.yaml (stkh_req, feat_req, comp_req, feat, comp, mod, logical interfaces, dec_rec, safety/security analysis types, testcase, …). Not forked.
  • Trace/event nodes — the part deliberately outside the needs model, where most context change actually happens: issue, discussion, pull_request, commit, code_change, contract, repo, module, team, person, artifact, ci_result.

Edge relations are a superset: all needs_extra_links from the metamodel (implements, satisfied_by, derived_from, covers, consists_of, mitigated_by, fully_verifies, …) plus the ADR trace relations (affects, depends_on, discussed_in, blocks, supersedes, conflicts_with, authored_by, owns). ADR_RELATION_MAPPINGS documents how ADR terms map onto existing metamodel links where they overlap.

Invariants baked in now so adapters can't violate them later:

  • Natural keys only — need id / dec_rec id / org/repo#123 / commit sha / file path / bazel module label. No synthetic UUIDs.
  • Provenance mandatory on every node AND edge — {repo, sha?, adapter, confidence∈[0,1], observed_at}. confidence=1.0 for deterministic extraction, lower for LLM-assisted; required for the multi-company / safety audit story.
  • All models are pydantic v2 with extra="forbid".

context-delta — the one unit every future adapter emits

class ContextDelta:            # delta.py
    signal: Signal             # {type, source: SourceRef, provenance, weight, decays}
    graph_ops: list[GraphOp]   # discriminated union: UpsertNode | UpsertEdge

context.jsonld maps every node/edge type to a stable IRI under https://eclipse-score.github.io/context-attention/ns# for git-friendly, vendor-neutral serialization.

Verification

uv sync, uv run ruff check ., ruff format --check, uv run pyright (0 errors), uv run pytest (4 passed) all green.

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 closed this Jul 23, 2026
@FScholPer
FScholPer deleted the devin/context-attention-phase0-schema branch July 23, 2026 07:34
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