Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

Preserve sealed Troy archer source bytes on checkout (#137)

Matthew Kissingerb3cc5048d362
diff --git a/.gitattributes b/.gitattributes
index f67424d6..76fc829a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -25,6 +25,11 @@ plugin.json -text
.claude-plugin/** -text
docs/**/*.mjs -text
+# These two Troy sources are byte-sealed inputs of the pinned archer pose bank.
+# Preserve their original bytes; text checkout conversion invalidates that bank.
+scenes/packages/troy/web/archer-bank.mjs -text
+scenes/packages/troy/web/archer-bow.mjs -text
+
# `render-service/src/**` was in the list above and is deliberately not any more.
# Its bytes ARE hashed -- `fingerprintRendererInputs` walks that directory into the
# renderer's capture identity -- but `-text` only froze whatever was committed, and
diff --git a/scenes/packages/troy/README.md b/scenes/packages/troy/README.md
index 2a01ded3..aa5942dd 100644
--- a/scenes/packages/troy/README.md
+++ b/scenes/packages/troy/README.md
@@ -46,6 +46,11 @@ The initial runtime pin is `troy-20261005-06`. Update it to the newly sealed and
verified release when adopting changed model/bank inputs. A pin change requires
rehydration; the preview refuses a cache selected for another release.
+The archer bank also checks the exact bytes of its source inputs. Two retained
+modules have a trailing CRLF line and scoped Git attributes preserve those bytes.
+Keep those line endings when using the initial pin; editing bank inputs requires
+rebaking and verifying the bank, rather than changing or bypassing its hashes.
+
## Build a public runtime
Keep source modules editable and prepare derivatives in a separate staged web
diff --git a/scenes/packages/troy/tests/bank-source-identity.test.mjs b/scenes/packages/troy/tests/bank-source-identity.test.mjs
new file mode 100644
index 00000000..1f71ea00
--- /dev/null
+++ b/scenes/packages/troy/tests/bank-source-identity.test.mjs
@@ -0,0 +1,26 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import {readFile} from 'node:fs/promises';
+import {createHash} from 'node:crypto';
+import {execFileSync} from 'node:child_process';
+import {fileURLToPath} from 'node:url';
+
+// These two editable modules are exact-byte inputs of the pinned 06 archer-v9
+// bank. A checkout conversion broke source-first startup even though JS parsed.
+const root=fileURLToPath(new URL('../../../../',import.meta.url));
+const sources={
+ 'archer-bank.mjs':'050ce5a28b8c7cf77a6164c23cb26511593b36a2bf5d829c53bba799b24892b5',
+ 'archer-bow.mjs':'7a04087c4421dcc3fa217b78f071819f91e5fb326f153024ab9f5017906f6499',
+};
+for(const [file,expected]of Object.entries(sources)){
+ test('pinned archer bank source retains exact bytes: '+file,async()=>{
+ const bytes=await readFile(new URL('../web/'+file,import.meta.url));
+ assert.equal(createHash('sha256').update(bytes).digest('hex'),expected);
+ });
+ test('Git retains mixed line endings for exact bank input: '+file,()=>{
+ const bytes=Buffer.from('// exact identity fixture\n\r\n');
+ const expected=createHash('sha1').update('blob '+bytes.length+'\0').update(bytes).digest('hex');
+ const actual=execFileSync('git',['hash-object','--path=scenes/packages/troy/web/'+file,'--stdin'],{cwd:root,input:bytes,encoding:'utf8'}).trim();
+ assert.equal(actual,expected,'Git clean filters must preserve the source bytes sealed into a bank');
+ });
+}
diff --git a/scenes/packages/troy/web/archer-bank.mjs b/scenes/packages/troy/web/archer-bank.mjs
index 05c99499..4801fec5 100644
--- a/scenes/packages/troy/web/archer-bank.mjs
+++ b/scenes/packages/troy/web/archer-bank.mjs
@@ -108,4 +108,4 @@ export function bakeAdaptiveArcherBank(T,{createReference,fps=50,tolerance=.0015
const selected=new Set(split);times=times.flatMap((t,i)=>selected.has(i)?[t,(t+times[i+1])/2]:[t]);
}}finally{a.dispose();}
}
-
+
diff --git a/scenes/packages/troy/web/archer-bow.mjs b/scenes/packages/troy/web/archer-bow.mjs
index 2c3da280..bb499c0d 100644
--- a/scenes/packages/troy/web/archer-bow.mjs
+++ b/scenes/packages/troy/web/archer-bow.mjs
@@ -5,4 +5,4 @@ export function bowBend(draw,{limb=.585,brace=.092,travel=.775}={}){
const point=(y,angle)=>{const t=angle*y/limb;return Math.abs(t)<1e-5?{y:y*(1-t*t/6),z:-y*t/2*(1-t*t/12)}:{y:y*Math.sin(t)/t,z:y*(Math.cos(t)-1)/t};};
let angle=0;if(draw>0){let lo=0,hi=Math.PI;for(let i=0;i<40;i++){const mid=(lo+hi)/2,p=point(limb,mid);if(Math.hypot(p.y,p.z+travel*draw)>limb)lo=mid;else hi=mid;}angle=(lo+hi)/2;}
const tip=point(limb,angle);return {angle,tipY:tip.y,tipZ:tip.z-brace,point:y=>point(y,angle)};
-}
+}