Agentic insights on the unified inventory (discover phase) (#25) - #82
Merged
matthewmoorcroft merged 3 commits intoSep 15, 2026
Merged
Conversation
Add an optional agent-authored insights layer on top of the standardized, source-neutral discover inventory. flowx contains no LLM: an external agent authors the insights JSON; the library validates it against the real inventory and, only when clean, merges it under one additive top-level `insights` key -- the same author-then-validate-merge contract `flowx.agentic` uses for gap resolution. Rebuilt against the new unified inventory (shared AST + per-pipeline lineage), replacing the closed PR #42 which targeted the old ADF-only shape. - models/insights.py: source-neutral schema (Insights, SystemRecommendation, RecommendedPattern, PipelineInsight, PipelineRelationship, LineageEdgeRef). - discovery_insights.py: standalone enrich_inventory(output_dir, insights=...) that foreign-key validates pipeline refs, resolves deterministic CONTROL-edge annotations against the inventory's per-pipeline lineage, requires evidence+confidence on agent-INFERRED edges, binds insights via inventory_sha256 + schema_version, and merges atomically + idempotently (existing keys byte- unchanged; single additive `insights` key that replaces any prior block). - Expose `enrich` on the adapter CLI and the MCP dispatcher, mirroring discover. - Author the insights layer: skills/flowx-discover/insights.md + SKILL.md pointer. - Unit tests: models, validator (every failure mode), atomic/idempotent merge, byte-compat, and the CLI + MCP wiring. Scope: #25 produces + validates + merges insight DATA only; it makes no routing/IR/conversion decision (deferred to #77). v1 supports deterministic control-edge annotations + inferred cross-pipeline relationships; cross-pipeline deterministic data edges are out of scope (DataEdge is intra-pipeline). Co-authored-by: Isaac <no-reply@databricks.com>
…-edge errors (#25) Two blocking validation-strictness fixes in discovery_insights._validate_edge: - A deterministic `control` edge now rejects `evidence` / `confidence` by KEY PRESENCE, not `.get() is not None`, so an explicit `evidence: null` / `confidence: null` is a violation instead of slipping through. - Per-edge validation aggregates every error instead of failing fast: an `inferred` edge that is both missing a valid identity AND missing evidence/confidence now reports all three problems in one pass, consistent with the collect-all behavior the rest of the validator uses. Tests: added the present-but-null control-edge case and a both-wrong inferred edge asserting identity + evidence + confidence errors together. Co-authored-by: Isaac <no-reply@databricks.com>
Member
Author
|
Addressed both blocking review findings in
Gates: |
`uv sync` / `uv run` locally rewrote uv.lock to repoint dependency provenance at pypi-proxy.cloud.databricks.com. That is an environment artifact unrelated to the insights work, so restore uv.lock byte-identical to base. Co-authored-by: Isaac <no-reply@databricks.com>
This was referenced Sep 15, 2026
This was referenced Sep 16, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this adds
This PR adds an optional, source-neutral, agent-authored insights layer to discovery. The deterministic inventory still records what the source workflows are; an external agent reads that inventory and authors judgment about intent, target patterns, and cross-pipeline relationships. flowx contains no LLM for this step: the library validates the authored object and atomically merges it under one additive top-level
insightskey.The PR is merged into
integration/discovery, notmain; this description documents the merged contract.Merged
inventory.json.insightsschemaThe complete merged block is:
{ "schema_version": "1", "inventory_sha256": "<sha256 of the deterministic inventory base>", "overview": "Short factory-wide narrative", "system_recommendation": { "headline": "The architectural decision to make first", "recommended_patterns": [ { "pattern": "Lakeflow Connect SQL Server connector", "fit": "Replaces the child extractor family", "simplification_pattern": true } ], "cascade": ["5 child extractors -> managed connector pipelines"], "decision_driver": "Is this connector approved for the source?" }, "pipeline_insights": [ { "pipeline": "IngestCustomers", "pattern_name": "Metadata-driven ingestion", "intent": "Land customer source tables", "databricks_pattern": "Managed ingestion", "recommended_patterns": [ { "pattern": "Lakeflow Connect", "fit": "Removes the bespoke copy loop", "simplification_pattern": true } ], "conversion_notes": ["Preserve source object selection"], "risk_if_ignored": "The custom watermark/control-table tier carries forward" } ], "pipeline_relationships": [ { "from_pipeline": "Orchestrator", "to_pipeline": "IngestCustomers", "lineage_edge": { "edge_type": "control", "edge_identity": "<real via_task_key>" }, "relationship_summary": "Orchestrator invokes ingestion", "databricks_pattern": "Run job dependency", "risk_if_ignored": "The invocation is lost" } ] }Top-level fields
schema_version— library-owned schema version.inventory_sha256— library-owned fingerprint binding the insights to the deterministic inventory they describe.overview— optional factory-wide narrative.system_recommendation— optional whole-factory architectural decision.pipeline_insights[]— optional per-pipeline judgments.pipeline_relationships[]— optional cross-pipeline judgments.Recommended patterns and simplification
system_recommendation.recommended_patterns[]and eachpipeline_insights[].recommended_patterns[]are ranked, best-first lists of 1–4 objects:{"pattern": "<real Databricks capability>", "fit": "<why it fits>", "simplification_pattern": true}simplification_pattern: trueis reserved for a distinctive capability that removes/collapses a legacy pattern—such as Lakeflow Connect, Auto Loader, declarativeAUTO CDC, or system tables replacing custom logging—not a like-for-like port. The whole-system object also carriesheadline, optionalcascade[], and optionaldecision_driver.Pipeline relationships
Every relationship names real inventory pipelines and contains
lineage_edge:edge_type: "control"annotates a deterministic control edge already present in inventory.edge_identitymust exactly match that edge'svia_task_keyfor the same(from_pipeline, to_pipeline)pair;evidenceandconfidencemust be omitted.edge_type: "inferred"records a coupling deterministic lineage could not prove.edge_identityis an agent-authored descriptor, and non-emptyevidenceplusconfidence: high|medium|loware required.The v1 deterministic data edges are intra-pipeline/task-scoped, so an agent-observed cross-pipeline data relationship uses the inferred tier.
Author -> validate -> merge contract
metadata/inventory.json, its lineage, and the source artifacts. It authors onlyoverview,system_recommendation,pipeline_insights, andpipeline_relationships. It does not supplyschema_versionorinventory_sha256.validate_insightschecks the object shape, pipeline foreign keys, ranked-pattern limits/content, exact control-edge triples, and the evidence/confidence requirements for inferred edges. Violations are aggregated so the author can fix them together.insightsblock when computing the deterministic base fingerprint, injectsschema_versionandinventory_sha256, and replaces the whole block atomically. Repeating the same enrichment is byte-idempotent; a failure leavesinventory.jsonuntouched.Insights are descriptive and additive. This PR does not choose a deterministic/agentic route, mutate IR, or alter conversion.
Agent-facing skill structure and decision ownership
This mirrors the “Agent-facing skill structure and decision ownership” section of the local
docs/agentic-conversion-design.md.The flowx-enrich workflow is documented in
skills/flowx-discover/insights.md:enrichthrough CLI or MCP.This is intentionally distinct from routing: enrich owns agent-authored recommendations; the customer later owns the per-connected-component deterministic/agentic choice.
Surfaces
python -m flowx.adapter enrich --output-dir <dir> --insights-path insights.jsonflowx("enrich", {"output_dir": "<dir>", "insights": {...}})orinsights_pathskills/flowx-discover/insights.mdNon-breaking behavior
The branch's unit coverage exercises malformed schemas, foreign keys, control-edge resolution, inferred evidence/confidence, ranked-pattern constraints, aggregate violations, fingerprinting, atomic/idempotent merge, CLI, and MCP behavior. The acceptance commands were
make testandmake fmt.