2.5 KiB
2.5 KiB
Project Context Model Design
Summary
Aggregate views need stable project identity attached to each issue so cross-project Kanban, timeline, and session views can filter and display project metadata consistently. This design adds a normalized ProjectContext payload to every issue returned from read flows while keeping the raw JSONL format untouched.
Requirements
- Use existing Windows-safe path normalization for stable identity.
- Attach project identity on every issue returned from read services.
- Include fields:
key,root,displayPath,name,source,addedAt. - Default single-project reads to
source="local"andaddedAt=null.
Data Model
export type ProjectSource = 'local' | 'registry' | 'scanner';
export interface ProjectContext {
key: string; // windowsPathKey(root)
root: string; // canonicalizeWindowsPath(root)
displayPath: string; // toDisplayPath(root)
name: string; // path.basename(root)
source: ProjectSource;
addedAt: string | null;
}
export type BeadIssueWithProject = BeadIssue & { project: ProjectContext };
Construction
- Add a helper (e.g.,
buildProjectContext) that acceptsprojectRoot,source, andaddedAt. - Normalize the root with
canonicalizeWindowsPath, compute the key withwindowsPathKey, display path withtoDisplayPath, and name frompath.basename. - No filesystem checks are required; this is identity metadata only.
Read Flow Integration
- Update
readIssuesFromDiskto attachprojectto each parsed issue. - Default
projectRoottoprocess.cwd()when not provided. - Keep the existing
BeadIssueshape for raw parsing; project context is added in read services only.
Error Handling
- If
projectRootis empty, throw a clear error early inbuildProjectContext. - Otherwise, treat normalization as pure string ops and do not swallow exceptions.
Tests
- Add unit tests for
buildProjectContextfield derivation (key/root/displayPath/name/source/addedAt). - Update
readIssuesFromDisktests to assertprojectis attached with expected fields.
Alternatives Considered
- Wrapper object
{ project, issue }
Pro: explicit separation; Con: more refactors across UI filtering and query shapes. metadata.projecton issues
Pro: zero type changes; Con: weak typing and harder discoverability.- Chosen:
issue.projectfield
Clear typing, predictable access, and minimal friction for UI + aggregate queries.