Skip to content

feat(data-access): add readAll capability to Consumer.CAPABILITIES#1573

Merged
ravverma merged 3 commits intomainfrom
feat/consumer-readall-capability
May 4, 2026
Merged

feat(data-access): add readAll capability to Consumer.CAPABILITIES#1573
ravverma merged 3 commits intomainfrom
feat/consumer-readall-capability

Conversation

@ravverma
Copy link
Copy Markdown
Contributor

@ravverma ravverma commented May 1, 2026

Adds 'readAll' as a valid action in Consumer.CAPABILITIES, enabling capability strings of the form <entity>:readAll (e.g. site:readAll, organization:readAll) to pass ConsumerCollection.validateCapabilities.

This is the shared-lib half of the S2S readAll capability rollout. The api-service consumes this in a follow-up PR to remap GET /sites and GET /organizations from <entity>:read to <entity>:readAll, allowing platform-level S2S consumers to enumerate sites/organizations across tenants without weakening tenant isolation on per-resource operations.

See docs/s2s/READALL_CAPABILITY_DESIGN.md (in adobe/spacecat-api-service) for the full design and trust-boundary analysis.

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

Related Issues

Thanks for contributing!

Adds 'readAll' as a valid action in Consumer.CAPABILITIES, enabling
capability strings of the form `<entity>:readAll` (e.g. `site:readAll`,
`organization:readAll`) to pass `ConsumerCollection.validateCapabilities`.

This is the shared-lib half of the S2S readAll capability rollout. The
api-service consumes this in a follow-up PR to remap GET /sites and
GET /organizations from `<entity>:read` to `<entity>:readAll`, allowing
platform-level S2S consumers to enumerate sites/organizations across
tenants without weakening tenant isolation on per-resource operations.

See docs/s2s/READALL_CAPABILITY_DESIGN.md (in adobe/spacecat-api-service)
for the full design and trust-boundary analysis.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ravverma ravverma requested a review from solaris007 May 1, 2026 04:41
@ravverma ravverma self-assigned this May 1, 2026
@ravverma ravverma added the enhancement New feature or request label May 1, 2026
Copy link
Copy Markdown
Member

@solaris007 solaris007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ravverma,

Clean, minimal change - this is the right scope for step 1 of the readAll rollout. A couple of minor suggestions.

Strengths

  • Correctly scoped to the shared library's responsibility: adds the schema-valid action, nothing more. The route-level and controller-level enforcement stays in spacecat-api-service where it belongs.
  • Existing validation chain is preserved: the "throws ValidationError for unknown entity in capability" test still exercises the entity-must-be-known guard. Adding readAll to CAPABILITIES does not loosen entity validation.
  • Model unit test updated to assert the new CAPABILITIES shape. Collection integration test exercises the positive path with site:readAll and organization:readAll.

Issues

Minor (Nice to Have)

Test name does not match test content
consumer.collection.test.js - new test case

The test is titled "accepts the readAll action for any registered entity" but only exercises site:readAll and organization:readAll. The title claims generality ("any registered entity") that the test body does not deliver. A reader might conclude all entities were tested when only two were. Either rename to "accepts site:readAll and organization:readAll capabilities" or extend with additional entities (audit:readAll, opportunity:readAll) to match the title.


Weak result assertion
consumer.collection.test.js - new test case

expect(result).to.not.be.null is the only assertion on the result. It does not verify that the readAll capability strings survived validation and reached the create call. Compare with the sibling test for existing capabilities, which may assert more about the returned consumer shape. Consider at minimum asserting that mockElectroService.entities.consumer.create was called (i.e. validation did not reject).

Recommendations

  • Add a brief JSDoc comment on the CAPABILITIES array explaining the semantic difference between the verb-actions (read, write, delete) and the scope+verb hybrid (readAll). A future reader encountering this array will not know that readAll conflates action and scope without reading a design doc in a different repo. One line is enough: "readAll is a scope+verb hybrid - see the S2S readAll design in mysticat-architecture.".
  • Consider adding a comment near the CAPABILITIES constant noting the design's off-ramp: "If 5+ entities adopt readAll, revisit in favor of a policy engine." This keeps the threshold visible to developers who might extend the list.

Assessment

Ready to merge? Yes

The change is minimal, correct per the design, and adequately tested. The minor suggestions above improve clarity but are not blockers. Once this merges and releases, spacecat-api-service PR 2305 can revert its dependency from the personal gist URL back to the npm registry.

Copy link
Copy Markdown
Member

@solaris007 solaris007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with two small asks:

  1. Add a brief JSDoc on Consumer.CAPABILITIES (consumer.model.js:54) explaining that readAll is a scope+verb hybrid, currently meaningful only on routes that opt in (site and organization). Schema validity does not imply a reachable route. This is the one place a future maintainer could be misled.

  2. In the new collection test ("accepts the readAll action..."), add expect(mockElectroService.entities.consumer.create).to.have.been.calledOnce to match the sibling happy-path assertion strength. Currently the test only proves "no exception thrown", not "validation passed and create was called". Also consider renaming the test to "accepts site:readAll and organization:readAll capabilities" since it only exercises those two.

Neither blocks the release - ship once folded in.

- Add JSDoc on Consumer.CAPABILITIES explaining readAll is a scope+verb
  hybrid meaningful only on opted-in routes (site, organization)
- Rename test to accurately reflect the two entities exercised
- Add calledOnce assertion to verify create was invoked after validation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

This PR will trigger a minor release when merged.

@ravverma
Copy link
Copy Markdown
Contributor Author

ravverma commented May 4, 2026

Thanks @solaris007 for review

All 1905 tests pass. Here's a summary of the three changes made to address the reviewer's asks:

  1. consumer.model.js:54 — Added a JSDoc comment on CAPABILITIES explaining that readAll is a scope+verb hybrid, currently only meaningful on routes that opt in (site and organization), and that schema validity doesn't imply a reachable route.

  2. consumer.collection.test.js — Renamed the test from "accepts the readAll action for any registered entity""accepts site:readAll and organization:readAll capabilities" to accurately reflect what's actually exercised.

  3. consumer.collection.test.js — Added expect(mockElectroService.entities.consumer.create).to.have.been.calledOnce to assert that validation passed and create was actually invoked, matching the assertion strength of the sibling happy-path test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ravverma ravverma merged commit 4475928 into main May 4, 2026
5 checks passed
@ravverma ravverma deleted the feat/consumer-readall-capability branch May 4, 2026 14:20
solaris007 pushed a commit that referenced this pull request May 4, 2026
## [@adobe/spacecat-shared-data-access-v3.56.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.55.1...@adobe/spacecat-shared-data-access-v3.56.0) (2026-05-04)

### Features

* **data-access:** add readAll capability to Consumer.CAPABILITIES ([#1573](#1573)) ([4475928](4475928))
@solaris007
Copy link
Copy Markdown
Member

🎉 This PR is included in version @adobe/spacecat-shared-data-access-v3.56.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

ravverma added a commit that referenced this pull request May 4, 2026
…tant (#1579)

## Session Summary

### PR #1573 — `feat(data-access): add readAll capability to
Consumer.CAPABILITIES`

**Review comments addressed (pushed to branch, now merged):**
1. Added JSDoc on `Consumer.CAPABILITIES` explaining `readAll` is a
scope+verb hybrid, only meaningful on opted-in routes
2. Renamed test: `"accepts the readAll action for any registered
entity"` → `"accepts site:readAll and organization:readAll
capabilities"`
3. Strengthened test assertion: added
`expect(mockElectroService.entities.consumer.create).to.have.been.calledOnce`

---

### CI failures investigated

| Failure | Root cause | Verdict |
| --------------------------------------------------- |
------------------------------------------------- |
----------------------------- |
| `mysticat-data-service:v1.67.8 not found` | Image removed from ECR |
Infrastructure issue |
| `TrialUser/TrialUserActivity IT timeout` | 10s hook timeout too tight
for v5.x image startup | Code fix needed |
| `HTML Utils warmup delay: expected 749 to be ≥ 750` | Wall-clock
timing flake in `tokowaka-client` | Pre-existing flake, unrelated |

---

### New PR branch — `fix/it-timeout-constant` (from main)

- Bumped default docker image tag to `v5.1.1` in `docker-compose.yml`
- Introduced `IT_HOOK_TIMEOUT = 30000` constant in
`test/it/util/util.js`
- Updated all 37 IT test files to import and use the constant instead of
the hard-coded `10000`

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
solaris007 pushed a commit that referenced this pull request May 4, 2026
## [@adobe/spacecat-shared-data-access-v3.56.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.56.0...@adobe/spacecat-shared-data-access-v3.56.1) (2026-05-04)

### Bug Fixes

* **data-access:** replace hard-coded IT hook timeout with shared constant ([#1579](#1579)) ([4fbc6e0](4fbc6e0)), closes [#1573](#1573)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants