Mapa de erros 4.8: sem hashes nem nomes de ficheiro técnicos na vista do investidor
O formulário fiscal público já estava limpo; o mesmo padrão continuava no percurso do investidor (sede do financiamento), no guia de investimento, no simulador (relatório aritmético, Modelo A e anexos da isenção) e nas orientações do dossier do Balcão. As exportações não mudam. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
@@ -590,16 +590,6 @@ export function InvestorGuidance({
|
||||
<h3 className="text-xl font-semibold">
|
||||
Cálculos existentes e cenários
|
||||
</h3>
|
||||
<details>
|
||||
<summary>Versões das ferramentas determinísticas</summary>
|
||||
{Object.entries(guidance.calculator_versions).map(
|
||||
([name, hash]) => (
|
||||
<p className="text-xs break-all" key={name}>
|
||||
{name} · SHA-256 do código: {hash}
|
||||
</p>
|
||||
),
|
||||
)}
|
||||
</details>
|
||||
{financialTools && (
|
||||
<details>
|
||||
<summary>
|
||||
|
||||
@@ -4737,37 +4737,6 @@ export function SimulationForm() {
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{arithmeticResult.integrity ===
|
||||
'versioned' &&
|
||||
arithmeticReportReference && (
|
||||
<>
|
||||
<div>
|
||||
<dt className="font-medium">
|
||||
ID
|
||||
do
|
||||
relatório
|
||||
imutável
|
||||
</dt>
|
||||
<dd className="break-all">
|
||||
{
|
||||
arithmeticReportReference.id
|
||||
}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="font-medium">
|
||||
SHA-256
|
||||
do
|
||||
relatório
|
||||
</dt>
|
||||
<dd className="break-all">
|
||||
{
|
||||
arithmeticReportReference.report_sha256
|
||||
}
|
||||
</dd>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</dl>
|
||||
<p className="mt-3 text-sm">
|
||||
Fórmula genérica: base ×
|
||||
|
||||
@@ -102,14 +102,10 @@ export function SimulationModeloA({
|
||||
)}
|
||||
</details>
|
||||
<EvidenceDetails title="Campos e fundamentos da estimativa — Modelo A">
|
||||
<EvidenceDetails title="Exemplar e integridade da fonte">
|
||||
<p>
|
||||
{modeloAReference.file}. {modeloAReference.edition}
|
||||
</p>
|
||||
<p className="break-all">
|
||||
SHA256: {modeloAReference.sha256}
|
||||
</p>
|
||||
</EvidenceDetails>
|
||||
<p>
|
||||
Exemplar oficial do Modelo A; a edição e a vigência do
|
||||
formulário estão por confirmar.
|
||||
</p>
|
||||
<p>
|
||||
O exemplar contém divergências de numeração/remissões,
|
||||
registadas no confronto documental. Não foram corrigidas no
|
||||
|
||||
@@ -166,7 +166,7 @@ export function SimulationOfferWorkflow({
|
||||
);
|
||||
onChange({ workflow: result.row.workflow });
|
||||
setNotice(
|
||||
'Conjunto preparado com pedido,elementos do formulário e despacho original conferido porSHA256;descarga iniciada.Submissão à autoridade permanece externa.',
|
||||
'Conjunto preparado com o pedido, os elementos do formulário e o despacho original conferido; descarga iniciada. A submissão à autoridade continua a ser feita fora do portal.',
|
||||
);
|
||||
};
|
||||
const text = (
|
||||
@@ -230,9 +230,9 @@ export function SimulationOfferWorkflow({
|
||||
</label>
|
||||
{w[field] && (
|
||||
<p>
|
||||
{w[field]!.name};SHA256:{w[field]!.sha256};estado da análise
|
||||
na associação:{w[field]!.scan}. Original privado
|
||||
conservado;nenhuma publicação automática.
|
||||
{w[field]!.name} · estado da análise na associação:{' '}
|
||||
{w[field]!.scan}. Original privado conservado; nenhuma
|
||||
publicação automática.
|
||||
</p>
|
||||
)}
|
||||
</fieldset>
|
||||
@@ -379,7 +379,7 @@ export function SimulationOfferWorkflow({
|
||||
edit({
|
||||
formContent:
|
||||
w.formContent ||
|
||||
`${offerWrittenRequest(row, w)}\nDespacho:${row.request?.decisionRef ?? ''};${row.request?.decisionOn ?? ''};emitente:${w.decisionIssuer}\nÂmbito:${row.request?.goods ?? ''};${row.request?.operationScope || row.request?.operation || ''};${row.request?.periodScope || `${row.request?.periodFrom ?? ''} a ${row.request?.periodTo ?? ''}`};${row.request?.conditions ?? ''}\nAnexo:${w.decisionAttachment?.name ?? ''};SHA256:${w.decisionAttachment?.sha256 ?? ''}`,
|
||||
`${offerWrittenRequest(row, w)}\nDespacho:${row.request?.decisionRef ?? ''};${row.request?.decisionOn ?? ''};emitente:${w.decisionIssuer}\nÂmbito:${row.request?.goods ?? ''};${row.request?.operationScope || row.request?.operation || ''};${row.request?.periodScope || `${row.request?.periodFrom ?? ''} a ${row.request?.periodTo ?? ''}`};${row.request?.conditions ?? ''}\nAnexo:${w.decisionAttachment?.name ?? ''}`,
|
||||
})
|
||||
}
|
||||
>
|
||||
|
||||
@@ -627,19 +627,11 @@ function GuideView(props: Props) {
|
||||
</p>
|
||||
)}
|
||||
{source.sha256 && (
|
||||
<details>
|
||||
<summary>
|
||||
Identificação do exemplar consultado
|
||||
</summary>
|
||||
<p className="break-all">
|
||||
SHA256: {source.sha256}
|
||||
</p>
|
||||
<p>
|
||||
A fonte externa pode ser actualizada; a
|
||||
referência guardada conserva os dados da
|
||||
edição utilizada.
|
||||
</p>
|
||||
</details>
|
||||
<p>
|
||||
A fonte externa pode ser actualizada; a
|
||||
referência guardada conserva os dados da edição
|
||||
utilizada.
|
||||
</p>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
|
||||
@@ -1307,10 +1307,6 @@ export default function InvestmentPath(path: Path) {
|
||||
: ''}{' '}
|
||||
· {row.location.source_reference}
|
||||
</p>
|
||||
<p>
|
||||
SHA-256 da origem:{' '}
|
||||
{row.location.source_document_sha256}
|
||||
</p>
|
||||
</section>
|
||||
)}
|
||||
<Link
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { createRequire } from 'node:module';
|
||||
import { compileFunction } from 'node:vm';
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import ts from 'typescript';
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { createRequire } from "node:module";
|
||||
import { compileFunction } from "node:vm";
|
||||
import React from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import ts from "typescript";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const root = path.resolve('resources/js');
|
||||
const root = path.resolve("resources/js");
|
||||
function load(file) {
|
||||
const absolute = path.resolve(root, file);
|
||||
const module = { exports: {} };
|
||||
const code = ts.transpileModule(fs.readFileSync(absolute, 'utf8'), {
|
||||
const code = ts.transpileModule(fs.readFileSync(absolute, "utf8"), {
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
target: ts.ScriptTarget.ES2022,
|
||||
jsx: ts.JsxEmit.ReactJSX,
|
||||
},
|
||||
}).outputText;
|
||||
compileFunction(code, ['require', 'module', 'exports'])(
|
||||
compileFunction(code, ["require", "module", "exports"])(
|
||||
(id) => {
|
||||
if (id === '@inertiajs/react')
|
||||
if (id === "@inertiajs/react")
|
||||
return {
|
||||
Link: ({ children, ...props }) =>
|
||||
React.createElement('a', props, children),
|
||||
usePage: () => ({ url: '/x', props: {} }),
|
||||
React.createElement("a", props, children),
|
||||
usePage: () => ({ url: "/x", props: {} }),
|
||||
};
|
||||
if (id.startsWith('.') || id.startsWith('@/')) {
|
||||
const base = id.startsWith('@/')
|
||||
if (id.startsWith(".") || id.startsWith("@/")) {
|
||||
const base = id.startsWith("@/")
|
||||
? path.resolve(root, id.slice(2))
|
||||
: path.resolve(path.dirname(absolute), id);
|
||||
const found = [base + '.tsx', base + '.ts'].find((p) =>
|
||||
const found = [base + ".tsx", base + ".ts"].find((p) =>
|
||||
fs.existsSync(p),
|
||||
);
|
||||
if (found) return load(path.relative(root, found));
|
||||
@@ -45,43 +45,38 @@ function load(file) {
|
||||
return module.exports;
|
||||
}
|
||||
|
||||
test('differences between places are a yearly table of whole people with the warning once (mapa de erros 4.1)', () => {
|
||||
test("differences between places are a yearly table of whole people with the warning once (mapa de erros 4.1)", () => {
|
||||
const { default: DemographicEvidence } = load(
|
||||
'components/demographic-evidence.tsx',
|
||||
"components/demographic-evidence.tsx",
|
||||
);
|
||||
const comparison = (year, left, right, difference) => ({
|
||||
year,
|
||||
left: 'BILENE',
|
||||
right: 'FUNHALOURO',
|
||||
left: "BILENE",
|
||||
right: "FUNHALOURO",
|
||||
left_value: left,
|
||||
right_value: right,
|
||||
left_import: 'a',
|
||||
right_import: 'b',
|
||||
left_import: "a",
|
||||
right_import: "b",
|
||||
difference,
|
||||
explanation:
|
||||
'Diferença dos totais de população no mesmo ano, nível, tipo de dado, unidade e identificação de edição. Não mede procura efectiva.',
|
||||
"Diferença dos totais de população no mesmo ano, nível, tipo de dado, unidade e identificação de edição. Não mede procura efectiva.",
|
||||
});
|
||||
const html = renderToStaticMarkup(
|
||||
React.createElement(DemographicEvidence, {
|
||||
evidence: {
|
||||
state: 'available',
|
||||
state: "available",
|
||||
start_year: 2026,
|
||||
end_year: 2028,
|
||||
limitations: [],
|
||||
territories: [],
|
||||
differences: [],
|
||||
comparisons: [
|
||||
comparison(
|
||||
2028,
|
||||
'161636.2',
|
||||
'47040.1',
|
||||
'114596.1',
|
||||
),
|
||||
comparison(2028, "161636.2", "47040.1", "114596.1"),
|
||||
comparison(
|
||||
2026,
|
||||
'157982.9857834139',
|
||||
'46656.505898723823',
|
||||
'111326.479884690077',
|
||||
"157982.9857834139",
|
||||
"46656.505898723823",
|
||||
"111326.479884690077",
|
||||
),
|
||||
],
|
||||
},
|
||||
@@ -91,29 +86,55 @@ test('differences between places are a yearly table of whole people with the war
|
||||
assert.match(html, /157\s983/);
|
||||
assert.match(html, /111\s326/);
|
||||
assert.doesNotMatch(html, /\d+\.\d{3,}/);
|
||||
assert.equal(html.split('não mede procura efectiva').length - 1, 1);
|
||||
assert.ok(html.indexOf('>2026<') < html.indexOf('>2028<'));
|
||||
assert.equal(html.split("não mede procura efectiva").length - 1, 1);
|
||||
assert.ok(html.indexOf(">2026<") < html.indexOf(">2028<"));
|
||||
});
|
||||
|
||||
test('next actions are a list of separate, easy-to-find links (mapa de erros 4.5)', () => {
|
||||
const { default: NextActions } = load('components/next-actions.tsx');
|
||||
test("next actions are a list of separate, easy-to-find links (mapa de erros 4.5)", () => {
|
||||
const { default: NextActions } = load("components/next-actions.tsx");
|
||||
const html = renderToStaticMarkup(
|
||||
React.createElement(NextActions, {
|
||||
title: 'Alternativas de exploração',
|
||||
title: "Alternativas de exploração",
|
||||
actions: [
|
||||
{ label: 'Ver oportunidades publicadas', href: '/oportunidades' },
|
||||
{ label: 'Consultar ZEE, ZFI e parques', href: '/zonas' },
|
||||
{ label: 'Transformar uma ideia num projecto', href: '/Simulador' },
|
||||
{
|
||||
label: "Ver oportunidades publicadas",
|
||||
href: "/oportunidades",
|
||||
},
|
||||
{ label: "Consultar ZEE, ZFI e parques", href: "/zonas" },
|
||||
{
|
||||
label: "Transformar uma ideia num projecto",
|
||||
href: "/Simulador",
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
assert.equal(html.split('<li').length - 1, 3);
|
||||
assert.equal(html.split("<li").length - 1, 3);
|
||||
assert.match(html, /<nav aria-label="Alternativas de exploração"/);
|
||||
assert.match(html, /<h3[^>]*>Alternativas de exploração<\/h3>/);
|
||||
assert.equal(
|
||||
renderToStaticMarkup(
|
||||
React.createElement(NextActions, { actions: [] }),
|
||||
),
|
||||
'',
|
||||
renderToStaticMarkup(React.createElement(NextActions, { actions: [] })),
|
||||
"",
|
||||
);
|
||||
});
|
||||
|
||||
test("investor-facing views no longer print hashes of sources, reports or code (mapa de erros 4.8)", () => {
|
||||
for (const file of [
|
||||
"pages/investor-path/show.tsx",
|
||||
"pages/investment/guide.tsx",
|
||||
"components/investor-guidance.tsx",
|
||||
"components/simulation-modelo-a.tsx",
|
||||
"components/simulation-offer-workflow.tsx",
|
||||
"pages/portal/fiscal-forms.tsx",
|
||||
]) {
|
||||
const source = fs.readFileSync(path.resolve(root, file), "utf8");
|
||||
assert.doesNotMatch(source, /SHA-?256/, file);
|
||||
}
|
||||
const simulator = fs.readFileSync(
|
||||
path.resolve(root, "components/simulation-form.tsx"),
|
||||
"utf8",
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
simulator,
|
||||
/ID\s+do\s+relatório|SHA-256\s+do\s+relatório/,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -452,17 +452,15 @@ test('cluster analysis omits empty field blocks but keeps documented evidence an
|
||||
assert.match(html, /Por confirmar/);
|
||||
assert.doesNotMatch(html, /<dt[^>]*>Fonte e referência/);
|
||||
});
|
||||
test('simulator keeps original calculation correspondence and source behind explicit details', () => {
|
||||
test('simulator keeps original calculation correspondence without technical source identifiers', () => {
|
||||
const { SimulationModeloA } = load('components/simulation-modelo-a.tsx');
|
||||
const html = renderToStaticMarkup(
|
||||
React.createElement(SimulationModeloA, { draft: {} }),
|
||||
);
|
||||
assert.match(html, /Modelo A/);
|
||||
assert.match(html, /SHA256/);
|
||||
assert.ok(
|
||||
html.indexOf('SHA256') >
|
||||
html.indexOf('Exemplar e integridade da fonte'),
|
||||
);
|
||||
// Mapa de erros 4.8: no file names or hashes in the investor's view.
|
||||
assert.doesNotMatch(html, /SHA256|\.docx|Exemplar e integridade/);
|
||||
assert.match(html, /edição e a vigência do\s+formulário estão por confirmar/);
|
||||
assert.match(html, /não é imposto final/);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user