Skip to content

Filter explorer data per view - #1212

Open
jviotti wants to merge 2 commits into
mainfrom
build-auth
Open

Filter explorer data per view#1212
jviotti wants to merge 2 commits into
mainfrom
build-auth

Conversation

@jviotti

@jviotti jviotti commented Aug 12, 2026

Copy link
Copy Markdown
Member

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Review in cubic

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 issues found across 14 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="test/cli/index/enterprise/rebuild-authentication-policy-added.sh">

<violation number="1" location="test/cli/index/enterprise/rebuild-authentication-policy-added.sh:152">
P3: The header comment still claims "since nothing filters yet", but this change removes `./explorer/public/schemas/a` and `./explorer/public/schemas/b` from `expected-after.txt` precisely because the `alpha` policy's `/schemas` path now filters those schemas out of the anonymous public view (they appear only under `./explorer/alpha/schemas/`). The comment is now stale and misleads future readers about what the test verifies. Update the comment to describe per-view filtering.</violation>
</file>

<file name="test/cli/index/enterprise/rebuild-authentication-policy-removed.sh">

<violation number="1" location="test/cli/index/enterprise/rebuild-authentication-policy-removed.sh:105">
P1: This change drops `./explorer/public/schemas/a/%/dependents.metapack` and `b/%/dependents.metapack` from the after-state expectation while keeping `schema.metapack` and `schema-html.metapack` for those same public schemas. Both `a` and `b` are public in the after state (`b` references `a`), so the public dependents listing is still valid; the test's own preamble says removing the policy should only make the removed view's tree disappear and that "nothing else about the catalog changes." A fresh public-only build and rebuilds with changed references still emit public dependents (see `rebuild-dependents-add-schema.sh`, which expects `explorer/public/example/schemas/*/%/dependents.metapack`). This asymmetry suggests the incremental-rebuild Combine path (delta.cc only regenerates dependents for `affected_leaves` and only restores missing artifacts when `dependents_rule.base != 0`, i.e. secondary views) fails to regenerate the primary/public view's dependents when a policy is removed — and this test now locks in that regression. Confirm the drop is intended; otherwise restoring these lines is the only fix in this file and the regeneration gap should be fixed in the build logic.</violation>
</file>

<file name="src/index/index.cc">

<violation number="1" location="src/index/index.cc:105">
P3: `view_filter_from` allocates two temporary `std::string`s and a concatenated one on every `visible` call. This predicate runs once per leaf per view in the hot loops of both the Produce and Combine delta phases (delta.cc ~577, ~875, ~1376), so it is hot for large registries with many views. Compute the `"/" + relative` path once per leaf instead of reallocating on each `visible` invocation.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

./explorer/public/schemas/%/login-html.metapack
./explorer/public/schemas/a
./explorer/public/schemas/a/%
./explorer/public/schemas/a/%/dependents.metapack

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: This change drops ./explorer/public/schemas/a/%/dependents.metapack and b/%/dependents.metapack from the after-state expectation while keeping schema.metapack and schema-html.metapack for those same public schemas. Both a and b are public in the after state (b references a), so the public dependents listing is still valid; the test's own preamble says removing the policy should only make the removed view's tree disappear and that "nothing else about the catalog changes." A fresh public-only build and rebuilds with changed references still emit public dependents (see rebuild-dependents-add-schema.sh, which expects explorer/public/example/schemas/*/%/dependents.metapack). This asymmetry suggests the incremental-rebuild Combine path (delta.cc only regenerates dependents for affected_leaves and only restores missing artifacts when dependents_rule.base != 0, i.e. secondary views) fails to regenerate the primary/public view's dependents when a policy is removed — and this test now locks in that regression. Confirm the drop is intended; otherwise restoring these lines is the only fix in this file and the regeneration gap should be fixed in the build logic.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/cli/index/enterprise/rebuild-authentication-policy-removed.sh, line 105:

<comment>This change drops `./explorer/public/schemas/a/%/dependents.metapack` and `b/%/dependents.metapack` from the after-state expectation while keeping `schema.metapack` and `schema-html.metapack` for those same public schemas. Both `a` and `b` are public in the after state (`b` references `a`), so the public dependents listing is still valid; the test's own preamble says removing the policy should only make the removed view's tree disappear and that "nothing else about the catalog changes." A fresh public-only build and rebuilds with changed references still emit public dependents (see `rebuild-dependents-add-schema.sh`, which expects `explorer/public/example/schemas/*/%/dependents.metapack`). This asymmetry suggests the incremental-rebuild Combine path (delta.cc only regenerates dependents for `affected_leaves` and only restores missing artifacts when `dependents_rule.base != 0`, i.e. secondary views) fails to regenerate the primary/public view's dependents when a policy is removed — and this test now locks in that regression. Confirm the drop is intended; otherwise restoring these lines is the only fix in this file and the regeneration gap should be fixed in the build logic.</comment>

<file context>
@@ -95,21 +95,6 @@ cat << 'EOF' > "$TMP/expected-before.txt"
 ./explorer/public/%/login-html.metapack
 ./explorer/public/%/mcp.metapack
 ./explorer/public/%/search.metapack
-./explorer/public/schemas
-./explorer/public/schemas/%
-./explorer/public/schemas/%/directory-html.metapack
-./explorer/public/schemas/%/directory.metapack
-./explorer/public/schemas/%/login-html.metapack
-./explorer/public/schemas/a
</file context>

@@ -149,16 +149,6 @@ cat << 'EOF' > "$TMP/expected-after.txt"
./explorer/public/schemas/%/directory-html.metapack

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The header comment still claims "since nothing filters yet", but this change removes ./explorer/public/schemas/a and ./explorer/public/schemas/b from expected-after.txt precisely because the alpha policy's /schemas path now filters those schemas out of the anonymous public view (they appear only under ./explorer/alpha/schemas/). The comment is now stale and misleads future readers about what the test verifies. Update the comment to describe per-view filtering.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/cli/index/enterprise/rebuild-authentication-policy-added.sh, line 152:

<comment>The header comment still claims "since nothing filters yet", but this change removes `./explorer/public/schemas/a` and `./explorer/public/schemas/b` from `expected-after.txt` precisely because the `alpha` policy's `/schemas` path now filters those schemas out of the anonymous public view (they appear only under `./explorer/alpha/schemas/`). The comment is now stale and misleads future readers about what the test verifies. Update the comment to describe per-view filtering.</comment>

<file context>
@@ -149,16 +149,6 @@ cat << 'EOF' > "$TMP/expected-after.txt"
-./explorer/public/schemas/b/%/dependents.metapack
-./explorer/public/schemas/b/%/schema-html.metapack
-./explorer/public/schemas/b/%/schema.metapack
 EOF
 
 diff "$TMP/after.txt" "$TMP/expected-after.txt"
</file context>

Comment thread src/index/index.cc
-> sourcemeta::one::ViewFilter {
return
[&gate](const std::size_t view, const std::string_view relative) -> bool {
return gate.visible(sourcemeta::one::Authentication::Path::relative(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: view_filter_from allocates two temporary std::strings and a concatenated one on every visible call. This predicate runs once per leaf per view in the hot loops of both the Produce and Combine delta phases (delta.cc ~577, ~875, ~1376), so it is hot for large registries with many views. Compute the "/" + relative path once per leaf instead of reallocating on each visible invocation.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/index/index.cc, line 105:

<comment>`view_filter_from` allocates two temporary `std::string`s and a concatenated one on every `visible` call. This predicate runs once per leaf per view in the hot loops of both the Produce and Combine delta phases (delta.cc ~577, ~875, ~1376), so it is hot for large registries with many views. Compute the `"/" + relative` path once per leaf instead of reallocating on each `visible` invocation.</comment>

<file context>
@@ -93,6 +93,21 @@ static constexpr std::array<BuildHandlerFunction, 27> HANDLERS{{
+    -> sourcemeta::one::ViewFilter {
+  return
+      [&gate](const std::size_t view, const std::string_view relative) -> bool {
+        return gate.visible(sourcemeta::one::Authentication::Path::relative(
+                                std::string{"/"} + std::string{relative}),
+                            view);
</file context>

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Benchmark Index (community)

Details
Benchmark suite Current: f6102fa Previous: ae9b0af Ratio
Add one schema (0 existing) 348 ms 306 ms 1.14
Add one schema (100 existing) 32 ms 31 ms 1.03
Add one schema (1000 existing) 99 ms 101 ms 0.98
Add one schema (10000 existing) 872 ms 939 ms 0.93
Update one schema (1 existing) 24 ms 22 ms 1.09
Update one schema (101 existing) 32 ms 32 ms 1
Update one schema (1001 existing) 101 ms 101 ms 1
Update one schema (10001 existing) 818 ms 837 ms 0.98
Cached rebuild (1 existing) 8 ms 8 ms 1
Cached rebuild (101 existing) 10 ms 11 ms 0.91
Cached rebuild (1001 existing) 38 ms 42 ms 0.90
Cached rebuild (10001 existing) 315 ms 358 ms 0.88
Index 100 schemas 582 ms 593 ms 0.98
Index 1000 schemas 1563 ms 1413 ms 1.11
Index 10000 schemas 13338 ms 13135 ms 1.02
Index 10000 schemas (custom meta-schema) 16338 ms 15987 ms 1.02
Index 10000 schemas ($ref fan-out) 16342 ms 16116 ms 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@augmentcode

augmentcode Bot commented Aug 12, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR makes explorer build output visibility-aware per authentication view.

Changes:

  • Adds a ViewFilter callback to the delta build API and supplies it from the indexer.
  • Builds an authentication artifact before planning so the planner uses the same visibility rules as request handling.
  • Emits leaf explorer artifacts only in views that can access each leaf.
  • Filters directory listings, search inputs, and dependent-schema graphs to each view’s visible content.
  • Skips empty secondary bases during dirty checks, output generation, and cleanup accounting.
  • Removes handler-side dependent filtering because the planner now supplies only permitted dependency artifacts.
  • Updates enterprise rebuild fixtures to expect hidden explorer leaf artifacts to be absent.
  • Adds unit coverage for a leaf that is visible in only one of two views.

Technical Notes: Primary schema artifacts remain available for internal build work; namespaced explorer artifacts are now selectively planned per authenticated view.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

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