Skip to content

Add shared PageIndex indexing and tree-guided documentation search - #75939

Merged
pelikhan merged 4 commits into
mainfrom
copilot/add-shared-agentic-workflow
Nov 8, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/add-shared-agentic-workflow

Conversation

Copilot AI commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Add reusable PageIndex indexing and search support, and apply it to workflows that navigate documentation and package specifications.

  • Shared component: Pin PageIndex and build local Markdown/MDX trees from configurable globs. The existing agent selects relevant sections and retrieves their text; no cloud uploads or indexing-model credentials.
  • Workflow adoption: Integrate with Daily Documentation Updater and Package Specification Librarian, with a package-only corpus for the librarian.
  • Retrieval safeguards: Preserve source paths, line numbers and document-scoped node IDs. Handle duplicate filenames, exclude path escapes, preserve hierarchy around bold paragraphs, and fall back to current-source search when the checkout changes.
imports:
  - uses: shared/pageindex.md
    with:
      patterns: "pkg/**/README.md"

Copilot AI changed the title Add shared local PageIndex indexing and tree-guided documentation search Add shared PageIndex indexing and tree-guided documentation search Nov 8, 2026
Copilot AI requested a review from pelikhan November 8, 2026 18:12
Comment thread .github/workflows/shared/pageindex.md Outdated
catalog = []
for path in sorted(sources):
source = path.relative_to(root).as_posix()
content = path.read_text(encoding="utf-8")
Comment thread .github/workflows/shared/pageindex.md Resolved
@pelikhan
pelikhan marked this pull request as ready for review November 8, 2026 18:22
Copilot AI adaptive review requested due to automatic review settings November 8, 2026 18:22
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Generated by PR Specification Reviewer for #75939

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Code Quality Reviewer · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: gpt56 max · ~2 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #75939

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@pelikhan pelikhan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot indexing on a separate job using a actions/cache, shallow checkout.
uv install with 3 day cooldown

@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.

Reviewed head 6f8d9db213d98b0af148f0b3917f4b48d2aadd6f against Security Architecture Specification v1.1.9.

Blocking finding: .github/workflows/shared/pageindex.md indexes repository Markdown/MDX and writes its raw text into trees that the agent is instructed to read. Under IS-01, content from untrusted sources must be sanitized before delivery to the agent; the new path bypasses the sanitization pipeline and allows prompt-injection instructions in docs/READMEs to influence an agent with safe outputs. The existing inline comment on line 73 records this finding. Remediate by sanitizing or isolating indexed content before agent consumption, with conformance coverage.

The shared import also adds the python network ecosystem (NI-02/NI-04); justify this broadened egress and pin/attest the package supply chain before merge. No specification synchronization is appropriate for a security regression.

Generated by PR Specification Reviewer for #75939 · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.7K
Comment /review-specs to run again

@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.

What this change does:

This adds a shared workflow import that installs PageIndex, builds local Markdown/MDX section trees, and teaches two agents to use them. It also adds regression tests for the embedded indexer.

Should fix:

  1. The regression suite is dead code (scripts/test_pageindex_workflow.py:L1)

    • What this is: This adds 143 lines of regression tests for the embedded indexer.
    • Problem: make test-scripts lists individual Python tests and does not include this file, so test-all never runs these cases; PageIndex is also not a repository Python dependency.
    • Fix: Wire the test into test-scripts with the pinned PageIndex environment, or remove this standalone suite.
    • If we skip it: The new indexer can regress without CI signal while these lines add maintenance cost.
  2. The document hash is unused (.github/workflows/shared/pageindex.md:L92)

    • What this is: Every indexed document gets a SHA-256 value in its tree JSON.
    • Problem: No workflow instruction or consumer reads this sha256 field; it is only asserted by the new test.
    • Fix: Remove this field and its test assertion unless a consumer will validate it.
    • If we skip it: Every run carries dead metadata and an extra full-content hash through the index.

Verdict: fix 1 and 2 first.

Not checked: generated lock files and correctness, security, and performance issues, per the requested scope; tests were inspected but not run.
Lean: -2 lines possible.

Generated by ✂️ Ponytail Reviewer for #75939 · codex · routed: gpt56 max · ~6 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again

@@ -0,0 +1,143 @@
"""Regression checks for the shared local PageIndex workflow."""

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.

Test suite is not wired — What this is: This adds 143 lines of regression tests for the embedded indexer. Problem: make test-scripts lists individual Python tests and does not include this file, so test-all never runs these cases; PageIndex is also not a repository Python dependency. Fix: Wire the test into test-scripts with the pinned PageIndex environment, or remove this standalone suite. If we skip it: The new indexer can regress without CI signal while these lines add maintenance cost.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the PageIndex suite to make test-scripts through a temporary Python 3.12 environment that installs pageindex==0.5.3. Commit af5b6520.

Comment thread .github/workflows/shared/pageindex.md Outdated
tree_path = output / f"{key}.json"
tree_path.write_text(json.dumps({
"source": source,
"sha256": hashlib.sha256(content.encode()).hexdigest(),

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.

Dead per-document hash — What this is: Every indexed document gets a SHA-256 value in its tree JSON. Problem: The consumers use revision.txt, source, and structure, but no workflow reads this sha256 field; it is only asserted by the new test. Fix: Remove this field and its test assertion unless a consumer will validate it. If we skip it: Every run carries dead metadata and an extra full-content hash through the index.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the unused per-document sha256 field and its test assertion; source-path hashing remains for stable tree filenames. Commit af5b6520.

@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.

Skills-Based Review 🧠

Applied /tdd and /diagnosing-bugs to the new PageIndex indexer and its test. Requesting changes because the regression test is not wired into any make target and fails without the pinned package.

📋 Key Themes & Highlights

Key Themes

  • Test is not run anywhere: scripts/test_pageindex_workflow.py is missing from test-scripts and test-unit, so CI never executes it.
  • Test depends on an uninstalled package: at HEAD the suite ends with FAILED (errors=11), all ModuleNotFoundError: pageindex. It needs an explicit dependency or a clear skip.
  • Coverage gap on node IDs: the docs say node IDs are document-scoped and the agent reads by ID, but no test checks them.
  • Least privilege: the bash allowlist sed * permits in-place edits, which conflicts with the docs rule to use the Edit tool.

Positive Highlights

  • ✅ The indexer rejects absolute paths and .., skips symlinks, and checks is_relative_to(root).
  • ✅ The test blocks sockets and patches subprocess, which keeps it hermetic.
  • ✅ Revision checks cover stale indexes.

Limits of this review

I could not install pageindex==0.5.3 in this sandbox, so I did not verify the indexer against the pinned library API. The existing GHAS comments on network: python and indexed-content prompt injection are still open and are not repeated here.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~2 AIC · ⊞ 5.4K
Comment /matt to run again

tree = self.tree(entry)["structure"]
self.assertEqual(tree[0]["text"], "Introduction")
self.assertEqual(tree[1]["title"], "Guide")
self.assertEqual(tree[1]["line_num"], 2)

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.

[/tdd] The PR says document-scoped node IDs are preserved, and the agent is told to read nodes by ID, yet no test asserts node_id. Add a check that every node in a document has a node_id and that IDs are unique within that document. Walk nested nodes recursively, because uniqueness is per document and not global.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added recursive checks that every node in each document has a non-empty string node_id and that IDs are unique within that document. Commit af5b6520.

@@ -0,0 +1,143 @@
"""Regression checks for the shared local PageIndex workflow."""

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.

[/tdd] No target runs this suite. scripts/test_pageindex_workflow.py is not listed in the test-scripts target (Makefile, around line 543), so the regression checks will not run. Add it beside the other Python script tests, with the pinned package available to the environment.

💡 Suggested Makefile entry

Add under test-scripts:

python3 scripts/test_pageindex_workflow.py

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wired the regression suite into make test-scripts; its target installs pinned pageindex==0.5.3 in a temporary Python 3.12 environment. Commit af5b6520.

Comment thread .github/workflows/shared/pageindex.md Outdated
tools:
bash:
- "jq *"
- "sed *"

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.

Least privilege: sed * is broader than the agent needs. sed * allows in-place edits (sed -i) and w-file writes. That conflicts with the rule in daily-doc-updater.md to edit with the Edit tool, not sed. The instructions only read with sed -n, so narrow the allowlist to sed -n *. Note that sed -n can still run a w command, so use the most specific pattern your matcher supports.

💡 Suggested change
tools:
  bash:
    - "jq *"
    - "sed -n *"
    - "git rev-parse HEAD"

Run make recompile afterward so both lock files pick this up.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Narrowed the shared workflow's sed allowance to sed -n * and recompiled the consumers. Commit af5b6520.

}), patch("subprocess.check_output", return_value="fixture-revision\n"), \
patch("socket.socket.connect", side_effect=AssertionError("Network forbidden")):
with contextlib.redirect_stdout(io.StringIO()):
exec(compile(script, str(SOURCE), "exec"), {})

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.

[/tdd] The suite cannot pass in a clean checkout. exec runs the embedded script, which imports pageindex, and nothing installs it for the test. At HEAD, python3 scripts/test_pageindex_workflow.py ends with FAILED (errors=11) and ModuleNotFoundError: pageindex. Declare the dependency explicitly, and skip with a clear reason when it is missing so failures are not confusing.

💡 Suggested guard
import importlib.util

@unittest.skipUnless(
    importlib.util.find_spec("pageindex"),
    "requires pageindex==0.5.3 (see shared/pageindex.md)",
)
class PageIndexWorkflowTests(unittest.TestCase):

A silent skip hides the regression, so pair this with an environment that installs the pinned version (see the Makefile comment).

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The suite now skips with an explicit reason when run directly without PageIndex; make test-scripts installs pageindex==0.5.3 first, and fails clearly if uv is unavailable. Commit af5b6520.

Copilot AI 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.

🟡 Changes recommended

Missing uv setup and unquoted wildcard inputs can block the workflows, while unnecessary network access and unverified transitive dependencies introduce critical security risks.

5 open issues
What changed in this PR

Adds reusable local PageIndex support to gh-aw workflows, letting existing agents navigate documentation through section trees without cloud indexing or separate model credentials.

Changes:

  • Build configurable Markdown/MDX catalogs with source paths, line numbers, and document-scoped node IDs.
  • Integrate tree-guided retrieval into the documentation updater and specification librarian, preserving source verification and exhaustive checks.
  • Add regression checks and regenerate both consumer workflow locks.
File Description
scripts/​test_pageindex_workflow.py Adds indexing and consumer-integration regression checks.
.github/​workflows/​spec-librarian.md Imports PageIndex with a package-specification-only corpus.
.github/​workflows/​spec-librarian.lock.yml Compiles indexing setup and retrieval guidance for the librarian.
.github/​workflows/​shared/​pageindex.md Defines configurable local indexing, retrieval guidance, and source safeguards.
.github/​workflows/​daily-doc-updater.md Uses PageIndex to discover documentation affected by recent changes.
.github/​workflows/​daily-doc-updater.lock.yml Compiles indexing setup and retrieval guidance for the updater.

Review effort: Max (auto)

Comment thread .github/workflows/shared/pageindex.md Resolved
Comment thread .github/workflows/shared/pageindex.md Outdated
- "git rev-parse HEAD"

steps:
- name: Install local PageIndex
Comment thread .github/workflows/shared/pageindex.md Outdated
run: |
set -euo pipefail
uv venv --python 3.12 --python-preference only-managed /tmp/gh-aw/pageindex/venv
uv pip install --python /tmp/gh-aw/pageindex/venv/bin/python "pageindex==0.5.3"
Comment thread .github/workflows/shared/pageindex.md Outdated

- name: Index Markdown with PageIndex
env:
PAGEINDEX_PATTERNS: ${{ github.aw.import-inputs.patterns }}
Comment thread .github/workflows/shared/pageindex.md Outdated
Comment on lines +74 to +78
headings, lines = extract_nodes_from_markdown(content)
headings = [
node for node in headings
if re.match(r"^#{1,6}\s+", lines[node["line_num"] - 1].strip())
]

Copilot AI commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot indexing on a separate job using a actions/cache, shallow checkout.
uv install with 3 day cooldown

Implemented in 0212baf: indexing now runs in a separate job with a credential-free depth-1 checkout, and the agent restores its exact-key actions/cache index. Added pinned uv setup and a three-day package cooldown; removed Python egress from the shared import. Both consumer locks regenerated, all 11 regressions and the final validation gate passed. CodeQL timed out.

Copilot AI requested a review from pelikhan November 8, 2026 19:05
Comment on lines +59 to +60
uv venv --python 3.12 /tmp/gh-aw/pageindex/venv
uv pip install --exclude-newer "$(date -u -d '3 days ago' +%Y-%m-%dT%H:%M:%SZ)" --only-binary=:all: --python /tmp/gh-aw/pageindex/venv/bin/python "pageindex==0.5.3"
catalog = []
for path in sorted(sources):
source = path.relative_to(root).as_posix()
content = path.read_text(encoding="utf-8")
Comment thread .github/workflows/shared/pageindex.md Outdated
tools:
bash:
- "jq *"
- "sed *"
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (scripts/test_pageindex_workflow.py:1): Test suite is not wired — What this is: This adds 143 lines of regression tests for the embedded indexer. Problem: make test-scripts lists individual Python tests and does not include this file, so test-all never runs these cases; PageIndex is also not a repository Python dependency. Fix: Wire the test into test-scripts with the pinned PageIndex environment, or remove this standalone suite. If we skip it: The new indexer can regress without CI signal while these lines add maintenance cost. - Add shared PageIndex indexing and tree-guided documentation search #75939 (comment)
  3. Review (.github/workflows/shared/pageindex.md:92): Dead per-document hash — What this is: Every indexed document gets a SHA-256 value in its tree JSON. Problem: The consumers use revision.txt, source, and structure, but no workflow reads this sha256 field; it is only asserted by the new test. Fix: Remove this field and its test assertion unless a consumer will validate it. If we skip it: Every run carries dead metadata and an extra full-content hash through the index. - Add shared PageIndex indexing and tree-guided documentation search #75939 (comment)
  4. Review (scripts/test_pageindex_workflow.py:69): [/tdd] The PR says document-scoped node IDs are preserved, and the agent is told to read nodes by ID, yet no test asserts node_id. Add a check that every node in a document has a node_id and that IDs are unique within that document. Walk nested nodes recursively, because uniqueness is per document and not global. - Add shared PageIndex indexing and tree-guided documentation search #75939 (comment)
  5. Review (scripts/test_pageindex_workflow.py:1): [/tdd] No target runs this suite. scripts/test_pageindex_workflow.py is not listed in the test-scripts target (Makefile, around line 543), so the regression checks will not run. Add it beside the other Python script tests, with the pinned package available to the environment. - Add shared PageIndex indexing and tree-guided documentation search #75939 (comment)
  6. Review (.github/workflows/shared/pageindex.md:11): Least privilege: sed * is broader than the agent needs. sed * allows in-place edits (sed -i) and w-file writes. That conflicts with the rule in daily-doc-updater.md to edit with the Edit tool, not sed. The instructions only read with sed -n, so narrow the allowlist to sed -n *. Note that sed -n can still run a w command, so use the most specific pattern your matcher supports. - Add shared PageIndex indexing and tree-guided documentation search #75939 (comment)
  7. Review (scripts/test_pageindex_workflow.py:49): [/tdd] The suite cannot pass in a clean checkout. exec runs the embedded script, which imports pageindex, and nothing installs it for the test. At HEAD, python3 scripts/test_pageindex_workflow.py ends with FAILED (errors=11) and ModuleNotFoundError: pageindex. Declare the dependency explicitly, and skip with a clear reason when it is missing so failures are not confusing. - Add shared PageIndex indexing and tree-guided documentation search #75939 (comment)

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: 0212baf
Sous-chef requested-work: 103f27ecfcb514ae320a25cebc3c7638e35e307af79b8488831485e35ac619ab 49ad190bceefd9e896d89c29569350d06667dbc9da66689047fd6f1c4472c711 7428eb8c37c6eda60b9e2e56949947d8d1020498f571558236a670fd8b813004 7e6da8d5e558bf3a0d2151e7c356ea5d82a29145f5aac7f603d3eb7233e6d3b7 b41ae1a6fc920d0509e4bc46c967439acc6ade83b5bddf7bc6da37b159cc04bb f26d4d38f4573afcf4caf39778b33cd8e6c35d46a79266dcc0af5cc3bc05ba36
Sous-chef requested-state: 0a2173303707893b762d9bd1883695ea544ba4355118867a77a9999e2d092563

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~7 AIC · ⌖ ~12 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Sous-chef requested-head: 0212baf
Sous-chef requested-work: 103f27ecfcb514ae320a25cebc3c7638e35e307af79b8488831485e35ac619ab 49ad190bceefd9e896d89c29569350d06667dbc9da66689047fd6f1c4472c711 7428eb8c37c6eda60b9e2e56949947d8d1020498f571558236a670fd8b813004 7e6da8d5e558bf3a0d2151e7c356ea5d82a29145f5aac7f603d3eb7233e6d3b7 b41ae1a6fc920d0509e4bc46c967439acc6ade83b5bddf7bc6da37b159cc04bb f26d4d38f4573afcf4caf39778b33cd8e6c35d46a79266dcc0af5cc3bc05ba36
Sous-chef requested-state: 0a2173303707893b762d9bd1883695ea544ba4355118867a77a9999e2d092563

Copilot AI and others added 2 commits November 8, 2026 19:43
…entic-workflow

# Conflicts:
#	.github/workflows/daily-doc-updater.lock.yml
#	.github/workflows/spec-librarian.lock.yml

Co-authored-by: gh-aw-bot <[email protected]>
`jq '.[].source' /tmp/gh-aw/pageindex/index/catalog.json`.
2. Read the outlines for a small set of relevant documents, then reason about
which sections answer the question. Do not load the entire corpus into context.
3. Read only the selected node IDs from the corresponding tree with `jq`;
@pelikhan
pelikhan merged commit 33243cf into main Nov 8, 2026
116 checks passed
@pelikhan
pelikhan deleted the copilot/add-shared-agentic-workflow branch November 8, 2026 20:10
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.2

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.

5 participants