Skip to content

feat(guidance): search installed workflow sections - #6996

Merged
gensokyo-dev merged 10 commits into
morluto:mainfrom
Deepak-Kambala:feat/6916-guidance-search
Oct 29, 2026
Merged

gensokyo-dev merged 10 commits into
morluto:mainfrom
Deepak-Kambala:feat/6916-guidance-search

Conversation

@Deepak-Kambala

@Deepak-Kambala Deepak-Kambala commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #6916. Analysts can find a workflow section with rea guidance --query "exact JavaScript module" or MCP search_guidance, then retrieve the selected section by locator with --action read / read_guidance_section. This continuation preserves the contributor history and integrates main f25d1e3e9.

Search reads only the eight installed MANAGED_SKILL_FILES; responses identify documentation rather than analysis results or Evidence. No target/provider is required or executed and no arbitrary directory or external service is accessed. This stays within the existing local documentation boundary.

Shared implementation and bounds

CLI/MCP share application search/retrieval and one ATX section parser. Every non-generic query word must occur in a section; generic-only or unmatched subjects return scoped no_matches, without a capability claim. Ranking and query/bundle-bound paging are deterministic. Bundle bytes are re-read on every operation; changed content produces stale locators/cursors. No new cache is retained.

  • Limits: 1 MiB/file, 4 MiB/bundle, 4,096 sections and 25,165,824 expanded UTF-16 code units. A line scan counts headings and a stack establishes spans before section strings/ranked objects are allocated. Search pages contain at most 20 entries with 500-code-unit excerpts; read returns the selected section.
  • Locators contain bundle, fixed guide, ordinal and complete-section SHA-256. The section hash already covers its heading, so the heading is not duplicated in the identity. Long headings remain readable within the 4,096-character input contract.
  • ATX closing hashes require whitespace; literal/escaped hashes, indented headings and empty headings retain their source meaning. Title cleanup scans each end directly instead of using suffix regexes with quadratic blank-run behavior. Ranking computes each section's distinct words once.
  • Each complete search/read request is admitted once; individual file reads use its child scope. Shutdown waits for later reads and finalization, while failed child cleanup remains owned by the root with its exact descriptor and live lease. New work after shutdown is refused. Deterministic gates reproduce both original shutdown failures and cover overlapping mixed outcomes/retry.
  • Unreadable/oversized bundles report bundle_unavailable, with no partial index or inferred absence. First-close and retry cleanup failures remain errors carrying the exact live lease. CLI shutdown settles both JavaScript/guidance owners; reusable CLI workers and dispatcher fixtures use the shared cleanup entrypoint. Unrelated Android/browser formatting was excluded.

Executed validation

Linux x64, Node 24.22.1 / npm 11.16.0; head 465a262ee (runtime unchanged from b667c16be):

  • 181 tests pass in 17 focused files on runtime head b667c16be, and again on local candidate 2d389f6c5 merging final head 465a262ee with current main 131fbe075, including public CLI/MCP, advertised schemas, paging/staleness, filesystem/symlink/size bounds, dispatcher/closed-pipe behavior, cleanup retry, mixed close outcomes and reusable CLI workers. Seven original boundary failures and both shutdown regressions were reproduced before their fixes. Final test-only follow-up 465a262ee reruns the four lifecycle tests and type/lint checks; gates now use bounded acknowledgement and unconditional release/join/close. Two temporary negative controls (early operation settlement and failed assertions, including denied cleanup) each produce the expected three failures and exit in about 1.2 s; restored tests pass.
  • check:fast, formatting, git diff --check, docs (9 README tests), catalog validation, and discovery (2,824 files exactly once) pass. Catalog check ran before the latest main-only integration; final CI checks the merged head.
  • Real generated bundle: 8 guides, 152,210 bytes, 69 ATX headings. Independent markdown-it-py 4.0.0/CommonMark heading maps verify returned titles and full section content. CLI search/read and SDK 2.3.1 stdio MCP select the expected exact-module recipe. Full module pagination retains all 19 results without duplicates, omissions or reordering.
  • A live MCP test changes an owned generated guide, observes stale locator and continuation responses, restores the exact bytes and confirms successful retrieval again. The unknown-subject/domain-word control returns no matches. The guide backup and all profiling evidence stay outside Git.

CI baseline and current-main verification

CI 40840282556 tests merge df89030ba on main 3503578f9: 21,777 source tests pass /16 skip across 1,172 files. Built shard 8 passes. Shard 5 has one failure in the unchanged bundleComparisonMcp.test.ts:168: it expects a legacy left_bundle_path: ... text substring while validation returns structured field issues. Pure main 3503578f9 reproduces the identical failure (8 pass /1 fail) with npm run test:focused -- tests/boundary/mcp/bundleComparisonMcp.test.ts. Matrix fail-fast cancels the other six shards; they are unverified on this run, not reported as passing. Platform results remain in the linked run. This is the only observed failed test; the operator explicitly authorized bypass for demonstrated main failures.

Current-main candidate 2d389f6c5 (tree 4f2e5359223864fc9876e00e49328fe021ef16e3, parents main 131fbe075 and final head 465a262ee) merges cleanly, passes all 181 focused tests /17 files, type/lint and diff checks. Its updated installed bundle is 152,417 bytes /8 guides /69 headings; independent CommonMark maps, real recipe search/read, all 19 module results and live drift/restore pass again. Greptile gives 5/5 on exact final head, with all eleven threads resolved. Codex could not review the final head because the repository review quota is exhausted.

Completed-task measurements

Before 1af45280e is the original implementation integrated on the same main base; after cb60adf28 includes the fixes. Two alternating/reversed repetitions per revision/workflow, fresh client/server sessions, warm OS caches; compile-cache state not independently controlled. application family and compact input schemas; initialization/instructions, catalog, requests, replies, notifications and both text/structured representations are counted.

Task Estimated tokens Elapsed CPU Peak family RSS
Before, recipe search + read 272,186 2.084–2.101 s 2.80–2.85 s 454.6–455.3 MiB
After, recipe search + read 272,133 2.121–2.138 s 2.86–3.00 s 454.3–454.5 MiB
Before, all module pages 280,518 2.251–2.339 s 2.96–3.13 s 454.1–455.9 MiB
After, all module pages 280,189 2.265–2.426 s 3.02–3.18 s 453.6–456.5 MiB

The recipe's chosen answer stays the same; requiring complete meaningful-term coverage reduces candidate sections from 41 to 11. Single-word pagination remains identical at 19 entries. Catalog 268,264 → 268,268 estimated tokens; compact locators offset that small addition. These whole-task measurements establish no overall speedup.

After the latest main integration, two more guarded tasks pass: recipe 272,133 tokens /3.632 s /4.72 CPU s /456.3 MiB; pagination 280,189 /3.818 s /4.93 CPU s /456.8 MiB. Historical comparisons remain pinned above. After the lifecycle fix, the same two tasks pass again: recipe 3.987 s /5.22 CPU s /454.7 MiB; paging 4.110 s /5.30 CPU s /453.8 MiB. Token counts remain 272,133 /280,189; no guard stop or surviving process. The live freshness/restore test also passes again.

The latest-main candidate also completes guarded recipe/paging tasks: 272,148 /280,204 tokens; 2.330 /2.496 s; 3.24 /3.42 CPU s; 455.5 /453.4 MiB. Its catalog is 268,283 tokens; updated main accounts for the changed catalog and guide bytes. These are additional observations, not an equivalent-base speed comparison. No guard stops or survivors.

A separate bounded diagnostic found a pre-linear title-cleanup expression took 440 ms for 16K internal spaces; the current complete section parser took 0.037 ms for that input and 0.108 ms at 64K. These have different scopes and are not a whole-workflow speed claim. The million-heading case was source-derived and deliberately not executed; a tiny boundary fixture proves refusal before expansion.

Tokenx 1.3.0 provides transport estimates, not billed model/context tokens. RSS is a 10 ms client/server process-group sum; CPU includes both and excludes the external sampler. A 1.5 GiB family/150 s guard bounds runs; all final measured tasks complete with no guard stops or survivors. Cold caches, full-schema discovery and OS-enforced network denial are unmeasured. One incomplete measurement preflight used the wrong legacy root-union payload shape; it cost 269,925 estimated tokens /3.392 s /4.58 CPU s /452.9 MiB, is retained separately and is not represented as passing. The corrected client follows the advertised SDK projection.

Author readiness

Human owner: @Deepak-Kambala

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-29T08:10:45.677302Z
We couldn’t complete this review. Comment @codex review to try again.
465a262 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

Adds shared CLI/MCP search and retrieval for the eight installed workflow guides.

  • Analysts can search installed REA guidance and read a selected section.
  • CLI shutdown now closes guidance resources alongside JavaScript analysis resources.
  • Development test setup and fixtures stay aligned with the updated test and cleanup helpers.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  CLI["CLI guidance"] --> Shared["Shared search/read operation"]
  MCP["MCP guidance tools"] --> Shared
  Shared --> Admission["Admit once; create child resource owner"]
  Admission --> Bundle["Read eight fixed guides with size bounds"]
  Bundle --> Parser["Parse bounded sections"]
  Parser --> Search["Rank and page matches"]
  Parser --> Read["Check locator and return section"]
  Admission --> Cleanup["Release resources or retain exact cleanup owner"]
Loading

Reviews (9) · Last reviewed commit: "test(guidance): bound lifecycle gates an..." · Reviewed by Greptile

Comment thread src/application/GuidanceAccess.test.ts Resolved
Comment thread src/application/GuidanceAccess.ts Resolved
Comment thread src/application/GuidanceAccess.ts Resolved
Comment thread src/cli/guidanceCommands.ts Resolved
Comment thread src/application/GuidanceAccess.test.ts Resolved
Comment thread src/contracts/toolEffects.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff9bfe508a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/application/GuidanceAccess.ts Resolved
Comment thread src/cli/guidanceCommands.ts Resolved
Comment thread scripts/rea.mjs Resolved
Comment thread src/application/GuidanceAccess.test.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7de4dce921

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread scripts/rea.mjs Resolved
Comment thread src/application/GuidanceAccess.ts Resolved
Deepak-Kambala and others added 2 commits October 25, 2026 09:16
…search

# Conflicts:
#	docs/mcp-prompts.md
#	src/cli.ts
#	src/cliCommandNames.ts
#	src/contracts/applicationToolContracts.ts
#	src/contracts/toolEffects.ts
#	src/server/registerApplicationTools.ts
Comment thread src/application/GuidanceAccess.ts Resolved
Comment thread src/server/registerGuidanceTools.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2a7876eb9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/application/GuidanceAccess.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9638b6d77b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/application/GuidanceAccess.ts Resolved
Comment thread src/application/GuidanceAccess.ts Resolved
Comment thread src/application/GuidanceAccess.ts Resolved
@gensokyo-dev gensokyo-dev changed the title feat(guidance): search bundled REA workflow guidance feat(guidance): search installed workflow sections Oct 29, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/application/GuidanceAccess.ts Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@gensokyo-dev

Copy link
Copy Markdown
Collaborator

Baseline CI audit for final head 465a262eeca8fa5402a5a951246269058a5d64f8:

  • Shard 5 failure: only bundleComparisonMcp.test.ts:168 fails, expecting a legacy colon-delimited message instead of the structured field issues now returned. The other 2,378 tests in that shard pass (42 skip).
  • A clean worktree at CI's pure main 3503578f911c2471adb237d1459b79e6dcae1f52, without this feature, reproduces the identical assertion with npm run test:focused -- tests/boundary/mcp/bundleComparisonMcp.test.ts: 8 pass /1 fail, Node 24.22.1. The baseline source assertion is here.
  • CI source tests: 21,777 pass /16 skip; static checks, build, docs, reverse-tools quality, all selected Linux/macOS/Windows package/capability lanes and real workflow lanes pass. Shard 8 passes. Six other shards were cancelled by matrix fail-fast and remain unverified on this run.
  • Current main 131fbe0754332cdcf6f2ce951dad3b026f982e8d plus final head merges cleanly. Local candidate 2d389f6c5 /tree 4f2e5359223864fc9876e00e49328fe021ef16e3 passes 181 focused tests /17 files, type/lint and the updated real-bundle/CommonMark/SDK MCP checks, including paging and live freshness recovery.
  • Greptile: 5/5 on the exact final head, all eleven threads resolved. Codex cannot complete a new review due to repository quota; this is recorded rather than represented as a passed review.

The operator explicitly authorized merging around demonstrated main failures. The bypass is limited to the baseline failure and its dependent/cancelled CI outcomes above; no failing PR behavior was left unresolved. The PR body retains the original contributor's readiness declarations and records the validation limits.

@gensokyo-dev
gensokyo-dev merged commit c88e1b0 into morluto:main Oct 29, 2026
40 of 49 checks passed
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: build Build, CI, packaging, and publishing enhancement New feature or request labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build, CI, packaging, and publishing enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Search and retrieve bundled REA guidance by analyst question

3 participants