USING LENS And APPLY ANALYSIS RUN

Generic Description

USING LENS attaches a registered lens abstraction to the current query stream. APPLY ANALYSIS RUN runs a registered analysis-run artifact against the current row stream and yields analysis output columns.

Example:

CREATE ABSTRACTION ACTOR Member
DESCRIPTION 'People whose retention, engagement, and churn risk are tracked.';

CREATE ABSTRACTION LENS ChurnInvestigation
DESCRIPTION 'Understand why members churn and identify useful separation rules.'
TAGS (assistant_generated, intent);

CREATE ANALYSIS RUN ChurnSeparabilityRules OPTIONS {
  kind: 'separability_filter',
  lens: 'ChurnInvestigation',
  target_abstraction: 'Member',
  target_feature: 'churned',
  confidence: 0.82,
  segment: 'low_activity',
  reason: 'Low recent activity separates churned members in the current feature snapshot.'
};

MATCH (c:actor(Member))
USING LENS ChurnInvestigation
APPLY ANALYSIS RUN ChurnSeparabilityRules ON c
YIELD passed, score, confidence, segment, reason
RETURN c, passed, score, confidence, segment, reason

Consumer-Level Explanation

Use USING LENS when a query is answering from a particular viewpoint. A lens may represent an assistant-captured user intent, a reporting perspective, a domain-specific investigation, or a reusable projection over the graph.

Use APPLY ANALYSIS RUN when a reusable analysis-run definition should be applied without re-planning or re-calling an LLM. The analysis run can represent a separability filter, scorer, projector, transformset, or segmenter. Once registered, applying it should be deterministic.

Conceptual Explanation

Lens and analysis runs solve different problems.

A lens is an abstraction. It is a abstraction viewpoint: what the user is trying to see, why the selection matters, and how the visible graph can be represented.

An analysis run is executable abstraction machinery stored as an artifact. It can be attached to a lens, but it is not itself an abstraction. For separability workflows, the analysis run stores the ruleset or scoring metadata produced by analysis. Query execution can then apply that definition to candidate subjects.

The clause order is intentionally row-stream oriented:

Advanced Example

CREATE ABSTRACTION ACTOR ActiveMember FOR LABEL User TAGS (retention);

CREATE ABSTRACTION IF NOT EXISTS LENS ChurnInvestigation
DESCRIPTION 'Find explainable churn patterns in member behavior.'
TAGS (assistant_generated, intent);

CREATE ANALYSIS RUN ChurnRules OPTIONS {
  kind: 'separability_filter',
  lens: 'ChurnInvestigation',
  target_abstraction: 'ActiveMember',
  target_feature: 'churned',
  confidence: 0.91,
  segment: 'inactive_recently',
  reason: 'Members with low recent activity are separated from the retained group.'
};

MATCH (m:actor(ActiveMember))
USING LENS ChurnInvestigation
APPLY ANALYSIS RUN ChurnRules ON m
YIELD passed, score, confidence, segment, reason
WHERE passed = true
RETURN segment, count(m) AS members, avg(score) AS average_score
ORDER BY average_score DESC

Real Use Cases

Real Limitations And Tradeoffs