Merge pull request 'Preserve native report transaction and qualified table reads' (#582) from dev/MC:fix/market-report-transaction-20261125 into main
All checks were successful
DuneRealms Web CI / web (push) Successful in 3m11s

This commit is contained in:
unimatrix 2026-11-25 01:17:41 +00:00
commit 2a7600c645
2 changed files with 7 additions and 1 deletions

View file

@ -78,7 +78,7 @@ export function createPoliticalDecisions(db,bank,keys,deps={}){
if(!source)fail('Choose an authorised office funding account.',403);
if(!tax||tax.state!=='active'||String(source.id)===String(tax.id)||BigInt(source.balance_minor)-BigInt(source.reserved_minor)<amount||BigInt(tax.balance_minor)+amount>9223372036854775807n)fail('Insufficient funds or unavailable treasury.');
const pol=polProgressionStore(tx),season=await readActiveXPSeason(pol,now),state=await lockXPAccount(pol,actor.id,now),level=levelForXP(state.effectiveXP,{base:Number(season.curve_base),cap:Number(season.level_cap)||null});if(level<d.level)fail('Reputation level '+d.level+' is required.',403);
let report=null;if(d.kind==='report'){if(!deps.marketReports)fail('Verified Exchange reporting unavailable. No decision was charged.',503);report=await deps.marketReports.report(b,d,now);}
let report=null;if(d.kind==='report'){if(!deps.marketReports)fail('Verified Exchange reporting unavailable. No decision was charged.',503);report=await deps.marketReports.report(tx,d,now);}
let receipt;
await keys.issue({accountId:STAFF_OFFICE_ACCOUNT_ID,keyType:'entity-state',scopeId:'state:political-decision:'+requestId,transactionStore:tx,authorize:async(_,{keyId})=>{
const effectId=randomUUID(),expiresAt=d.durationMs?now+d.durationMs:null;

View file

@ -35,6 +35,12 @@ test('market reports use the paid decision transaction and safe retries return t
await assert.rejects(f.service.execute(f.people.Owner,{...input,report:{invented:true}}),/Review/);
}finally{f.db.close();}
});
test('native reports keep the original transaction without rewriting qualified tables or metadata literals',async()=>{
const f=await fixture('ordos',{verifyStorage:async()=>'main',marketReports:{ready:async()=>true,report:async tx=>{
const row=(await tx.query("SELECT 'pb_guild_passages' marker"))[0];assert.equal(row.marker,'pb_guild_passages');
await tx.query('SELECT id FROM `main`.`pb_accounts` LIMIT 1');return{schema:'pol-market-report-v1',observedAt:1000,byWorld:[]};
}}});try{const result=await f.service.execute(f.people.Owner,f.input('ORD-03'));assert.equal(result.ok,true);assert.equal(result.report.schema,'pol-market-report-v1');}finally{f.db.close();}
});
test('a failed report source or receipt journal leaves fees, Reputation and keys unchanged',async()=>{
let unavailable=true;const f=await fixture('spacing_guild',{marketReports:{ready:async()=>{if(unavailable)throw Error('Unavailable');},report:async()=>{if(unavailable)throw Object.assign(Error('Unavailable'),{status:503});return{schema:'pol-market-report-v1',observedAt:1000,byWorld:[]};}}});try{
await f.pol.query('UPDATE jarvis_progression_accounts SET effective_xp=100000,total_xp=100000');assert.equal((await f.service.read(f.people.Owner,'SG-04')).canExecute,false);const before=(await f.db.first('SELECT COUNT(*) n FROM organisation_keys')).n;