Merged the refactorer's notifications-query property-test suite and reviewed it architecturally. Property tests are well-placed in test/property/, reuse the shared harness, and the independent buildExpected oracle traces 1:1 against the production aggregation/sort/pagination. No production source changed. Verification: 39 property tests pass, 315 unit tests pass, lint clean, mutation differential 0/0/0 (no regression), DRY no candidates, soft Gherkin mutation 0 killed / 16 intrinsic equivalents. By architect.
6.8 KiB
Notifications — Architectural Review Summary
Task: notifications
Commit reviewed: f1841b64a6 (refactorer) — "Refactor notifications: extract reply predicate, add manifests"
By: architect
Scope
Reviewed the refactorer's notifications refactor and the surrounding read-only
notifications feature across psf-memo-db (aggregation adapters, use case,
REST controller) and psf-memo-client (notifications page service).
Architectural findings and fixes applied
- Extracted a shared
getPostOrNullhelper. The post lookup-with-null behavior was duplicated verbatim innotifications-query.jsandpost-query.js. Moved it tosrc/adapters/lib/get-post-or-null.jsand had both adapters call it, so not-found handling is identical across adapters and the duplication is removed (DRY: no candidates). - Confirmed the refactorer's reply-predicate extraction. The
_replyNotificationChildhelper cleanly separates the reply-notification predicate from the collection loop and keeps both functions at low CRAP. - Added a dedicated unit suite for
NotificationsQuery. The adapter had no direct unit coverage; addedtest/unit/adapters/notifications-query.unit.js(26 tests) covering constructor validation, follow/like/reply collection, self-exclusion, unfollow exclusion, ordering, pagination, defaulting, and missing-record handling. This raised the adapter to 100% line coverage. - Hardening tests to kill survivors. Added a follow-of-someone-else
exclusion test (covers the
followeePkHashguard) and a three-notification sort test (kills the- -> +sort-comparator mutation).
Verification results
- Language mutation (
mutate4javascript,--max-workers 8 --mutate-all):notifications-query.js: Killed 15, Survived 5, Uncovered 0.post-query.js: Killed 40, Survived 0, Uncovered 0.lib/get-post-or-null.js: Killed 1, Survived 0, Uncovered 0.
- Documented equivalents (5 survivors, all intrinsic):
constructorline 21|| -> &&: default REST URL fallback; no test setsRESTURL, so the fallback branch is unreachable in tests._collectFollowNotificationsline 68[0] -> [1]:key.split(':')[0]follower-addr fallback is dead in practice — the indexer always writesfollowerAddr, and the key prefix isbitcoincash(address contains a colon), so the fallback is never a real address._collectReplyNotificationsline 113|| -> &&: the guard is redundant with the downstream_replyNotificationChildnull checks; observable behavior is identical._sortNotificationsline 1500 -> 1(x2):seen ?? 0default; tests use explicitseenvalues, so the default is never exercised.
- DRY (
dry4javascript): no duplicate candidates in the changed files. - Cyclomatic complexity (CRAP): all functions well under the 8.0 threshold (max 6.0); all changed functions at 100% coverage.
- Soft Gherkin acceptance mutation (
gherkin-mutator --level soft): Killed 0, Survived 16, Errors 0. All 16 are single-character case mutations of example values (addresses, txids, text) used consistently on both the setup and assertion sides of each scenario — intrinsic equivalents for this read-only feature; not chased.
Suite status
psf-memo-db: unit 315 passing, lint clean.psf-memo-client: 239 passing, lint clean, build succeeds.
Handoffs sent
git_handoffto coder and refactorer (priority: 00) with the review commit for follow-up review.
Notifications (property tests) — Architectural Review Summary
Task: notifications (property-test follow-up)
Commit reviewed: 2704c2059d (refactorer) — "Add notifications-query property
tests for ordering and pagination", merged as cf09636a
By: architect
Scope
Reviewed the refactorer's addition of a property-test suite for the NotificationsQuery
aggregation adapter in psf-memo-db/test/property/notifications-query.property.test.js.
This is a purely additive, test-only change: no production source was modified.
Architectural findings
- No changes required. The addition is well-placed in
test/property/alongside the eleven existing property suites, and correctly reuses the sharedharness.js(seeded PRNG +forAllgenerator driver). - Reference-oracle design is sound.
buildExpectedis an explicit, documented independent oracle that mirrors the adapter aggregation and sort. I traced it line by line againstnotifications-query.jsand confirmed every filter matches: follow unfollow-skip +followeePkHashmatch + self-exclusion, the like missing-target-post exclusion, and the reply parent-authored-by-viewer / child-authored-by-someone-else predicate (via_replyNotificationChild). TheblockHeight/seendescending sort andslice(offset, offset+limit)pagination match exactly. - Invariants covered. The suite pins newest-first ordering with the
seentie-break, global ordering, pagination conservation, and exacttotal, over 500 random samples. The generator also exercises the?? 0defaulting paths (follows with omittedblockHeight/seen) and the dangling-like exclusion path, which are otherwise difficult to reach. - Test/property separation respected. Property tests live in
test/property/, run via the dedicatednpm run property, and do not participate in unit coverage, mutation, CRAP, or Gherkin mutation, per engineering rules. Dependency direction is test → core (no core→test coupling). The small comparator duplication between the production_sortNotificationsand the test oracle is deliberate (an independent cross-check), not a DRY candidate.
Verification results
- Property tests (separate command,
npm run property): 39 passing, including the 2 new notifications-query properties. - Language mutation (
mutate4javascript, differential,--max-workers 8):Killed 0, Survived 0, Uncovered 0onnotifications-query.js— source is unchanged, manifest preserved, no regression. - DRY (
dry4javascript):No duplicate candidates found. - Soft Gherkin acceptance mutation (
notifications.feature --level soft): Total 16, Killed 0, Survived 16, Errors 0. All 16 are single-character case mutations of example values (txids/addresses) used consistently on both the setup and assertion sides of their scenario — intrinsic equivalents, not chased (unchanged from the prior read-only review). - Cyclomatic complexity (CRAP): all notifications-query functions well under the 8.0 threshold (max 6.0), unchanged.
Suite status
psf-memo-db: unit 315 passing, lint clean, property 39 passing.
Handoffs sent
git_handoffto coder and refactorer (priority: 00) with the merge/review commit for follow-up review.