* docs(cargo-context): document graph linking rules and server-side frontmatter enforcement Linking guidelines (how context-graph edges actually form): - Add "Source references and graph edges" sections to cargo-context SKILL.md and references/conventions.md covering the three edge-creating forms (frontmatter references:, markdown links, wikilinks), the no-bare-paths rule, root-relative resolution, optional extensions, broken-target behavior, _template.* exclusion, and YAML/title/summary parsing. - Update cross-reference and template bullets to note edges only form via the three link forms. - Add a source-citation example to references/examples/authoring.md and point the repetition-threshold guidance at frontmatter references:. Frontmatter enforcement (422 / invalidContent): - Update the File conventions frontmatter bullet plus the write and edit sections in SKILL.md to describe server-side rejection and recovery. - Add invalidContent troubleshooting entries (missing fields, malformed YAML, edit-strips-meta) and write/edit error reasons in references/response-shapes.md. - Refresh the cargo-context recap in the top-level overview. * fix(cargo-context): correct frontmatter rules to match backend (soft-fail, no 422) The earlier frontmatter-enforcement docs described a write/edit validation gate (HTTP 422, reason "invalidContent") and a description->graph-summary fallback that the backend does not implement. The runtime write/edit services have no frontmatter validation, and the graph builder fails soft: a missing title falls back to the filename and the node summary to the first paragraph (the graph reads `summary`, never `description`). Align the skill with the actual capability behavior: - Reframe frontmatter as a strong convention, not enforced — missing/empty/ malformed frontmatter is still committed, it just indexes poorly. - Replace the invalidContent/422 notes in SKILL.md (write + edit), the File conventions bullet, conventions.md, authoring.md, and the overview recap. - List the real write/edit failure reasons in response-shapes.md and troubleshooting.md (repositoryNotFound, syncConflict/syncFailed, failedToWrite/failedToEdit, stringNotFound/stringNotUnique, fileNotFound, noOp, deniedPath). - Fix the node-summary source: `summary` (fallback first paragraph), not `description`. The linking rules (edge origins, resolution order, _template/.git exclusion) were already accurate and are unchanged. * fix(cargo-context): stop skills-lint flagging illustrative source-link examples The internal-link checker regex-scans whole files (code fences and inline code included) and resolves every `[text](target)` against the skills repo. The example source paths (`outputs/sales-notes/...`) point into a workspace context repo, so they never exist here and were reported as broken links. Keep the examples but avoid literal `](fake-path)` for the markdown-link form: describe the `[label]`+`(path)` syntax with the path in inline code, and switch the authoring example's body citation to an aliased wikilink (which forms a real edge and isn't matched by the link checker). The frontmatter `references:` and wikilink illustrations are unchanged. skills-lint now passes: 0 errors, 0 warnings. * docs(cargo-context): trim verbose error-reason lists from response-shapes The write/edit "Error reasons" lines enumerated internal failure codes (repositoryNotFound, syncConflict, syncFailed, failedToWrite, etc.) that are accurate but generic infra detail — redundant with the generic error shape documented at the top of the file, and not actionable for context authoring. Keep only the load-bearing points (frontmatter is not validated; the .files/ denied-write case) and point to troubleshooting.md, which already holds the full reason enumeration. --------- Co-authored-by: Claude <noreply@anthropic.com>
5.7 KiB
Troubleshooting
Common errors and solutions for cargo-ai context commands.
General
{"errorMessage": "..."}
All failed commands exit non-zero and return an error JSON. Read the errorMessage for the specific issue.
Unauthorized / 403
Your API token may lack the required permissions, or the workspace's context repository isn't configured. Verify with cargo-ai whoami; if a context repo hasn't been set up for the workspace, ask an admin (or do it via the Cargo app under workspace settings).
Runtime — browse / read
Path not found
The path does not exist in the runtime sandbox. Use cargo-ai context runtime browse --path <parent> to confirm the file layout before reading. Paths are relative to the repo root, no leading slash (persona/vp-sales.md, not /persona/vp-sales.md).
Out-of-range lines
--start-line and --end-line are 1-indexed and inclusive on both ends. If they fall outside the file's line count the read fails. Read the file without a range first to confirm length, or omit one end (e.g. only --start-line) to read to EOF.
Runtime — write
Push fails / commit not appearing
write pushes to the context repo's default branch. Pushes fail if the configured GitHub connector lost permissions or the branch was deleted/renamed. Verify the connector via cargo-ai connection connector list and check the default-branch setting in the Cargo app under workspace settings.
No _template.md for the domain
Some workspaces customize their context repo. If a domain doesn't ship a template, browse the domain (cargo-ai context runtime browse --path <domain>) and model the new file after an existing entry.
Missing / empty / malformed frontmatter (not an error)
Frontmatter is a strong convention but not validated — write never rejects a file for a missing title/description or malformed YAML; the file is committed as-is. The graph fails soft: a missing title falls back to the filename, the node summary falls back to the body's first paragraph, and a malformed frontmatter block is stripped so it doesn't leak into the summary. Nothing dangles, but the node indexes poorly — set title (and a summary: if you want a specific summary) on every file. Note the graph reads summary, not description.
Other notWritten reasons
write can fail with repositoryNotFound, syncConflict, syncFailed, failedToWrite, or deniedPath (writing under .files/ — update those via Content instead). syncFailed / failedToWrite / deniedPath carry an errorMessage. See references/response-shapes.md.
Runtime — edit
--old-string not found
--old-string did not match any substring in the file. Whitespace must match exactly — escape newlines (\n) where present, and watch for trailing spaces. Read the file first and copy the substring verbatim.
--old-string matches more than once
edit requires the match to be unique. Add enough surrounding context to make the match unique (extend with the line before or after), or do multiple targeted edits in sequence.
Other notEdited reasons
Besides the --old-string cases above, edit can return fileNotFound, noOp (the new string equals the old), syncConflict / syncFailed (push race), failedToEdit, or deniedPath (editing under .files/). Frontmatter is not validated, so an edit that removes or empties title/description still applies — keep the block intact so the node stays discoverable.
Edits not appearing in GitHub
edit commits and pushes; execute does not push. If you ran a shell command that modified files (e.g. sed -i, redirecting into a file), the change stays in the ephemeral sandbox and is discarded. Use write or edit for any change that should land in git.
Runtime — execute
Command output is empty / unexpected
The runtime sandbox starts clean for each call; mutations from prior execute calls are not preserved between invocations. Don't rely on state across execute runs — chain operations in a single --command (e.g. via sh -c) instead.
Side effects not pushed
By design, execute does not commit. Use execute for inspection (grep, ls, find, counting, validation); use write/edit for any persistent change.
Argument escaping
--args is a JSON array of strings, not a shell-quoted list. Wrap the whole thing in single quotes so the shell doesn't mangle the JSON:
# Correct
cargo-ai context runtime execute --command grep --args '["-r","vp-sales","."]'
# Wrong — shell will eat the inner double quotes
cargo-ai context runtime execute --command grep --args ["-r","vp-sales","."]
Graph
Stale results after writes
graph get is cached. After a series of writes, expect a short delay before the graph reflects them. Re-run after a few seconds, or restructure logic so it does not depend on immediately-fresh graph data.
Broken cross-references
If a file references domain/slug and that target doesn't exist, the link won't resolve in the graph. Use cargo-ai context runtime browse --path <domain> to verify the target exists before writing the reference, or pipe graph get through jq to enumerate dangling refs (see references/examples/graph-queries.md).
When to escalate
If the CLI errors and --help plus the notes above don't get you unstuck — file a workspace management report rather than retrying silently. See cargo-workspace-management/SKILL.md (Reports section).
cargo-ai workspaceManagement report create \
--title "context <subcommand> fails with <errorMessage>" \
--description "Ran: cargo-ai context ... Got: {...errorMessage...} Expected: ..."