Skip to content

fix(hive): avoid rewriting generated docs during runtime operations - #474

Merged
chaitanyagiri merged 1 commit into
HarnessMD:mainfrom
HsienW:fix/hive-generated-doc-refresh
Oct 2, 2026
Merged

chaitanyagiri merged 1 commit into
HarnessMD:mainfrom
HsienW:fix/hive-generated-doc-refresh

Conversation

@HsienW

@HsienW HsienW commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What & why

  • ensureHive() currently mixes two responsibilities: ensuring the Hive structure exists and refreshing generated docs. That means ordinary runtime paths such as writeTasks() and ensureAgent() can unexpectedly overwrite PROTOCOL.md and COMMANDS.md.

  • This change makes runtime setup non destructive by creating those files only when missing, and moves explicit refresh behavior to the bootstrap path. It also adds generated notices and focused regressions so both the runtime preservation and bootstrap refresh contracts stay covered.

  • Closes ensureHive() rewrites PROTOCOL.md/COMMANDS.md outside bootstrap, and neither file is marked generated #451

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Docs
  • Build / CI

Evidence

Before

The same focused regression was run against the pre fix production implementation. Both ordinary runtime paths reproduced the overwrite behavior.

2026-09-08-041124

After

The generated doc lifecycle is now separated from ordinary Hive setup. Runtime operations preserve existing docs, while bootstrap still performs the explicit refresh.

2026-09-08-021750

How I tested it

  • OS: Windows 11
  • Version: 0.4.6
  • Steps:
    • node --test --test-name-pattern="writeTasks|ensureAgent" test/hive-generated-docs.test.cjs
      • Before fix: 0 passed, 2 failed as expected
    • node --test test/hive-generated-docs.test.cjs
      • After fix: 6/6 passed
    • npm run typecheck
      • Passed
    • npm run build
      • Passed
    • git diff --check
      • Passed
    • npm run test:focused

Checklist

  • Before and after evidence is attached above, under both headings.
  • npm run typecheck passes.
  • npm run test:focused passes.
  • npm run build succeeds.
  • This PR is one change. Unrelated fixes belong in their own PR.
  • I read the diff myself before opening this, and there is no debug output,
    commented-out code, or unrelated formatting churn in it.
  • Any new UI derives from DESIGN.md / tokens.ts — no ad-hoc colors,
    spacing, or fonts.
  • If I added art, it's my own or compatibly licensed, and listed in
    ATTRIBUTION.md.

- make ensureHive() create PROTOCOL.md and COMMANDS.md only when missing

- add an explicit refreshGeneratedDocs() path for generated hive docs

- refresh generated docs only during bootstrap

- add generated notices to PROTOCOL.md and COMMANDS.md

- add regressions for writeTasks(), ensureAgent(), explicit refresh, and missing-doc recovery
DannyBaanks pushed a commit to DannyBaanks/ISyCo-Worlds that referenced this pull request Sep 25, 2026
…h on bootstrap

M1 property 5. Upstream evidence: HarnessMD/munder-difflin#474 (cited as
evidence of the property, NOT ported as code).

ensureHive() mixed two responsibilities: making the hive skeleton exist, and
refreshing the two generated docs. But ensureHive is on the runtime path —
ensureAgent and writeTasks both call it — so saving one card or spawning one
agent silently rewrote PROTOCOL.md and COMMANDS.md, the files every agent is
told to treat as the authority. A local edit made on a real floor was reverted
with nothing in the log to say so.

Split in two: ensureHive creates them when absent, and the new
refreshGeneratedDocs() replaces them. The refresh keeps its original purpose —
this repo's own hive once carried a protocol file from the day it was
initialised, so every protocol change since had reached new hives only — by
running where a change can actually land, app start. bootstrapHiveServices()
calls it right after ensureHive, and nothing on the runtime path does.

New suite test/hive-generated-docs.test.cjs: a fresh hive still gets both
files, writeTasks and ensureAgent leave a locally edited copy alone, the
explicit refresh does replace it, and the refresh is wired to app bootstrap.

  before (docs rewritten inside ensureHive): 1 pass / 4 fail
  after:                                     5 pass / 0 fail

Gates: typecheck exit 0, check:links ok, test:focused 1045 pass / 0 fail /
6 skipped, build exit 0, git diff --check clean.
@chaitanyagiri
chaitanyagiri merged commit 6f406b9 into HarnessMD:main Oct 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ensureHive() rewrites PROTOCOL.md/COMMANDS.md outside bootstrap, and neither file is marked generated

2 participants