fix: WorkCompletionLearning reads nonexistent state files#1050
Open
qozle wants to merge 1 commit intodanielmiessler:mainfrom
Open
fix: WorkCompletionLearning reads nonexistent state files#1050qozle wants to merge 1 commit intodanielmiessler:mainfrom
qozle wants to merge 1 commit intodanielmiessler:mainfrom
Conversation
…lmiessler#972) Two bugs prevented the hook from ever generating learning files: 1. findStateFile() looked for current-work.json / current-work-{sessionId}.json but nothing in PAI creates these files. Replaced with findWorkSession() that reads work.json (populated by PRDSync hook) and matches by sessionUUID. 2. ISC regex matched "## IDEAL STATE CRITERIA" but PRD format v2.0 uses "## Criteria". Updated regex to accept both headers. Also added field mapping in parseYaml() for v2.0 frontmatter fields (task->title, slug->id, started->created_at). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #972
Problem
WorkCompletionLearning.hook.tsnever generates learning files due to two bugs:findStateFile()looks for files that don't exist. It searches forMEMORY/STATE/current-work.jsonorcurrent-work-{sessionId}.json, but nothing in PAI creates these files. The hook always exits with "No active work session."ISC regex doesn't match PRD v2.0 format. The regex looks for
## IDEAL STATE CRITERIAbutPRDFORMAT.mdv2.0 defines the section as## Criteria. ISC content is never extracted.There's also a field name mismatch: PRD frontmatter uses
task/slug/startedbut theWorkMetainterface expectstitle/id/created_at.Fix
Replace
findStateFile()withfindWorkSession()that readswork.json(the actual state file, populated by PRDSync hook) and matches sessions bysessionUUID.Update the ISC regex to accept both
## IDEAL STATE CRITERIA(legacy) and## Criteria(v2.0).Add field mapping in
parseYaml()so v2.0 frontmatter fields get mapped to the interface fields the rest of the hook expects.Verification
PRDSync.hook.tswrites toMEMORY/STATE/work.jsonviasyncToWorkJson()inprd-utils.tsprd-utils.tscountCriteria()uses## Criteriaheader (line 61), matching the fixwork.jsonregistry keys sessions by slug (= the WORK directory name), sosession_dirmapping is correct