Skip to content

docs(requirements): add contextual user model requirements with scoring model rationale#786

Draft
tianjianjiang wants to merge 2 commits intomasterfrom
docs/user_model_requirements
Draft

docs(requirements): add contextual user model requirements with scoring model rationale#786
tianjianjiang wants to merge 2 commits intomasterfrom
docs/user_model_requirements

Conversation

@tianjianjiang
Copy link
Copy Markdown
Member

@tianjianjiang tianjianjiang commented Feb 14, 2026

Summary

  • Add complete requirements.md with 10 functional requirements (FR-0 through FR-9) using Job Stories and EARS acceptance criteria
  • FR-0 requires algorithm.md to document both the Viterbi DP walk and the scoring model rationale: legacy score hack problem, seven-technique smoothing comparison, the "丼 problem" design breakthrough, and four-level backoff formulas
  • FR-0 EARS criteria enriched with PR Refactor: extract walk strategy with dynamic span support #779 postmortem context and algorithm selection analysis from design plan Phase 0B
  • FR-1 through FR-5 document completed phases (dynamic span, walk strategy, structural fixes, contextual user model, walk integration)
  • FR-6 through FR-9 define TODO phases (KeyHandler integration, legacy removal, migration, observability)
  • FR-4 cross-references FR-0's scoring model analysis as design rationale
  • References include SLP3, FSNLP, Chen & Goodman (1999), and Bilmes & Kirchhoff (2003)
  • All <required> criteria use EARS syntax with no C++ implementation details

#786 (independent, base: master)

Test plan

  • Document renders correctly on GitHub (especially comparison table in FR-0 context)
  • All phase sections follow consistent template
  • FR-0 EARS criteria are outcome-focused (no C++ syntax in <required>)
  • FR-0 context includes legacy problem statement, 7-technique comparison table, and "丼 problem" narrative
  • FR-4 context opens with cross-reference to FR-0's scoring model analysis
  • References section includes smoothing chapters for SLP3/FSNLP and Chen & Goodman (1999)
  • PR stack table matches actual PRs
  • Test names match actual test suite

Generated with Claude Code

Copilot AI review requested due to automatic review settings February 14, 2026 18:36
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an exceptionally detailed and well-structured requirements document for the Contextual User Model. The document thoroughly covers the problem statement, design, and a phased implementation plan, which will be a great asset for the project. My review includes one high-severity suggestion to address an inconsistency in the reporting of phase statuses to ensure clarity for all stakeholders.

Comment thread requirements.md Outdated
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Issues Found

I've identified 4 critical issues in this requirements document:

  1. PR dependency ordering (line 94): The PR stack table doesn't reflect that this PR depends on #784 being merged first, creating merge strategy ambiguity.

  2. Algorithm logic ambiguity (line 561): Contradictory description of fixedSpan blocking behavior - unclear whether it blocks all candidates at the fixed position or only positions inside the span.

  3. KN formula correctness (line 786): The continuation probability normalization is incorrect - should normalize by sum of N+(w') for words in that reading context, not total unique bigrams N++. This affects all probability calculations.

  4. User data loss risk (line 1012): Phase 4 is marked DONE and saves contextual model data, but Phase 6 migration (backing up UserPhrasesLM) is TODO. Users could lose existing phrase data if Phase 4 ships before migration is implemented.

The first three are documentation correctness issues. The fourth is a potential user data loss scenario that should be addressed before any phase ships to users.

Comment thread requirements.md Outdated
Comment thread requirements.md
Comment thread requirements.md Outdated
Comment thread requirements.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a comprehensive requirements.md document that specifies and tracks the phased design/implementation plan for introducing a contextual, persisted user preference model (KN-smoothed) to replace legacy score-hack mechanisms in McBopomofo.

Changes:

  • Introduces a full multi-phase requirements/specification document (phases 0A–6) with goals, motivations, acceptance criteria, and test summaries.
  • Documents design principles and architecture (session structural fixes, KN backoff scoring, persistence).
  • Captures known limitations, deferred work, and a PR stack plan tying phases to related PRs/commits.

Comment thread requirements.md Outdated
Comment thread requirements.md Outdated
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed requirements.md for critical issues. Found 5 consistency/correctness problems that need resolution:

  1. PR #777 vs #779 inconsistency - Text references PR #777 but table shows #779
  2. Commit hash mismatch - Different commit hashes referenced for same work (9fa53a6 vs 9f9477d)
  3. Circular documentation reference - References "original Phase 1 requirements" within the requirements doc itself
  4. Phase dependency graph contradiction - Linear chain notation doesn't match stated parallel dependencies
  5. Missing PR stack table entry - This PR (#786) should be listed in the table

These are documentation correctness issues that will cause confusion for readers trying to understand the implementation history and phase relationships.

Comment thread requirements.md Outdated
Comment thread requirements.md Outdated
Comment thread requirements.md
Comment thread requirements.md Outdated
Comment thread requirements.md Outdated
@github-actions
Copy link
Copy Markdown

Claude Code Review Failed

The automated Claude review encountered an error and could not complete. You can:

  • Check the workflow logs for details
  • Trigger a manual review by commenting @claude on this PR
  • The review will be retried automatically on the next push

This does not affect the PR approval process.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Issue: Commit References Don't Exist

The document claims phases 0A-4 are "DONE" with specific commits, but those commits don't exist in the repository. All referenced PRs (#779, #780, #781) are still open with different commit SHAs than documented.

This creates correctness issues for anyone relying on this requirements doc to understand implementation status or verify completed work.

Comment thread requirements.md Outdated
@tianjianjiang tianjianjiang force-pushed the docs/user_model_requirements branch from e246baa to c9154c8 Compare February 14, 2026 21:02
@tianjianjiang tianjianjiang changed the title docs(requirements): contextual user model requirements (phases 0-6) docs(requirements): add contextual user model requirements with outcome-focused EARS Feb 14, 2026
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Issues

This requirements document has several issues that could cause confusion about implementation status and architectural assumptions:

  1. Status inconsistencies: Features marked "DONE" reference PRs listed as "Open", creating ambiguity about what's actually implemented
  2. Test status misleading: All tests marked "(Pass)" for features that may not be merged yet
  3. Base branch assumptions: Document references commits and PRs that may not exist in the base branch ancestry
  4. Documentation standard violations: Timestamp format doesn't follow CLAUDE.md requirements

These issues don't affect code correctness but could mislead contributors and AI agents about the current state of the codebase.

Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
@tianjianjiang tianjianjiang force-pushed the docs/user_model_requirements branch from c9154c8 to 8df0535 Compare February 14, 2026 21:58
@tianjianjiang tianjianjiang changed the title docs(requirements): add contextual user model requirements with outcome-focused EARS docs(requirements): add contextual user model requirements with scoring model rationale Feb 14, 2026
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Issues Summary

Found 6 critical issues that need resolution:

1. Phase Status Inconsistency

FR-1 through FR-5 marked "TODO" in phase summary but claim implementation with "(Pass)" test results. Unclear what's actually done vs planned.

2. Non-existent PR References

PR stack references #779-785 as if they exist, but they're future PRs. Document credibility issue.

3. False File Path References

Multiple FRs reference walk_strategy.h/cpp and contextual_user_model.h/cpp that don't exist yet, using past-tense language implying they're implemented.

4. Missing Time Unit in Decay Formula

halfLife=20 lacks unit specification (selections? days? sessions?). Formula cannot be implemented correctly without this.

5. YAGNI Violation

FR-2 claims YAGNI but includes detailed specs for Pruned Viterbi, MMSEG, Segment Viterbi with specific parameters. Either implement them or remove the specs.

6. Memory Safety Issue Misclassified as "Low"

L4 describes stack-allocated LM wrapped in aliasing shared_ptr with no-op deleter - this is a use-after-free vulnerability, not a low-priority limitation. Should be blocker priority.

Most critical: #6 (memory safety) and #1 (status clarity).

Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed requirements.md for critical issues. Found 6 issues requiring attention before merge:

  1. PR reference inconsistency: PR #777 vs #779 for Viterbi walk implementation
  2. Ambiguous phase status: TODO markers conflict with implemented features
  3. Formula notation: Temporal decay formula needs clarification
  4. High-severity correctness issue: Dual model systems (UOM + ContextualUserModel) running simultaneously
  5. Test count verification: Ensure 54 tests matches actual suite
  6. Phase dependency error: Linear sequence doesn't match described parallel dependencies

The dual-model issue (L7) is particularly critical as it creates non-deterministic behavior and should be resolved before FR-6 is considered complete.

Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
@tianjianjiang tianjianjiang force-pushed the build/cpp_standard_enforcement branch from 988b086 to 34143ba Compare February 15, 2026 09:03
@tianjianjiang tianjianjiang force-pushed the docs/user_model_requirements branch from 0ab7122 to edb593e Compare February 15, 2026 09:03
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 6 critical issues requiring fixes:

  1. FR-0 requirement ambiguity: "at minimum 7 techniques" vs "Seven techniques" inconsistency
  2. FR-6 test completeness: Verify 35 XCTests is the complete suite or add qualifier
  3. Phase 4 dependency error: FR-4 incorrectly depends on Phase 2 (should be standalone)
  4. PR stack mismatch: Description mentions #787, stack shows #783; numbering inconsistent
  5. Temporal decay unit missing: halfLife=20 in what units? (seconds/days/observations)
  6. Test numbering confusion: "10 tests (1.5.1-1.5.12)" is actually 12 items, not 10

All issues impact requirements correctness, implementation guidance, or internal consistency.

Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
Comment thread requirements.md
@tianjianjiang tianjianjiang self-assigned this Feb 24, 2026
@tianjianjiang tianjianjiang marked this pull request as draft February 24, 2026 04:55
@tianjianjiang tianjianjiang force-pushed the build/cpp_standard_enforcement branch from 34143ba to bd56fc6 Compare February 26, 2026 17:18
@tianjianjiang tianjianjiang force-pushed the docs/user_model_requirements branch from edb593e to d39c375 Compare February 26, 2026 17:18
@tianjianjiang tianjianjiang changed the base branch from build/cpp_standard_enforcement to docs/agents_guardrails February 26, 2026 17:18
@github-actions
Copy link
Copy Markdown

Claude Code Review Failed

The automated Claude review encountered an error and could not complete. You can:

  • Check the workflow logs for details
  • Trigger a manual review by commenting @claude on this PR
  • The review will be retried automatically on the next push

This does not affect the PR approval process.

@tianjianjiang tianjianjiang force-pushed the docs/user_model_requirements branch from d39c375 to 05b59d5 Compare February 26, 2026 18:02
@tianjianjiang tianjianjiang changed the base branch from docs/agents_guardrails to master February 26, 2026 18:02
@github-actions
Copy link
Copy Markdown

Claude Code Review Failed

The automated Claude review encountered an error and could not complete. You can:

  • Check the workflow logs for details
  • Trigger a manual review by commenting @claude on this PR
  • The review will be retried automatically on the next push

This does not affect the PR approval process.

…ng model rationale

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tianjianjiang tianjianjiang force-pushed the docs/user_model_requirements branch from 05b59d5 to bbf280f Compare February 26, 2026 18:49
@github-actions
Copy link
Copy Markdown

Claude Code Review Failed

The automated Claude review encountered an error and could not complete. You can:

  • Check the workflow logs for details
  • Trigger a manual review by commenting @claude on this PR
  • The review will be retried automatically on the next push

This does not affect the PR approval process.

The stack consists of 3 stacked PRs (#779, #780, #781)
plus 4 independent PRs (#784, #785, #786, #787) targeting
master directly, not "a stack of 6 PRs each building on
the previous".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 1, 2026

Claude Code Review Failed

The automated Claude review encountered an error and could not complete. You can:

  • Check the workflow logs for details
  • Trigger a manual review by commenting @claude on this PR
  • The review will be retried automatically on the next push

This does not affect the PR approval process.

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.

2 participants