Skip to content

fix: harden location extraction and docs automation safety - #4

Merged
aj1126 merged 6 commits into
mainfrom
copilot/update-readme-and-documentation
Jun 12, 2026
Merged

fix: harden location extraction and docs automation safety#4
aj1126 merged 6 commits into
mainfrom
copilot/update-readme-and-documentation

Conversation

Copilot AI commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixed greedy location capture while preserving case-insensitive keyword matching by updating extractLocations to use Unicode-aware capture rules with scoped case sensitivity.
  • Added regression coverage in tests for uppercase keyword inputs (for example LOCATION / NEAR) to ensure location extraction behavior remains correct.
  • Corrected docs generation section replacement logic to find each end marker only after its matching start marker.
  • Hardened the docs workflow by adding explicit minimal GITHUB_TOKEN permissions (contents: read) to satisfy security checks.

Checklist

  • I reviewed whether this change affects README, architecture docs, or legacy docs.
  • If commands, supported file types, or layout metadata changed, I ran npm run docs:generate.
  • I ran npm run docs:check.
  • If historical Python prototype guidance changed, I updated docs/legacy-prototype.md.

Copilot AI changed the title fix: prevent greedy location capture caused by case-insensitive regex flag fix: prevent greedy location capture from case-insensitive regex flag Jun 1, 2026
Copilot finished work on behalf of aj1126 June 1, 2026 09:43
Copilot AI requested a review from aj1126 June 1, 2026 09:43
@aj1126
aj1126 marked this pull request as ready for review June 1, 2026 09:45
@aj1126
aj1126 requested a review from Copilot June 1, 2026 09:46

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

Pull request overview

This PR tightens location extraction to avoid case-insensitive regex behavior causing greedy captures, and introduces a small docs automation workflow (generated README sections + validation) to keep documentation aligned with the current Node CLI implementation.

Changes:

  • Adjusted extractLocations regexes to prevent greedy capture of trailing lowercase words.
  • Added documentation generation + validation scripts, wired into package.json and a GitHub Actions workflow.
  • Refreshed README + architecture/diagram docs and moved Python prototype guidance into docs/legacy-prototype.md.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/ingestion/file-ingestion.js Updates location-extraction regex flags/keywords to prevent greedy captures.
scripts/validate-docs.js Adds a docs consistency validator for scripts/docs/README cross-references.
scripts/generate-docs.js Adds README section generator for commands/file-types/layout sections.
README.md Refocuses README on current Node CLI and adds generated sections + docs workflow guidance.
package.json Adds docs:generate and docs:check scripts.
docs/legacy-prototype.md Introduces a dedicated legacy doc for the Python prototype.
docs/docs-source.json Adds metadata source for generated README sections and required-doc links.
docs/diagrams/sequenceDiagram.mermaid Updates sequence diagram labels to clarify current vs planned behavior.
docs/diagrams/architectureDiagram.mermaid Updates architecture diagram to distinguish current components vs planned expansion.
docs/architecture.md Rewrites architecture doc into “current vs planned” structure and references diagrams.
.github/workflows/docs.yml Adds CI job to run docs validation on PRs and releases.
.github/pull_request_template.md Adds a checklist prompting docs checks.
.github/prompts/update-readme.prompt.md Updates prompt to cover the full “active documentation set” and generation workflow.

Comment thread src/ingestion/file-ingestion.js Outdated
Comment on lines +37 to +38
const metadataPattern = /\b(?:location|city|site|Location|City|Site)\s*:\s*([A-Z][a-zA-Z]+(?:[ -][A-Z][a-zA-Z]+)*)/g;
const sentencePattern = /\b(?:in|at|near|In|At|Near)\s+([A-Z][a-zA-Z]+(?:[ -][A-Z][a-zA-Z]+)*)/g;
Comment thread scripts/validate-docs.js Outdated
Comment on lines +19 to +23
const docsSource = loadJson('docs/docs-source.json');
const packageJson = loadJson('package.json');
const readme = readFile('README.md');
const architecture = readFile('docs/architecture.md');
const legacyPrototype = readFile('docs/legacy-prototype.md');
Comment thread docs/legacy-prototype.md Outdated

## Legacy Scope

The prototype in `/tmp/workspace/aj1126/UAP_AnalyticsBot/ingestion.py` provided:

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread src/ingestion/file-ingestion.js Outdated
Comment on lines +37 to +38
const metadataPattern = /\b(?:[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn]|[Cc][Ii][Tt][Yy]|[Ss][Ii][Tt][Ee])\s*:\s*([A-Z][a-zA-Z]+(?:[ -][A-Z][a-zA-Z]+)*)/g;
const sentencePattern = /\b(?:[Ii][Nn]|[Aa][Tt]|[Nn][Ee][Aa][Rr])\s+([A-Z][a-zA-Z]+(?:[ -][A-Z][a-zA-Z]+)*)/g;
Comment thread scripts/generate-docs.js
@aj1126

aj1126 commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • The i flag on both regex patterns in extractLocations caused [A-Z] in the capture group to match lowercase letters, making (?:[ -][A-Z][a-zA-Z]+)* greedily consume entire phrases (e.g. "Roswell and hovered over the desert") instead of stopping at the location name.
  • Removed i flag from metadataPattern and sentencePattern; added explicit title-case variants to the keyword groups to preserve case-insensitive keyword matching without affecting the capture group.
// Before — i flag bleeds into capture group
/\b(?:location|city|site)\s*:\s*([A-Z][a-zA-Z]+(?:[ -][A-Z][a-zA-Z]+)*)/gi

// After — keywords handle their own case; [A-Z] strictly means uppercase
/\b(?:location|city|site|Location|City|Site)\s*:\s*([A-Z][a-zA-Z]+(?:[ -][A-Z][a-zA-Z]+)*)/g

Checklist

  • I reviewed whether this change affects README, architecture docs, or legacy docs.
  • If commands, supported file types, or layout metadata changed, I ran npm run docs:generate.
  • I ran npm run docs:check.
  • If historical Python prototype guidance changed, I updated docs/legacy-prototype.md.

@copilot what must be done to finish the checklist?

Copilot AI changed the title fix: prevent greedy location capture from case-insensitive regex flag fix: harden location extraction and docs automation safety Jun 12, 2026
@aj1126
aj1126 merged commit 3fc8f8a into main Jun 12, 2026
1 check passed
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.

3 participants