tinkaria
Artifacts

Patch & token efficiency

Patch live index.html with a small patchlang envelope and know when to replace.

Patch when the edit is small and anchored. Replace when a retry would cost as much as sending a new full artifact.

Patch envelope

POST /apps/{id}/content/patch applies one patchlang envelope to the current dist artifact:

{
  "file": "index.html",
  "pre": "<index-pre>",
  "find": "Contact PKR Docs",
  "replace": "Contact PKR Docs patched"
}

file defaults to index.html. pre is the patchlang content hash of the current target file bytes. find must occur exactly once.

# Patch index.html inside the current dist artifact.
# docjourney: step=artifact-patch
curl -s -X POST "https://t.tini.works/apps/journey/content/patch" \
  -H "authorization: Bearer <short-key>" \
  -H "content-type: application/json" \
  -d '{"file":"index.html","pre":"<index-pre>","find":"Contact PKR Docs","replace":"Contact PKR Docs patched"}'
# -> {"artifact_id":"<new-sha256>","app":"journey","file":"index.html","hash":"<new-sha256>","live":true,"new_hash":"<new-sha256>","old_hash":"<old-sha256>","old_file_hash":"<index-pre>","new_file_hash":"<next-index-pre>","target":"dist"}

409 taxonomy

error_kindMeaningNext action
stale_preconditionpre does not match the current target file hash.Re-read the current artifact file hash before deciding patch or replace.
missing_anchorfind matched 0 times.Do not fuzzy patch. Recompute cost, then replace if the retry is not cheaper.
ambiguous_anchorfind matched more than once.Pick a unique anchor or replace the target file.

On any 409, the current dist artifact stays live.

Patch-vs-replace rule

Patch-vs-replace rule: patch only when target_file_tokens >= 6 AND edit_count <= 25 AND edited_share_pct <= 31.25 AND no fail-closed anchor retry; after any anchor failure compute retry-adjusted cost and replace when >= replacement. Replace means send a fresh template or Emmet publish request for the whole target instead of another patch.

On this page