Skip to content

fix(memory): read turn_lessons' row-token helper through text_scoring - #15737

Closed
unstablebrainiac wants to merge 1 commit into
kirodotdev:mainfrom
unstablebrainiac:fix/turn-lessons-row-tokens
Closed

unstablebrainiac wants to merge 1 commit into
kirodotdev:mainfrom
unstablebrainiac:fix/turn-lessons-row-tokens

Conversation

@unstablebrainiac

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Matching lessons to follow-up messages works again on main: turn_lessons stops raising NameError.

On main, every call to turn_lessons raises NameError: name '_row_stem_tokens_for_scan' is not defined at src/kiro_crew/vector_memory_runtime/lessons.py:1206, and flake8 reports F821 on that line. test/test_lesson_turn_injection.py fails on main for the same reason.

Why it matters

A session with memory.inject_lessons_per_turn on hits the error on its follow-up messages, so the feature #15517 added cannot run. Any branch built on current main also fails flake8 on this line and the turn-lesson tests, whatever it changes.

Not a goal

What changed (motivation → approach → change)

#15688 replaced lessons.py's by-name imports from text_scoring with reads through the owner module (_text_scoring.<name>). #15517 went green on a base from before #15688 and merged after it. Its new turn_lessons kept one bare _row_stem_tokens_for_scan(...) call, which no longer resolves. The two edits did not touch the same lines, so the merge was clean and nothing re-ran the checks.

turn_lessons now reads _text_scoring._row_stem_tokens_for_scan, as the file's other two callers do. The change is that one line in src/kiro_crew/vector_memory_runtime/lessons.py.

Backwards compatibility

Compatible: it restores the behavior #15517 shipped. No API, config or stored data changes.

Tests

No new test. test/test_lesson_turn_injection.py already calls turn_lessons: on main it fails with this NameError, and with this change it passes. Together with the composition-contract, keyword-scoring and vector-memory suites: 392 passed, 14 skipped. flake8 over src/kiro_crew test, isort and mypy over src/kiro_crew/ are clean.

Manual verification

N/A — the existing unit tests call the failing line directly.

Related Issues

no linked issue: this fixes a regression on main from the merge order of #15688 and #15517.

Pattern harvest

Not generalizable: flake8 F821 already flags this name. It reached main because #15517's checks ran on a base from before #15688 and the clean textual merge started no re-run. That is a merge-ordering gap, not a missing lint or review rule.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

kirodotdev#15688 replaced lessons.py's by-name imports from text_scoring with reads through the owner module. kirodotdev#15517, which merged after it, added turn_lessons with one bare _row_stem_tokens_for_scan call, so main raises NameError: name '_row_stem_tokens_for_scan' is not defined on every turn_lessons call (flake8 F821). Read it through _text_scoring like the other callers in the file.
@unstablebrainiac
unstablebrainiac requested a review from a team as a code owner October 1, 2026 06:20
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of 62306ceef83cb82462825072cea3f8fcb00ce6d3 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 62306ce

Description read

[DESCRIPTION-READ] 40954c6bc6a0d9a41086167b229e142acc95cd30547835b63017b3350078eb9c

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed 62306ceef83cb82462825072cea3f8fcb00ce6d3 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 62306ce

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of 62306ceef83cb82462825072cea3f8fcb00ce6d3 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (1 item) — 1 justified

Intent: FIX — make turn_lessons stop raising NameError on main so per-turn lesson injection runs again.

  1. turn_lessons resolves its row-token helper again instead of crashing every call — justified

Verified on base: lessons.py:1206 calls bare _row_stem_tokens_for_scan with no by-name import (only _stem_one is imported by name; the module is imported as _text_scoring), so the NameError is read directly off the source. Grepped _row_stem_tokens_for_scan across the package: 1 bare call (the fixed line), 3 module-qualified callers (lessons.py:1267, 1385; semantic.py:784) — zero unfixed siblings. The merge-order root cause is named in the description and out of scope.

[FIRST-PRINCIPLES-REVIEWED] 62306ce

Description read

[DESCRIPTION-READ] 734b692028d4f07dd156a533af64c642b4672f6335f21e8ebce37215b1aa0270

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — ✅ no blocking findings

Reviewed 62306ceef83cb82462825072cea3f8fcb00ce6d3 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 62306ce

@unstablebrainiac

unstablebrainiac commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

CI on 62306ce fails the tests main fails, minus the ones this PR fixes, plus what looks like one Windows flake.

@bolichen97

Copy link
Copy Markdown
Contributor

Thanks @unstablebrainiac — this exact lessons.py hunk landed on main via #15744 (d8fa6a5), which also carried the fold-catalogue fix, so this PR is now a no-op. Closing as superseded; credit for the F821 fix is yours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants