okf index leaves a stale index.md when a directory's last concept is deleted

Open
#67 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
dart
Domain
cli

Research direction

Start in lib/src/index_generator.dart at OkfIndexGenerator.generate, especially the entries.isEmpty case, then trace how index generation compares and writes existing index.md files. Reproduce the scenario with okf index and --check after deleting the last concept. Done means an empty directory index is removed or rewritten, and --check reports the existing stale index.

Written by the indexing model from the issue text.

Description

Summary

When a directory's last concept is deleted, the index.md left in that directory is never updated or flagged. okf index reports "Indexes are current." and okf index --check exits 0, so the stale index keeps listing a directory that no longer exists.

Reproduce (okf 0.5.0)

  1. A bundle with one concept at specs/seats/spec.md.
  2. okf index specs --declare-version 0.2. This writes specs/index.md, which lists seats/.
  3. rm -rf specs/seats
  4. okf index specs --declare-version 0.2 prints Indexes are current.
  5. okf index specs --check exits 0, and okf validate specs --strict prints OK: 0 concept(s) validated.
  6. specs/index.md still contains * [seats](seats/index.md) - …

If a second concept remains in the bundle, the same deletion regenerates the root index correctly. Only the "no entries left" case is affected.

Cause

OkfIndexGenerator.generate in lib/src/index_generator.dart skips directories without entries:

if (entries.isEmpty) {
  continue;
}

Nothing is generated for that path, so the writer never compares or rewrites the index.md already on disk, and check mode has nothing to report.

Expected

For an existing index.md whose directory has no entries, okf index --check reports it as stale, and okf index either removes it or rewrites it with no entries (keeping okf_version at the root).

Dominant language
Dart
Stars
0
Forks
0
Avg merge
4h 39m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from btwld/okf

All issues in btwld/okf

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.