| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Harmonic.Rules.Import.Graph
Description
Provides connectNeo4j for database connection and write operations
for storing cadence nodes and transition edges during data ingestion.
Synopsis
- connectNeo4j :: IO Pipe
- initGraph :: BoltActionT IO ()
- truncateCadenceGraph :: BoltActionT IO ()
- type ComposerWeights = Map Text Double
- writeCadenceEdges :: [(Cadence, Cadence, ComposerWeights)] -> BoltActionT IO ()
- buildQuery :: Cadence -> Cadence -> ComposerWeights -> Text
- showText :: Cadence -> Text
- movementText :: Cadence -> Text
- chordText :: Cadence -> Text
- dissonanceText :: Cadence -> Text
- confidenceText :: ComposerWeights -> Text
- weightsLiteral :: ComposerWeights -> Text
- queryNextCadences :: Text -> BoltActionT IO [Text]
Connection
connectNeo4j :: IO Pipe Source #
Open a Bolt connection to the local Neo4j on port 7687, using the credentials in Harmonic.Config. Every online generation path needs one.
Schema
initGraph :: BoltActionT IO () Source #
Initialise schema. Node identity is the show string (movement +
functionality) — the functionality half of every key follows the naming
contract documented at the head of Harmonic.Rules.Import.Transform
(the live DB carries legacy names; read the warning there BEFORE any
re-ingestion).
truncateCadenceGraph :: BoltActionT IO () Source #
Delete every Cadence node and its NEXT edges, batched through
apoc.periodic.iterate to avoid memory spikes on a full corpus. Run before
a re-ingestion.
Writing cadence transitions
type ComposerWeights = Map Text Double Source #
How much each composer contributes to one NEXT edge. Written to the
edge as a JSON literal by weightsLiteral, and summed into a single
confidence property by confidenceText.
writeCadenceEdges :: [(Cadence, Cadence, ComposerWeights)] -> BoltActionT IO () Source #
Write a batch of cadence transitions. Each triple merges both endpoint
nodes and the NEXT edge between them. Transitions with no composer weight
are skipped rather than written with zero confidence.
buildQuery :: Cadence -> Cadence -> ComposerWeights -> Text Source #
Build the Cypher MERGE for one transition. Node identity is the show
string; see initGraph for the naming contract that governs it.
Cypher field rendering
showText :: Cadence -> Text Source #
Node identity: the cadence's show string, used as the MERGE key.
movementText :: Cadence -> Text Source #
The movement half of a cadence, as a Cypher string value.
dissonanceText :: Cadence -> Text Source #
The cadence's dissonance level, as a Cypher numeric value. Computed at write time so queries can filter on it without recomputing.
confidenceText :: ComposerWeights -> Text Source #
Total edge weight across all composers, stored as r.confidence. This is
what a "*" (all-composers) query ranks on.
weightsLiteral :: ComposerWeights -> Text Source #
Per-composer weights as a JSON literal, stored as r.weights. Single
composer and blend queries read this rather than r.confidence.
Vestigial
queryNextCadences :: Text -> BoltActionT IO [Text] Source #
Vestigial stub: always returns [] and ignores its argument. Cadence
lookup lives in Harmonic.Evaluation.Database.Query instead. Retained only
so existing imports keep compiling; do not build on it.