-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Feature/jcode integration #2578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akvarel
wants to merge
10
commits into
Graphify-Labs:v8
Choose a base branch
from
akvarel:feature/jcode-integration
base: v8
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c346508
attributes
akvarel 5d74b91
test: specify native Jcode integration
akvarel a633ec6
feat: add native Jcode integration
akvarel 17968ff
AI-assisted: Jcode sync uv.lock to project version
akvarel 79fe28b
AI-assisted: Jcode test: specify validated knowledge ingestion
akvarel cee64f3
AI-assisted: Jcode test: cover knowledge reference resolution and ret…
akvarel 5dcee5a
AI-assisted: Jcode feat: add validated lat.md knowledge ingestion
akvarel a50d92e
AI-assisted: Jcode docs: document validated knowledge workflow
akvarel 77a7f17
fix: harden validated knowledge integration
akvarel d1ec2d3
feat: validate knowledge during graph updates
akvarel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Validated knowledge ingestion TDD evidence | ||
|
|
||
| ## Source | ||
|
|
||
| The user approved implementation of the recommended Graphify and Jcode validated | ||
| knowledge plan. This document covers the first Graphify milestone: native | ||
| `lat.md` ingestion, integrity checking, implementation linkage, and retrieval. | ||
|
|
||
| ## User journeys | ||
|
|
||
| 1. As an agent, I can query curated design constraints together with source-code | ||
| symbols so that I do not miss project invariants before editing code. | ||
| 2. As a maintainer, I can validate wiki links, source links, and required | ||
| implementation mentions so that project knowledge does not silently drift. | ||
| 3. As a project adopting lat.md, I can use Graphify's normal update workflow | ||
| without running a second retrieval service. | ||
|
|
||
| ## Requirement-to-check evidence | ||
|
|
||
| | # | Guarantee | Test or command | Type | Result | | ||
| |---|---|---|---|---| | ||
| | 1 | Headings become stable knowledge sections with first-paragraph summaries | `test_lattice_markdown_emits_stable_sections_summaries_and_wiki_edges` | Unit | PASS | | ||
| | 2 | Inline and fenced examples are ignored while source links become `documents` edges | `test_lattice_ignores_example_links_and_emits_source_documentation_edges` | Integration | PASS | | ||
| | 3 | `@lat` comments connect a knowledge section to its implementation file | `test_full_extract_links_at_lat_comment_to_knowledge_section` | Integration | PASS | | ||
| | 4 | Cross-file shorthand wiki links resolve to full stable section IDs | `test_full_extract_resolves_cross_file_short_wiki_reference` | Integration | PASS | | ||
| | 5 | Broken, ambiguous, and missing implementation references are diagnosed | `test_validate_lattice_reports_broken_ambiguous_and_unimplemented_required_sections` | Unit | PASS | | ||
| | 6 | Invalid lattices return structured JSON and exit code 1 | `test_check_knowledge_cli_returns_json_and_nonzero_for_invalid_lattice` | CLI acceptance | PASS | | ||
| | 7 | Query scoring searches summaries and returns the summary in bounded output | `test_query_retrieves_lattice_summary_after_normal_extraction` | Public retrieval | PASS | | ||
| | 8 | A real valid lattice is accepted through the public CLI | `uv run python -m graphify check-knowledge /home/sergey/.jcode/scratch/graphify-lattice-valid --json` | CLI acceptance | PASS, 2 sections, 0 errors | | ||
| | 9 | The implementation is compatible with the official lat.md repository | `validate_lattice(Path('/home/sergey/.jcode/scratch/lat.md-official'))` | Real integration | PASS, 24 files, 192 sections, 0 errors | | ||
| | 10 | Dotted lattice filenames remain knowledge references rather than source paths | `test_dotted_lattice_file_reference_is_not_misclassified_as_source` | Integration | PASS | | ||
| | 11 | Incremental lattice updates rediscover mentions in unchanged source files | `test_lattice_change_rescans_unchanged_source_mentions` | Incremental integration | PASS | | ||
| | 12 | Source links cannot escape the project root | `test_source_reference_cannot_escape_project_root` | Security | PASS | | ||
| | 13 | Code-mention validation honors Graphify ignore rules | `test_validation_respects_graphifyignore_when_scanning_code_mentions` | Integration | PASS | | ||
| | 14 | Adjacent extraction, CLI, query, and security behavior remains intact | focused regression command below | Regression | PASS, 460 tests | | ||
|
|
||
| ## RED evidence | ||
|
|
||
| 1. `uv run pytest -q tests/test_lattice_ingest.py` failed during collection with | ||
| `ModuleNotFoundError: graphify.lattice_ingest` before production code existed. | ||
| 2. After the first minimal implementation, the strengthened tests failed because | ||
| cross-file shorthand links were pruned and summary-only queries returned | ||
| `No matching nodes found.` | ||
| 3. The source-link compatibility test failed because no `documents` edge was | ||
| emitted before Markdown-aware parsing was implemented. | ||
| 4. Independent review added four regressions which initially failed: incremental | ||
| `@lat` rediscovery, dotted lattice filenames, source-root containment, and | ||
| ignore-aware validation scanning. | ||
|
|
||
| Checkpoint commits: | ||
|
|
||
| - `79fe28b` specifies the initial missing behavior. | ||
| - `cee64f3` specifies cross-file resolution and public retrieval behavior. | ||
|
|
||
| ## GREEN evidence | ||
|
|
||
| - `uv run pytest -q tests/test_lattice_ingest.py`: 11 passed. | ||
| - `uv run pytest -q tests/test_lattice_ingest.py tests/test_manifest_ingest.py tests/test_languages.py tests/test_cli_export.py tests/test_query_cli.py tests/test_security.py`: 460 passed. | ||
| - `env -u DEEPSEEK_API_KEY -u DEEPSEEK_BASE_URL uv run pytest -q --ignore=tests/test_falkordb_integration.py`: 4,157 passed, 1 skipped. The excluded integration requires a FalkorDB server with the `GRAPH.QUERY` module; the available localhost service was plain Redis. | ||
| - `uv run ruff check graphify/lattice_ingest.py graphify/extract.py graphify/serve.py graphify/cli.py graphify/__main__.py tests/test_lattice_ingest.py`: passed. | ||
| - GREEN implementation checkpoint: `5dcee5a`. | ||
|
|
||
| ## Coverage | ||
|
|
||
| `uv run pytest -q tests/test_lattice_ingest.py --cov=graphify.lattice_ingest --cov-report=term-missing --cov-fail-under=80` | ||
|
|
||
| The initial seven-test milestone reached 89% statement coverage. The final | ||
| eleven-test suite adds independent-review coverage for incremental, security, | ||
| ignore, and dotted-filename edge cases. | ||
|
|
||
| ## Known boundaries | ||
|
|
||
| - Graphify validates that referenced source files exist. Symbol-level source-link | ||
| validation is deferred to the next milestone, where links will resolve against | ||
| Graphify's language-aware symbol index. | ||
| - This milestone does not add a separate lat.md semantic index or service. | ||
| Curated summaries participate directly in Graphify's existing query scorer. | ||
| - Jcode changes are intentionally deferred until the Graphify public graph and | ||
| CLI contract is committed and stable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,13 @@ | |
| from .cache import load_cached, save_cached | ||
| from .mcp_ingest import extract_mcp_config, is_mcp_config_path | ||
| from .manifest_ingest import extract_package_manifest, is_package_manifest_path | ||
| from .lattice_ingest import ( | ||
| extract_lattice_code_ref_edges, | ||
| extract_lattice_markdown, | ||
| is_lattice_markdown_path, | ||
| project_source_paths, | ||
| resolve_lattice_reference_edges, | ||
| ) | ||
| from .resolver_registry import ( | ||
| LanguageResolver, | ||
| register as register_language_resolver, | ||
|
|
@@ -4719,6 +4726,11 @@ def _is_cpp_header(path: Path) -> bool: | |
|
|
||
| def _get_extractor(path: Path) -> Any | None: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
fans out to 7 callees (efferent coupling); 26 callers depend on it (afferent coupling). Grounded coupling-delta finding (deterministic), not an LLM guess. |
||
| """Return the correct extractor function for a file, or None if unsupported.""" | ||
| # A lat.md lattice is curated, validated knowledge rather than ordinary | ||
| # prose. Route it before generic Markdown so section ids, summaries and | ||
| # wiki-link edges remain compatible with lat.md's public format. | ||
| if is_lattice_markdown_path(path): | ||
| return extract_lattice_markdown | ||
| if path.name.lower().endswith(".blade.php"): | ||
| return extract_blade | ||
| # MCP config files (.mcp.json, claude_desktop_config.json, ...) are routed | ||
|
|
@@ -5257,6 +5269,47 @@ def extract( | |
| all_nodes.extend(result.get("nodes", [])) | ||
| all_edges.extend(result.get("edges", [])) | ||
| all_raw_calls.extend(result.get("raw_calls", [])) | ||
| # Bind curated knowledge to implementation files through explicit | ||
| # `@lat: [[section]]` comments. The file endpoint uses the same pre-remap id | ||
| # recipe as every extractor, so the canonical path remap below updates it | ||
| # together with the file node. | ||
| resolve_lattice_reference_edges(all_edges, all_nodes) | ||
| lattice_changed = any(is_lattice_markdown_path(path) for path in paths) | ||
| if lattice_changed: | ||
| # Incremental updates often contain only the changed lat.md file. Rescan | ||
| # unchanged, ignore-filtered source files so newly-added section ids can | ||
| # bind to existing @lat comments in the merged graph. | ||
| code_ref_paths = project_source_paths(root) | ||
| else: | ||
| code_ref_paths = paths | ||
| lattice_code_edges = extract_lattice_code_ref_edges(code_ref_paths, all_nodes) | ||
| if lattice_changed: | ||
| # The incremental extraction result must retain these edges until it is | ||
| # merged with the previous graph. Add minimal file endpoints for unchanged | ||
| # mentioned sources, otherwise the normal dangling-edge cleanup would | ||
| # discard the relationship before the merge can reconnect it. | ||
| existing_ids = {str(node.get("id")) for node in all_nodes} | ||
| mentioned_paths = { | ||
| Path(str(edge["source_file"])) | ||
| for edge in lattice_code_edges | ||
| if edge.get("source_file") | ||
| } | ||
| for mentioned_path in sorted(mentioned_paths): | ||
| file_id = _file_node_id(mentioned_path) | ||
| if file_id in existing_ids: | ||
| continue | ||
| existing_ids.add(file_id) | ||
| all_nodes.append( | ||
| { | ||
| "id": file_id, | ||
| "label": mentioned_path.name, | ||
| "type": "file", | ||
| "file_type": "code", | ||
| "source_file": str(mentioned_path), | ||
| "source_location": "L1", | ||
| } | ||
| ) | ||
| all_edges.extend(lattice_code_edges) | ||
| # Function / method / class def ids for the cross-file indirect_call callable | ||
| # guard. Built from the `_callable` node marker AFTER the id-remap / disambiguation | ||
| # passes below (which rewrite node ids), so it can never go stale — see the | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_get_extractor()fans out to 7 callees (efferent coupling); 26 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.