@semacode/cli 2.3.0 → 3.0.0

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.
Files changed (267) hide show
  1. package/LICENSE +39 -39
  2. package/README.md +112 -41
  3. package/dist/agentContextPack.js +14 -10
  4. package/dist/agentEntryPoints.d.ts +5 -0
  5. package/dist/agentEntryPoints.js +102 -91
  6. package/dist/angular-consumer-standalone.d.ts +3 -1
  7. package/dist/angular-consumer-standalone.js +12 -8
  8. package/dist/bin.d.ts +6 -0
  9. package/dist/bin.js +130 -0
  10. package/dist/cliArgs.js +4 -4
  11. package/dist/cliControlError.d.ts +12 -0
  12. package/dist/cliControlError.js +47 -0
  13. package/dist/cliGrammar.d.ts +11 -0
  14. package/dist/cliGrammar.js +551 -0
  15. package/dist/cliHelp.d.ts +13 -0
  16. package/dist/cliHelp.js +19 -0
  17. package/dist/cliHelpTexto.d.ts +3 -0
  18. package/dist/cliHelpTexto.js +168 -0
  19. package/dist/cliRuntime.d.ts +2 -0
  20. package/dist/cliRuntime.js +31 -0
  21. package/dist/comandos.js +9 -22
  22. package/dist/contexto.js +5 -5
  23. package/dist/dev/index.d.ts +1 -0
  24. package/dist/dev/index.js +51 -9
  25. package/dist/discovery/catalog.js +3 -3
  26. package/dist/distribuicao/filesystemGlobal.d.ts +63 -0
  27. package/dist/distribuicao/filesystemGlobal.js +701 -0
  28. package/dist/distribuicao/index.d.ts +7 -0
  29. package/dist/distribuicao/index.js +227 -0
  30. package/dist/distribuicao/launcherGlobal.d.ts +53 -0
  31. package/dist/distribuicao/launcherGlobal.js +643 -0
  32. package/dist/distribuicao/launcherWindows.d.ts +28 -0
  33. package/dist/distribuicao/launcherWindows.js +326 -0
  34. package/dist/distribuicao/lockContextGlobal.d.ts +10 -0
  35. package/dist/distribuicao/lockContextGlobal.js +17 -0
  36. package/dist/distribuicao/lockGlobal.d.ts +6 -0
  37. package/dist/distribuicao/lockGlobal.js +520 -0
  38. package/dist/distribuicao/skillGlobal.d.ts +48 -0
  39. package/dist/distribuicao/skillGlobal.js +652 -0
  40. package/dist/distribuicao/skillIntentPolicy.d.ts +21 -0
  41. package/dist/distribuicao/skillIntentPolicy.js +115 -0
  42. package/dist/distribuicao/tipos.d.ts +50 -0
  43. package/dist/distribuicao/tipos.js +10 -0
  44. package/dist/distribuicao/versaoSemantica.d.ts +3 -0
  45. package/dist/distribuicao/versaoSemantica.js +62 -0
  46. package/dist/drift.part01.d.ts +34 -2
  47. package/dist/drift.part01.js +3 -0
  48. package/dist/drift.part04.d.ts +12 -2
  49. package/dist/drift.part04.js +89 -15
  50. package/dist/drift.part05.d.ts +2 -1
  51. package/dist/drift.part05.js +9 -6
  52. package/dist/drift.part06.d.ts +2 -1
  53. package/dist/drift.part06.js +115 -24
  54. package/dist/drift.part07.d.ts +11 -10
  55. package/dist/drift.part07.js +261 -255
  56. package/dist/drift.part08.d.ts +2 -1
  57. package/dist/drift.part08.js +35 -25
  58. package/dist/drift.part11.js +279 -32
  59. package/dist/drift.part12.d.ts +1 -1
  60. package/dist/drift.part12.js +196 -11
  61. package/dist/drift.part13.d.ts +18 -2
  62. package/dist/drift.part13.js +654 -76
  63. package/dist/drift.part14.js +21 -7
  64. package/dist/driftCacheCas.d.ts +43 -0
  65. package/dist/driftCacheCas.js +351 -0
  66. package/dist/driftCacheFilesystem.d.ts +64 -0
  67. package/dist/driftCacheFilesystem.js +313 -0
  68. package/dist/driftCacheModes.d.ts +38 -0
  69. package/dist/driftCacheModes.js +147 -0
  70. package/dist/driftCacheStore.d.ts +80 -0
  71. package/dist/driftCacheStore.js +603 -0
  72. package/dist/driftCatalogo.d.ts +65 -0
  73. package/dist/driftCatalogo.js +516 -0
  74. package/dist/driftEscopo.d.ts +21 -0
  75. package/dist/driftEscopo.js +647 -0
  76. package/dist/driftEscopoReferencias.d.ts +8 -0
  77. package/dist/driftEscopoReferencias.js +612 -0
  78. package/dist/driftOrcamento.d.ts +6 -0
  79. package/dist/driftOrcamento.js +20 -3
  80. package/dist/geracaoCore.js +4 -6
  81. package/dist/iaPrompts.d.ts +3 -3
  82. package/dist/iaPrompts.js +13 -14
  83. package/dist/index.d.ts +4 -1
  84. package/dist/index.js +6 -25
  85. package/dist/index.part01.d.ts +21 -14
  86. package/dist/index.part01.js +20 -165
  87. package/dist/index.part02.js +57 -43
  88. package/dist/index.part03.d.ts +23 -1
  89. package/dist/index.part03.js +83 -8
  90. package/dist/index.part04.d.ts +10 -2
  91. package/dist/index.part04.js +48 -14
  92. package/dist/index.part05.d.ts +1 -1
  93. package/dist/index.part05.js +109 -30
  94. package/dist/index.part06.js +34 -16
  95. package/dist/index.part07.js +31 -27
  96. package/dist/index.part08.d.ts +1 -1
  97. package/dist/index.part08.js +23 -28
  98. package/dist/init/templates.part01.js +393 -393
  99. package/dist/init/templates.part02.js +189 -189
  100. package/dist/initCommand.js +5 -1
  101. package/dist/initTemplatesBackend.js +73 -73
  102. package/dist/initTemplatesBase.js +7 -5
  103. package/dist/initTemplatesFlutter.js +137 -137
  104. package/dist/initTemplatesRuntime.js +350 -350
  105. package/dist/initTemplatesWeb.js +309 -309
  106. package/dist/pipelineConteudo/command.d.ts +1 -0
  107. package/dist/pipelineConteudo/command.js +4 -32
  108. package/dist/pipelineConteudo/help.d.ts +2 -0
  109. package/dist/pipelineConteudo/help.js +33 -0
  110. package/dist/profileAuthorCommand.js +3 -7
  111. package/dist/profileCommand.js +3 -7
  112. package/dist/projeto.d.ts +1 -1
  113. package/dist/projetoCarregar.d.ts +2 -2
  114. package/dist/projetoCarregar.js +69 -28
  115. package/dist/projetoCatalogo.d.ts +8 -0
  116. package/dist/projetoCatalogo.js +164 -0
  117. package/dist/projetoOrigens.d.ts +2 -0
  118. package/dist/projetoOrigens.js +65 -9
  119. package/dist/projetoTipos.d.ts +15 -5
  120. package/dist/resultadoCli.d.ts +20 -0
  121. package/dist/resultadoCli.js +57 -0
  122. package/dist/saidaCli.d.ts +35 -0
  123. package/dist/saidaCli.js +118 -0
  124. package/dist/sistemasInterativos/acceptanceEvidence.d.ts +22 -0
  125. package/dist/sistemasInterativos/acceptanceEvidence.js +345 -0
  126. package/dist/sistemasInterativos/engineObservation.d.ts +12 -0
  127. package/dist/sistemasInterativos/engineObservation.js +438 -0
  128. package/dist/sistemasInterativos/jobOrchestration.d.ts +2 -0
  129. package/dist/sistemasInterativos/jobOrchestration.js +204 -0
  130. package/dist/sistemasInterativos/operationPrimitives.d.ts +21 -0
  131. package/dist/sistemasInterativos/operationPrimitives.js +194 -0
  132. package/dist/sistemasInterativos/operations.d.ts +4 -39
  133. package/dist/sistemasInterativos/operations.js +5 -1164
  134. package/dist/skillCommand.d.ts +5 -0
  135. package/dist/skillCommand.js +88 -0
  136. package/dist/sync/index.js +35 -35
  137. package/docs/README.md +11 -7
  138. package/docs/ai-integration.md +18 -11
  139. package/docs/ai-onboarding.md +81 -62
  140. package/docs/ai-workflow.md +10 -4
  141. package/docs/auth.md +26 -26
  142. package/docs/cli.md +197 -79
  143. package/docs/commands.md +30 -6
  144. package/docs/database.md +15 -15
  145. package/docs/deploy.md +54 -41
  146. package/docs/documentation.md +11 -10
  147. package/docs/drift-cache.md +108 -0
  148. package/docs/env.md +16 -16
  149. package/docs/frontend.md +41 -41
  150. package/docs/getting-started.md +82 -57
  151. package/docs/i18n.md +15 -15
  152. package/docs/repositories.md +60 -43
  153. package/docs/rollback.md +38 -31
  154. package/docs/security.md +54 -32
  155. package/docs/sistemas-interativos.md +27 -27
  156. package/docs/support.md +8 -8
  157. package/docs/testing.md +123 -17
  158. package/docs/vocabulary.md +29 -29
  159. package/exemplos/agendamento.sema +1 -1
  160. package/exemplos/assinatura.sema +1 -1
  161. package/exemplos/auditoria.sema +1 -1
  162. package/exemplos/autenticacao.sema +1 -1
  163. package/exemplos/author_obra_comum.sema +1 -1
  164. package/exemplos/author_tema_sensivel.sema +1 -1
  165. package/exemplos/automacao.sema +1 -1
  166. package/exemplos/cadastro_usuario.sema +1 -1
  167. package/exemplos/calculadora.sema +1 -1
  168. package/exemplos/crud_simples.sema +1 -1
  169. package/exemplos/estoque.sema +1 -1
  170. package/exemplos/exportacao.sema +1 -1
  171. package/exemplos/fila.sema +1 -1
  172. package/exemplos/integracao_externa.sema +1 -1
  173. package/exemplos/multi_tenant.sema +1 -1
  174. package/exemplos/notificacao.sema +1 -1
  175. package/exemplos/operacao_estrategia.sema +132 -132
  176. package/exemplos/operacao_estrategia_discovery.sema +220 -220
  177. package/exemplos/operacao_estrategia_fluxo.sema +114 -114
  178. package/exemplos/operacao_estrategia_gates.sema +106 -106
  179. package/exemplos/operacao_estrategia_quarentena.sema +133 -133
  180. package/exemplos/operacao_estrategia_rollout.sema +124 -124
  181. package/exemplos/pagamento.sema +1 -1
  182. package/exemplos/pagamento_dominio.sema +1 -1
  183. package/exemplos/pedido.sema +1 -1
  184. package/exemplos/permissao.sema +1 -1
  185. package/exemplos/persistencia_vendor_first.sema +1 -1
  186. package/exemplos/profile_conversas.sema +165 -165
  187. package/exemplos/profile_game.sema +1 -1
  188. package/exemplos/profile_legal.sema +1 -1
  189. package/exemplos/profile_ops.sema +1 -1
  190. package/exemplos/profile_research.sema +1 -1
  191. package/exemplos/profile_software.sema +1 -1
  192. package/exemplos/profile_workflow_n8n.sema +1 -1
  193. package/exemplos/relatorio.sema +1 -1
  194. package/exemplos/replica_analitica_erp.sema +1 -1
  195. package/exemplos/testes_embutidos.sema +1 -1
  196. package/exemplos/tratamento_erro.sema +1 -1
  197. package/exemplos/upload_arquivo.sema +1 -1
  198. package/exemplos/webhook.sema +1 -1
  199. package/node_modules/@sema/gerador-cpp/dist/index.js +176 -176
  200. package/node_modules/@sema/gerador-css/dist/index.part01.js +10 -10
  201. package/node_modules/@sema/gerador-css/dist/index.part02.js +460 -460
  202. package/node_modules/@sema/gerador-dotnet/dist/index.js +169 -169
  203. package/node_modules/@sema/gerador-html/dist/index.js +17 -17
  204. package/node_modules/@sema/gerador-python/dist/index.part02.js +3 -3
  205. package/node_modules/@sema/gerador-typescript/dist/index.part02.js +11 -11
  206. package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +42 -42
  207. package/node_modules/@sema/nucleo/dist/semantico/analisador.d.ts +1 -0
  208. package/node_modules/@sema/nucleo/dist/semantico/analisador.js +1 -0
  209. package/package.json +7 -2
  210. package/scripts/postinstall.mjs +148 -0
  211. package/skills/sema/SKILL.md +199 -0
  212. package/skills/sema/agents/openai.yaml +4 -0
  213. package/node_modules/@sema/gerador-cpp/dist/index.js.map +0 -1
  214. package/node_modules/@sema/gerador-css/dist/index.js.map +0 -1
  215. package/node_modules/@sema/gerador-css/dist/index.part01.js.map +0 -1
  216. package/node_modules/@sema/gerador-css/dist/index.part02.js.map +0 -1
  217. package/node_modules/@sema/gerador-dart/dist/index.js.map +0 -1
  218. package/node_modules/@sema/gerador-dotnet/dist/index.js.map +0 -1
  219. package/node_modules/@sema/gerador-html/dist/index.js.map +0 -1
  220. package/node_modules/@sema/gerador-javascript/dist/index.js.map +0 -1
  221. package/node_modules/@sema/gerador-lua/dist/index.js.map +0 -1
  222. package/node_modules/@sema/gerador-php/dist/index.js.map +0 -1
  223. package/node_modules/@sema/gerador-python/dist/index.js.map +0 -1
  224. package/node_modules/@sema/gerador-python/dist/index.part01.js.map +0 -1
  225. package/node_modules/@sema/gerador-python/dist/index.part02.js.map +0 -1
  226. package/node_modules/@sema/gerador-typescript/dist/index.js.map +0 -1
  227. package/node_modules/@sema/gerador-typescript/dist/index.part01.js.map +0 -1
  228. package/node_modules/@sema/gerador-typescript/dist/index.part02.js.map +0 -1
  229. package/node_modules/@sema/gerador-typescript/dist/index.part03.js.map +0 -1
  230. package/node_modules/@sema/nucleo/dist/ast/tipos.js.map +0 -1
  231. package/node_modules/@sema/nucleo/dist/diagnosticos/index.js.map +0 -1
  232. package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js.map +0 -1
  233. package/node_modules/@sema/nucleo/dist/diagnosticos/snippets.js.map +0 -1
  234. package/node_modules/@sema/nucleo/dist/formatador/index.js.map +0 -1
  235. package/node_modules/@sema/nucleo/dist/formatador/index.part01.js.map +0 -1
  236. package/node_modules/@sema/nucleo/dist/formatador/index.part02.js.map +0 -1
  237. package/node_modules/@sema/nucleo/dist/index.js.map +0 -1
  238. package/node_modules/@sema/nucleo/dist/ir/conversor.js.map +0 -1
  239. package/node_modules/@sema/nucleo/dist/ir/conversor.part01.js.map +0 -1
  240. package/node_modules/@sema/nucleo/dist/ir/conversor.part02.js.map +0 -1
  241. package/node_modules/@sema/nucleo/dist/ir/conversor.part03.js.map +0 -1
  242. package/node_modules/@sema/nucleo/dist/ir/modelos.js.map +0 -1
  243. package/node_modules/@sema/nucleo/dist/lexer/lexer.js.map +0 -1
  244. package/node_modules/@sema/nucleo/dist/lexer/tokens.js.map +0 -1
  245. package/node_modules/@sema/nucleo/dist/parser/parser.declaracoes.js.map +0 -1
  246. package/node_modules/@sema/nucleo/dist/parser/parser.js.map +0 -1
  247. package/node_modules/@sema/nucleo/dist/parser/parser.modulo.js.map +0 -1
  248. package/node_modules/@sema/nucleo/dist/parser/parser.part01.js.map +0 -1
  249. package/node_modules/@sema/nucleo/dist/parser/parser.part02.js.map +0 -1
  250. package/node_modules/@sema/nucleo/dist/parser/parser.part03.js.map +0 -1
  251. package/node_modules/@sema/nucleo/dist/persistencia/contratos.js.map +0 -1
  252. package/node_modules/@sema/nucleo/dist/semantico/analisador.js.map +0 -1
  253. package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js.map +0 -1
  254. package/node_modules/@sema/nucleo/dist/semantico/analisador.part02.js.map +0 -1
  255. package/node_modules/@sema/nucleo/dist/semantico/analisador.part03.js.map +0 -1
  256. package/node_modules/@sema/nucleo/dist/semantico/analisador.part04.js.map +0 -1
  257. package/node_modules/@sema/nucleo/dist/semantico/analisador.part05.js.map +0 -1
  258. package/node_modules/@sema/nucleo/dist/semantico/analisador.part06.js.map +0 -1
  259. package/node_modules/@sema/nucleo/dist/semantico/analisador.part07.js.map +0 -1
  260. package/node_modules/@sema/nucleo/dist/semantico/analisador.part08.js.map +0 -1
  261. package/node_modules/@sema/nucleo/dist/semantico/estruturas.js.map +0 -1
  262. package/node_modules/@sema/nucleo/dist/semantico/estruturas.part01.js.map +0 -1
  263. package/node_modules/@sema/nucleo/dist/semantico/estruturas.part02.js.map +0 -1
  264. package/node_modules/@sema/nucleo/dist/semantico/orcamentoSemantico.js.map +0 -1
  265. package/node_modules/@sema/nucleo/dist/semantico/seguranca.js.map +0 -1
  266. package/node_modules/@sema/nucleo/dist/util/arquivos.js.map +0 -1
  267. package/node_modules/@sema/padroes/dist/index.js.map +0 -1
package/docs/cli.md CHANGED
@@ -1,79 +1,197 @@
1
- # Sema CLI
2
-
3
- Sema is a Codex-native local CLI distribution. The public package reads the
4
- workspace on the user's machine, validates `.sema` contracts, checks drift,
5
- maps impact, and generates code without login, user authorization, license
6
- activation, tokens, credits, billing services, a control panel, or external
7
- service credentials.
8
-
9
- Support: suporte@otimitare.online
10
-
11
- ## Install
12
-
13
- ```bash
14
- npm install -g @semacode/cli
15
- sema --version
16
- ```
17
-
18
- For development inside this repository:
19
-
20
- ```bash
21
- npm install
22
- npm run build
23
- node pacotes/cli/dist/index.js --help
24
- ```
25
-
26
- ## Codex Setup
27
-
28
- `AGENTS.md` is the official Sema entrypoint for Codex. Create or refresh it from
29
- the local CLI:
30
-
31
- ```bash
32
- sema sync-codex --json
33
- ```
34
-
35
- Codex automatically loads `AGENTS.md` as repository guidance. Sema is an
36
- independent product and is not affiliated with or endorsed by OpenAI.
37
-
38
- ## Required Local Flow
39
-
40
- Codex and humans should use the same local sequence before changing governed
41
- code, contracts, workflows, release scripts, or operational docs:
42
-
43
- ```bash
44
- sema --version
45
- sema resumo
46
- sema docs-impacto --intencao "describe the change" --json
47
- sema inspecionar contratos/example.sema --json
48
- sema drift contratos/example.sema --escopo modulo --json
49
- sema impacto contratos/example.sema --alvo sema.example.target --mudanca "describe the change" --json
50
- ```
51
-
52
- Commands run directly against the local workspace. If `sema --version` fails,
53
- install or repair the npm package; there is no separate authorization gate.
54
-
55
- ## Core Commands
56
-
57
- - `sema iniciar`: create a governed starting point.
58
- - `sema validar`: validate `.sema` contracts.
59
- - `sema inspecionar`: inspect the applicable contract surface.
60
- - `sema drift`: compare contracts and implementation.
61
- - `sema impacto`: map the blast radius of a planned change.
62
- - `sema docs-impacto`: identify docs that must be read or updated.
63
- - `sema finalizar-mudanca`: close the governed change with evidence.
64
- - `sema compilar`: generate code from contracts.
65
- - `sema testar`: generate, compile, and execute local contract tests, including `dotnet` and `cpp`.
66
- - `sema verificar`: run the final local verification bundle.
67
- - `sema contexto-ia`: build local AI context from a contract.
68
- - `sema sync-codex`: create or refresh the official `AGENTS.md` entrypoint.
69
-
70
- Generation targets are `typescript`, `python`, `php`, `dart`, `lua`,
71
- `javascript`, `html`, `css`, `dotnet`, and `cpp`. The aliases `cs` and
72
- `csharp` select `dotnet`; `c++`, `cxx`, and `cc` select `cpp`.
73
- Native targets are opt-in in `sema.config.json.alvos` for project-wide
74
- verification because they require local compiler toolchains.
75
-
76
- ## Public Boundary
77
-
78
- Do not publish private or sensitive operational material in public Sema
79
- artifacts.
1
+ # Sema CLI
2
+
3
+ Sema is a Codex-native local CLI distribution. The public package reads the
4
+ workspace on the user's machine, validates `.sema` contracts, checks drift,
5
+ maps impact, and generates code without login, user authorization, license
6
+ activation, tokens, credits, billing services, a control panel, or external
7
+ service credentials.
8
+
9
+ Support: suporte@otimitare.online
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install -g @semacode/cli
15
+ sema --version
16
+ sema skill status --json
17
+ ```
18
+
19
+ The global install bundles the portable Sema skill and creates a launcher under
20
+ `~/.sema/bin` with absolute Node.js and CLI paths. If the npm shim is absent
21
+ from `PATH`, run `~/.sema/bin/sema` on macOS/Linux. On Windows, PowerShell
22
+ resolves `sema.ps1` from `PATH`, while `cmd.exe` resolves `sema.cmd`; invoke the
23
+ managed fallback through the absolute system executable:
24
+
25
+ ```powershell
26
+ & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\.sema\bin\sema-managed.ps1" --version
27
+ ```
28
+
29
+ Use `sema skill sync --json` to repair an installation performed with lifecycle
30
+ scripts disabled.
31
+
32
+ For development inside this repository:
33
+
34
+ ```bash
35
+ npm install
36
+ npm run build
37
+ node pacotes/cli/dist/bin.js --help
38
+ ```
39
+
40
+ ## Side-Effect-Free Help
41
+
42
+ `--help` and `-h` take precedence wherever they appear in argv, including after
43
+ an unknown command or option. The CLI exits with status `0` before command
44
+ runtime import, command dispatch, or handler resolution. Help does not inspect or mutate the workspace,
45
+ home, user cache, or plugin cache, start a subprocess, or make a network call.
46
+
47
+ `dist/bin.js` is the executable bootstrap and imports the operational runtime
48
+ only after these control paths finish. `dist/index.js` remains the package API
49
+ entrypoint and is not an executable alias.
50
+
51
+ ```bash
52
+ sema iniciar --help
53
+ sema formatar --help
54
+ sema sync-codex --help
55
+ sema skill sync --help
56
+ sema unknown --option value --help
57
+ ```
58
+
59
+ ## Public JSON Output
60
+
61
+ `sema --version` (and its version aliases) prints one plain exact SemVer string.
62
+ It is intentionally not wrapped in JSON.
63
+
64
+ ### Help and command control
65
+
66
+ Adding `--json` to help or a command-control failure emits exactly one JSON
67
+ document on stdout and keeps stderr empty:
68
+
69
+ ```json
70
+ {
71
+ "schemaVersion": "sema.cli.control/v1",
72
+ "ok": true,
73
+ "kind": "HELP",
74
+ "code": "CLI_HELP",
75
+ "message": "Sema CLI help",
76
+ "exitCode": 0
77
+ }
78
+ ```
79
+
80
+ The envelope contains exactly `schemaVersion`, `ok`, `kind`, `code`, `message`,
81
+ and `exitCode`. Supported control kinds are `HELP`, `UNKNOWN_COMMAND`,
82
+ `ARGUMENT_ERROR`, and `FATAL_ERROR`. Help uses exit code `0`; failures preserve
83
+ a non-zero process status equal to `exitCode`. Failure messages are public and
84
+ redacted: they do not include stacks, absolute paths, raw argv, or internal
85
+ causes.
86
+
87
+ Command-control failures are unknown top-level commands or subcommands, missing
88
+ or invalid required CLI arguments/options rejected before valid dispatch, and
89
+ uncaught runtime exceptions. An uncaught exception uses the redacted
90
+ `FATAL_ERROR` control envelope. `sema.cli.control/v1` is never nested inside a
91
+ command result.
92
+
93
+ ### Valid command results
94
+
95
+ In 3.0.0, every syntactically valid command invoked with `--json` emits exactly
96
+ one `sema.cli.result/v1` document on stdout with empty stderr:
97
+
98
+ ```json
99
+ {
100
+ "schemaVersion": "sema.cli.result/v1",
101
+ "ok": true,
102
+ "kind": "SUCCESS",
103
+ "command": "resumo",
104
+ "code": "CLI_SUCCESS",
105
+ "message": null,
106
+ "exitCode": 0,
107
+ "payload": {
108
+ "comando": "resumo",
109
+ "sucesso": true
110
+ }
111
+ }
112
+ ```
113
+
114
+ The result envelope contains exactly `schemaVersion`, `ok`, `kind`, `command`,
115
+ `code`, `message`, `exitCode`, and `payload`; extra or missing fields are
116
+ invalid, and `data` is not an alias for `payload`. `command` is the canonical
117
+ top-level command name. `payload` is always present and may be any JSON value,
118
+ including an object, array, scalar, or `null`.
119
+
120
+ - `SUCCESS` requires `ok: true`, `code: "CLI_SUCCESS"`, `message: null`, and
121
+ `exitCode: 0`.
122
+ - `DOMAIN_ERROR` requires `ok: false`, `code: "CLI_DOMAIN_ERROR"`, a non-empty
123
+ safe public `message`, and a positive `exitCode` equal to the process status.
124
+
125
+ The envelope describes the CLI result transport and classification. It does
126
+ not replace the command's domain model: consumers must unwrap `payload` and
127
+ evaluate fields such as `payload.sucesso`, `payload.aprovado`,
128
+ `payload.bloqueado`, or another command-specific verdict separately. A
129
+ syntactically valid operation that returns a structured domain failure uses
130
+ `DOMAIN_ERROR`; it does not fall back to `sema.cli.control/v1`.
131
+
132
+ ## Codex Setup
133
+
134
+ `AGENTS.md` is the official Sema entrypoint for Codex. Create or refresh it from
135
+ the local CLI:
136
+
137
+ ```bash
138
+ sema sync-codex --json
139
+ ```
140
+
141
+ Codex automatically loads `AGENTS.md` as repository guidance. Sema is an
142
+ independent product and is not affiliated with or endorsed by OpenAI.
143
+
144
+ ## Required Local Flow
145
+
146
+ Codex and humans should use the same local sequence before changing governed
147
+ code, contracts, workflows, release scripts, or operational docs:
148
+
149
+ ```bash
150
+ sema --version
151
+ sema resumo --drift none
152
+ sema docs-impacto --intencao "describe the change" --json
153
+ sema inspecionar contratos/example.sema --drift none --json
154
+ sema drift contratos/example.sema --escopo modulo --cache fresh --json
155
+ sema impacto contratos/example.sema --alvo sema.example.target --mudanca "describe the change" --json
156
+ ```
157
+
158
+ Commands run directly against the local workspace. If `sema --version` fails,
159
+ try the managed absolute launcher before declaring the CLI unavailable. If both
160
+ fail, install or repair the npm package; there is no separate authorization
161
+ gate.
162
+
163
+ ## Core Commands
164
+
165
+ - `sema iniciar`: create a governed starting point.
166
+ - `sema validar`: validate `.sema` contracts.
167
+ - `sema inspecionar`: inspect the applicable contract surface; add `--drift cache|fresh` to request code evidence.
168
+ - `sema drift`: compare contracts and implementation with `--cache none|cache|fresh` (default `fresh`).
169
+ - `sema impacto`: map the blast radius of a planned change.
170
+ - `sema docs-impacto`: identify docs that must be read or updated.
171
+ - `sema finalizar-mudanca`: close the governed change with evidence.
172
+ - `sema compilar`: generate code from contracts.
173
+ - `sema testar`: generate, compile, and execute local contract tests, including `dotnet` and `cpp`.
174
+ - `sema verificar`: run the final local verification bundle.
175
+ - `sema contexto-ia`: build local AI context from a contract.
176
+ - `sema sync-codex`: create or refresh the official `AGENTS.md` entrypoint.
177
+ - `sema skill status|sync`: inspect or repair the managed launcher and bundled
178
+ global skill without touching plugin caches or workspace files.
179
+
180
+ `resumo` and `inspecionar` default to `--drift none`, so they do not fabricate
181
+ scores or implementation evidence. In this mode those fields inside `payload`
182
+ are `null` or explicitly not evaluated. `sema drift --cache none` still runs
183
+ the analysis but does not touch persistent cache. `cache` reuses only a validated extraction hit;
184
+ `fresh` ignores hits and republishes recalculated extraction data. Cache objects
185
+ live in the operating system's user-cache directory outside the workspace, and
186
+ the final links, diagnostics, score, and success decision are always recomputed.
187
+
188
+ Generation targets are `typescript`, `python`, `php`, `dart`, `lua`,
189
+ `javascript`, `html`, `css`, `dotnet`, and `cpp`. The aliases `cs` and
190
+ `csharp` select `dotnet`; `c++`, `cxx`, and `cc` select `cpp`.
191
+ Native targets are opt-in in `sema.config.json.alvos` for project-wide
192
+ verification because they require local compiler toolchains.
193
+
194
+ ## Public Boundary
195
+
196
+ Do not publish private or sensitive operational material in public Sema
197
+ artifacts.
package/docs/commands.md CHANGED
@@ -7,19 +7,30 @@ Use this file when Codex does not know which command to run. A Sema command is a
7
7
 
8
8
  ```bash
9
9
  sema --version
10
- sema resumo
10
+ sema resumo --drift none
11
11
  sema docs-impacto --intencao "<acao>" --json
12
12
  ```
13
13
 
14
+ If `sema` is absent from `PATH`, use `$HOME/.sema/bin/sema` on macOS/Linux. On Windows, PowerShell resolves `sema.ps1` from PATH, cmd.exe resolves `sema.cmd`, and the absolute fallback is `& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\.sema\bin\sema-managed.ps1" --version`. `sema skill sync --json` repairs launcher and skill without touching the workspace or plugin caches.
15
+
14
16
  Then read every required doc returned by `docs-impacto`.
15
17
 
18
+ ## Public JSON output
19
+
20
+ `sema --version` stays plain exact SemVer text. With `--json`, help and command-control failures use exactly one six-field `sema.cli.control/v1` document on stdout with empty stderr. Every syntactically valid command uses exactly one eight-field `sema.cli.result/v1` document containing only `schemaVersion`, `ok`, `kind`, `command`, `code`, `message`, `exitCode`, and `payload`. The command-specific result is nested under `payload`, never `data`; envelope `ok` does not replace domain fields inside that payload. Valid structured domain failures use `DOMAIN_ERROR`, while uncaught runtime exceptions remain redacted `FATAL_ERROR` control failures.
21
+
22
+ ## Global Distribution
23
+
24
+ - `sema skill status --json`: diagnoses the managed launcher and bundled skill without writing.
25
+ - `sema skill sync --json`: repairs only Sema-managed launcher and skill destinations; it never writes into the workspace or plugin caches.
26
+
16
27
  ## Contract and Discovery
17
28
 
18
29
  - `sema iniciar --template <template> [--force]`: creates a new Sema project and preserves existing files by default; `--force` is the only explicit overwrite path.
19
30
  - `sema validar <arquivo-ou-pasta> --json`: validates `.sema` contracts.
20
31
  - `sema diagnosticos <arquivo.sema> --json`: details errors and warnings.
21
32
  - `sema formatar <arquivo-ou-pasta>`: formats contracts.
22
- - `sema inspecionar <arquivo-ou-pasta> --json`: shows modules, tasks, routes, entities, links, and expected files.
33
+ - `sema inspecionar <arquivo-ou-pasta> [--drift <none|cache|fresh>] --json`: shows the contract surface; drift is skipped by default.
23
34
  - `sema ast <arquivo.sema> --json`: shows AST for syntax debugging.
24
35
  - `sema ir <arquivo.sema> --json`: shows the IR used by gates and generators.
25
36
  - `sema descobrir catalogo --json`: lists governance flows, profiles, specialized workflows, pipelines, generators, capability tokens, and adapters from their canonical registries.
@@ -30,12 +41,24 @@ Then read every required doc returned by `docs-impacto`.
30
41
  ## Change and Closure
31
42
 
32
43
  - `sema docs-impacto --intencao "<acao>" --json`: discovers required docs and documentary blockers.
33
- - `sema drift <arquivo-ou-pasta> --escopo modulo --json`: compares contract and implementation.
44
+ - `sema drift <arquivo-ou-pasta> --escopo modulo [--cache <none|cache|fresh>] --json`: plans a safe physical scope, then compares contract and implementation without a global fallback.
34
45
  - `sema impacto <arquivo-ou-pasta> --alvo <token> --mudanca "<descricao>" --json`: maps impact before changing behavior.
35
46
  - `sema verificar <arquivo-ou-pasta> --json`: runs aggregated final verification.
36
47
  - `sema finalizar-mudanca --intencao "<acao>" --doc-lida <arquivo> --json`: proves documentation reading before closure.
37
48
 
38
- Honest closure: treat drift JSON as the source of truth. `sucesso:false`, `vinculos_quebrados`, `rotas_divergentes`, or broken impls mean the change is not complete yet. Do not report "clean drift" without green JSON.
49
+ Honest closure: unwrap drift JSON and treat its command payload as the source of truth. `payload.sucesso:false`, non-empty `payload.vinculos_quebrados`, non-empty `payload.rotas_divergentes`, or non-empty `payload.impls_quebrados` mean the change is not complete yet. Do not report "clean drift" without a green payload.
50
+
51
+ Focused drift exposes its planned, declared, inferred, and missing files plus catalog visit/read metrics in `escopo_aplicado`. File and module scopes fail closed without a safe anchor, with homonymous implementation candidates, or with missing local dependencies; only `--escopo projeto` may walk every configured code root. Logical roots such as `src` are probed deterministically without a discovery walk. Configured contract origins and code roots are confined before enumeration, and `inspecionar`, `impacto`, and `renomear-semantico` reuse the same directed boundary without reopening arbitrary external paths.
52
+
53
+ Drift analysis and cache modes are explicit:
54
+
55
+ - `sema drift` defaults to `--cache fresh`. `none` still executes drift but performs zero persistent-cache I/O; `cache` reuses a fully validated extraction hit and publishes misses; `fresh` ignores hits, recalculates, and publishes the new extraction.
56
+ - `sema resumo` and `sema inspecionar` default to `--drift none`. In that mode their payload does not execute drift and returns `null` for score, confidence, implementation, routes, or other code evidence that was not observed. Use `--drift cache` or `--drift fresh` when that evidence is required. `--com-drift` remains a temporary alias for `--drift fresh`.
57
+ - When a query explicitly runs drift, `payload.analiseDrift.sucesso` exposes the result and a failed requested analysis returns a nonzero exit code.
58
+ - The value aliases `off`, `auto`, and `refresh` normalize to `none`, `cache`, and `fresh` for one compatibility release and emit a structured deprecation warning. Wrong flags, repeated flags, conflicts, and invalid values fail instead of falling back silently.
59
+ - Persistent cache objects live outside the workspace under the operating system's user-cache directory. Workspace identity is hashed; public JSON and events expose only an opaque key and `$SEMA_CACHE/...` paths. Corruption or cache unavailability becomes a miss and never changes the drift result. Only validated extraction data is reused; links, diagnostics, scores, and the final success decision are recalculated.
60
+
61
+ A cache hit is acceleration, not final evidence; closure still requires fresh drift.
39
62
 
40
63
  ## Sema Code
41
64
 
@@ -63,6 +86,7 @@ Ready UI rule: if the task generates an app, site, dashboard, form, or static HT
63
86
  - `sema ajuda-ia`: short guidance for Codex.
64
87
  - `sema starter-ia`: operational starter.
65
88
  - `sema contexto-ia <arquivo.sema> --saida <dir> --json`: AI context package.
89
+ - `sema resumo <arquivo-ou-pasta> [--drift <none|cache|fresh>] --json`: compact context; drift is not executed unless requested.
66
90
  - `sema prompt-curto <arquivo-ou-pasta> --json`: compact prompt.
67
91
  - `sema sync-codex --json`: synchronizes the official Codex entrypoint and local support docs.
68
92
  - `sema instalar-exemplos --json`: installs official examples in the workspace.
@@ -119,12 +143,12 @@ Spatial model and render mode are orthogonal: `THREE_D + HEADLESS` is valid, whi
119
143
 
120
144
  ## Forbidden
121
145
 
122
- - Do not use an external workspace source to inspect a local workspace when `sema --version` works.
146
+ - Do not use an external workspace source to inspect a local workspace when `sema --version` or the managed launcher works.
123
147
  - Do not search the entire disk for `.sema` syntax; use `exemplos/`, `docs/syntax.md`, and this catalog.
124
148
  - Do not stop after `sema compilar` if the contract target files still do not exist.
125
149
  - Do not replace `sema compilar` with `sema testar` when the contract requires generated code.
126
150
  - Do not create a Markdown report to pretend a gate ran.
127
- - Do not say drift passed when `sema drift --json` returned `sucesso:false`, broken link, divergent route, or broken impl.
151
+ - Do not say drift passed when the unwrapped `sema drift --cache fresh --json` payload returned `sucesso:false`, a non-empty `vinculos_quebrados`, `rotas_divergentes`, or `impls_quebrados` list.
128
152
  - Do not declare a UI responsive without mobile/desktop proof; horizontal scroll at 390px blocks closure.
129
153
 
130
154
  Governed code policy: keep the `SEMA-GOVERNED` marker, split large code by real responsibility, preserve contract links, and never treat a generated output directory as the final delivery.
package/docs/database.md CHANGED
@@ -1,15 +1,15 @@
1
- # Database Boundary
2
-
3
- The public Sema CLI does not require a database.
4
-
5
- Sema reads contracts and source files from the local workspace. Any database used
6
- by an application governed by Sema belongs to that application, not to the public
7
- Sema CLI distribution.
8
-
9
- ## Public Rule
10
-
11
- Do not ship private database material, real credentials, operational schemas, or
12
- project-specific data in the public Sema package.
13
-
14
- Application-specific database docs should live in the application repository
15
- that owns the database.
1
+ # Database Boundary
2
+
3
+ The public Sema CLI does not require a database.
4
+
5
+ Sema reads contracts and source files from the local workspace. Any database used
6
+ by an application governed by Sema belongs to that application, not to the public
7
+ Sema CLI distribution.
8
+
9
+ ## Public Rule
10
+
11
+ Do not ship private database material, real credentials, operational schemas, or
12
+ project-specific data in the public Sema package.
13
+
14
+ Application-specific database docs should live in the application repository
15
+ that owns the database.
package/docs/deploy.md CHANGED
@@ -1,41 +1,54 @@
1
- # Deployment Boundary
2
-
3
- The public Sema repository documents two coordinated release surfaces: the
4
- local npm CLI and the Codex bootstrap skill. The skill remains a separate,
5
- explicit Codex installation and is never injected by npm lifecycle scripts.
6
-
7
- Run the complete public gate:
8
-
9
- ```bash
10
- npm run build
11
- npm run codex:sync-entrypoint
12
- npm run status:check
13
- npm run repo:verificar-publico
14
- npm run plugin:testar-codex
15
- npm test
16
- npm run release:verificar-drift
17
- npm run release:preparar-publica
18
- npm run release:publicar-npm-dry-run
19
- ```
20
-
21
- `release:preparar-publica` performs the Codex entrypoint sync before checking
22
- the public boundary, so a clean clone does not depend on ignored generated
23
- handshake files left by a previous local run.
24
-
25
- The plugin smoke installs the repo marketplace into an isolated `CODEX_HOME`,
26
- installs `sema@sema`, compares the cached skill with the versioned source, and
27
- proves no Sema MCP server was registered. Plugin and CLI versions must match
28
- before the commit is pushed. The release command itself runs the full test suite
29
- and project-wide Sema drift gate; these are not optional manual preliminaries.
30
-
31
- Push the commit containing `.agents/plugins/marketplace.json` and
32
- `plugins/sema/` before telling users to install from `gerlanss/Sema`. Publish
33
- the npm package only after the tarball smoke passes. After npm publication, run
34
- `npm run release:verificar-distribuicao` to verify the registry and live GitHub
35
- state. That final verifier also requires the remote GitHub HEAD to match the
36
- local commit, installs `sema@sema` from `gerlanss/Sema` in an isolated
37
- `CODEX_HOME`, compares the remote skill with the versioned source, and proves
38
- that the remote plugin registers no Sema MCP. The current contract does not
39
- permit creating a GitHub Release or release asset.
40
-
41
- Do not publish private or sensitive operational material in this repository.
1
+ # Deployment Boundary
2
+
3
+ The public Sema repository documents one coordinated npm artifact containing
4
+ the local CLI, its absolute managed launcher, and the portable bootstrap skill.
5
+ The repository Codex plugin remains an optional namespaced distribution channel
6
+ for the same versioned skill.
7
+
8
+ Run the complete public gate:
9
+
10
+ ```bash
11
+ npm run build
12
+ npm run codex:sync-entrypoint
13
+ npm run status:check
14
+ npm run repo:verificar-publico
15
+ npm run plugin:testar-codex
16
+ npm test
17
+ npm run release:verificar-drift
18
+ npm run release:preparar-publica
19
+ npm run release:publicar-npm-dry-run
20
+ ```
21
+
22
+ `release:preparar-publica` performs the Codex entrypoint sync before checking
23
+ the public boundary, so a clean clone does not depend on ignored generated
24
+ handshake files left by a previous local run.
25
+
26
+ All release and local-install routes delegate to `npm run
27
+ cli:empacotar-publica`. The factory uses a unique private stage, disables npm
28
+ lifecycle scripts while packing that stage, and publishes only a fully
29
+ validated tarball. Do not use `npm pack --workspace @semacode/cli`; the source
30
+ package guard rejects that unsupported path without staging files in the
31
+ workspace.
32
+
33
+ The public-package smoke performs a global install with isolated home, npm
34
+ prefix, npm cache, and user cache. It proves the launcher works through its
35
+ absolute path with Node.js and npm removed from `PATH`. On Windows it exercises
36
+ `sema.ps1` as the PowerShell `PATH` entrypoint, `sema-managed.ps1` through the
37
+ absolute `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe`, and
38
+ `sema.cmd` through `cmd.exe`. The smoke also proves the synchronized
39
+ skill matches the packaged source, the real user home is unchanged, and local
40
+ installs leave global state untouched. The plugin smoke independently compares
41
+ its cached skill with the versioned source and proves no Sema MCP server was
42
+ registered. Plugin and CLI versions must match before the commit is pushed.
43
+
44
+ Push the commit containing `.agents/plugins/marketplace.json` and
45
+ `plugins/sema/` before telling users to install from `gerlanss/Sema`. Publish
46
+ the npm package only after the tarball smoke passes. After npm publication, run
47
+ `npm run release:verificar-distribuicao` to verify the registry and live GitHub
48
+ state. That final verifier also requires the remote GitHub HEAD to match the
49
+ local commit, installs `sema@sema` from `gerlanss/Sema` in an isolated
50
+ `CODEX_HOME`, compares the remote skill with the versioned source, and proves
51
+ that the remote plugin registers no Sema MCP. The current contract does not
52
+ permit creating a GitHub Release or release asset.
53
+
54
+ Do not publish private or sensitive operational material in this repository.
@@ -35,14 +35,15 @@ sema finalizar-mudanca \
35
35
  - Keep commands, file paths, package names, environment variable names, and DSL
36
36
  keywords literal.
37
37
  - Do not include private or sensitive operational material.
38
- - Prefer local CLI examples.
39
- - Point support requests to suporte@otimitare.online.
40
-
41
- ## Contract Split Plan
38
+ - Prefer local CLI examples.
39
+ - Point support requests to suporte@otimitare.online.
40
+
41
+ ## Contract Structure
42
42
 
43
- `contratos/sema/governanca_ia_documentacao.sema` is close to the 500-line
44
- blocking limit. Before adding another documentation capability, split it by
45
- responsibility into contracts for required-document resolution, localization,
46
- and change-finalization evidence. Preserve the existing task names, guarantees,
47
- implementations, and links; the contracts may continue to govern the same CLI
48
- files through multiple `vinculos`. Do not create numbered part files.
43
+ Documentation governance is split by capability: required-document resolution
44
+ stays in `governanca_ia_documentacao.sema`, while localization and
45
+ change-finalization evidence live in explicitly named child contracts. The
46
+ same rule applies to drift and semantic-budget governance: keep a cohesive
47
+ primary capability in the root contract and move secondary responsibilities to
48
+ named children. Preserve task names, guarantees, implementations, and
49
+ `vinculos`; never create numbered part files.
@@ -0,0 +1,108 @@
1
+ # Drift Cache And Query Evidence
2
+
3
+ Sema exposes three drift modes, but the `none` mode intentionally means
4
+ different things for direct drift execution and for query commands. The
5
+ defaults preserve honest, low-cost queries while keeping an explicit drift run
6
+ fresh by default.
7
+
8
+ | Mode | `sema drift --cache <mode>` | `sema resumo --drift <mode>` / `sema inspecionar --drift <mode>` |
9
+ | --- | --- | --- |
10
+ | `none` | Runs drift without reading or writing persistent cache. | Skips drift analysis. This is the query default. |
11
+ | `cache` | Reuses a valid cache entry; otherwise recalculates and publishes a new entry. | Runs drift with the same reuse-or-recalculate behavior. |
12
+ | `fresh` | Does not reuse a prior hit, recalculates, and publishes a fresh entry. This is the direct drift default. | Runs drift from fresh inputs without reusing prior extraction data, then publishes the resulting entry. |
13
+
14
+ Use `--cache none` when a direct analysis must leave no persistent cache access.
15
+ Use `--drift none` when a summary or inspection should not perform drift at all.
16
+ The two forms are not interchangeable.
17
+
18
+ ## Honest Query Evidence
19
+
20
+ `sema resumo` and `sema inspecionar` default to `--drift none`. Their JSON
21
+ payload includes an `analiseDrift` envelope that makes the omitted evaluation
22
+ explicit:
23
+
24
+ ```json
25
+ {
26
+ "analiseDrift": {
27
+ "modo": "none",
28
+ "executada": false,
29
+ "sucesso": null,
30
+ "cache": null
31
+ },
32
+ "scoreDrift": null,
33
+ "confiancaGeral": null
34
+ }
35
+ ```
36
+
37
+ The surrounding payload varies by command. A human-readable `aviso` or
38
+ `avisos` entry explains why drift was not evaluated. Drift-derived framework,
39
+ route, surface, bridge, and module implementation evidence is also `null` when
40
+ applicable. In this context, `null` means **not evaluated**; it must never be
41
+ interpreted as zero, empty, passing, or absent drift.
42
+
43
+ Request `--drift cache` or `--drift fresh` when a query needs evaluated drift
44
+ evidence. In that case, `payload.analiseDrift.sucesso` is `true` or `false`, and a
45
+ failed requested analysis makes the command exit nonzero instead of hiding the
46
+ failure behind a successful query response.
47
+
48
+ ## External Cache Location
49
+
50
+ Persistent drift cache is stored outside the governed workspace:
51
+
52
+ | Platform | Cache root |
53
+ | --- | --- |
54
+ | Windows | `%LOCALAPPDATA%\Sema\Cache`, falling back to `%USERPROFILE%\AppData\Local\Sema\Cache` |
55
+ | macOS | `~/Library/Caches/Sema` |
56
+ | Linux and other Unix systems | `$XDG_CACHE_HOME/sema`, falling back to `~/.cache/sema` |
57
+
58
+ Drift entries live below `drift/v3/workspaces/<opaque-id>/objects/` inside that
59
+ root. Public output represents such paths as `$SEMA_CACHE/drift/v3/...`.
60
+ `$SEMA_CACHE` is a safe display placeholder, not a promise that an environment
61
+ variable with that name exists, and Sema does not expose the real user cache
62
+ path.
63
+
64
+ Sema never writes persistent drift cache inside the repository, `.sema`,
65
+ `.tmp`, generated project folders, or any other workspace location.
66
+
67
+ ## Authority And Recovery
68
+
69
+ The cache is an acceleration layer, not governance evidence and not a source of
70
+ truth. Contracts, source files, the active analysis plan, and the validated
71
+ result remain authoritative.
72
+
73
+ - A corrupt or incompatible entry is treated as a recoverable miss: Sema
74
+ recalculates instead of trusting it.
75
+ - If external cache storage is unavailable, analysis continues by
76
+ recalculating; cache persistence does not become a governance blocker.
77
+ - `cache` may reuse only a valid entry for the current workspace and inputs.
78
+ - `fresh` never reuses cached extraction data before analysis. Publication may
79
+ read and validate an existing content-addressed winner to preserve CAS
80
+ integrity without changing the freshly calculated result.
81
+ - Direct `none` performs no persistent cache reads or writes.
82
+
83
+ These rules keep cache failures from hiding drift and keep the governed
84
+ workspace free of machine-local state.
85
+
86
+ ## Semantic Integrity And Trust Limit
87
+
88
+ The reusable payload stores canonical per-extractor indices. It does not store
89
+ `todosSimbolos`, route aggregates, resource aggregates, or known-file
90
+ aggregates as independent sources. Sema derives those values again after a
91
+ cache entry is restored, so a redundant aggregate cannot silently override its
92
+ source indices.
93
+
94
+ Before accepting a hit, Sema checks exact field allowlists, relative catalog
95
+ paths, extractor-specific file extensions and symbol origins, consumer-surface
96
+ to route relationships, and derived integrity digests across symbols, routes,
97
+ resources, surfaces, and persistence details. Detectable structural or
98
+ semantic inconsistency becomes a corrupt miss, followed by a fresh in-memory
99
+ calculation and repair. A valid hit is therefore limited to a compatible
100
+ payload produced for the same CLI, schema, extractor, workspace identity, Git
101
+ HEAD, plan, configuration, contracts, and content-digested members.
102
+
103
+ These SHA-256 digests detect corruption and incoherent rewriting; they do not
104
+ authenticate a hostile process running as the same operating-system user. Such
105
+ a process can read the implementation and rewrite both data and checksums. The
106
+ external cache is not a security boundary, a signature, or final evidence.
107
+ Use `--cache fresh` for closure and retain stronger evidence outside the local
108
+ user cache when the threat model includes local-user compromise.