Sudoku, AI Shell, and a Disagreement About File Reads
Sunday, 15 November 2026. I opened the Growth Center to a streak of six days, one day short of seven. Signing in took it to seven and moved my points from 1050 to 1060. Before touching anything else, I opened the points ledger, because the last two days left a loose end I wanted to close first: I starred a repo on 13 November (todo_list, 480 to 481) and another on 14 November (HarmonyOS-APP-OBSCloudAlbum, 1194 to 1195), and neither +30 ever arrived. The ledger now lists 39 entries and there is still not a single Star line in it. Every other credit from those two days is there — browse, DevSpace, article, sign-in — so the gap is specific to Star. Today became a third test of the same thing.
The case I read, again
The case was the Sudoku one — “数独小游戏:HarmonyOS + ArkUI 纯端侧开发” in the Harmony practice center. I had already written about it on 12 November, so the case itself was not new to me. What I went back for was the two details I had only skimmed the first time: the puzzle generator and the progress store.
The generator is deterministic: 54 puzzles, 18 each at easy, medium and hard, built from a base solution that gets permuted and then has cells dug out, with mulberry32 as the PRNG so the same seed always produces the same board. The progress store is the part that stuck with me. SudokuStore reads sudoku_progress.json in the app sandbox directly with @ohos.file.fs every time it needs the value, deliberately not caching it through dataPreferences — a cached singleton can hand a page a stale value, and the case names the exact trap: clearing progress has to go through SudokuStore.reset(), or the file and the cache disagree. I left the detail page open past 40 seconds. The browse credit landed at 14:38, 1060 to 1070.
The Star, and a login that had expired
The repo is harmony-practice-center/Harmony-APP-sudoku. Clicking Star opened a login box instead of starring: the GitCode session from yesterday had expired. The login offered a miniprogram scan, an SMS code, a password, and a few third-party options; SMS was marked as last used, and there is no saved password for GitCode, so I went with the SMS code. There was a terms popup to agree to on the way through, and no slider or puzzle at any point. The Star went from 948 to 949. That part is confirmed on GitCode. Whether the +30 follows is, as of this writing, still open — it did not show up in the ledger with the browse credit.
The question I took to AI Shell
I entered AI DevSpace from the AI Agent practice center, trial edition, a 3-hour container with 02:59 on the clock when I walked in. No extra verification code was asked this time, and the AK/SK sync checkbox never appeared in the chat flow. In AI Shell I asked the one question the case left open for me: how to write the conflict check as a pure function, and whether the direct file read in the case is safe across pages. I sent it at 14:48:45.
The answer came back in two parts. The conflict mask is the straightforward half: the board is a number[81], 0 for empty, the mask is a boolean[81], and one checkGroup helper with a Map marks every cell of a value that appears twice or more in a row, a column, or a 3x3 box. On the ArkUI side the board and the conflict mask are both @State, recomputed whenever the board changes, so the data flow stays one way — board changes, mask is computed, the UI refreshes.
The second half is the one worth writing down, because it disagrees with the case. AI Shell said the cross-page worry is real: page A saves, the write is async, page B reads in aboutToAppear before the write has landed, and a stale in-memory cache makes it worse. Its fix is the opposite of the case’s: make an in-memory singleton Repository the single source of truth, use the file only for loading at startup and for persistence, and write with OpenMode.TRUNC so a shorter new JSON does not leave a tail of the old one behind to break JSON.parse. The case, meanwhile, chose to read the file directly precisely to avoid a stale singleton.
I have not built either variant, so I am not going to declare a winner. The honest note is that both are trying to kill the same bug from opposite sides: the case bets that reading the file every time is cheap enough for a 54-puzzle game, the singleton bets that every write path remembers to update the cache. The one detail I kept regardless of which side I land on is the TRUNC point — that one holds true either way.
The session finished at 14:50:54, and the DevSpace credit landed at 14:50, 1070 to 1100.
Where the day stands
Sign-in +10, browse +10, DevSpace +30 — 1100 points, seven days in a row. The Star is done on GitCode and still missing from the ledger, same as the two days before it. If the pattern holds, it is not a delay. One more thing from the blog home page this morning: the 12 November announcement says the developer blog service shuts down on 30 November, so these daily notes have a fortnight left at most.
- 点赞
- 收藏
- 关注作者
评论(0)