@ngockhoale/ukit 3.4.78 → 3.4.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -201,9 +201,9 @@ const HOOK_DEADLINE_MS = Number.parseInt(process.env.UKIT_HOOK_DEADLINE_MS || ''
201
201
  setTimeout(() => process.exit(0), HOOK_DEADLINE_MS).unref();
202
202
 
203
203
  (async () => {
204
- // BEGIN GENERATED SEMANTIC ENGINE sha256=c04c341ecd5922273ac127ddd37adf9dccc6c3927f0149b96845bf991bff2014
204
+ // BEGIN GENERATED SEMANTIC ENGINE sha256=db789c44db60937d51b7d9a4a9481264feb9f7152b88721bc973a16c4129f7fc
205
205
  // Canonical task semantics; intent never grants authorization or proves completion.
206
- const SEMANTIC_ENGINE_VERSION = 'round4-semantic-1:a489851b01e95788d8a3e0a080b80c04d8161c734b6c0ed5c9758a765f5bc0a4';
206
+ const SEMANTIC_ENGINE_VERSION = 'round4-semantic-1:86afd8b71e068da6a63a85fcf003f79be262881f6c203fa44682853cf8acb4f7';
207
207
 
208
208
  function semanticContractIdentity({ promptText = '', targetFile = '', taskInstanceId = null } = {}) {
209
209
  return { taskInstanceId, targetFile, engineVersion: SEMANTIC_ENGINE_VERSION,
@@ -847,7 +847,11 @@ function classifySemanticText(input = {}) {
847
847
  const PLAIN_CHANGE_VERB = /\b(?:add|change|remove|delete|bump|rename|update|fix(?:es)?|edit|modify|implement|refactor|create|write|replace|set|toggle|enable|disable|upgrade|install|them|bo sung|xoa|(?<!thay )doi(?!\s+chieu)|sua|tao|viet|chinh|cap nhat)\b/;
848
848
  const HISTORY_OBJECT = /\b(?:release(?:\s+history)?|lich su release|receipts?|worklog|ledger|status)\b/;
849
849
  const AUTH_EXCLUSION = /\b(?:khong cap phep|not authori[sz]e\w*|does not authori[sz]e|khong duoc phep)\b[^.]*\./g;
850
+ const NON_DOC_TARGET = /\b(?:tests?|code|source|ma nguon|functions?|ham|endpoints?|api|routes?|scripts?|database|db|schema|tables?|dockerfile|makefile|config(?:uration)?|cau hinh|environment|package|dependenc(?:y|ies)|publish|deploy|restart|run|chay|yarn|npm|pnpm|git|commit|push|build|install|helpers?|modules?|class(?:es)?|components?|hooks?|lint|handlers?|parsers?|bugs?|crash\w*|prs?|pull request|prod|production|staging|cron|process(?:es)?|server|service|users?|customers?)\b|[\w-]+\.(?!md\b|txt\b)[a-z][a-z0-9]{0,4}\b|(?:^|\s)\.?[\w-]+\/[\w./-]+/;
851
+ // Action verbs that, inside a docs clause, order something besides the docs edit ("update docs/x.md to fix ...").
852
+ const ACTION_VERB = /\b(?:implement|fix(?:es)?|apply|refactor|modify|add|build|make|remove|delete|rename|replace|change|set|bump|rewrite|correct|resolve|patch|optimi[sz]e|upgrade|merge|tag|upload|send|migrate|enable|disable|cancel|kill|reboot|rollback|roll out|go live|flip|verify|ship|launch|do|execute|proceed|handle|finish|complete|continue|go ahead|take care|wire|clean|sua|them|xoa|doi|bo sung|cai|lam|thuc hien|xu ly|tiep tuc|hoan thanh)\b/;
850
853
  function classifySemanticCore({ promptText = '', targetFile = '' } = {}) {
854
+ const rawPrompt = String(promptText);
851
855
  promptText = publicationScope(promptText).text;
852
856
  const releaseText = String(promptText).normalize('NFD').replace(/[̀-ͯ]/g, '').replace(/[đĐ]/g, 'd').toLowerCase();
853
857
  const preflight = releaseText.match(/\b(?:yarn\s+release:verify|npm\s+run\s+release:verify)\b/)?.[0];
@@ -868,9 +872,59 @@ function classifySemanticCore({ promptText = '', targetFile = '' } = {}) {
868
872
  const sourceOrder = actionable.some((clause) => /\b(?:implement|fix(?:es)?|apply|refactor|modify|edit|write|update|sua|viet|chinh)\b/.test(clause)
869
873
  && /\b(?:source|code|logic|scheduler|implementation|ma nguon)\b|\.[cm]?[jt]sx?\b/.test(clause));
870
874
  const codeChangeVerb = actionable.some((clause) => !/^(?:run\s+|execute\s+)?git\s+/.test(clause) && /\b(?:implement|fix(?:es)?|apply|refactor|modify|edit|write|update|sua|viet|chinh)\b/.test(clause));
871
- const reportArtifact = String(promptText).match(/(?:^|\s)((?:docs\/|reports\/)[A-Za-z0-9_./-]+\.(?:md|txt))(?=\s|[.,;:]|$)/)?.[1];
872
- const documentation = !sourceOrder && !/\b(?:implement|fix|refactor|modify|edit|update|sua|chinh)\b/.test(actionable.join(' ')) && reportArtifact && actionable.some((clause) => /\b(?:write|create|save|viet|tao|luu)\b/.test(clause))
873
- && /\b(?:report|bao cao|analysis|phan tich|document)\b/.test(text);
875
+ const scopedArtifact = String(promptText).match(/(?:^|\s)((?:docs\/|reports\/)[A-Za-z0-9_./-]+\.(?:md|txt))(?=\s|[.,;:]|$)/)?.[1];
876
+ // The scoped text is lowercased; keep the prompt's own casing so the artifact resolves on case-sensitive disks.
877
+ const reportArtifact = scopedArtifact && ([...rawPrompt.matchAll(/(?:docs|reports)\/[A-Za-z0-9_./-]+\.(?:md|txt)/gi)]
878
+ .map((match) => match[0]).find((candidate) => candidate.toLowerCase() === scopedArtifact) || scopedArtifact);
879
+ // DOCUMENTATION_OUTPUT only when EVERY actionable clause is doc-only (whitelist, fail safe): a clause naming a
880
+ // docs/ or reports/ .md/.txt file may carry only doc wording beside it; a clause naming none may contain only
881
+ // connector/doc-noun words. Any other word (a verb, a code/config/release/operation target) keeps the code or
882
+ // operation contract.
883
+ const DOC_PATH = /(?:^|\s)(?:docs|reports)\/[a-z0-9_./-]+\.(?:md|txt)\b/g;
884
+ const DOC_WORD = /^(?:a|an|the|this|that|these|those|new|full|short|brief|detailed|current|updated|final|draft|clear|concise|for|of|in|into|on|to|at|from|with|about|as|by|please|just|also|only|now|then|it|its|our|my|same|section|sections|report|reports|analysis|document|documents|documentation|doc|docs|plan|plans|planning|guide|guides|notes|note|design|spec|readme|changelog|runbook|summary|overview|proposal|roadmap|checklist|describe|describing|explain|explaining|document|documenting|summari[sz]e|summari[sz]ing|cover|covering|list|listing|record|recording|outline|outlining|write|create|save|draft|update|edit|revise|refresh|amend|viet|tao|luu|soan|lap|cap|nhat|chinh|sua doi|tai|lieu|ke|hoach|bao|cao|phan|tich|huong|dan|ghi|chu|cho|ve|vao|trong|cua|va|mot|cac|nhung|ban|moi|day|du|chi|tiet|v?\d+(?:\.\d+)*|[^a-z0-9]+)$/;
885
+ // An ordering noun (release/migration/deployment/rollout/upgrade) is prose only as the modifier of a doc noun
886
+ // ("release notes", "migration guide"); bare, it is an order ("…and release", "write the migration").
887
+ const DOC_NOUN = '(?:notes?|guides?|plans?|docs?|documents?|documentation|reports?|summary|overview|checklist|runbook|tai lieu|ke hoach|huong dan|ghi chu|bao cao)';
888
+ const docWordList = (fragment) => fragment
889
+ .replace(new RegExp(`\\b(?:release|migration|deployment|rollout|upgrade|trien khai|complete|comprehensive|thorough|step-by-step)\\s+(?=${DOC_NOUN}\\b)`, 'g'), ' ')
890
+ .replace(/\b(tai lieu|ke hoach|huong dan|bao cao)\s+(?:trien khai|nang cap|phat hanh|di chuyen)\b/g, '$1')
891
+ .split(/\s+/).filter(Boolean).every((word) => DOC_WORD.test(word.replace(/^[^a-z0-9]+|[^a-z0-9]+$/g, '')) || !/[a-z0-9]/.test(word));
892
+ const docWordsOnly = (fragment) => docWordList(fragment)
893
+ // A doc verb must name a doc noun: a bare "write"/"update" (its object neutralized, e.g. "write the fix") orders
894
+ // something unnamed and keeps the code contract.
895
+ && (!/\b(?:write|create|save|draft|update|edit|revise|refresh|amend|viet|tao|luu|soan|lap|cap nhat|chinh)\b/.test(fragment)
896
+ || /\b(?:reports?|analysis|documents?|documentation|docs?|plans?|planning|guides?|notes?|design|spec|readme|changelog|runbook|summary|overview|proposal|roadmap|checklist|tai lieu|ke hoach|bao cao|phan tich|huong dan|ghi chu)\b/.test(fragment));
897
+ // Free subject-matter prose is allowed only after a describe/explain lead ("to describe how to handle errors"),
898
+ // and only up to the next coordinator: whatever follows plus/once/as well as/parentheses/colon/dash must itself
899
+ // be doc words, so "describe X plus revert main" keeps the code contract.
900
+ const DESCRIBE_LEAD = /\b(?:describe|describing|explain|explaining|document|documenting|cover|covering|list|listing|summari[sz]e|summari[sz]ing|outline|outlining|record|recording|mo ta|giai thich)\b/;
901
+ const PROSE_BREAK = /\b(?:plus|as well as|along with|together with|once|after|before|also|first|afterwards|sau khi|truoc khi|dong thoi)\b|[()[\]{}&+:]|\s-\s/;
902
+ const INSPECTION_LEAD = /^[\s*+•>\d.)-]*(?:(?:please|just|hay|vui long|now|also|first)\s+)*(?:investigate|inspect|review|audit|analy[sz]e|check|debug|trace|look into|read|study|kiem tra|phan tich|dieu tra|tim hieu|xem)\b/;
903
+ const docOnly = actionable.length > 0 && actionable.every((clause) => {
904
+ const rest = clause.replace(DOC_PATH, ' ');
905
+ // A docs clause is whitelist-only (the path is its doc noun): every word before a describe/explain lead must be
906
+ // a doc word; after the lead, subject-matter prose is free up to the next coordinator, and each coordinated tail
907
+ // must again be doc words only ("update docs/x.md plus revert main", "…: revert main" keep the code contract).
908
+ if (rest !== clause) {
909
+ const lead = DESCRIBE_LEAD.exec(rest);
910
+ if (!lead) return docWordList(rest);
911
+ const [prose, ...tails] = rest.slice(lead.index).split(PROSE_BREAK);
912
+ return docWordList(rest.slice(0, lead.index)) && !NON_DOC_TARGET.test(prose) && tails.every((tail) => docWordList(tail));
913
+ }
914
+ // A read-only inspection clause ("investigate logs", "review the crash") feeds the report; it orders nothing.
915
+ // Every coordinated segment must itself be inspection-only or doc words only, so "investigate logs and write
916
+ // the fix" / "xem log roi cap nhat code" keep the code contract (write/update verbs are not in ACTION_VERB).
917
+ if (INSPECTION_LEAD.test(rest)) {
918
+ return rest.split(/\b(?:and|then|roi|va|sau do)\b|[,;:]/).every((segment) => (INSPECTION_LEAD.test(segment)
919
+ ? !ACTION_VERB.test(segment) && !/\b(?:write|create|update|edit|modify|cap nhat|viet|tao)\b/.test(segment)
920
+ : docWordsOnly(segment)));
921
+ }
922
+ return docWordsOnly(rest);
923
+ });
924
+ const documentation = docOnly && !sourceOrder && reportArtifact
925
+ && (actionable.some((clause) => clause.replace(DOC_PATH, ' ') !== clause && /\b(?:update|edit|modify|cap nhat|chinh)\b/.test(clause))
926
+ || (actionable.some((clause) => /\b(?:write|create|save|viet|tao|luu|soan|lap)\b/.test(clause))
927
+ && /\b(?:report|bao cao|analysis|phan tich|document(?:ation)?|tai lieu|ke hoach|plans?|guide|huong dan|notes|ghi chu|design|spec|readme|changelog|runbook)\b/.test(text.replace(/\S*\/\S*\.(?:md|txt)\b/g, ' '))));
874
928
  const hasOperationId = /\b[a-f0-9]{8}(?:[a-f0-9-]{0,28})\b/.test(text);
875
929
  const cronOperation = actionable.some((clause) => /\b(?:delete|remove|cancel|xoa|huy|ensure|dam bao)\b/.test(clause)
876
930
  && /\bcron\b|scheduled\s+(?:cron\s+)?(?:task|job)|tac vu\s+(?:cron|dinh ky)/.test(clause))
@@ -901,7 +955,9 @@ function classifySemanticCore({ promptText = '', targetFile = '' } = {}) {
901
955
  // bookkeeping next to the report it closes; it is not an ordered history operation with a remote proof.
902
956
  const statusWrapUp = /^[\s*+•>\d.)-]*(?:(?:please|hay|vui long)\s+)*(?:check|status|report|show|summari[sz]e|kiem tra|bao cao)\b/.test(actionable[0] || '')
903
957
  && actionable.some((clause) => /^[\s*+•>\d.)-]*(?:report|bao cao)\s*$/.test(clause));
904
- const runtimeClause = (clause) => !operationNotOrdered(clause) && /(?<!\b(?:process|crash|hard|soft|graceful|after|upon|during|across|following)\s)\b(?:restart|redeploy|deploy|khoi dong lai|trien khai\s+(?:len\s+)?(?:service|server|production|prod|staging|dich vu|may chu|moi truong))\b/.test(clause)
958
+ // File-path tokens name artifacts, not orders: "docs/plans/deploy.md" is not a deploy order.
959
+ const unpathed = (clause) => clause.replace(/[a-z0-9_.-]*\/[a-z0-9_./-]*|[a-z0-9_-]+\.(?:md|txt)\b/g, ' ');
960
+ const runtimeClause = (clause) => !operationNotOrdered(clause) && /(?<!\b(?:process|crash|hard|soft|graceful|after|upon|during|across|following)\s)\b(?:restart|redeploy|deploy|khoi dong lai|trien khai\s+(?:len\s+)?(?:service|server|production|prod|staging|dich vu|may chu|moi truong))\b/.test(unpathed(clause))
905
961
  && !/\.[cm]?[jt]sx?\b/.test(clause) && !/\bgit\b/.test(clause);
906
962
  const runtimeOperation = actionable.some(runtimeClause);
907
963
  // Only a PURE status wrap-up drops its bare commit; one that also orders a deploy keeps the git goal.
@@ -80,6 +80,8 @@ Two queue kinds share the `queued/` lane and must not be confused:
80
80
  - **Mandatory overflow** (`feasible`/`adapted` rows beyond the 10-task threshold): queued WITHOUT `QueueIntent` (no `Queue*` header line at all). Fullstack folds it into the cycle like a legacy blueprint; it is consumable work, never excluded.
81
81
  - **Deliberate-future** (`deferred` rows only): carries the four `Queue*` lines above. Fullstack reports it as `Backlog: <slug>`, never folds it, and drains it only when the human names the slug.
82
82
 
83
+ - **Stale / superseded** (already delivered or replaced): `QueueIntent: superseded|stale` + `QueueSupersededBy: archive:cycle-NN[, …] | queue:<slug>`. Excluded only when the runtime proves the provenance (every task archived as delivered, or a live non-cyclic replacement); otherwise it fails closed and still counts.
84
+
83
85
  A blueprint without the line keeps the legacy fold-in behaviour. The contract is documented in `docs/AI_HANDOFF/queued/README.md`.
84
86
 
85
87
  **Mandatory overflow naming (default):** group overflow tasks by dependency chain (a task and everything it depends on that is also overflow form one group). Each group is one blueprint: `queued/<plan-slug>-overflow-<NN>/`, where `<plan-slug>` is the plan's slug and `<NN>` is the next unused two-digit index under that plan (scan existing `overflow-*` dirs, take max+1). Never reuse or overwrite an existing blueprint dir; on any collision append `-2`, `-3`, … to the directory name. Each blueprint's `HANDOFF.md` lists its R-IDs and task IDs.
@@ -1,6 +1,6 @@
1
1
  // Canonical task semantics; intent never grants authorization or proves completion.
2
2
  import crypto from 'node:crypto';
3
- export const SEMANTIC_ENGINE_VERSION = 'round4-semantic-1:a489851b01e95788d8a3e0a080b80c04d8161c734b6c0ed5c9758a765f5bc0a4';
3
+ export const SEMANTIC_ENGINE_VERSION = 'round4-semantic-1:86afd8b71e068da6a63a85fcf003f79be262881f6c203fa44682853cf8acb4f7';
4
4
 
5
5
  export function semanticContractIdentity({ promptText = '', targetFile = '', taskInstanceId = null } = {}) {
6
6
  return { taskInstanceId, targetFile, engineVersion: SEMANTIC_ENGINE_VERSION,
@@ -644,7 +644,11 @@ function classifySemanticText(input = {}) {
644
644
  const PLAIN_CHANGE_VERB = /\b(?:add|change|remove|delete|bump|rename|update|fix(?:es)?|edit|modify|implement|refactor|create|write|replace|set|toggle|enable|disable|upgrade|install|them|bo sung|xoa|(?<!thay )doi(?!\s+chieu)|sua|tao|viet|chinh|cap nhat)\b/;
645
645
  const HISTORY_OBJECT = /\b(?:release(?:\s+history)?|lich su release|receipts?|worklog|ledger|status)\b/;
646
646
  const AUTH_EXCLUSION = /\b(?:khong cap phep|not authori[sz]e\w*|does not authori[sz]e|khong duoc phep)\b[^.]*\./g;
647
+ const NON_DOC_TARGET = /\b(?:tests?|code|source|ma nguon|functions?|ham|endpoints?|api|routes?|scripts?|database|db|schema|tables?|dockerfile|makefile|config(?:uration)?|cau hinh|environment|package|dependenc(?:y|ies)|publish|deploy|restart|run|chay|yarn|npm|pnpm|git|commit|push|build|install|helpers?|modules?|class(?:es)?|components?|hooks?|lint|handlers?|parsers?|bugs?|crash\w*|prs?|pull request|prod|production|staging|cron|process(?:es)?|server|service|users?|customers?)\b|[\w-]+\.(?!md\b|txt\b)[a-z][a-z0-9]{0,4}\b|(?:^|\s)\.?[\w-]+\/[\w./-]+/;
648
+ // Action verbs that, inside a docs clause, order something besides the docs edit ("update docs/x.md to fix ...").
649
+ const ACTION_VERB = /\b(?:implement|fix(?:es)?|apply|refactor|modify|add|build|make|remove|delete|rename|replace|change|set|bump|rewrite|correct|resolve|patch|optimi[sz]e|upgrade|merge|tag|upload|send|migrate|enable|disable|cancel|kill|reboot|rollback|roll out|go live|flip|verify|ship|launch|do|execute|proceed|handle|finish|complete|continue|go ahead|take care|wire|clean|sua|them|xoa|doi|bo sung|cai|lam|thuc hien|xu ly|tiep tuc|hoan thanh)\b/;
647
650
  function classifySemanticCore({ promptText = '', targetFile = '' } = {}) {
651
+ const rawPrompt = String(promptText);
648
652
  promptText = publicationScope(promptText).text;
649
653
  const releaseText = String(promptText).normalize('NFD').replace(/[̀-ͯ]/g, '').replace(/[đĐ]/g, 'd').toLowerCase();
650
654
  const preflight = releaseText.match(/\b(?:yarn\s+release:verify|npm\s+run\s+release:verify)\b/)?.[0];
@@ -665,9 +669,59 @@ function classifySemanticCore({ promptText = '', targetFile = '' } = {}) {
665
669
  const sourceOrder = actionable.some((clause) => /\b(?:implement|fix(?:es)?|apply|refactor|modify|edit|write|update|sua|viet|chinh)\b/.test(clause)
666
670
  && /\b(?:source|code|logic|scheduler|implementation|ma nguon)\b|\.[cm]?[jt]sx?\b/.test(clause));
667
671
  const codeChangeVerb = actionable.some((clause) => !/^(?:run\s+|execute\s+)?git\s+/.test(clause) && /\b(?:implement|fix(?:es)?|apply|refactor|modify|edit|write|update|sua|viet|chinh)\b/.test(clause));
668
- const reportArtifact = String(promptText).match(/(?:^|\s)((?:docs\/|reports\/)[A-Za-z0-9_./-]+\.(?:md|txt))(?=\s|[.,;:]|$)/)?.[1];
669
- const documentation = !sourceOrder && !/\b(?:implement|fix|refactor|modify|edit|update|sua|chinh)\b/.test(actionable.join(' ')) && reportArtifact && actionable.some((clause) => /\b(?:write|create|save|viet|tao|luu)\b/.test(clause))
670
- && /\b(?:report|bao cao|analysis|phan tich|document)\b/.test(text);
672
+ const scopedArtifact = String(promptText).match(/(?:^|\s)((?:docs\/|reports\/)[A-Za-z0-9_./-]+\.(?:md|txt))(?=\s|[.,;:]|$)/)?.[1];
673
+ // The scoped text is lowercased; keep the prompt's own casing so the artifact resolves on case-sensitive disks.
674
+ const reportArtifact = scopedArtifact && ([...rawPrompt.matchAll(/(?:docs|reports)\/[A-Za-z0-9_./-]+\.(?:md|txt)/gi)]
675
+ .map((match) => match[0]).find((candidate) => candidate.toLowerCase() === scopedArtifact) || scopedArtifact);
676
+ // DOCUMENTATION_OUTPUT only when EVERY actionable clause is doc-only (whitelist, fail safe): a clause naming a
677
+ // docs/ or reports/ .md/.txt file may carry only doc wording beside it; a clause naming none may contain only
678
+ // connector/doc-noun words. Any other word (a verb, a code/config/release/operation target) keeps the code or
679
+ // operation contract.
680
+ const DOC_PATH = /(?:^|\s)(?:docs|reports)\/[a-z0-9_./-]+\.(?:md|txt)\b/g;
681
+ const DOC_WORD = /^(?:a|an|the|this|that|these|those|new|full|short|brief|detailed|current|updated|final|draft|clear|concise|for|of|in|into|on|to|at|from|with|about|as|by|please|just|also|only|now|then|it|its|our|my|same|section|sections|report|reports|analysis|document|documents|documentation|doc|docs|plan|plans|planning|guide|guides|notes|note|design|spec|readme|changelog|runbook|summary|overview|proposal|roadmap|checklist|describe|describing|explain|explaining|document|documenting|summari[sz]e|summari[sz]ing|cover|covering|list|listing|record|recording|outline|outlining|write|create|save|draft|update|edit|revise|refresh|amend|viet|tao|luu|soan|lap|cap|nhat|chinh|sua doi|tai|lieu|ke|hoach|bao|cao|phan|tich|huong|dan|ghi|chu|cho|ve|vao|trong|cua|va|mot|cac|nhung|ban|moi|day|du|chi|tiet|v?\d+(?:\.\d+)*|[^a-z0-9]+)$/;
682
+ // An ordering noun (release/migration/deployment/rollout/upgrade) is prose only as the modifier of a doc noun
683
+ // ("release notes", "migration guide"); bare, it is an order ("…and release", "write the migration").
684
+ const DOC_NOUN = '(?:notes?|guides?|plans?|docs?|documents?|documentation|reports?|summary|overview|checklist|runbook|tai lieu|ke hoach|huong dan|ghi chu|bao cao)';
685
+ const docWordList = (fragment) => fragment
686
+ .replace(new RegExp(`\\b(?:release|migration|deployment|rollout|upgrade|trien khai|complete|comprehensive|thorough|step-by-step)\\s+(?=${DOC_NOUN}\\b)`, 'g'), ' ')
687
+ .replace(/\b(tai lieu|ke hoach|huong dan|bao cao)\s+(?:trien khai|nang cap|phat hanh|di chuyen)\b/g, '$1')
688
+ .split(/\s+/).filter(Boolean).every((word) => DOC_WORD.test(word.replace(/^[^a-z0-9]+|[^a-z0-9]+$/g, '')) || !/[a-z0-9]/.test(word));
689
+ const docWordsOnly = (fragment) => docWordList(fragment)
690
+ // A doc verb must name a doc noun: a bare "write"/"update" (its object neutralized, e.g. "write the fix") orders
691
+ // something unnamed and keeps the code contract.
692
+ && (!/\b(?:write|create|save|draft|update|edit|revise|refresh|amend|viet|tao|luu|soan|lap|cap nhat|chinh)\b/.test(fragment)
693
+ || /\b(?:reports?|analysis|documents?|documentation|docs?|plans?|planning|guides?|notes?|design|spec|readme|changelog|runbook|summary|overview|proposal|roadmap|checklist|tai lieu|ke hoach|bao cao|phan tich|huong dan|ghi chu)\b/.test(fragment));
694
+ // Free subject-matter prose is allowed only after a describe/explain lead ("to describe how to handle errors"),
695
+ // and only up to the next coordinator: whatever follows plus/once/as well as/parentheses/colon/dash must itself
696
+ // be doc words, so "describe X plus revert main" keeps the code contract.
697
+ const DESCRIBE_LEAD = /\b(?:describe|describing|explain|explaining|document|documenting|cover|covering|list|listing|summari[sz]e|summari[sz]ing|outline|outlining|record|recording|mo ta|giai thich)\b/;
698
+ const PROSE_BREAK = /\b(?:plus|as well as|along with|together with|once|after|before|also|first|afterwards|sau khi|truoc khi|dong thoi)\b|[()[\]{}&+:]|\s-\s/;
699
+ const INSPECTION_LEAD = /^[\s*+•>\d.)-]*(?:(?:please|just|hay|vui long|now|also|first)\s+)*(?:investigate|inspect|review|audit|analy[sz]e|check|debug|trace|look into|read|study|kiem tra|phan tich|dieu tra|tim hieu|xem)\b/;
700
+ const docOnly = actionable.length > 0 && actionable.every((clause) => {
701
+ const rest = clause.replace(DOC_PATH, ' ');
702
+ // A docs clause is whitelist-only (the path is its doc noun): every word before a describe/explain lead must be
703
+ // a doc word; after the lead, subject-matter prose is free up to the next coordinator, and each coordinated tail
704
+ // must again be doc words only ("update docs/x.md plus revert main", "…: revert main" keep the code contract).
705
+ if (rest !== clause) {
706
+ const lead = DESCRIBE_LEAD.exec(rest);
707
+ if (!lead) return docWordList(rest);
708
+ const [prose, ...tails] = rest.slice(lead.index).split(PROSE_BREAK);
709
+ return docWordList(rest.slice(0, lead.index)) && !NON_DOC_TARGET.test(prose) && tails.every((tail) => docWordList(tail));
710
+ }
711
+ // A read-only inspection clause ("investigate logs", "review the crash") feeds the report; it orders nothing.
712
+ // Every coordinated segment must itself be inspection-only or doc words only, so "investigate logs and write
713
+ // the fix" / "xem log roi cap nhat code" keep the code contract (write/update verbs are not in ACTION_VERB).
714
+ if (INSPECTION_LEAD.test(rest)) {
715
+ return rest.split(/\b(?:and|then|roi|va|sau do)\b|[,;:]/).every((segment) => (INSPECTION_LEAD.test(segment)
716
+ ? !ACTION_VERB.test(segment) && !/\b(?:write|create|update|edit|modify|cap nhat|viet|tao)\b/.test(segment)
717
+ : docWordsOnly(segment)));
718
+ }
719
+ return docWordsOnly(rest);
720
+ });
721
+ const documentation = docOnly && !sourceOrder && reportArtifact
722
+ && (actionable.some((clause) => clause.replace(DOC_PATH, ' ') !== clause && /\b(?:update|edit|modify|cap nhat|chinh)\b/.test(clause))
723
+ || (actionable.some((clause) => /\b(?:write|create|save|viet|tao|luu|soan|lap)\b/.test(clause))
724
+ && /\b(?:report|bao cao|analysis|phan tich|document(?:ation)?|tai lieu|ke hoach|plans?|guide|huong dan|notes|ghi chu|design|spec|readme|changelog|runbook)\b/.test(text.replace(/\S*\/\S*\.(?:md|txt)\b/g, ' '))));
671
725
  const hasOperationId = /\b[a-f0-9]{8}(?:[a-f0-9-]{0,28})\b/.test(text);
672
726
  const cronOperation = actionable.some((clause) => /\b(?:delete|remove|cancel|xoa|huy|ensure|dam bao)\b/.test(clause)
673
727
  && /\bcron\b|scheduled\s+(?:cron\s+)?(?:task|job)|tac vu\s+(?:cron|dinh ky)/.test(clause))
@@ -698,7 +752,9 @@ function classifySemanticCore({ promptText = '', targetFile = '' } = {}) {
698
752
  // bookkeeping next to the report it closes; it is not an ordered history operation with a remote proof.
699
753
  const statusWrapUp = /^[\s*+•>\d.)-]*(?:(?:please|hay|vui long)\s+)*(?:check|status|report|show|summari[sz]e|kiem tra|bao cao)\b/.test(actionable[0] || '')
700
754
  && actionable.some((clause) => /^[\s*+•>\d.)-]*(?:report|bao cao)\s*$/.test(clause));
701
- const runtimeClause = (clause) => !operationNotOrdered(clause) && /(?<!\b(?:process|crash|hard|soft|graceful|after|upon|during|across|following)\s)\b(?:restart|redeploy|deploy|khoi dong lai|trien khai\s+(?:len\s+)?(?:service|server|production|prod|staging|dich vu|may chu|moi truong))\b/.test(clause)
755
+ // File-path tokens name artifacts, not orders: "docs/plans/deploy.md" is not a deploy order.
756
+ const unpathed = (clause) => clause.replace(/[a-z0-9_.-]*\/[a-z0-9_./-]*|[a-z0-9_-]+\.(?:md|txt)\b/g, ' ');
757
+ const runtimeClause = (clause) => !operationNotOrdered(clause) && /(?<!\b(?:process|crash|hard|soft|graceful|after|upon|during|across|following)\s)\b(?:restart|redeploy|deploy|khoi dong lai|trien khai\s+(?:len\s+)?(?:service|server|production|prod|staging|dich vu|may chu|moi truong))\b/.test(unpathed(clause))
702
758
  && !/\.[cm]?[jt]sx?\b/.test(clause) && !/\bgit\b/.test(clause);
703
759
  const runtimeOperation = actionable.some(runtimeClause);
704
760
  // Only a PURE status wrap-up drops its bare commit; one that also orders a deploy keeps the git goal.
@@ -1499,6 +1499,17 @@ async function main() {
1499
1499
  if (!result.ok) process.exitCode = 3;
1500
1500
  return;
1501
1501
  }
1502
+ if (command === 'queue-status') {
1503
+ // Read-only queued/ lifecycle inventory (eligible / excluded / invalid) — the same classifier
1504
+ // the Stop gate uses. Lazy import: the coordinator is only needed for this command.
1505
+ const { classifyQueuedBlueprints, parseScopeQueue } = await import(new URL('./stop-coordinator.mjs', import.meta.url).href);
1506
+ const qflags = parseCliFlags([taskId, ...rest].filter((v) => v !== undefined));
1507
+ const scope = typeof qflags.scope === 'string' ? parseScopeQueue(qflags.scope) : null;
1508
+ const result = await classifyQueuedBlueprints(projectRoot, { scope });
1509
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
1510
+ if (!result.ok) process.exitCode = 3;
1511
+ return;
1512
+ }
1502
1513
  if ((command === 'claim' || command === 'release') && taskId) {
1503
1514
  // Main-agent participation in the existing claim registry (no second scheduler): the
1504
1515
  // orchestrator that must run a task itself claims it first; the guard honours `main:<session>`.
@@ -1532,6 +1543,7 @@ async function main() {
1532
1543
  process.stderr.write(
1533
1544
  'usage: resumable-run.mjs read <projectRoot> <taskId> [--boundary <id>]\n'
1534
1545
  + ' resumable-run.mjs archive-cycle <projectRoot> <NN>\n'
1546
+ + ' resumable-run.mjs queue-status <projectRoot> [--scope <slug,slug|none>]\n'
1535
1547
  + ' resumable-run.mjs claim|release <projectRoot> <taskId> --owner <main:session> [--cycle <NN>] [--generation <N>]\n'
1536
1548
  + ' resumable-run.mjs suspend <projectRoot> <taskId> [--boundary <id>] '
1537
1549
  + '[--phase <phase>] [--next <action>] [--completed <a,b,...>]\n',