[PR #265·266] A Spec and Implementation Plan Written Before Head Office Answered: Choosing a Structure That Fits Any Answer
These two PRs changed no code; they only wrote documents. PR 265 is the spec draft (a design document that settles what to build) for Detail 4 (quests, routines, head office review), and PR 266 turns that spec into implementation plans for the server, admin web, and customer app. The design material from head office hadn’t all arrived yet, so this was prepared ahead so that plans could be written on the day development starts.
- PR 265: A Claude session on my Windows computer (Claude Opus 5.5) wrote it at the lead session’s request. One sub-agent (a helper Claude that takes a share of the work) on the same model reviewed the spec. Codex was not used.
- PR 266: A Claude session on the same computer (Claude Opus 5.5) wrote it. No sub-agents or Codex were used.
PR 265: The spec draft
What was done and why
The spec was written only from material at hand: the existing specification and the quest, routine, and review screens in the design documents, the quest candidate sheet (43 rows) and proposal from an older planning folder, and answers head office had already given. Before writing, Claude showed the outline and seven major decisions, and I approved them with “go with the recommendations.”
What was chosen, and what was dropped
- A structure that fits any answer: The rule for what happens when the quest list changes decides the data structure, but head office hadn’t answered yet. So a structure that works whatever the answer was chosen: the list is stored as versioned sets, each cycle (one operating period from start to end) is pinned to a version, task text is copied when a task is created, and there is a “move to the new version” button.
- Dropped alternative — editing one table in place: changes would spread straight to sites already in progress.
- Dropped alternative — copying the whole list for each cycle: one typo would mean fixing every copy.
- Conditional quests later: Conditional quests such as “if a reading looks abnormal, measure again” were moved to the next detail. Without warning thresholds, “abnormal” can’t be defined.
- A destination for every sheet row: The 43 rows were split into 22 quests, 3 quests not included, 12 routine candidates, and 6 rows dropped. Numbers that weren’t confirmed were removed from the text.
- A pinning point that changed after approval: At approval the plan was to “pin the version when a cycle starts,” but while writing, the sheet turned out to have preparation quests starting 30 days before the start. So the pinning point became “when the cycle is created,” and it was marked separately for me to confirm.
- Routines piling up: Missed routines would pile up day after day. When a new routine appears, the previous one is closed as “no record.” Quests stay until they are done.
How it was checked
- The sheet rows were recounted (22 + 3 + 12 + 6 = 43).
- The cycle states (planned, active, closed) and date fields (planned start, start, planned end) were confirmed in the server code.
- The sub-agent read the spec as a developer and listed 5 questions to settle before planning and 3 places that contradicted each other. All were reflected in the spec. For example, the cutoff date for quests became the version-pinning date, site-level routines leave the cycle field empty, and routines done twice a day don’t close each other within the same day. Only the fact that the code has no way yet to end a cycle was left for me to confirm.
- The term check (
check-terms) passed. - The full
npm run verifypassed on the third run (13 min 44 s, 862 server tests). The first run failed because packages weren’t installed in the work folder, and the cause of the second failure, afternpm ci(package install), wasn’t found. The third passed without any changes.
PR 266: The implementation plans
What was done and why
To hand development out task by task, a plan that fixes table names, request paths, data types, and the tests and working style for each task has to come first. As in Detail 3, one plan was written per track — three in all: server (11 tasks), admin web (7 tasks), and customer app (6 tasks).
What was chosen, and what was dropped
- Rules in one file of pure functions: Quest dates, routine intervals, state changes, progress counts, and sorting rules are gathered in one file of pure functions (functions that always give the same result for the same input and touch nothing outside). This is where most of the number and state rules live, so the side writing tests and the side implementing must be separate. It’s the same approach as the input calculation in Detail 3.
- “Never create twice” with a unique constraint instead of a lock: To keep the same task from being created twice, a database unique constraint (a rule that keeps two rows from having the same value) and
INSERT … ON CONFLICT DO NOTHING(a save that does nothing if the row already exists) are used. The scheduled run and the first lookup call the same function, so there’s no lock ordering to reason about. - Scheduled runs with a timer inside the server: It checks the Korean date every 5 minutes. It’s the same approach as the existing periodic jobs, so no new package is needed.
- Dropped alternative — adding a scheduling package: more packages, and setting the clock in tests gets harder.
- One request per tab for today’s tasks: This can hold the spec’s “quests arrived but routines failed” state as is.
- Dropped alternative — both tabs in one request: holding a state where only one side failed makes the response shape complicated.
- Comparing “the same content” for a request number with a hash: This is the server-side fix for the problem PR 261 couldn’t fully block in the app (the same request number with different content). A hash of the request body (a short fingerprint of the content) is stored and compared. The column is added as nullable, so older rows aren’t compared.
- Priorities carried straight into the task table: The spec’s first and second priorities were moved into the task table. Each second-priority item is a separate task, so if it slips, only that task moves to the next detail.
How it was checked
- Each of the spec’s 9 completion criteria was traced to the task and test that confirms it.
- Confirmed in the code: how the 6 Detail 3 save paths handle repeated requests, the three places that create cycles, the latest migration (a database structure change file) number, how periodic jobs run, and the app’s bottom menu and related tab screens.
- While reviewing its own work, Claude found that the sort function used a column the table didn’t have, and added an order column to the task table.
- The full
npm run verifyresult isn’t in the devlog, so it is unverified (the devlog only says it goes in the PR description).
Lessons
- When the answer isn’t in yet, choose a structure that fits any answer. Versioned sets and copied text hold up whichever answer comes.
- Start task date rules with “what happens if the date is missed.” A quest comes only once per cycle, so if it isn’t created that day, it never shows up again. This gap was found while writing the spec’s failure table.