fix: only the designer side approves files; specks are not strokes
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m52s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m14s

- "The designer approves every file" (Dropstar's rule D-16): the Operador
  leaves "produce", so it no longer approves final files, picks the
  contraction, treats the art or marks the contact wait. It pulls and
  prints. The order panel says the Designer approves and shows the
  contraction read-only; the profiles table follows.
- The stroke measure drops ink components under 30 px (at 300 DPI) before
  the distance, as Dropstar's method says (2026-10-30). Each strip keeps
  at least 30 rows of context, so a speck is always seen whole and a
  component cut by the strip is a stroke. One real order sheet went from
  C1 (2 px, specks) to C2 (5 px); Dropstar's four test sheets still give
  2, 5, 20 and 4 px. The artwork browser test checks widths 2, 5 and 6,
  and a C3 sheet with 300 specks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-03 11:10:23 -03:00
parent 67fad3a2d7
commit a17f5fc08d
5 changed files with 77 additions and 15 deletions

View File

@@ -114,8 +114,11 @@ def login_failed(email):
"""Count a failed sign-in (or registration attempt) against the account."""
rate_limit('auth-account', email, 1_000_000)
# What each Kanban profile may do. "view" is reading; "produce" moves cards and
# handles artwork; "print" is the print room's side of it (the machine, the
# What each Kanban profile may do. "view" is reading; "produce" handles the
# artwork: approving the final files, the contraction, "Tratar a arte", the
# contact wait. "The designer approves every file" (Dropstar's rule D-16), so
# the operator does not: they pull and print. "print" is the print room's side
# of it (the machine, the
# queue's order, its files and folder); "manage" covers quotes, cancellations
# and payments; "users" is the Usuários page; "integrations" is everything in
# Integrações but the print room's folder (connecting Tiny, the checks, the
@@ -125,7 +128,7 @@ def login_failed(email):
ROLES = ('superadmin', 'admin', 'gestao', 'designer', 'operador', 'revisor', 'vendedor', 'financeiro')
CAPABILITIES = {
'view': set(ROLES),
'produce': {'superadmin', 'admin', 'gestao', 'designer', 'operador'},
'produce': {'superadmin', 'admin', 'gestao', 'designer'},
'print': {'superadmin', 'admin', 'gestao', 'operador'},
'manage': {'superadmin', 'admin', 'gestao'},
# Registering an order paid outside the system, from its Site quote (D-35).
@@ -144,7 +147,7 @@ CAPABILITIES = {
'cancel': {'superadmin', 'admin', 'gestao', 'financeiro'},
# "Retirado" at the counter (Dropstar's third round, item 14): everyone
# but the seller, who only views (D-30). It includes everyone who produces,
# so an operator upload (artwork.py) takes it for its parts.
# and the operator, so an operator upload (artwork.py) takes it for its parts.
'deliver': {'superadmin', 'admin', 'gestao', 'designer', 'operador', 'revisor'},
}

View File

@@ -159,6 +159,16 @@ try{
stale:/14,90|conforme a nota|desconto|escada|menor preço da tabela/i.test(document.body.textContent)};})()`),
{file:['R$ 19,90','R$ 19,90','R$ 19,90','R$ 19,90'],avulsa:['R$ 21,90','R$ 21,90'],
uvfile:['R$ 79,90','R$ 79,90'],uv:['R$ 89,90','R$ 89,90'],stale:false});
// Item 9: the thinnest stroke at 300 DPI as Dropstar measures it, an odd
// width being 2d - 1, and ink specks under 30 px left out (2026-10-30).
assert.deepEqual(await evaluate(`(async()=>{
const medir=async(...rects)=>{const c=document.createElement('canvas');c.width=900;c.height=700;
const g=c.getContext('2d');g.fillStyle='#000';for(const r of rects)g.fillRect(...r);
return analisarMapa(await mapaDaImagem(await createImageBitmap(c),900/300*2.54)).traco;};
const linhas=w=>[[50,50,800,w],[50,400,800,40]];
const ciscos=Array.from({length:300},(_,i)=>[60+(i%30)*25,200+Math.floor(i/30)*15,3,3]);
return [(await medir(...linhas(2))).px,(await medir(...linhas(5))).px,(await medir(...linhas(6))).px,
(await medir(...linhas(20))).classe,(await medir(...linhas(20),...ciscos)).classe];})()`),[2,5,6,'C3','C3']);
await click('[data-modo="file"]');
// Opening a product paints on the next frame; on a busy runner the check
// must wait for it rather than race it.

View File

@@ -153,6 +153,11 @@ def run():
assert (me['machine_question'], me['machine_answered'], me['machine']) == ('required', False, None), me
assert {str(uv_o), str(textil_o)} <= {o['id'] for o in op.call('/operator/board')['orders']}
assert sorted(me['moves']) == [['imp', 'rev'], ['imp', 'tra'], ['rev', 'imp'], ['tra', 'imp']]
# The designer approves every file (D-16): the operator neither approves
# a final nor picks the contraction.
assert me['can'] == ['deliver', 'print', 'view'], me
op.call(f'/operator/orders/{uv_o}/contraction', {'item_index': 0, 'value': 'C2'}, expected=403)
op.call(f'/operator/orders/{uv_o}/final-files', {'version': 0, 'note': '', 'files': []}, expected=403)
op.call(f'/operator/orders/{uv_o}/move', {'state': 'tra', 'version': 0, 'reason': ''}, expected=403)
with db.connect() as c:
c.execute("UPDATE dtf_local.orders SET state='imp' WHERE id=%s", (uv_o,))

View File

@@ -1471,10 +1471,14 @@ function nextBox(order){
:st==='rev'?'A folha impressa é conferida e liberada pelo Revisor.':'Daqui em diante, com a produção.');
if(st==='rec'||st==='cor'){
if(!finalDone(order)&&trans.includes('tra')){
const lead=st==='rec'||fixed, a=approveParts(order,lead);
if(st==='rec')title='Aprovar o arquivo final';
if(lead){if(a.files)body.push(a.files);note(a.text);body.push(contractionList(order));main.push(a.approve,...a.extra);}
else more.push(a.approve,...a.extra);
// The designer approves every file (D-16); the others see it waiting.
if(!may('produce')){note('O Designer confere e aprova o arquivo final.');body.push(contractionList(order));}
else{
const lead=st==='rec'||fixed, a=approveParts(order,lead);
if(lead){if(a.files)body.push(a.files);note(a.text);body.push(contractionList(order));main.push(a.approve,...a.extra);}
else more.push(a.approve,...a.extra);
}
}else if(st==='rec'){
title='Mandar para a fila';
note('O arquivo final está aprovado. Na fila, o operador puxa para a máquina.');
@@ -2046,7 +2050,7 @@ function avatar(u,className='ava'){
}
// "O que cada perfil faz": Y does it, V only looks; the server's rules (app/core/auth.py).
const ROLE_COLUMNS=['admin','gestao','designer','operador','revisor','vendedor','financeiro'];
const ROLE_MATRIX=[['Aprovar o arquivo final','YYYYNNN'],['Pedir correção','YYYNNNN'],['Puxar da fila e imprimir','YNNYNNN'],
const ROLE_MATRIX=[['Aprovar o arquivo final','YYYNNNN'],['Pedir correção','YYYNNNN'],['Puxar da fila e imprimir','YNNYNNN'],
['Liberar para Finalizado','YNNNYNN'],['Voltar uma etapa, com motivo','YYYYYNN'],['Marcar retirado','YYYYYNN'],
['Cotações e Números','YYNNNVV'],['Pagamentos','YYNNNNV'],['Pedido pago fora do site','YYNNNNN'],['Cancelar pedido','YYNNNNY'],
['Abrir retrabalho','NYNNNNN'],['Autorizar retrabalho','YNNNNNN'],['Usuários e máquinas','YNNNNNN']];

View File

@@ -70,12 +70,51 @@ function novoMapa(wPx,hPx,larguraCm){
// larguras, em pixels a 300 DPI: até 4 é C1, de 5 a 19 é C2, 20 ou mais é C3.
// A folha passa em faixas, linha a linha: cada faixa guarda 20 linhas antes e
// depois, o alcance da distância, e nada maior que uma faixa fica na memória.
const ALFA_TRACO=40, TRACO_D=20, TRACO_FAIXA=256;
const ALFA_TRACO=40, TRACO_D=20, TRACO_FAIXA=256, TRACO_CISCO=30;
// O contexto de cada faixa: as linhas acima e abaixo que ela lê sem medir. Um
// cisco (menos de 30 px de tinta a 300 DPI) tem menos linhas que isso, então
// a faixa sempre o vê inteiro; o que encosta na borda cortada é traço.
function novoTraco(wPx,dpi){
const linhas=TRACO_FAIXA+2*TRACO_D;
return {w:wPx,dpi,linhas,tinta:new Uint8Array(wPx*linhas),dist:new Uint16Array(wPx*linhas),
const cisco=Math.ceil(TRACO_CISCO*(dpi/300)**2), ctx=Math.min(120,Math.max(TRACO_D,cisco));
const linhas=TRACO_FAIXA+2*ctx;
return {w:wPx,dpi,linhas,ctx,cisco,tinta:new Uint8Array(wPx*linhas),dist:new Uint16Array(wPx*linhas),
rot:new Int32Array(wPx*linhas),pai:new Int32Array((wPx*linhas>>1)+2),area:new Int32Array((wPx*linhas>>1)+2),
n:0,inicio:0,hist:new Float64Array(2*TRACO_D+2),total:0,tintaPx:0,largosPx:0};
}
// Como a sala mede (Dropstar, 30/10/2026): componentes de tinta com menos de
// 30 px não são traço e saem antes da distância. Vizinhos nas oito direções.
function tiraCiscos(t,topo,fim){
const {w,n,tinta,rot,pai,area,cisco}=t;
let prox=1;
const raiz=a=>{while(pai[a]!==a){pai[a]=pai[pai[a]];a=pai[a];}return a;};
const une=(a,b)=>{a=raiz(a);b=raiz(b);if(a===b)return a;if(a<b){pai[b]=a;return a;}pai[a]=b;return b;};
// O pixel de cima já encosta nos outros três vizinhos lidos; sem ele, o da
// esquerda encosta no de cima à esquerda. Só sobra unir o de cima à direita.
for(let y=0;y<n;y++){ const o=y*w;
for(let x=0;x<w;x++){ const p=o+x;
if(!tinta[p]){ rot[p]=0; continue; }
const a=p-w, cima=y>0&&tinta[a], dir=y>0&&x<w-1&&tinta[a+1];
let r=0;
if(cima) r=rot[a];
else{
if(x>0&&tinta[p-1]) r=rot[p-1];
else if(y>0&&x>0&&tinta[a-1]) r=rot[a-1];
if(dir) r=r?une(r,rot[a+1]):rot[a+1];
}
if(!r){ r=prox++; pai[r]=r; area[r]=0; }
rot[p]=r; } }
if(prox===1) return;
// Cada rótulo aponta para um menor: em ordem, um passo só leva à raiz.
for(let r=1;r<prox;r++) pai[r]=pai[pai[r]];
for(let p=0;p<w*n;p++) if(rot[p]) area[pai[rot[p]]]++;
// Encostar numa borda que não é a da folha: o componente continua fora da faixa.
if(!topo) for(let x=0;x<w;x++) if(rot[x]) area[pai[rot[x]]]=cisco;
if(!fim) for(let x=0,o=(n-1)*w;x<w;x++) if(rot[o+x]) area[pai[rot[o+x]]]=cisco;
let ciscos=0;
for(let r=1;r<prox;r++) if(pai[r]===r&&area[r]<cisco) ciscos++;
if(!ciscos) return;
for(let p=0;p<w*n;p++) if(rot[p]&&area[pai[rot[p]]]<cisco) tinta[p]=0;
}
function tracoLinha(t,alfa,inicio,de){
const o=t.n*t.w, ink=t.tinta;
for(let x=0,i=inicio;x<t.w;x++,i+=de) ink[o+x]=alfa[i]>ALFA_TRACO?1:0;
@@ -84,8 +123,9 @@ function tracoLinha(t,alfa,inicio,de){
}
// A distância na faixa, e as larguras das linhas que ela já mede inteiras.
function tracoFaixa(t,fim){
const {w,n,tinta,dist}=t, CAP=TRACO_D*10+10, topo=t.inicio===0;
const {w,n,tinta,dist,ctx}=t, CAP=TRACO_D*10+10, topo=t.inicio===0;
if(!n) return;
tiraCiscos(t,topo,fim);
for(let p=0;p<w*n;p++) dist[p]=tinta[p]?CAP:0;
// ida: de cima para baixo; fora da folha é fundo
for(let y=0;y<n;y++){ const o=y*w, a=o-w;
@@ -108,7 +148,7 @@ function tracoFaixa(t,fim){
else if(fim) d=Math.min(d,10);
dist[p]=d; } }
// As linhas medidas por inteiro: longe das bordas da faixa, salvo as da folha.
const de=topo?0:TRACO_D, ate=fim?n:n-TRACO_D;
const de=topo?0:ctx, ate=fim?n:n-ctx;
const escala=300/t.dpi, hist=t.hist, max=hist.length-1;
const at=(x,y)=>(x<0||x>=w||y<0||y>=n)?0:dist[y*w+x];
// Item 16: tinta em áreas de 20 px ou mais (a 300 DPI) é a que fica a 10 px
@@ -134,7 +174,7 @@ function tracoFaixa(t,fim){
}
// As últimas linhas ficam como contexto da próxima faixa.
if(!fim){
const fica=2*TRACO_D;
const fica=2*ctx;
tinta.copyWithin(0,(n-fica)*w,n*w);
t.inicio+=n-fica; t.n=fica;
}
@@ -145,7 +185,7 @@ function tracoFaixa(t,fim){
function tracoFim(t){
if(t.lido!==undefined) return t.lido;
tracoFaixa(t,true);
t.tinta=t.dist=null; // a faixa não serve mais
t.tinta=t.dist=t.rot=t.pai=t.area=null; // a faixa não serve mais
if(!t.total) return t.lido=null;
let soma=0, px=1;
for(let i=1;i<t.hist.length;i++){ soma+=t.hist[i]; if(soma>=t.total*0.01){ px=i; break; } }