Repository navigation
kb engineering rules
Status: Implemented
Last Updated: 2026-11-13
Audience: Developers and coding agents
Last verified: 2026-11-13 against c662974ea
Code: scripts/Test-Martlet.ps1, scripts/Invoke-MartletMcp.ps1, scripts/Clean-Martlet.ps1
These are the full repository rules, linked from the short root bootstrap. The knowledge base contract also applies to every change.
These instructions apply throughout Martlet. Follow more specific instructions and explicit user constraints as well. Read the relevant contracts and current implementation before editing; historical plans are not evidence of completion.
Before you change a rule, find the file that owns it in the decision map. Change the owner, not the pages and tools that only show its result, and update the map when an owner moves. Use the names in the glossary in code, UI text and docs; do not add a new name for a concept that is there.
Work autonomously end to end as if in autopilot mode. Make the decisions, do the work and finish it without waiting on the owner. Do not stop for routine confirmation, plan approval or choice questionnaires; state material assumptions briefly and continue. Stop only for a genuine blocker or an action outside the authorization boundaries below.
For an implementation request: inspect, implement, validate, commit, publish a
pull request and merge into main. Routine branch creation, commits, PR
publication and normal merging are authorized by default once the change is
validated; do not stop at a plan, a local patch or an open PR when the
requested work can be completed safely. Do not ask "should I proceed?" at each
step.
An explicit review-only, planning, local-only, no-push, draft, approval-hold or no-merge request overrides this default. Existing task-specific holds remain binding. Make routine decisions directly using best practices and repository evidence. Ask only when missing authority or a consequential unresolved decision cannot responsibly be resolved from the user's goal and available evidence.
- Be aggressive about completing the requested outcome, not defensive about preserving obsolete designs. Replace them when warranted, updating affected callers, contracts, migration paths and documentation together. Keep scope focused; decisiveness is not permission for unrelated rewrites or unsafe work.
- Deliver working production paths early, not endless disabled foundations, stubs or configuration-only milestones. Wire the actual supported route through its callers. Preserve required consent, opt-in defaults and qualification gates; report remaining prerequisites honestly rather than enabling an unqualified feature.
- Investigate uncertainty in current code, documentation and local evidence. Choose the simplest complete solution and act without routine questionnaires, speculative scaffolding or repeated plans.
- Fix root causes across affected callers and documentation; do not silently reduce scope to finish.
- Continue through each next authorized step without routine approval prompts. If blocked, try reasonable alternatives within scope and authorization, then preserve the work and report the exact blocker and smallest human action needed. Do not repeat unsuccessful attempts without new evidence.
- Batch relevant reads and avoid duplicate investigation. When work changes code or files, distinguish local work, open review and verified integration; completion requires a working persistent result, not a proposal or queued merge.
When you find a bug, defect or other problem during a task and you do not fix
it in the same change, file a GitHub issue so that it is not lost. This
applies to problems in the code, tests, scripts, tools and documentation.
Examples are a test that fails on origin/main, a flaky test, a crash, a
wrong result, a setting that is not shared, a slow path, a broken script and
a wrong or old document.
- Search the open issues first (
gh issue list --search "<words>"). If an issue is there, add a comment with your new evidence instead. - File the issue in
throndir2/Martletwith the app'screate_issuetool when it is available. Otherwise usegh issue create. - Give it a short, specific title and a body that tells what happens, what you expected, how to make it happen again (commands, files and lines), the commit or branch, and the error or log text.
- Add the labels that apply: a kind (
bug,reliability,performance,security,settings-sync,tech-debt,ux,documentation), onearea: ...label and, when you can tell, onepriority: ...label. - Link the issue in your PR description and in any
tests\known-failures.txtline or code comment about the problem.
Do not file an issue for a problem that your change makes and fixes before merge. Do not put secrets, API keys, private data or personal paths in an issue. Never assign an issue to Copilot or any other cloud agent.
Write responses, progress updates, PR descriptions and developer documentation in ASD-STE100 Simplified Technical English (STE), so that technical text is easy to understand. Give as much detail as the reader needs; do not cut useful information only to be short.
- Use simple, common words, each with only one meaning. Use the same word for the same thing every time.
- Keep sentences short: no more than 20 words in an instruction and no more than 25 words in a description. Put one instruction in each sentence.
- Use the active voice. Write instructions in the imperative and write procedures as numbered steps.
- Keep each paragraph to one topic and no more than six sentences.
- Use a technical term only when it is necessary, and explain it in simple words the first time.
- Do not use slang, idioms or unexplained abbreviations.
User-facing text (CHANGELOG.md, the README and the app) keeps its own plain,
friendly voice; apply the STE rules where they do not conflict with it.
The time from the end of the user's speech (or Send) to Martlet's first
audible word must never grow. Treat it as a hard product goal: any change on
that path (prompt assembly, provider requests, background work after a reply,
speech and playback) must keep it the same or make it shorter, for local and
cloud models alike. Keep the start of every Thinking request stable so prompt
caches (OpenAI, OpenRouter, Ollama) are reused, and never let background work
evict the conversation from a local model's cache. When verifying such a
change, compare the desktop log's Reply latency and Thinking input lines
before and after, and report the numbers.
The owner uses Martlet on many computers (companion PCs, host PCs and phones) as one app. A choice made on one computer must be the same on all of them, also on a computer that the owner adds later.
- Share every new setting by default. This includes lists, model choices,
provider choices and their API keys. Add its shared section in the same change
(
AppSettingsSectionsinMartlet.Core, or the desktop'sDesktopSections), as One Martlet on every computer tells. An API key travels as the setting's secret, never in its value. - Keep a setting on one computer only when it describes that computer: its devices (microphone, speakers, cameras, screens), what is installed or measured there, its pairings and how it starts. Add a row with the reason to What stays with each computer.
- Register each settings file in
SettingsFiles(src\Martlet.Core\Settings\SettingsFiles.cs): its name, its scope (shared, account or local), its store and, for what stays here, the reason from that row. Read and write the file only through its store, also in MCP checks (for exampleTalkPreferences.Readfortalk-preferences.json), never with a parser and defaults of their own. - When one list has both kinds (for example the Thinking pool), share the parts that are not about the computer and keep only the rest local.
- A computer that cannot use a shared value yet keeps its own value, says why and tries again. Its own default never replaces a choice made on another computer.
- Show it with two simulated computers: a
Martlet.Core.Teststest, and a step in MCPsettings_sync_selftestwhen keys or files travel. - A setting that stays on one computer without such a reason is a bug. Fix it in your change when it is in scope; otherwise open an issue.
- Use one focused task branch per bounded change, based on freshly fetched
origin/main. Never implement directly onmain. - Reuse an assigned task branch/worktree; do not create another branch just
because a session starts. Inspect its status and ancestry first. If it needs
current
main, reconcile without discarding existing work. - Give new branches short, descriptive kebab-case names. In app-managed sessions, use the app's branch/session tools and preserve its configured prefix; otherwise use normal non-interactive Git branch creation.
- Work only in the assigned worktree. Never switch, edit or clean the main checkout or another task's worktree. Preserve unrelated and uncommitted work.
- Start independent tasks from current
main. Stack on an unmerged task branch only when explicitly requested or when the work genuinely depends on it; merge prerequisites first and target the final integration tomain. - Run independent reads, checks and bounded workstreams in parallel when safe. Use isolated sessions/worktrees for substantial independent implementation; do small tasks directly rather than multiplying agents or coordination.
- Agree shared-file and contract ownership before parallel edits; assign one integration owner for overlaps. Exchange exact commits, not competing snapshots. Serialize merges and refresh against each preceding merge; parallel implementation never permits concurrent integration.
- Do not force-push, rewrite shared history, amend without permission, or delete branches/worktrees containing unmerged or unrelated work.
Every change except documentation is validated locally before it merges, by the flow in Validating changes. Both parts are required:
-
Targeted tests only: run just the tests you added or changed and the test
project or suite that directly covers the changed code:
.\scripts\Test-Martlet.ps1 -Project <Project>.Tests -Filter '<your tests>'(-Project python:<worker>for a worker suite;-Listshows which projects the change touches directly). Never run the runner's default diff-wide selection,-Allor suites that merely depend on the changed project unless the owner asks: many suites fail for unrelated reasons or under parallel load, and that noise is not evidence about the change. Name test projects exactly;-Project <Project>without.Testspulls in every dependent suite. When a change alters an API other projects use, build them instead of testing them. The targeted tests must pass: fix every failure your change causes. A failure it cannot cause (also failing onorigin/main, or only under load and passing alone) does not block; narrow the filter, note it in the PR and do not chase it in this change. Add totests\known-failures.txtonly a test shown failing onorigin/mainwithout your change (noted in the PR and #332), never one your change breaks, and delete a line when its test passes again. Add or update tests for new behavior in the matchingtests\project. Details: Targeted tests only. -
Behavior through Martlet MCP: every feature or behavior change is shown
working through Martlet's own MCP server (
src\Martlet.Mcp) on this machine whenever it can exercise it. Build what the change needs, then drive the actual feature withscripts\Invoke-MartletMcp.ps1: Doctor and status tools for headless behavior and-Desktopfor UI behavior, always on a disposable data directory, never the real profile. Check the expected outcome (status values, control state, Doctor report), not merely that a call returned. -
Always extend the MCP server with the feature. In the same change, make
everything new reachable and observable through MCP: stable automation IDs
on new controls, passive navigation in
SafeClicks, non-secret status fields inSafeValues, and new or extended tools (or Doctor probes) for new headless capabilities, with the MCP page of its area updated to match. A feature MCP cannot reach or observe is not finished. -
--allow-ui-effectsis allowed for this verification only with a disposable data directory and no real credentials. It never authorizes spending, real provider requests, credential handling, audio capture/playback or data disclosure; stop at those steps. -
Run what the tests do not cover (scripts, packaging, worker hosts,
workflows) the way it is used;
-Listnames such files. -
Use the developer's validation hosts. The developer profile
(
~\.martlet-dev\validation.jsonandNOTES.md, shared by all of that developer's checkouts and worktrees, never committed) lists the machines the developer has set up: Docker on this PC, Linux boxes over key-based SSH, GPU hosts. Read it before validating and run what needs those machines there; the runner already sends targeted Linux-only suites to them. Record useful facts about listed hosts inNOTES.md. Adding a host, installing anything on one or using a password is the developer's decision, not an agent's. - When full validation is impossible here (locked or headless desktop, missing hardware, credentials or paid services, another OS, no suitable host), validate everything reachable up to that boundary and report the rest as NOT RUN with the exact reason. Never claim unrun or partial validation passed.
- Put the runner's
artifacts\validation\summary.md, the MCP calls and what they showed, and every NOT RUN item in the PR description.
Keep changes focused and surface errors instead of silently falling back. Never present fixture, fake-native or historical results as real-device, model or release qualification. Independent review agents and package/smoke gates are optional; use them when the change warrants it.
Martlet has its own MCP server, src\Martlet.Mcp
(Use Martlet from an AI assistant).
Use it to work with Martlet itself, not only to validate changes:
- To make or change a character, change a setting or see how Martlet is set
up, call
martlet_guidefirst. Then usecharacters_list,character_create(from a description or a SillyTavern card),character_update,character_use,character_delete,settings_get,settings_schemaandsettings_set.martlet_callruns any other tool by name. - From a checkout, run the tools with
scripts\Invoke-MartletMcp.ps1(-AllowChangeslets them save). Without adataDirectoryit uses a disposable data folder. Pass the owner's data folder (%LOCALAPPDATA%\Martlet) only when the owner asks for a change to their Martlet. -
scripts\Register-MartletMcp.ps1adds the server to the owner's assistants (GitHub Copilot, Claude, VS Code). Run it only when the owner asks.
Before merge, run python scripts\kb\check_kb.py --diff origin/main.
Fix every error. Review coverage warnings and update the matching KB pages.
If no KB change applies, state KB: no change needed and the reason in the PR.
Follow the validation policy and the rules in this section. Before each push, PR creation/update or merge, check the applicable workflow triggers so publishing starts no remote validation, including self-hosted Actions. If no safe path exists, retain the local work and report the exact blocker.
Publish only the task's changes to the repository's configured remote. Use a
focused PR targeting main with a short description and the validation report.
Every PR with a change users can notice also adds a line under
## [Unreleased] in CHANGELOG.md (see
Changelog and release notes).
Refresh origin/main before merging and reconcile if it advanced (rerun the
targeted tests when the reconcile touched the code they cover). Merge eligible PRs
one at a time through the normal GitHub path. Never bypass protections, dismiss
required review, fabricate check statuses or merge a held PR.
Auto-merge is encouraged for autonomous work, after validation: once the targeted tests pass, MCP verification is done and NOT RUN items are reported, the agent merges its own PR without waiting for approval. A PR whose validation failed or was skipped is not eligible. Automatic completion means the agent performs the normal eligible PR merge; it does not mean changing repository settings or adding background/remote automation. If GitHub queues a merge, the task remains pending until the merged result is verified.
Verify the PR is merged and its result is present on freshly fetched
origin/main; a successful push or pending auto-merge is not completion.
Report integrated delivery versus local/open/blocked work accurately.
Martlet builds make much output that Git ignores: each worktree grew to
2.7-4.5 GB, mostly bin\, obj\ and node_modules\. Many worktrees made
checkouts and session archiving very slow. Cleaning up disk space
tells what Martlet makes, where, its size and how to remove it.
- Before you finish a session, stop the processes you started from your checkout (Desktop, MCP server, worker hosts).
- Make sure
artifacts\validation\summary.mdis in the PR description. - Run
.\scripts\Clean-Martlet.ps1to remove your checkout's build output and old disposable%TEMP%folders. Use-WhatIffirst to see what it removes. - Clean only your own checkout. Use
-AllWorktreesor-Git(shared Git housekeeping) only when the developer asks. - Never delete tracked files, uncommitted work, unmerged branches or another
session's worktree. Never use
git clean -x,git gc --prune=noworgit worktree remove --forcefor cleanup.
Autonomous delivery does not authorize spending, sensitive-data disclosure, production deployment, destructive actions, installing host services/drivers, or changing permissions, protections or billing. Do not create, enable, expand, dispatch or retry remote validation CI.
- Never use Copilot Cloud: do not start, delegate to, assign issues to or request work from the Copilot cloud/coding agent, cloud sessions, Copilot code review or any other GitHub-hosted agent. All agent work runs locally.
- Never consume GitHub Actions minutes, apart from building a release with
windows-release.yml. Do not add, enable, dispatch or rerun any other workflow, addcopilot-setup-steps.yml, or use hosted or self-hosted runners for builds, tests, validation, agents or automation. - Releasing is the only exception: dispatch
windows-release.ymlonly to publish an actual release, at most once per version unless a build failure has been fixed.
Releases are pre-authorized. Agents may create and maintain a minimal build/package/release workflow (manual dispatch or tag/release trigger only), dispatch it and publish GitHub releases without asking. It contains no tests or validation, and releases are never cut merely to obtain validation evidence.
To release, follow Changelog and release notes:
one normal merged release PR bumps <Version> in Directory.Build.props,
dates the changelog section and refreshes the README's What's new; then run
gh workflow run windows-release.yml --ref main -f version=<that version>
and confirm the release is published as Latest on GitHub with its notes. If the
build fails, fix the cause before dispatching again. The release stays a draft
until the Linux and macOS files are attached; when only a platform job failed
for a reason outside the code, use Re-run failed jobs on that run instead
of a new dispatch (When a release run fails).
Code signing is not required. Martlet is a personal project and publishes unsigned installers as actual, normal releases; do not label them prototype builds or prereleases, and do not buy or require a signing certificate. Never claim an unsigned build is signed or suppress Windows security warnings; a GitHub asset digest checks integrity, not publisher identity. Retain explicit user consent for download and installation, the narrow official-binary use rights and third-party notices. Keep the private V07 signed-candidate library's trust contract separate from this GitHub installer delivery route.
CHANGELOG.md is the single source of every release's notes, and the README's What's new is its newest highlights. Both are written for people who use Martlet, not developers.
In every PR with a change users can notice (a feature, a behavior change, a
fix, a removal), add one line under ## [Unreleased] in the matching
### Added, ### Changed, ### Fixed or ### Removed subsection (create it
if missing, in that order). Write one plain sentence about what users notice,
not how it was built, and end it with the PR link, for example
- The talk window keeps your place when a reply arrives. ([#480](https://github.com/throndir2/Martlet/pull/480)).
Add the link after opening the PR (or use the PR number GitHub will assign).
Internal-only work (tests, refactors, CI policy, agent instructions,
developer docs) needs no line, or one shared "Behind-the-scenes improvements"
line under ### Changed when a release would otherwise look empty. Never
rewrite the sections of versions that were already released, except to fix
a wrong statement.
In the release PR (title Release <version>), in this order:
- Pick the version: minor (
0.49.0) whenUnreleasedhas anything under Added or Removed, otherwise patch (0.48.1). - Set
<Version>inDirectory.Build.props. - In
CHANGELOG.md, rename## [Unreleased]to## [<version>] - <YYYY-MM-DD>(today's date) and add a new empty## [Unreleased]above it. Tidy the entries: merge duplicates, fix wording, keep the newest first. The section must contain at least one-bullet. - In
README.md, replace the What's new in section's heading version and its three to five highlight bullets with the most notable entries of the new section (plain words, no PR links), keeping the links to the changelog and releases. The download and version badges update themselves; don't hardcode the version anywhere else in the README. - Refresh the bundled model catalog: run
.\scripts\Update-ModelCatalog.ps1and commit the changedsrc\Martlet.Core\Planning\Catalog\model-catalog.jsonwith the release PR (The model catalog). If a public source can't be read, the script writes nothing; release with the old snapshot and say so. - Check the notes locally:
.\scripts\Get-ReleaseNotes.ps1 -Version <version>must print the section. - Merge the PR, then dispatch
windows-release.ymlwith that version. The workflow runs the same script before restoring anything, stops if the section is missing, and publishes it as the release's What's new followed by the install, license and SHA-256 text. - Confirm on GitHub that
v<version>is Latest and its notes show the changelog entries.
If a published release's notes need correcting, fix CHANGELOG.md in a normal
PR and update the release body with gh release edit v<version> --notes-file;
never re-dispatch the workflow for notes.
Martlet: download · repository · changelog · issues
These pages come from docs/wiki in the repository. To suggest a change, open an issue or a pull request there.
- Home
- Accounts and households
- Accounts and Household
- Android phones and tablets: what it takes, and the plan
- Martlet's API for other apps and scripts
- App Guides
- App Settings and Updates
- App guides: game and app knowledge from the web
- Architecture
- Bounded PCM playback
- Audio dependency inventory and notices
- Avatar guide: Live2D, VRM and speech animation
- V01a explicit microphone capture
- Chatterbox voice engines
- Cleaning up disk space
- One Martlet on all your computers
- Companion controls and behavior requirements
- Components, jobs and placement (design)
- Live conversation
- Creations
- Decision map: which file owns each decision
- Deep research: web search and long research jobs
- The desktop app: updates, notification area, exiting and appearance
- Linux and macOS desktop companion: research, decision and plan
- Developer Guide
- Dia voice engine
- Diagnostics
- Discord
- Architecture and provider contracts
- Discord
- Memory (P03a/P03b/P03c)
- Singing
- Desktop troubleshooting and local support
- Recognizing people by voice, and Parakeet
- Echo cancellation
- ElevenLabs voice: your cloned voice with tones
- F5 worker and reference-voice foundation
- FAQ
- First Steps
- Game state plan: implementation history
- Glossary: one name for each concept
- GPT-SoVITS voice
- Hosted Thinking: cloud models when Thinking can't run on this PC
- Installation and support
- Installing Martlet
- iOS and iPadOS: what it takes, and the plan
- Repository instructions for coding agents
- Repository knowledge base
- Knowledge base maintenance
- GitHub Wiki mirror
- Linux and Mac
- Listening and Voice ID
- Local model apps
- Lorebooks
- macOS: what it takes, and the plan
- Martlet MCP Server
- MCP in Martlet
- MCP: The app's window
- MCP: Apps, home and memory
- MCP: Characters
- MCP: Diagnostics and logs
- MCP: Computers, network and accounts
- MCP: Other
- MCP: Tool permissions
- MCP pages
- MCP: Server and protocol internals
- MCP: Settings
- MCP: Start here
- MCP: Thinking and models
- MCP: Voice and listening
- Memory
- Messaging apps
- Model catalog: sources, conflicts and design
- Motion host role
- Multiple Computers
- Your Martlet network
- OCR host role
- Share your language models: the OpenAI-compatible endpoint
- Packaging
- Perception worker contracts
- Personality and Characters
- Picture making
- Pictures and Creations
- Picture making host role
- Platforms: what each device can do
- Prerequisites: what Martlet bundles, installs for you, or needs from you
- Privacy and Safety
- Reading the text on your screen
- Wiki source
- Recommendation design: ask three questions, plan for three situations
- Recommended setups: one machine to unlimited budget
- Releasing
- Repository Layout
- Research and provenance ledger
- Resource footprints
- Roadmap
- Watch my screen: screen-aware commentary
- Search engine
- Image and audio models: who sees, who hears, who answers
- Setting Up a Host
- Setup, Windows credentials and local audio
- Sharing with Friends
- Singing
- Smart Home
- Smart home and cameras
- Source Projects
- Talking to Martlet
- Telegram and WhatsApp
- The Character
- Thinking
- Tools and MCP
- Troubleshooting
- Martlet desktop UI design
- User stories and target flows
- Voice activity detection
- Validating changes
- Validation and Testing
- Vision
- Voice latency: from you stopping talking to Martlet's voice
- Voice recognition host role
- Multi-engine voice setup and comparison
- Voices
- The welcome wizard
- XTTS-v2 voice engine