Skip to content

Extract Neo4j node-label read/remove into a shared helper#1098

Merged
JeroenDeDauw merged 1 commit into
fix/544-referenced-subject-stubsfrom
refactor/stub-label-dedup
Jul 20, 2026
Merged

Extract Neo4j node-label read/remove into a shared helper#1098
JeroenDeDauw merged 1 commit into
fix/544-referenced-subject-stubsfrom
refactor/stub-label-dedup

Conversation

@JeroenDeDauw

Copy link
Copy Markdown
Member

Follows-up to #1080

The stub reduction added in #1080 gave Neo4jProjectionStore a getSubjectLabels() and removeNonStubLabels() that near-verbatim duplicated Neo4jSubjectUpdater's getNodeLabels() and the remove branch of updateNodeLabels(): the same read-labels query, the same empty guard, and the same array_diff + Cypher::buildLabelList + MATCH … REMOVE orchestration.

Both operations now live in a small stateless Neo4jNodeLabels helper (read() and remove()), which the Store's removeNonStubLabels() and the Updater's updateNodeLabels() both call. The Updater still reads its labels once and keeps its add branch inline, since that branch is not duplicated anywhere.

Why this clears the original "grows beyond a safe move" objection: the two classes hold their transaction differently — the Updater receives it in its constructor, the Store threads it through its methods from writeTransaction() — but neither needs to own the transaction to run these queries. Neo4jNodeLabels takes the TransactionInterface as a parameter, so it is agnostic to ownership, and as a static utility (like the sibling Cypher class) it is not a DI collaborator: nothing to inject or wire.

No behavior change and no test-expectation edits. Neo4jProjectionStoreTest gains a @covers for the new helper — it exercises it through both the stub path and, via savePage, the Updater path; the Updater unit test mocks the transaction and never runs the label queries, so it does not claim coverage. The now-dead getNodeLabels phpstan-baseline entries are dropped.

AI-authored — Claude Code, Opus 4.8 (max); follow-up from the Relations Phase 1 batch, directed by @JeroenDeDauw; detailed spec, worked autonomously (no human steering); diff not yet human-reviewed; ran the affected test classes, the full PHPUnit suite (1799 pass, 4 pre-existing skips) and make cs (phpcs + phpstan), plus a mutation check confirming the stub tests fail when the shared label-strip is broken.

Follows-up to #1080

The stub reduction added in #1080 gave Neo4jProjectionStore a getSubjectLabels() and
removeNonStubLabels() that near-verbatim duplicated Neo4jSubjectUpdater's getNodeLabels()
and the remove branch of updateNodeLabels(): the same read-labels query, the same empty
guard, and the same array_diff + Cypher::buildLabelList + MATCH ... REMOVE orchestration.

Both operations now live in a small stateless Neo4jNodeLabels helper (read() and remove()),
which the Store's removeNonStubLabels() and the Updater's updateNodeLabels() both call. The
Updater still reads its labels once and keeps its add branch inline, since that branch is not
duplicated anywhere.

Why this clears the original "grows beyond a safe move" objection: the two classes hold their
transaction differently -- the Updater receives it in its constructor, the Store threads it
through its methods from writeTransaction() -- but neither needs to own the transaction to run
these queries. Neo4jNodeLabels takes the TransactionInterface as a parameter, so it is agnostic
to ownership, and as a static utility (like the sibling Cypher class) it is not a DI
collaborator: nothing to inject or wire.

No behavior change and no test-expectation edits. Neo4jProjectionStoreTest gains a @Covers for
the new helper -- it exercises it through both the stub path and, via savePage, the Updater
path; the Updater unit test mocks the transaction and never runs the label queries, so it does
not claim coverage. The now-dead getNodeLabels phpstan-baseline entries are dropped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JeroenDeDauw
JeroenDeDauw marked this pull request as ready for review July 20, 2026 17:50
@JeroenDeDauw
JeroenDeDauw merged commit b6bb7e7 into fix/544-referenced-subject-stubs Jul 20, 2026
6 checks passed
@JeroenDeDauw
JeroenDeDauw deleted the refactor/stub-label-dedup branch July 20, 2026 17:50
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