Skip to content

fix(bin): match whole multi-word project names in the registry lookup - #5659

Merged
kunchenguid merged 3 commits into
kunchenguid:mainfrom
karotkriss:fm/fm-up-1977-registry-multiword
Sep 25, 2026
Merged

kunchenguid merged 3 commits into
kunchenguid:mainfrom
karotkriss:fm/fm-up-1977-registry-multiword

Conversation

@karotkriss

@karotkriss karotkriss commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Fixes #1977

bin/fm-project-mode.sh resolves a project's registered posture with an awk match on $2, which is only the first whitespace-delimited token of a registry row, so a project whose name contains a space never matches.
The lookup then warns that the project is not in the registry and silently defaults it to no-mistakes off instead of its declared mode, yolo posture, branch prefix, and forge.
Make the lookup match the whole registered name, so a row such as - 048. Blast- Lease summary drafter [local-only] - description (added 2026-08-08) resolves to local-only off, while single-word names, bracket parsing, and every existing output stay exactly as they are.
A name that is a leading prefix of another registered name must still resolve to its own row.

What Changed

  • Rewrote the awk lookup in bin/fm-project-mode.sh to match a project's whole registered name against the raw line text (literal, never a regex) instead of only the first whitespace-delimited token ($2), so a name containing spaces now resolves to its declared mode, yolo posture, branch prefix, and forge instead of warning "not in registry" and defaulting to no-mistakes off.
  • Anchored the match to - + name and required the trailing text to be empty or start with [ or -, so a name that is a leading prefix of a longer registered name no longer matches the longer row; bracket-token parsing now works off the post-name remainder.
  • Added a tests/fm-task-delivery.test.sh case covering multi-word resolution, leading-prefix disambiguation (longer row listed first), the registered branch prefix, and a single-word control name.

Risk Assessment

✅ Low: A minimal, well-bounded awk lookup fix that correctly matches whole multi-word registered names with a literal boundary check, preserves single-word and bracket-parsing behavior, rejects leading-prefix collisions, and is covered by a proper behavioral regression test.

Testing

Drove the real fm-project-mode.sh CLI end-to-end against an isolated fixture registry. On the fixed commit every case resolves correctly: 048. Blast- Lease summary drafter -> local-only off (no warning), foo bar -> local-only on with --branch-prefix x/, foo -> direct-PR off (not stolen by the earlier foo bar row), controlproj and single-word rows unchanged, legacy no-bracket legacy multi word -> no-mistakes off, and --forge gerritproj -> gerrit. Running the same fixture through the pre-fix base script reproduces #1977 (multi-word names warn "not in registry" and default to no-mistakes off). The repo's task-delivery test file, including the added multi-word regression test, passes. Product surface is a CLI, so evidence is a CLI transcript rather than a visual artifact.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
A registered multi-word name resolves to its own row (issue #1977) ✅ pass live fm-project-mode.sh "048. Blast- Lease summary drafter" => stdout local-only off, rc 0, no stderr warning
A single-word name that is a leading prefix of a longer registered name resolves to its own row, not the longer one ✅ pass live foo => direct-PR off even though - foo bar [...] is listed before - foo [...] in the fixture
A longer multi-word name resolves its own bracket tokens (mode, yolo, branch prefix) ✅ pass live foo bar => local-only on; --branch-prefix foo bar => x/
Single-word rows and legacy no-bracket rows keep existing output unchanged ✅ pass live controlproj => direct-PR off; legacy multi word (no brackets, " - " terminator) => no-mistakes off; --forge gerritproj => gerrit
Regression reproduces before the fix ✅ pass live base commit c643b57 script on the same fixture: 048. Blast- Lease summary drafter and foo bar both warn "not in registry" and default to no-mistakes off
Evidence: fm-project-mode multi-word lookup transcript (fixed vs base)

Source: fm-project-mode multi-word lookup transcript (fixed vs base)

=== bin/fm-project-mode.sh registry lookup (issue #1977) ===
Fixture data/projects.md (longer 'foo bar' listed BEFORE 'foo' to defeat prefix match):
- 048. Blast- Lease summary drafter [local-only] - description (added 2026-08-08)
- foo bar [local-only +yolo branch=x/] - fixture (added 2026-01-01)
- foo [direct-PR] - fixture (added 2026-01-01)
- controlproj [direct-PR] - fixture (added 2026-01-01)
- gerritproj [no-mistakes forge=gerrit] - fixture (added 2026-01-01)
- legacy multi word - fixture (added 2026-01-01)

--- FIXED commit cca46bf ---
$ fm-project-mode.sh 048. Blast- Lease summary drafter             => stdout=[local-only off] rc=0
$ fm-project-mode.sh foo                                           => stdout=[direct-PR off] rc=0
$ fm-project-mode.sh foo bar                                       => stdout=[local-only on] rc=0
$ fm-project-mode.sh --branch-prefix foo bar                       => stdout=[x/] rc=0
$ fm-project-mode.sh controlproj                                   => stdout=[direct-PR off] rc=0
$ fm-project-mode.sh legacy multi word                             => stdout=[no-mistakes off] rc=0
$ fm-project-mode.sh --forge gerritproj                            => stdout=[gerrit] rc=0

--- BASE commit c643b57 (pre-fix), same fixture: the bug ---
$ fm-project-mode.sh 048. Blast- Lease summary drafter             => stdout=[no-mistakes off] rc=0 stderr=[warn: project "048. Blast- Lease summary drafter" not in registry; defaulting to no-mistakes off]
$ fm-project-mode.sh foo bar                                       => stdout=[no-mistakes off] rc=0 stderr=[warn: project "foo bar" not in registry; defaulting to no-mistakes off]

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
A registered multi-word name resolves to its own row (issue #1977) ✅ pass live fm-project-mode.sh "048. Blast- Lease summary drafter" => stdout local-only off, rc 0, no stderr warning
A single-word name that is a leading prefix of a longer registered name resolves to its own row, not the longer one ✅ pass live foo => direct-PR off even though - foo bar [...] is listed before - foo [...] in the fixture
A longer multi-word name resolves its own bracket tokens (mode, yolo, branch prefix) ✅ pass live foo bar => local-only on; --branch-prefix foo bar => x/
Single-word rows and legacy no-bracket rows keep existing output unchanged ✅ pass live controlproj => direct-PR off; legacy multi word (no brackets, " - " terminator) => no-mistakes off; --forge gerritproj => gerrit
Regression reproduces before the fix ✅ pass live base commit c643b57 script on the same fixture: 048. Blast- Lease summary drafter and foo bar both warn "not in registry" and default to no-mistakes off
  • Ran bin/fm-project-mode.sh against a fixture data/projects.md (via FM_HOME) for: 048. Blast- Lease summary drafter, foo, foo bar, --branch-prefix foo bar, controlproj, legacy multi word, --forge gerritproj, and an unregistered name
  • Reproduced the regression by driving the base-commit script (git show c643b57:bin/fm-project-mode.sh) against the same fixture
  • bash tests/fm-task-delivery.test.sh (includes the new test_project_mode_matches_whole_multiword_names)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Copy link