Skip to content

feat(coordination): implied Related-Section detection via title-keyword match - #283

Merged
thewrz merged 3 commits into
mainfrom
feat/issue-261
Jun 25, 2026
Merged

feat(coordination): implied Related-Section detection via title-keyword match#283
thewrz merged 3 commits into
mainfrom
feat/issue-261

Conversation

@thewrz

@thewrz thewrz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Why

#256 A4: a spec body can imply a Related Section it doesn't list — e.g. a conduit spec describing firestopping should reference 07 84 00 Firestopping. This is fuzzy concept→section inference.

What

Adds an advisory implied_related_section coordination finding: when a spec body mentions a distinctive keyword from an in-scope section title but does not already list that section under Related Sections, it's suggested (with the matched keyword, source paragraph, and a confidence score). Surfaced via REST + MCP; demo renders it behind API_FEATURES.impliedRelated. Adds ADR-035.

Design decisions

  • Title keywords derived from in-scope sections (present + required + source-library), normalized with a stop-word list + light suffix stemmer; keywords appearing in >2 titles are suppressed (precision bias).
  • Confidence is advisory and fixed (0.72 base, +0.08/extra keyword, cap 0.92).
  • Review fix: sections already explicitly cited in the body are suppressed (they're covered by related_cited_not_listed) — prevents double-findings on the same section.

Testing

  • Unit + integration 14/14 (run on an isolated DB during review)
  • pnpm build, pnpm lint, redocly lint openapi.yaml
  • Conduit→firestopping implied; already-listed → none; generic word → none; explicitly-cited → no duplicate finding
  • CI green

🤖 Implemented by Codex (GPT-5.5 xhigh), reviewed + adversarially re-reviewed by Claude Opus 4.8 (one P2 precision fix applied). Closes #261.

Summary by CodeRabbit

  • New Features

    • Added implied related-section suggestions in coordination reports to highlight likely missing section references.
    • Expanded the demo UI and report summaries to show the new suggestion type and its confidence details.
  • Bug Fixes

    • Improved matching rules to reduce false positives from generic wording and avoid duplicates when sections are already listed or cited.
  • Documentation

    • Added an ADR describing the new suggestion behavior and its review-time guidance.

thewrz and others added 2 commits June 24, 2026 23:46
Co-Authored-By: Codex <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 78cc13dd-8a3a-420c-9edf-3e986d9f30d7

📥 Commits

Reviewing files that changed from the base of the PR and between a1d1c63 and 08ea023.

📒 Files selected for processing (11)
  • docs/adr/035-implied-related-section.md
  • examples/web_ui_demo/js/coordination.js
  • examples/web_ui_demo/js/features.js
  • openapi.yaml
  • src/coordination/implied-related.test.ts
  • src/coordination/implied-related.ts
  • src/coordination/index.ts
  • src/db/queries/coordination-implied.ts
  • src/db/queries/coordination.integration.test.ts
  • src/db/queries/coordination.ts
  • src/mcp/tools.ts

📝 Walkthrough

Walkthrough

Adds an advisory implied_related_section finding, its title-keyword detection, report aggregation, schema updates, and demo UI rendering.

Changes

Implied related-section detection

Layer / File(s) Summary
Keyword detector and ADR
docs/adr/035-implied-related-section.md, src/coordination/implied-related.ts, src/coordination/index.ts, src/coordination/implied-related.test.ts
ADR-035 defines the implied-related finding, the detector normalizes section titles and paragraph text, exports the matcher APIs, and unit tests cover match and suppression cases.
Report assembly and query
src/db/queries/coordination-implied.ts, src/db/queries/coordination.ts, src/db/queries/coordination.integration.test.ts
The coordination report query reads catalog titles and paragraphs for implied matching, merges implied_related_section findings into the report, counts them in the summary, and integration tests cover the new flow.
Schema and demo UI
openapi.yaml, examples/web_ui_demo/js/features.js, examples/web_ui_demo/js/coordination.js, src/mcp/tools.ts
The OpenAPI schema adds the new finding variant and summary counter, the demo UI gates and renders the finding with a feature flag, and the MCP tool description text is rewrapped.

Sequence Diagram(s)

sequenceDiagram
  participant getCoordinationReport
  participant readImpliedRelatedFindings
  participant buildTitleKeywordIndex
  participant findImpliedRelatedSections
  participant buildFindings
  participant summarize
  getCoordinationReport->>readImpliedRelatedFindings: load catalog, paragraphs, and classified refs
  readImpliedRelatedFindings->>buildTitleKeywordIndex: build title keyword index
  readImpliedRelatedFindings->>findImpliedRelatedSections: scan spec bodies for implied matches
  getCoordinationReport->>buildFindings: merge implied findings into report findings
  getCoordinationReport->>summarize: count implied_related_section findings
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • wrzonance/SpecR#241: Similar coordination-report schema and aggregation changes that added another finding variant to the same report model.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/issue-261

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

# Conflicts:
#	examples/web_ui_demo/js/coordination.js
#	examples/web_ui_demo/js/features.js
#	openapi.yaml
#	src/db/queries/coordination.integration.test.ts
#	src/db/queries/coordination.ts
@thewrz
thewrz merged commit d350f4c into main Jun 25, 2026
4 of 5 checks passed
@thewrz
thewrz deleted the feat/issue-261 branch June 25, 2026 13:13
thewrz added a commit that referenced this pull request Jul 1, 2026
#325)

* docs(readme): sync capabilities to last month of merged PRs

Reflect shipped work in the README's "Included Today", "API Surface", and MCP
tool table, validated against the merged diffs and current main:

- PDF ingest (text-layer + OCR + font-encoding recovery) accepted by POST /parse
  (#287, #290, #311)
- coordination / E&O report + submittal register (#241, #269, #277, #282, #283,
  #284) and article-role tagging (#273)
- onboarding pipeline: library import, editability review/override, reclassify,
  finalize/reopen, open-comments (#243, #247, #248, #249, #272)
- spec/project soft-delete + restore (#257, #313), document concurrency (#197),
  revision/addendum manual rendering (#221), numbering profiles (#317, #322)
- add missing MCP tools get_numbering_profile, submittal_register,
  open_comments_report; document GET /docs (Scalar) (#213, #285)
- add Example Client pointer to examples/web_ui_demo (#225)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(roadmap): move shipped work to done; re-date to 2026-07-01

Reconcile the roadmap with merged reality (was stamped 2026-06-17). Moved from
planned/in-progress to Included, each validated against the diff:

- PDF ingest (#287, #290, #311) — remove from "Later"
- deep paragraph nesting pr6/pr7 (#215)
- revision nomenclature (#216) + revision/addendum manual rendering (#221) —
  the two "Near Term" Phase 2e items are done
- coordination / E&O report, required-sections, article-role, submittal register
  (#239, #241, #269, #273, #277, #282, #283, #284) — new "Coordination and
  Semantics" section; removed "coordination report" from planned Phase 4
- onboarding APIs (#243, #247, #248, #249, #272) — API done; UI remains planned
- soft-delete/withdraw (#257, #313), section-number format (#266, #271),
  external-content associations (#242), structural numbering profiles (#317)

Kept as planned (foundation only): header/footer composition (#222, #314) and
keynote surfacing (#315) — DB/AST exist, no resolution/render/export yet.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(architecture): reflect merged structural changes

Update the architecture spec for shipped work, validated against the diffs and
current schema/routes:

- Tech Stack + Data Flow: Parse — PDF text-layer (unpdf/pdfjs-dist) + OCR
  (tesseract.js/@napi-rs/canvas) path and numberingProfileId override (#287,
  #290, #311, #317; ADR-034, ADR-039)
- DB schema — specs.onboarding_status/withdrawn_at, projects.section_number_format
  /deleted_at/deleted_by, paragraphs.source_facts/classification/
  editability_override; "Additional tables" summary for editing_conventions,
  paragraph_associations, required_sections, keynotes, header_footer_configs,
  numbering_profiles, revision_nomenclature_profiles (foundation-only tables
  flagged) (ADR-021/022/023/028/031/032; #187, #242)
- new Coordination Report / E&O section (finding vocabulary) and Document
  Concurrency section (locks/optimistic/lifecycle) (#197, #241, #269, #277,
  #282, #283, #284; ADR-018, ADR-033/035/036/037)
- AST meta.articleRole (#273, ADR-033); API-surface note pointing at the
  CI-enforced openapi.yaml + GET /docs; refreshed MCP tool list

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

feat(coordination): implied Related-Section detection via title-keyword match

1 participant