Skip to content

Merge working-tree manifests with staged overrides and deduplicate Prolog codec#139

Merged
Looted merged 14 commits intomasterfrom
develop
Apr 7, 2026
Merged

Merge working-tree manifests with staged overrides and deduplicate Prolog codec#139
Looted merged 14 commits intomasterfrom
develop

Conversation

@Looted
Copy link
Copy Markdown
Owner

@Looted Looted commented Apr 6, 2026

No description provided.

Copilot AI and others added 3 commits April 6, 2026 11:06
…e codec toPrologString

- buildManifestLookup() now pre-populates the manifest lookup from the
  working-tree config.paths.symbols file before processing staged manifests.
  This prevents code-only staged changes from incorrectly failing traceability
  when symbols.yaml is not staged but is already linked in the KB.
- Remove duplicate toPrologString() in temp-kb.ts and import the shared
  implementation from ../prolog/codec to keep Prolog serialisation consistent.
- Add .changeset/fix-manifest-lookup-and-prolog-codec.md for release tracking.

Agent-Logs-Url: https://github.com/Looted/kibi/sessions/d11497ec-c000-4b40-978d-2f5d5eb012e4

Co-authored-by: Looted <6255880+Looted@users.noreply.github.com>
…ew-comments

fix(cli): merge working-tree manifest into staged lookup + dedup toPrologString
Copilot AI review requested due to automatic review settings April 6, 2026 11:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves kibi check --staged traceability resolution by incorporating existing symbol IDs/relationships from the working tree manifest (before applying staged-manifest overrides), and removes duplicated Prolog string encoding to keep serialization consistent across the CLI.

Changes:

  • Pre-populate manifestLookup from the working-tree config.paths.symbols manifest, then apply staged symbols.yaml overrides.
  • Deduplicate toPrologString by reusing the shared implementation from ../prolog/codec.
  • Add a Changeset for a kibi-cli patch release describing both fixes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/cli/src/traceability/temp-kb.ts Removes the local toPrologString helper and imports the shared Prolog codec version.
packages/cli/src/commands/check.ts Enhances staged-check manifest lookup by seeding it from the working tree manifest prior to staged override parsing.
.changeset/fix-manifest-lookup-and-prolog-codec.md Documents the behavior change and Prolog codec deduplication for release notes.

Comment thread packages/cli/src/commands/check.ts Outdated
} catch (e) {
// Ignore working-tree manifest parsing errors; staged-only fallback still applies
const msg = e instanceof Error ? e.message : String(e);
console.debug(`[kibi] skipping working-tree manifest ${absSymbolsPath}: ${msg}`);
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.debug here will emit output unconditionally when the working-tree manifest is invalid, even if the user didn’t enable tracing. Elsewhere (e.g. traceability/git-staged.ts) debug logging is gated behind KIBI_TRACE/KIBI_DEBUG; consider gating this message similarly or routing it through the existing trace mechanism to avoid noisy/unstable CLI output.

Suggested change
console.debug(`[kibi] skipping working-tree manifest ${absSymbolsPath}: ${msg}`);
if (process.env.KIBI_TRACE || process.env.KIBI_DEBUG) {
console.debug(`[kibi] skipping working-tree manifest ${absSymbolsPath}: ${msg}`);
}

Copilot uses AI. Check for mistakes.
Comment on lines +79 to +88
// Pre-populate lookup from working-tree manifests so that code-only changes
// (where symbols.yaml is not staged) still resolve to the correct symbol IDs
// and relationships already defined on disk.
const config = loadConfig(process.cwd());
const symbolsRelPath = config.paths.symbols;
if (symbolsRelPath) {
const absSymbolsPath = path.resolve(process.cwd(), symbolsRelPath);
if (existsSync(absSymbolsPath)) {
try {
const entries = extractFromManifest(absSymbolsPath);
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is meant to fix the case where code is staged but symbols.yaml is not; however, the existing --staged tests appear to stage symbols.yaml along with the code. Please add a test that commits a valid symbols.yaml, then stages only a code change, and asserts kibi check --staged still resolves the symbol ID/relationships from the working tree manifest (no hash fallback).

Copilot uses AI. Check for mistakes.
@Looted
Copy link
Copy Markdown
Owner Author

Looted commented Apr 6, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

@Looted I can’t apply these changes because the pull request’s branch is the repository’s default branch, which I’m not allowed to push to directly.

You can ask me to create a new pull request with the requested changes instead and I'll open a separate PR on a new branch.

@Looted
Copy link
Copy Markdown
Owner Author

Looted commented Apr 6, 2026

@Looted I can’t apply these changes because the pull request’s branch is the repository’s default branch, which I’m not allowed to push to directly.

You can ask me to create a new pull request with the requested changes instead and I'll open a separate PR on a new branch.

@copilot Please create a new PR with this work.

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

@Looted I've opened a new pull request, #140, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 9 commits April 6, 2026 11:24
…_DEBUG and add test for code-only staged check

Agent-Logs-Url: https://github.com/Looted/kibi/sessions/93b43b29-7204-4f56-82c3-399980819276

Co-authored-by: Looted <6255880+Looted@users.noreply.github.com>
fix(cli): gate working-tree manifest debug log and add code-only staged check test
- Use path.resolve instead of path.join in repo-posture.ts and
  workspace-health.ts so absolute configured doc roots in .kb/config.json
  are honored and no longer trigger false-positive bootstrap warnings.
- Rebuild packages/cli/src/prolog/codec.js so toPrologAtom and
  toPrologString are available as named exports at runtime, fixing CLI
  traceability test imports.
- Add missing toPrologAtom/toPrologString mock exports in
  service.test.ts to prevent Bun mock.module leakage breaking other
  test files in full-suite runs.
- Add regression test for healthy absolute custom doc roots and add
  staged symbol traceability comments to codec.js.
- workspace-health.ts: restore the legacy >2 missing dirs threshold
  for root_partial workspaces so small gaps (e.g. flags/events) do not
  trigger bootstrap nags. This fixes the ~/projects/align regression.
- opencode-comment-guidance e2e: bootstrap temp projects with .kb/config.json
  and required doc directories so the packed plugin sees root_active posture
  and injects comment guidance as expected.
- discovery-shared.test.ts: add mock.restore() in afterEach to prevent
  the MockPrologProcess mock from leaking into temp-kb.test.ts during
  full-suite runs.
- service.test.ts: add mock.restore() in beforeEach to prevent the
  prolog/codec mock from leaking into other tests.

This fixes the suite-order-dependent Prolog query failure in temp-kb
(projectStagedEntities retract timeout) that only occurred in bun test v1.3.6 (d530ed99)
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ .kb/ directory already exists, skipping creation
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ .kb/ directory already exists, skipping creation
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
📦 Packing packages...
  Packing packages/core...
    → kibi-core-0.4.0.tgz
  Packing packages/cli...
    → kibi-cli-0.5.0.tgz
  Packing packages/mcp...
    → kibi-mcp-0.6.0.tgz
📥 Bootstrapping shared packed test installation...
✓ Created .kb/ directory structure
✓ Created branches/my-branch/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Added .kb/ to .gitignore
✓ Copied 1 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents but not in isolation.
The  script and Docker entrypoint were running bun test v1.3.6 (d530ed99)
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ .kb/ directory already exists, skipping creation
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ .kb/ directory already exists, skipping creation
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
📦 Packing packages...
  Packing packages/core...
    → kibi-core-0.4.0.tgz
  Packing packages/cli...
    → kibi-cli-0.5.0.tgz
  Packing packages/mcp...
    → kibi-mcp-0.6.0.tgz
📥 Bootstrapping shared packed test installation...
✓ Created .kb/ directory structure
✓ Created branches/my-branch/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Added .kb/ to .gitignore
✓ Copied 1 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents
✓ Created .kb/ directory structure
✓ Created branches/main/ directory
✓ Created config.json with default paths
✓ Added .kb/ to .gitignore
✓ Copied 3 schema files
✓ Installed git hooks (pre-commit, post-checkout, post-merge, post-rewrite)

Kibi initialized successfully!
Next steps:
  1. Run 'kibi doctor' to verify setup
  2. Run 'kibi sync' to extract entities from documents without , so they used Bun's default 5000ms per-test
timeout. Under full-suite load, integration tests that spawn swipl processes
(e.g. ) can exceed 5 seconds and fail intermittently.

The  script already used ; snip this change makes
 and the Docker test runner consistent with that configuration,
fixing the last intermittent timeout failure.
@Looted
Copy link
Copy Markdown
Owner Author

Looted commented Apr 7, 2026

@copilot apply changes based on the comments in this thread in a new pr

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

@Looted I've opened a new pull request, #141, to work on those changes. Once the pull request is ready, I'll request review from you.

@Looted Looted merged commit 5fe6b07 into master Apr 7, 2026
6 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.

3 participants