Skip to content

fix: resolve 14 test failures, add coverage tooling, and align docs with codebase#35

Merged
Coldaine merged 2 commits into
mainfrom
fix/test-remediation-and-docs-consistency
Apr 19, 2026
Merged

fix: resolve 14 test failures, add coverage tooling, and align docs with codebase#35
Coldaine merged 2 commits into
mainfrom
fix/test-remediation-and-docs-consistency

Conversation

@Coldaine

@Coldaine Coldaine commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes all 14 test failures on main, adds missing test infrastructure, and aligns documentation with the current codebase state.

Test Fixes (14 failures → 0)

Missing exports from prompts.ts (5 failures)

  • Added ShadowContextPacket type and buildUserMessage function to prompt-builder.ts (not prompts.ts, since that file is generated and shouldn't contain hand-written code)
  • Re-exported SHADOW_SYSTEM_PROMPT from prompt-builder.ts for import convenience
  • Updated shadow-mcp-server.ts to import from prompt-builder instead of prompts

Missing packContext in context-packager.ts (7 failures)

  • Added packContext function with richer return shape: { packet, truncated, approximateTokens }
  • Refactored buildContextPacket to delegate to packContext (eliminates ~90 lines of duplication)
  • Added PackContextOptions and PackContextResult interfaces

Test expectation mismatches (2 failures)

  • Fixed inference-contract.test.ts tool history expectations to match actual tool_startedtool_completed/tool_failed pairing behavior

Infrastructure

  • test:coverage script: Added to package.json with @vitest/coverage-v8 dependency (61% statement coverage)
  • CI: Added npm test step to prompt-parity.yml workflow (previously only checked prompt sync)
  • Pre-commit hook: Now runs npm test in addition to prompts:check
  • .gitignore: Added coverage/ directory

Documentation Alignment

  • architecture.md: Updated Phase 1 to "Completed", Phase 2 status to reflect inference scaffolding on main
  • domain-inference.md: Updated file map to match actual exports, removed non-existent opencode-client.ts
  • getting-started.md: Corrected project structure description (Canvas2D renderer not yet on main)
  • todo.md: Marked merged PRs as completed, updated status tracking
  • AGENTS.md: Clarified third_party/ is reference material, not runtime dependency

Verification

  • ✅ 145/145 tests pass
  • ✅ Build succeeds (Vite renderer + esbuild Electron)
  • ✅ Prompt artifacts in sync
  • ✅ Coverage tooling functional

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

PR Summary: Fix 14 Test Failures, Add Coverage Tooling, and Align Docs with Codebase

Overview

This PR resolves 14 failing tests, implements missing inference infrastructure exports, adds coverage tooling and CI integration, and updates documentation to reflect the current codebase state. All 145 tests now pass.

Key Changes by Category

🔧 Core Inference Module Updates

File Changes
prompt-builder.ts • Re-exported SHADOW_SYSTEM_PROMPT from ./prompts
• Added ShadowContextPacket type (canonical inference context shape)
• Implemented buildUserMessage(packet, options) with privacy controls
• Added BuildUserMessageOptions interface
buildInferenceRequest() now uses local buildUserMessage implementation
context-packager.ts • Switched ShadowContextPacket import source to prompt-builder
• Introduced packContext(state, events, options) returning { packet, truncated, approximateTokens }
• Refactored buildContextPacket() to delegate to packContext().packet
• Added PackContextOptions (configurable tokenBudget, recentWindowSize)
• Added PackContextResult interface
• Dynamic truncation logic based on approximateTokens vs tokenBudget
shadow-mcp-server.ts • Updated SHADOW_SYSTEM_PROMPT import source from prompts to prompt-builder

🧪 Test Infrastructure

File Changes
package.json • Added test:coverage script: vitest run --coverage
• Added @vitest/coverage-v8 dev dependency
inference.test.ts • Updated SHADOW_SYSTEM_PROMPT import source to prompt-builder
inference-contract.test.ts • Updated imports for SHADOW_SYSTEM_PROMPT, buildUserMessage, ShadowContextPacket from prompt-builder
• Adjusted "builds tool history" test: added tool_started event for bash; updated expectations from 3-entry to 2-entry toolHistory
.gitignore • Added coverage/ directory

🚀 CI/CD & Pre-commit Enhancements

File Changes
prompt-parity.yml • Renamed workflow from "Prompt Parity" to "CI"
• Renamed job from prompt-parity to test
• Added npm test step
• Added npm run build step in shadow-agent directory
.husky/pre-commit • Added npm test --prefix shadow-agent to commit validation

📚 Documentation Updates

File Changes
README.md • Added "How to read this repo" section
• Clarified root README covers workspace layout; shadow-agent/README.md covers app scope
• Clarified third_party/ as disposable reference material (not runtime imports)
• Updated description: patterns for inspection/porting only; can be removed once absorbed
AGENTS.md • Added clarification that third_party/ is reference material, not product surface
• Noted patterns should not be used for runtime imports
docs/architecture.md • Updated project status: Phase 2 (Release Candidate)
• Noted Canvas2D renderer and capture pipeline remain on feature branches
• Expanded Phase 2 inference-engine details: auth, context packaging, prompt building, response parsing, trigger logic, orchestrator, direct Anthropic fallback, MCP server
• Noted OpenCode client implementation incomplete
docs/domain-inference.md • Updated status from "mostly scaffolding" to "partial implementation"
• Marked modules as implemented: auth loader, context-packager, prompt-builder, response parser, trigger logic, orchestrator, MCP server
• Explicitly marked opencode-client.ts as not yet implemented
docs/getting-started.md • Updated shadow-agent/src/electron/ responsibility: file loading (not filesystem watching)
• Clarified Canvas2D visualization on feature branch; main uses simplified panels
• Expanded shadow-agent/src/shared/ scope: privacy, transcript parsing, replay store
• Added shadow-agent/src/inference/ and src/mcp/ sections
docs/todo.md • Marked inference-related tasks completed (with PR references)
• Marked several test tasks completed
• Updated OpenCode client status to "Not yet implemented"
• Marked Phase 2 capture/visual tests as "Blocked"
• Added Infrastructure section with coverage tooling, CI, and pre-commit hook improvements
shadow-agent/README.md • Added note clarifying this documents only app scope; reference root README for workspace context

Test Results

145/145 tests pass (was 14 failures)

Build Verification

✅ Vite renderer + esbuild Electron build succeeds
✅ Prompt artifacts in sync
✅ Coverage tooling functional (~61% statement coverage)

…ith codebase

- Add ShadowContextPacket type and buildUserMessage function to prompt-builder.ts
  (fixes missing exports that caused 5 test failures across prompt-builder and inference tests)
- Add packContext wrapper to context-packager.ts with richer return shape
  (fixes 7 test failures in inference-contract tests)
- Refactor buildContextPacket to delegate to packContext (eliminates code duplication)
- Re-export SHADOW_SYSTEM_PROMPT from prompt-builder.ts for import convenience
- Update shadow-mcp-server.ts to import from prompt-builder instead of prompts
- Fix inference-contract test expectations to match actual tool history behavior
- Add test:coverage script with @vitest/coverage-v8 dependency
- Add npm test step to CI workflow (prompt-parity.yml)
- Add npm test to pre-commit hook
- Add coverage/ to .gitignore
- Update docs: architecture.md, domain-inference.md, getting-started.md, todo.md
  to reflect current codebase state (merged PRs, actual file layout, Phase 1 completion)
- Clarify third_party/ usage policy in AGENTS.md

All 145 tests pass. Build succeeds. Prompts in sync.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 19, 2026 22:15
@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Coldaine has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 23 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 52 minutes and 23 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b160646e-77fc-4c66-afc9-a627ae538dcd

📥 Commits

Reviewing files that changed from the base of the PR and between fb01493 and fb4d611.

📒 Files selected for processing (2)
  • .husky/pre-commit
  • shadow-agent/src/inference/prompt-builder.ts
📝 Walkthrough

Walkthrough

This PR refactors the inference module's architecture by establishing prompt-builder.ts as the canonical home for ShadowContextPacket, implementing buildUserMessage() with privacy controls, refactoring context-packager.ts to support configurable token budgets and truncation, updating CI/pre-commit hooks to run tests and builds, and updating documentation to reflect the completed implementation status of the inference pipeline.

Changes

Cohort / File(s) Summary
CI & Infrastructure
.github/workflows/prompt-parity.yml, .husky/pre-commit, shadow-agent/.gitignore, shadow-agent/package.json
Added npm test and npm run build to CI workflow (renamed from "Prompt Parity" to "CI"), extended Husky pre-commit hook to run npm test --prefix shadow-agent, added coverage directory to gitignore, and added test:coverage npm script with @vitest/coverage-v8 dependency.
Core Inference Refactoring
shadow-agent/src/inference/context-packager.ts, shadow-agent/src/inference/prompt-builder.ts
Refactored context-packager to introduce packContext(state, events, options) returning PackContextResult with token budget and truncation tracking; added configurable tokenBudget and recentWindowSize via PackContextOptions. Established prompt-builder as canonical home for ShadowContextPacket type; implemented buildUserMessage(packet, options) with privacy controls (delivery mode validation, conditional transcript sanitization, privacy mode annotation); re-exported SHADOW_SYSTEM_PROMPT from prompts module.
Import Updates
shadow-agent/src/mcp/shadow-mcp-server.ts, shadow-agent/tests/inference.test.ts, shadow-agent/tests/inference/inference-contract.test.ts
Updated imports to reflect new canonical sources: SHADOW_SYSTEM_PROMPT and buildUserMessage now sourced from prompt-builder; adjusted inference contract test expectations for tool history entries.
Documentation
README.md, AGENTS.md, docs/architecture.md, docs/domain-inference.md, docs/getting-started.md, shadow-agent/README.md, docs/todo.md
Clarified workspace layout (root README covers tooling/structure, shadow-agent/README.md covers app scope); documented third_party/ as disposable reference material; updated architecture roadmap to Phase 2 (RC) status with detailed inference engine implementation notes; marked completed inference tasks (auth loader, context packager, prompt builder, trigger engine, MCP server, Anthropic fallback) with strikethrough and PR references; documented OpenCode client as not yet implemented; added Infrastructure section tracking test suite and CI improvements.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • Build shadow prompt builder #13: Directly implements the shadow prompt builder feature with ShadowContextPacket, buildUserMessage(), and SHADOW_SYSTEM_PROMPT re-export as specified in the issue.
  • Build shadow context packager #12: Directly implements the context packager feature with packContext() function and ShadowContextPacket type shape satisfying the issue's acceptance criteria.

Possibly related PRs

  • test: inference contract tests #32: Related through overlapping changes to context-packager API, inference contract test adjustments, and refactoring of the same inference logic.

Poem

🐰 A rabbit hops through inference halls,
Where prompts and packets build strong walls,
Privacy guards each message sent,
Token budgets wisely spent—
The shadow pipeline's nearly complete,
And tests ensure each step's neat! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the three main changes: fixing 14 test failures, adding coverage tooling, and aligning documentation with the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/test-remediation-and-docs-consistency

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb014935be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .husky/pre-commit
@@ -1,2 +1,3 @@
#!/usr/bin/env sh
npm run prompts:check
npm test --prefix shadow-agent

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Make pre-commit stop when prompt parity check fails

Because this hook script does not enable set -e (and commands are on separate lines), a failing npm run prompts:check is ignored if npm test --prefix shadow-agent succeeds, so commits can pass with prompt artifacts out of sync. This was introduced when the second command was added; chain commands with && or enable fail-fast behavior so any failed check blocks the commit.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

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 repairs broken test imports/exports in the inference stack, adds coverage tooling + CI/pre-commit test execution, and updates documentation to match what’s actually shipped in main.

Changes:

  • Fixes inference test failures by moving the canonical ShadowContextPacket/buildUserMessage exports into prompt-builder.ts, updating imports, and adding packContext() to context-packager.ts.
  • Adds vitest coverage support plus CI and pre-commit hooks to run npm test (and build in CI).
  • Aligns workspace/app/docs READMEs and inference/architecture docs with the current implementation status.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
shadow-agent/tests/inference/inference-contract.test.ts Updates imports and tool-history expectations to match current pairing behavior.
shadow-agent/tests/inference.test.ts Consolidates prompt imports via prompt-builder.
shadow-agent/src/mcp/shadow-mcp-server.ts Switches SHADOW_SYSTEM_PROMPT import to prompt-builder.
shadow-agent/src/inference/prompt-builder.ts Introduces canonical context packet type and user-message rendering (with privacy gating).
shadow-agent/src/inference/context-packager.ts Adds packContext() API and refactors buildContextPacket() to delegate to it.
shadow-agent/package.json Adds test:coverage script and coverage dependency.
shadow-agent/package-lock.json Locks @vitest/coverage-v8 and transitive deps.
shadow-agent/README.md Clarifies relationship between workspace README and app README.
shadow-agent/.gitignore Ignores coverage/ output directory.
docs/todo.md Updates project status tracking and adds infra notes for this remediation.
docs/getting-started.md Corrects project structure to match current main.
docs/domain-inference.md Updates inference file map/status to reflect implemented modules.
docs/architecture.md Updates phase status and roadmap bullets to reflect what’s merged vs feature branches.
README.md Clarifies workspace reading order and third_party/ expectations.
AGENTS.md Clarifies third_party/ as reference-only (no runtime imports).
.husky/pre-commit Adds shadow-agent test run to pre-commit.
.github/workflows/prompt-parity.yml Expands prompt-parity into CI running prompt checks + tests + build.
Files not reviewed (1)
  • shadow-agent/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +39 to +51
const delivery = options.delivery ?? 'local';
const privacy = options.privacy ?? { allowRawTranscriptStorage: false, allowOffHostInference: false };

if (delivery === 'off-host' && !privacy.allowOffHostInference) {
throw new Error('Off-host inference is disabled until the user explicitly opts in.');
}

const sanitize = (text: string): string => {
if (delivery === 'off-host' && privacy.allowOffHostInference && options.includeRawTranscript && privacy.allowRawTranscriptStorage) {
return text;
}
return sanitizeTranscriptText(text);
};

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

includeRawTranscript is never validated against privacy.allowRawTranscriptStorage. If a caller requests raw transcript inclusion off-host but hasn’t opted into raw transcript handling, this currently silently falls back to sanitization instead of failing fast. Consider reusing assertOffHostInferenceAllowed(privacy, { includeRawTranscript }) (and DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS) or adding an explicit check so behavior matches the privacy module’s contract.

Copilot uses AI. Check for mistakes.
'',
`--- Recent Events (${packet.recentEvents.length}) ---`,
...packet.recentEvents.map((e) =>
`${e.timestamp} [${e.kind}] ${e.actor}: ${sanitize(JSON.stringify(e.payload).slice(0, 120))}`

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

The payload preview is truncated before sanitization (JSON.stringify(e.payload).slice(0, 120)), which can leak partial secrets (e.g., a token prefix that no longer matches the redaction regex). Sanitize first, then truncate (or sanitize the structured payload via sanitizeCanonicalEvent / sanitizeUnknown before stringifying).

Suggested change
`${e.timestamp} [${e.kind}] ${e.actor}: ${sanitize(JSON.stringify(e.payload).slice(0, 120))}`
`${e.timestamp} [${e.kind}] ${e.actor}: ${sanitize(JSON.stringify(e.payload)).slice(0, 120)}`

Copilot uses AI. Check for mistakes.
Comment on lines +135 to +139
while (approximateTokens > tokenBudget && trimOldest()) {
approximateTokens = estimateTokens(truncatedPacket);
}

return truncatedPacket;
return { packet: truncatedPacket, truncated: true, approximateTokens };

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

packContext can return approximateTokens still above tokenBudget when trimOldest() can no longer remove items (e.g., very small tokenBudget values). That breaks the implied contract of “respecting tokenBudget”. Consider detecting this case after the loop and either (a) further truncating strings, (b) returning a minimal packet, or (c) returning an additional flag/error indicating the budget cannot be met.

Copilot uses AI. Check for mistakes.
Comment thread .husky/pre-commit
@@ -1,2 +1,3 @@
#!/usr/bin/env sh

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

This hook now runs multiple commands, but the script doesn’t set -e or chain with &&. If npm run prompts:check fails but npm test passes, the hook may exit 0 (since the last command succeeds), allowing commits that break prompt parity. Add set -e at the top (or chain commands with &&) so any failure blocks the commit.

Suggested change
#!/usr/bin/env sh
#!/usr/bin/env sh
set -e

Copilot uses AI. Check for mistakes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.husky/pre-commit:
- Around line 1-3: Add "set -e" immediately after the shebang so the pre-commit
hook exits on the first failing command; update the pre-commit script that
currently runs npm run prompts:check followed by npm test --prefix shadow-agent
to include set -e (so a failing npm run prompts:check cannot be masked by the
later npm test command).

In `@shadow-agent/src/inference/prompt-builder.ts`:
- Around line 39-40: The default privacy object is being re-declared inline in
prompt-builder.ts; instead import and use the canonical
DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS exported from
shadow-agent/src/shared/privacy.ts and use it in the privacy fallback (replace
the literal used in the privacy const). Update imports to include
DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS and change the privacy assignment to default
to that constant so future fields won't drift (reference symbols: privacy const
in prompt-builder.ts and DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS from
shared/privacy).
- Around line 46-51: The sanitize() predicate currently gates raw-text
passthrough on delivery === 'off-host', which prevents local raw transcripts
even when privacy.allowRawTranscriptStorage and options.includeRawTranscript are
true; change the condition in the sanitize function to only check the privacy
flags (options.includeRawTranscript && privacy.allowRawTranscriptStorage) so raw
content is allowed independent of delivery mode. Replace the duplicated
DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS with an import from ../shared/privacy and
use that constant where defaults are applied. Also rename the options flag
includeRawTranscript to a clearer name (e.g., includeRawPayloads or
includeRawEventPayloads) across prompt-builder.ts and related callers to reflect
that it controls event payloads, tool args, and transcript text, updating
references and types accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 881974fd-afbc-400a-89cc-d6c3242ee83b

📥 Commits

Reviewing files that changed from the base of the PR and between 28b2d33 and fb01493.

⛔ Files ignored due to path filters (1)
  • shadow-agent/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (16)
  • .github/workflows/prompt-parity.yml
  • .husky/pre-commit
  • AGENTS.md
  • README.md
  • docs/architecture.md
  • docs/domain-inference.md
  • docs/getting-started.md
  • docs/todo.md
  • shadow-agent/.gitignore
  • shadow-agent/README.md
  • shadow-agent/package.json
  • shadow-agent/src/inference/context-packager.ts
  • shadow-agent/src/inference/prompt-builder.ts
  • shadow-agent/src/mcp/shadow-mcp-server.ts
  • shadow-agent/tests/inference.test.ts
  • shadow-agent/tests/inference/inference-contract.test.ts

Comment thread .husky/pre-commit
Comment thread shadow-agent/src/inference/prompt-builder.ts Outdated
Comment on lines +46 to +51
const sanitize = (text: string): string => {
if (delivery === 'off-host' && privacy.allowOffHostInference && options.includeRawTranscript && privacy.allowRawTranscriptStorage) {
return text;
}
return sanitizeTranscriptText(text);
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, locate and read the prompt-builder.ts file around the flagged lines
find . -name "prompt-builder.ts" -type f

Repository: Coldaine/AgentVisualCrazy

Length of output: 115


🏁 Script executed:

# Also check for documentation files mentioned
find . -name "domain-inference.md" -o -name "architecture.md" | head -20

Repository: Coldaine/AgentVisualCrazy

Length of output: 118


🏁 Script executed:

# Search for DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS to understand the duplication claim
rg "DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS" --type ts --type tsx -A 3 -B 1

Repository: Coldaine/AgentVisualCrazy

Length of output: 96


🏁 Script executed:

# Corrected search for DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS
rg "DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS" --type ts -A 3 -B 1

Repository: Coldaine/AgentVisualCrazy

Length of output: 3365


🏁 Script executed:

# Read prompt-builder.ts - check file size first
wc -l ./shadow-agent/src/inference/prompt-builder.ts

Repository: Coldaine/AgentVisualCrazy

Length of output: 118


🏁 Script executed:

# Read the critical section and surrounding context (lines 35-91)
sed -n '35,91p' ./shadow-agent/src/inference/prompt-builder.ts

Repository: Coldaine/AgentVisualCrazy

Length of output: 1973


🏁 Script executed:

# Also check the imports at the top
head -30 ./shadow-agent/src/inference/prompt-builder.ts

Repository: Coldaine/AgentVisualCrazy

Length of output: 1264


🏁 Script executed:

# Read documentation files to verify privacy matrix claims
cat ./docs/architecture.md

Repository: Coldaine/AgentVisualCrazy

Length of output: 8138


🏁 Script executed:

cat ./docs/domain-inference.md

Repository: Coldaine/AgentVisualCrazy

Length of output: 5107


🏁 Script executed:

# Search for BuildUserMessageOptions interface to see full signature
rg "BuildUserMessageOptions" shadow-agent/src/inference/prompt-builder.ts -A 10

Repository: Coldaine/AgentVisualCrazy

Length of output: 839


Clarify privacy matrix: raw transcript availability is gated to off-host delivery, but docs describe it as a separate opt-in.

The sanitize condition at line 47 requires delivery === 'off-host', which means local prompts always sanitize even when allowRawTranscriptStorage: true and includeRawTranscript: true. However, architecture.md and domain-inference.md both describe "raw transcript storage/export" as a separate explicit opt-in, which could reasonably be interpreted as independent from transport mode. If local-raw should be allowed, relax the condition to gate only on privacy flags:

if (options.includeRawTranscript && privacy.allowRawTranscriptStorage) {

Also, line 40 duplicates DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS from ../shared/privacy — import and use the constant instead to keep defaults aligned. Finally, the option name includeRawTranscript understates scope: it controls sanitization of event payloads, tool arguments, and transcript text.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shadow-agent/src/inference/prompt-builder.ts` around lines 46 - 51, The
sanitize() predicate currently gates raw-text passthrough on delivery ===
'off-host', which prevents local raw transcripts even when
privacy.allowRawTranscriptStorage and options.includeRawTranscript are true;
change the condition in the sanitize function to only check the privacy flags
(options.includeRawTranscript && privacy.allowRawTranscriptStorage) so raw
content is allowed independent of delivery mode. Replace the duplicated
DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS with an import from ../shared/privacy and
use that constant where defaults are applied. Also rename the options flag
includeRawTranscript to a clearer name (e.g., includeRawPayloads or
includeRawEventPayloads) across prompt-builder.ts and related callers to reflect
that it controls event payloads, tool args, and transcript text, updating
references and types accordingly.

- Add set -e to pre-commit hook so prompts:check failure blocks commit
- Sanitize event payload before truncating to prevent partial secret leakage
- Import DEFAULT_TRANSCRIPT_PRIVACY_SETTINGS from shared/privacy instead of
  re-declaring the default literal inline

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Coldaine
Coldaine merged commit a78bd7f into main Apr 19, 2026
4 checks passed
Coldaine added a commit that referenced this pull request Apr 20, 2026
Nine drift items were identified during the 2026-04-19 end-of-day review
(captured in docs/third-party-readiness-briefing.html, added here). Each is
addressed as a targeted edit rather than a rewrite -- the docs are mostly
right, they were just out of step with what PRs #28/#29/#31/#32/#34/#35
actually landed.

Changes:

- architecture.md: "Phase 2 (Release Candidate)" was misleading -- Canvas2D
  (#26) and live capture (#27) are still on branches. Relabel to "Phase 2
  (In Progress)" and state the two PRs that close the phase. Also replaces
  the Three.js-only background claim with the Citadel-dot-grid-preferred
  decision from plan-gui-rendering.md, and converts the four section-sign
  cross-refs to real Markdown links.
- domain-gui.md / domain-events.md / domain-inference.md: unify status
  headers under one schema (Planned / Partial on main / Landed on main)
  instead of the three different styles previously in use.
- history/log.md: fix ascending chronological ordering (04-18 was before
  04-12) and add the missing 2026-04-19 entry covering PRs #29, #31, #32,
  #34, #35 merged that day.
- plan-master-a-must-do.md: RepoVis archival, temp-file removal, and
  domain status headers were listed as TODO but were all completed
  2026-04-18/19. Mark them done with audit-trail strikethrough. Also
  refresh the Pre-Commit/CI section (husky -> .githooks migration) and
  the Definition of Done (five PRs merged, four remain).
- plan-master-coordination.md: remove the three empty Stream A/B/C
  scratchpad placeholders and replace the Round 2 Dispatch TODO list with
  a closeout record pointing to the promoted outputs.
- plan-gui-rendering.md / plan-event-capture.md / plan-inference-engine.md:
  convert the remaining section-sign cross-refs into Markdown links with
  descriptive section names.
- getting-started.md: cd into shadow-agent for test commands, note the
  PR #35 bisect caveat, and mention the CI/pre-commit gates.
- prompts/shadow-system-prompt.json: append a 2026-04-19 iteration-log
  entry documenting the regeneration; regenerated docs/prompts/
  shadow-system-prompt.md is in sync (npm run prompts:check passes).
- docs/third-party-readiness-briefing.html: commit the HTML artifact that
  drove this pass so the reasoning behind these edits is auditable.

Validation: 145 tests pass (npm test), npm run prompts:check clean, no
lint errors.

Scope note: open PRs #26, #27, #30, #33 are deliberately untouched --
those are thousand-plus-line product-feature or infrastructure branches
and each deserves its own focused session.

Made-with: Cursor
Coldaine added a commit that referenced this pull request Apr 20, 2026
* docs: remediate drift between documentation and current main state

Nine drift items were identified during the 2026-04-19 end-of-day review
(captured in docs/third-party-readiness-briefing.html, added here). Each is
addressed as a targeted edit rather than a rewrite -- the docs are mostly
right, they were just out of step with what PRs #28/#29/#31/#32/#34/#35
actually landed.

Changes:

- architecture.md: "Phase 2 (Release Candidate)" was misleading -- Canvas2D
  (#26) and live capture (#27) are still on branches. Relabel to "Phase 2
  (In Progress)" and state the two PRs that close the phase. Also replaces
  the Three.js-only background claim with the Citadel-dot-grid-preferred
  decision from plan-gui-rendering.md, and converts the four section-sign
  cross-refs to real Markdown links.
- domain-gui.md / domain-events.md / domain-inference.md: unify status
  headers under one schema (Planned / Partial on main / Landed on main)
  instead of the three different styles previously in use.
- history/log.md: fix ascending chronological ordering (04-18 was before
  04-12) and add the missing 2026-04-19 entry covering PRs #29, #31, #32,
  #34, #35 merged that day.
- plan-master-a-must-do.md: RepoVis archival, temp-file removal, and
  domain status headers were listed as TODO but were all completed
  2026-04-18/19. Mark them done with audit-trail strikethrough. Also
  refresh the Pre-Commit/CI section (husky -> .githooks migration) and
  the Definition of Done (five PRs merged, four remain).
- plan-master-coordination.md: remove the three empty Stream A/B/C
  scratchpad placeholders and replace the Round 2 Dispatch TODO list with
  a closeout record pointing to the promoted outputs.
- plan-gui-rendering.md / plan-event-capture.md / plan-inference-engine.md:
  convert the remaining section-sign cross-refs into Markdown links with
  descriptive section names.
- getting-started.md: cd into shadow-agent for test commands, note the
  PR #35 bisect caveat, and mention the CI/pre-commit gates.
- prompts/shadow-system-prompt.json: append a 2026-04-19 iteration-log
  entry documenting the regeneration; regenerated docs/prompts/
  shadow-system-prompt.md is in sync (npm run prompts:check passes).
- docs/third-party-readiness-briefing.html: commit the HTML artifact that
  drove this pass so the reasoning behind these edits is auditable.

Validation: 145 tests pass (npm test), npm run prompts:check clean, no
lint errors.

Scope note: open PRs #26, #27, #30, #33 are deliberately untouched --
those are thousand-plus-line product-feature or infrastructure branches
and each deserves its own focused session.

Made-with: Cursor

* docs: address Copilot + Codex review feedback on drift-remediation PR

Fixes all six inline comments from the automated reviewers on PR #36. Root
cause for four of them was my conflation of the in-flight husky -> .githooks
migration (which is stashed, not on this branch) with current reality on
main. The other two were residual section-sign cross-refs that my first
sweep missed.

- getting-started.md: reference the actual `.husky/pre-commit` hook (not a
  speculative `.githooks/pre-commit`); name the CI workflow correctly (it
  is `CI`, defined in `.github/workflows/prompt-parity.yml`); accurately
  describe what the hook runs (`prompts:check` and
  `npm test --prefix shadow-agent`).
- plan-master-a-must-do.md: drop the incorrect "hook has since migrated to
  .githooks/pre-commit" claim; describe the current `.husky/pre-commit`
  instead. Convert the remaining "under section 3" cross-ref to a clickable
  anchor link.
- plan-master-coordination.md: replace the Stream A/B/C "section 1 / 2 / 3"
  cross-refs with descriptive Markdown links to the actual files and named
  sections. Same fix applied to the Round 2 Dispatch PR-fix bullet.
- architecture.md: replace the "section 8" cross-ref with the full step
  heading "Optional Background Atmosphere Layer (Choose One)" as a
  descriptive link target.

Validation: rg for section-sign notation returns zero hits;
`npm run prompts:check` clean; `npm test` 145/145 pass.

Made-with: Cursor
@Coldaine
Coldaine deleted the fix/test-remediation-and-docs-consistency branch May 30, 2026 16:04
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.

2 participants