@@ -115,25 +115,34 @@ The following Go packages under `pkg/` each require a README.md specification:
115115
116116### Initialize or Load
117117
118- 1 . Check if cache exists:
118+ 1 . Check if cache exists and initialize rotation state :
119119 ``` bash
120- if [ -d /tmp/gh-aw/cache-memory/spec-extractor ]; then
121- echo " Cache found, loading state"
122- cat /tmp/gh-aw/cache-memory/spec-extractor/rotation.json 2> /dev/null || echo " {}"
120+ mkdir -p /tmp/gh-aw/cache-memory/spec-extractor/extractions
121+ if [ -f /tmp/gh-aw/cache-memory/spec-extractor/rotation.json ]; then
122+ echo " Cache found, loading rotation state"
123+ cat /tmp/gh-aw/cache-memory/spec-extractor/rotation.json
123124 else
124- echo " Initializing new cache"
125- mkdir -p /tmp/gh-aw/cache-memory/spec-extractor/extractions
125+ echo " Initializing default rotation state"
126+ cat > /tmp/gh-aw/cache-memory/spec-extractor/rotation.json << EOF
127+ {
128+ "last_index": 0,
129+ "last_packages": [],
130+ "last_run": "",
131+ "total_packages": 20
132+ }
133+ EOF
126134 fi
127135 ```
128136
129- 2 . Load ` rotation.json ` to determine which packages to process next:
137+ 2 . Load ` rotation.json ` to determine which packages to process next.
138+ Example state ** after processing** ` envutil,fileutil,gitutil,logger ` :
130139 ``` json
131- {
132- "last_index" : 4 ,
133- "last_packages" : [" envutil" , " fileutil" ],
134- "last_run" : " 2026-04-12" ,
135- "total_packages" : 20
136- }
140+ {
141+ "last_index" : 4 ,
142+ "last_packages" : [" envutil" , " fileutil" , " gitutil " , " logger " ],
143+ "last_run" : " 2026-04-12" ,
144+ "total_packages" : 20
145+ }
137146 ```
138147
1391483 . Load ` package-hashes.json ` to detect changes:
@@ -146,23 +155,27 @@ The following Go packages under `pkg/` each require a README.md specification:
146155
147156## Phase 1: Select Packages (Round Robin)
148157
149- Select ** 3- 4 packages** for this run using round-robin with change detection :
158+ Select ** exactly 4 packages** for this run using deterministic round-robin:
150159
151- 1 . ** Get current git hashes** for all packages:
152- ``` bash
153- for dir in $( find pkg/* -maxdepth 0 -type d | sort) ; do
154- pkg=$( basename " $dir " )
155- hash=$( git log -1 --format=%H -- " $dir " 2> /dev/null || echo " none" )
156- echo " $pkg : $hash "
157- done
158- ```
160+ 1 . ** Use the fixed package order** listed in the table above (20 total packages).
161+
162+ 2 . ** Read** ` last_index ` from ` rotation.json ` (default ` 0 ` ).
163+ - ` last_index ` means the ** next package index to process** , not the previously processed index.
164+
165+ 3 . ** Select the next 4 packages** using modular arithmetic:
166+ - Package 1 index: ` last_index `
167+ - Package 2 index: ` (last_index + 1) % 20 `
168+ - Package 3 index: ` (last_index + 2) % 20 `
169+ - Package 4 index: ` (last_index + 3) % 20 `
159170
160- 2 . ** Priority selection** :
161- - ** Priority 1** : Packages with source changes since last extraction
162- - ** Priority 2** : Packages without a README.md
163- - ** Priority 3** : Next packages in round-robin rotation
171+ 4 . ** Update rotation state** after processing:
172+ - ` last_index = (last_index + 4) % 20 `
173+ - ` last_packages = [pkg1, pkg2, pkg3, pkg4] `
164174
165- 3 . ** Update rotation state** in ` rotation.json `
175+ 5 . ** Worked examples** :
176+ - If ` last_index = 0 ` , process indices ` 0,1,2,3 ` , then set ` last_index = 4 `
177+ - If ` last_index = 16 ` , process indices ` 16,17,18,19 ` , then set ` last_index = 0 `
178+ - If ` last_index = 18 ` , process indices ` 18,19,0,1 ` , then set ` last_index = 2 `
166179
167180## Phase 2: Extract Package Specification
168181
316329
317330If any README.md files were created or updated, create a PR:
318331
319- ** PR Title** : ` Update package specifications for <pkg1>, <pkg2>, <pkg3> `
332+ ** PR Title** : ` Update package specifications for <pkg1>, <pkg2>, <pkg3>, <pkg4> `
320333
321334** PR Body** :
322335``` markdown
@@ -356,13 +369,13 @@ This PR updates README.md specifications for the following packages:
3563691 . ** W3C specification style** : Write clear, precise, normative documentation
3573702 . ** Source-verified only** : Every statement must be verifiable from source code
3583713 . ** Preserve existing content** : Never overwrite manually-written README.md sections
359- 4 . ** Round-robin fairness** : Process packages in rotation order, prioritizing changes
372+ 4 . ** Round-robin fairness** : Process packages in deterministic rotation order
3603735 . ** Cache efficiency** : Use cache-memory to avoid re-analyzing unchanged packages
3613746 . ** Filesystem-safe filenames** : Use ` YYYY-MM-DD-HH-MM-SS ` format for timestamps in cache files
362375
363376## Success Criteria
364377
365- - ✅ 3- 4 packages analyzed per run (from all packages under ` pkg/ ` )
378+ - ✅ Exactly 4 packages analyzed per run (from all packages under ` pkg/ ` )
366379- ✅ README.md created or updated for each analyzed package
367380- ✅ All documented APIs verified against source code
368381- ✅ Cache memory updated with extraction state
0 commit comments