Pepguy commited on
Commit
5fc03de
Β·
verified Β·
1 Parent(s): 9872447

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +44 -36
app.js CHANGED
@@ -16,6 +16,8 @@
16
  * 5. DOWNLOAD endpoint returns dated filename.
17
  * 6. RPS throttle on AI calls, SAMPLES_PER_CALL configurable.
18
  * 7. AWS BEDROCK updated to ConverseCommand with NodeHttpHandler.
 
 
19
  *
20
  * Endpoints:
21
  * GET /status
@@ -45,12 +47,12 @@ import { NodeHttpHandler } from "@smithy/node-http-handler";
45
  // ── CONFIG ────────────────────────────────────────────────────────────────────
46
  const PORT = parseInt(process.env.PORT || "7860");
47
  const AWS_REGION = process.env.AWS_REGION || "us-east-1";
48
- const BEDROCK_MODEL = "arn:aws:bedrock:us-east-1:106774395747:inference-profile/global.anthropic.claude-sonnet-4-6";
49
 
50
  const DATASET_PATH = process.env.DATASET_PATH || "axl_dataset.json";
51
  const DEFAULT_RPS = parseFloat(process.env.DEFAULT_RPS || "3");
52
  const MAX_RPS = parseFloat(process.env.MAX_RPS || "8");
53
- const SAMPLES_PER_CALL = parseInt(process.env.SAMPLES_PER_CALL || "20");
54
  const SCALE_K = 30.0;
55
  const LATENT_D_MAX = 8;
56
 
@@ -392,7 +394,7 @@ function synthXorSamples(n) {
392
  ` END ENTITY`,
393
  ].join("\n")).join("\n");
394
 
395
- const axl = [
396
  `SCOPE xor_bit_level[level: 0]`,
397
  ` ASSUME bit EXISTS`,
398
  ` ASSUME bit DISCRETE VALUES {0, 1}`,
@@ -405,20 +407,20 @@ function synthXorSamples(n) {
405
  bitEntities,
406
  `END SCOPE`,
407
  ``,
408
- `SCOPE xor_byte_level [level: 1]`,
409
  ` ASSUME xor_bit_level SCOPE HOLDS`,
410
  ` ENTITY byte_assembler`,
411
- ` FIELD value: INTEGER BOUND [0, 255]`,
412
  ` DERIVES value FROM {bit_7..bit_0} BY binary_weighted_sum`,
413
  ` END ENTITY`,
414
  ` CONSERVES bit_count ACROSS binary_weighted_sum`,
415
  ` ENTITY key_byte`,
416
- ` FIELD raw: INTEGER BOUND [0, 255]`,
417
  ` FIELD normalised: REAL BOUND [0, 1]`,
418
  ` DERIVES normalised FROM raw BY divide_255`,
419
  ` END ENTITY`,
420
  ` ENTITY plain_byte`,
421
- ` FIELD raw: INTEGER BOUND [0, 255] EQUALS ${plain}`,
422
  ` END ENTITY`,
423
  ` ENTITY cipher_byte`,
424
  ` FIELD raw: INTEGER BOUND[0, 255]`,
@@ -444,11 +446,11 @@ function synthXorSamples(n) {
444
  samples.push({
445
  id: randomUUID(), domain: "cryptography", subdomain: "xor_byte",
446
  sense: "EQUAL", n_vars: 1,
447
- vars_text: "VARS c0 IN[0 255]",
448
  expr_text: `EXPR XOR plain=${plain} cipher=${cipher} key=UNKNOWN`,
449
  sense_text: "SENSE EQUAL",
450
  b_raw: fmt(cipher), b_norm: fmt(safeNorm(cipher), 8),
451
- c_values: [key],
452
  mask: [1], candidates:[], step_count: 0, axl_source: axl,
453
  metadata: {
454
  description: `XOR byte: plain=${plain} key=${key} β†’ cipher=${cipher}`,
@@ -515,7 +517,7 @@ function synthCaesarSamples(n) {
515
  `SCOPE caesar_message [level: 2]`,
516
  ` ASSUME caesar_char SCOPE HOLDS`,
517
  ` ENTITY message`,
518
- ` FIELD plaintext: VECTOR OF INTEGER EQUALS [${plains.join(", ")}]`,
519
  ` FIELD ciphertext: VECTOR OF INTEGER`,
520
  ` FIELD length: INTEGER EQUALS ${msgLen}`,
521
  ` DERIVES ciphertext FROM {plaintext, shift_key.raw} BY caesar_transform APPLIED_TO_EACH`,
@@ -534,7 +536,7 @@ function synthCaesarSamples(n) {
534
  samples.push({
535
  id: randomUUID(), domain: "cryptography", subdomain: "caesar",
536
  sense: "EQUAL", n_vars: 1,
537
- vars_text: "VARS c0 IN [0 25]",
538
  expr_text: `EXPR CAESAR plains=[${plains}] ciphers=[${ciphers}] shift=UNKNOWN`,
539
  sense_text: "SENSE EQUAL",
540
  b_raw: fmt(bRaw), b_norm: fmt(safeNorm(bRaw), 8),
@@ -573,7 +575,7 @@ function synthVigenereSamples(n) {
573
  `SCOPE alphabet_ring [level: 0]`,
574
  ` ASSUME integer EXISTS`,
575
  ` TRANSFORM modular_add_26`,
576
- ` INPUT {a: INTEGER BOUND [0,25], b: INTEGER BOUND [0,25]}`,
577
  ` OUTPUT {result: INTEGER BOUND [0,25]}`,
578
  ` PRODUCES result = (a + b) % 26`,
579
  ` END TRANSFORM`,
@@ -606,7 +608,7 @@ function synthVigenereSamples(n) {
606
  ` END ENTITY`,
607
  ` OBSERVE ciphertext_vector.chars EQUALS[${cipher.join(", ")}]`,
608
  ` OBSERVE SUM(ciphertext_vector.chars) EQUALS ${bRaw}`,
609
- ` UNKNOWN key_vector.normalised: VECTOR OF REAL BOUND [0, 1]`,
610
  ` COLLAPSE vigenere_composition`,
611
  ` GIVEN {plaintext_vector.chars, ciphertext_vector.chars}`,
612
  ` FIND key_vector.normalised`,
@@ -651,7 +653,7 @@ function synthAffineSamples(n) {
651
  const verify = ((aInv*(cipher-b))%26+26)%26;
652
  if (verify !== p) continue;
653
 
654
- const axl = [
655
  `SCOPE modular_arithmetic [level: 0]`,
656
  ` ASSUME integer EXISTS`,
657
  ` TRANSFORM modular_multiply_add`,
@@ -673,7 +675,7 @@ function synthAffineSamples(n) {
673
  ` FIELD a: INTEGER DISCRETE VALUES {1,3,5,7,9,11,15,17,19,21,23,25}`,
674
  ` FIELD b: INTEGER BOUND[0, 25]`,
675
  ` FIELD a_idx: INTEGER BOUND[0, 11]`,
676
- ` FIELD a_norm: REAL BOUND [0, 1]`,
677
  ` FIELD b_norm: REAL BOUND [0, 1]`,
678
  ` DERIVES a FROM a_idx BY lookup_valid_a`,
679
  ` DERIVES a_norm FROM a_idx BY divide_11`,
@@ -684,13 +686,11 @@ function synthAffineSamples(n) {
684
  ` FIELD plaintext: INTEGER BOUND[0, 25] EQUALS ${p}`,
685
  ` FIELD ciphertext: INTEGER BOUND[0, 25]`,
686
  ` DERIVES ciphertext FROM {affine_key.a, plaintext, affine_key.b} BY modular_multiply_add`,
687
- ` # f(${p}) = (${a} * ${p} + ${b}) mod 26 = ${cipher}`,
688
  ` END ENTITY`,
689
  ` ENTITY affine_inverse`,
690
  ` FIELD a_inv: INTEGER EQUALS ${aInv}`,
691
  ` FIELD recovery: INTEGER`,
692
  ` DERIVES recovery FROM {a_inv, ciphertext, b} BY modular_multiply_add`,
693
- ` # a_inv*(cipher-b) mod 26 = ${p} βœ“`,
694
  ` END ENTITY`,
695
  ` CONTRADICT invertible WITH non_coprime_a`,
696
  ` AT SCOPE affine_cipher`,
@@ -698,7 +698,7 @@ function synthAffineSamples(n) {
698
  ` END CONTRADICT`,
699
  ` OBSERVE affine_transform_result.ciphertext EQUALS ${cipher}`,
700
  ` UNKNOWN affine_key.a_norm: REAL BOUND[0, 1]`,
701
- ` UNKNOWN affine_key.b_norm: REAL BOUND [0, 1]`,
702
  ` COLLAPSE affine_cipher`,
703
  ` GIVEN {affine_transform_result.plaintext, affine_transform_result.ciphertext}`,
704
  ` FIND {affine_key.a_norm, affine_key.b_norm}`,
@@ -752,7 +752,7 @@ function synthOptimizationSamples(n) {
752
  ``,
753
  ` ENTITY decision_variables`,
754
  ...Array.from({length:nVars},(_,j)=>
755
- ` FIELD c${j}: REAL BOUND [0, 1]`),
756
  ` END ENTITY`,
757
  ``,
758
  ` ENTITY objective_function`,
@@ -898,7 +898,7 @@ existence conditions. An entity does not exist unless its
898
  REQUIRES clause is satisfied.
899
 
900
  ENTITY <name>
901
- FIELD <name>: <type> [BOUND <range>] [CONSERVES] [DISCRETE]
902
  STATE <name>: REQUIRES <condition>
903
  TENDS <field> <direction>
904
  DERIVES FROM <entity_list>
@@ -1295,7 +1295,7 @@ END SCOPE
1295
  OBSERVE spectral_emission EQUALS {656nm, 486nm, 434nm, 410nm}
1296
 
1297
  UNKNOWN element: SYMBOLIC WITHIN periodic_table
1298
- UNKNOWN atomic_number: INTEGER BOUND[1, 118]
1299
  UNKNOWN electron_configuration: VECTOR
1300
 
1301
  COLLAPSE atom
@@ -1321,7 +1321,7 @@ axl:
1321
  # the output must satisfy a bound.
1322
  # ════════════════════════════════════════════════════
1323
 
1324
- SCOPE bitfield [level: 0]
1325
 
1326
  ASSUME bit EXISTS
1327
  ASSUME bit DISCRETE VALUES {0, 1}
@@ -1334,7 +1334,7 @@ SCOPE bitfield [level: 0]
1334
  END SCOPE
1335
 
1336
 
1337
- SCOPE sha256_internals [level: 1]
1338
 
1339
  ASSUME bitfield SCOPE HOLDS
1340
 
@@ -1541,7 +1541,7 @@ SCOPE genome[level: 1]
1541
  END ENTITY
1542
 
1543
  ENTITY dna_polymerase
1544
- FIELD error_rate: REAL BOUND [1e-9, 1e-9] # one error per billion bases
1545
  TENDS accuracy MAX
1546
  TRANSFORMS dna_strand INTO dna_strand_copy
1547
  CONSERVES sequence UNLESS error_rate TRIGGERS
@@ -1749,7 +1749,7 @@ STRICT REQUIREMENTS:
1749
  2. Every sample MUST have all fields in the schema below.
1750
  3. b_raw must be a computed finite float matching the AXL program's logic.
1751
  4. c_values must be in RAW domain units matching the declared bounds in vars_text.
1752
- DO NOT pre-normalize to [0,1] β€” the pipeline does that. Example: if
1753
  vars_text says "VARS c0 IN [200 800]" then c_values should be like[650, 210].
1754
  5. Every vars_text MUST start with the word VARS.
1755
  6. Every sample must use a DIFFERENT domain or structural pattern.
@@ -1769,7 +1769,7 @@ JSON SCHEMA (output array of these):
1769
  "subdomain": "<specific topic>",
1770
  "sense": "<EQUAL|MINIMIZE|MAXIMIZE|SELECT|TEND>",
1771
  "n_vars": <integer>,
1772
- "vars_text": "VARS c0 IN [lo hi] c1 IN[lo hi] ...",
1773
  "expr_text": "EXPR <description>",
1774
  "sense_text": "SENSE <EQUAL|MINIMIZE|MAXIMIZE|SELECT|TEND>",
1775
  "b_raw": <float>,
@@ -1794,7 +1794,7 @@ OUTPUT THE JSON ARRAY NOW:`;
1794
 
1795
  async function callBedrock(prompt) {
1796
  const command = new ConverseCommand({
1797
- modelId: BEDROCK_MODEL,
1798
  messages: [{ role: "user", content:[{ text: prompt }] }],
1799
  inferenceConfig: {
1800
  maxTokens: 10000,
@@ -1875,14 +1875,22 @@ app.post("/generate", async (req, res) => {
1875
  if (nSynthetic > 0) {
1876
  const gens = Object.values(SYNTHETIC_GENERATORS);
1877
  const perGen = Math.max(1, Math.ceil(nSynthetic / gens.length));
1878
- for (const[name, genFn] of Object.entries(SYNTHETIC_GENERATORS)) {
1879
- for (const raw of genFn(perGen)) {
1880
- if (!validateSample(raw)) { errors++; continue; }
1881
- const norm = normalizeSample(raw);
1882
- if (!norm) { errors++; continue; }
1883
- generated.push(norm);
1884
- tracker.record(norm.domain);
1885
- }
 
 
 
 
 
 
 
 
1886
  }
1887
  log(`Synthetic: ${generated.length} valid`, "OK");
1888
  }
@@ -1962,7 +1970,7 @@ app.get("/dataset/sample", (req, res) => {
1962
  loadDataset();
1963
  app.listen(PORT, '0.0.0.0', () => {
1964
  log(`AXL Dataset Server listening on :${PORT}`, "OK");
1965
- log(`Model: ${BEDROCK_MODEL}`);
1966
  log(`Dataset: ${DATASET_PATH}`);
1967
  log(`RPS: ${DEFAULT_RPS} default / ${MAX_RPS} max`);
1968
  });
 
16
  * 5. DOWNLOAD endpoint returns dated filename.
17
  * 6. RPS throttle on AI calls, SAMPLES_PER_CALL configurable.
18
  * 7. AWS BEDROCK updated to ConverseCommand with NodeHttpHandler.
19
+ * 8. [FIXED] Synthetic array strictly sliced to exact requested fraction.
20
+ * 9.[FIXED] SAMPLES_PER_CALL lowered to 4 to prevent AWS token truncation.
21
  *
22
  * Endpoints:
23
  * GET /status
 
47
  // ── CONFIG ────────────────────────────────────────────────────────────────────
48
  const PORT = parseInt(process.env.PORT || "7860");
49
  const AWS_REGION = process.env.AWS_REGION || "us-east-1";
50
+ const BEDROCK_MODEL_ID = "arn:aws:bedrock:us-east-1:106774395747:inference-profile/global.anthropic.claude-sonnet-4-6";
51
 
52
  const DATASET_PATH = process.env.DATASET_PATH || "axl_dataset.json";
53
  const DEFAULT_RPS = parseFloat(process.env.DEFAULT_RPS || "3");
54
  const MAX_RPS = parseFloat(process.env.MAX_RPS || "8");
55
+ const SAMPLES_PER_CALL = parseInt(process.env.SAMPLES_PER_CALL || "4"); // Reduced to prevent token cutoff
56
  const SCALE_K = 30.0;
57
  const LATENT_D_MAX = 8;
58
 
 
394
  ` END ENTITY`,
395
  ].join("\n")).join("\n");
396
 
397
+ const axl =[
398
  `SCOPE xor_bit_level[level: 0]`,
399
  ` ASSUME bit EXISTS`,
400
  ` ASSUME bit DISCRETE VALUES {0, 1}`,
 
407
  bitEntities,
408
  `END SCOPE`,
409
  ``,
410
+ `SCOPE xor_byte_level[level: 1]`,
411
  ` ASSUME xor_bit_level SCOPE HOLDS`,
412
  ` ENTITY byte_assembler`,
413
+ ` FIELD value: INTEGER BOUND[0, 255]`,
414
  ` DERIVES value FROM {bit_7..bit_0} BY binary_weighted_sum`,
415
  ` END ENTITY`,
416
  ` CONSERVES bit_count ACROSS binary_weighted_sum`,
417
  ` ENTITY key_byte`,
418
+ ` FIELD raw: INTEGER BOUND[0, 255]`,
419
  ` FIELD normalised: REAL BOUND [0, 1]`,
420
  ` DERIVES normalised FROM raw BY divide_255`,
421
  ` END ENTITY`,
422
  ` ENTITY plain_byte`,
423
+ ` FIELD raw: INTEGER BOUND[0, 255] EQUALS ${plain}`,
424
  ` END ENTITY`,
425
  ` ENTITY cipher_byte`,
426
  ` FIELD raw: INTEGER BOUND[0, 255]`,
 
446
  samples.push({
447
  id: randomUUID(), domain: "cryptography", subdomain: "xor_byte",
448
  sense: "EQUAL", n_vars: 1,
449
+ vars_text: "VARS c0 IN [0 255]",
450
  expr_text: `EXPR XOR plain=${plain} cipher=${cipher} key=UNKNOWN`,
451
  sense_text: "SENSE EQUAL",
452
  b_raw: fmt(cipher), b_norm: fmt(safeNorm(cipher), 8),
453
+ c_values:[key],
454
  mask: [1], candidates:[], step_count: 0, axl_source: axl,
455
  metadata: {
456
  description: `XOR byte: plain=${plain} key=${key} β†’ cipher=${cipher}`,
 
517
  `SCOPE caesar_message [level: 2]`,
518
  ` ASSUME caesar_char SCOPE HOLDS`,
519
  ` ENTITY message`,
520
+ ` FIELD plaintext: VECTOR OF INTEGER EQUALS[${plains.join(", ")}]`,
521
  ` FIELD ciphertext: VECTOR OF INTEGER`,
522
  ` FIELD length: INTEGER EQUALS ${msgLen}`,
523
  ` DERIVES ciphertext FROM {plaintext, shift_key.raw} BY caesar_transform APPLIED_TO_EACH`,
 
536
  samples.push({
537
  id: randomUUID(), domain: "cryptography", subdomain: "caesar",
538
  sense: "EQUAL", n_vars: 1,
539
+ vars_text: "VARS c0 IN[0 25]",
540
  expr_text: `EXPR CAESAR plains=[${plains}] ciphers=[${ciphers}] shift=UNKNOWN`,
541
  sense_text: "SENSE EQUAL",
542
  b_raw: fmt(bRaw), b_norm: fmt(safeNorm(bRaw), 8),
 
575
  `SCOPE alphabet_ring [level: 0]`,
576
  ` ASSUME integer EXISTS`,
577
  ` TRANSFORM modular_add_26`,
578
+ ` INPUT {a: INTEGER BOUND [0,25], b: INTEGER BOUND[0,25]}`,
579
  ` OUTPUT {result: INTEGER BOUND [0,25]}`,
580
  ` PRODUCES result = (a + b) % 26`,
581
  ` END TRANSFORM`,
 
608
  ` END ENTITY`,
609
  ` OBSERVE ciphertext_vector.chars EQUALS[${cipher.join(", ")}]`,
610
  ` OBSERVE SUM(ciphertext_vector.chars) EQUALS ${bRaw}`,
611
+ ` UNKNOWN key_vector.normalised: VECTOR OF REAL BOUND[0, 1]`,
612
  ` COLLAPSE vigenere_composition`,
613
  ` GIVEN {plaintext_vector.chars, ciphertext_vector.chars}`,
614
  ` FIND key_vector.normalised`,
 
653
  const verify = ((aInv*(cipher-b))%26+26)%26;
654
  if (verify !== p) continue;
655
 
656
+ const axl =[
657
  `SCOPE modular_arithmetic [level: 0]`,
658
  ` ASSUME integer EXISTS`,
659
  ` TRANSFORM modular_multiply_add`,
 
675
  ` FIELD a: INTEGER DISCRETE VALUES {1,3,5,7,9,11,15,17,19,21,23,25}`,
676
  ` FIELD b: INTEGER BOUND[0, 25]`,
677
  ` FIELD a_idx: INTEGER BOUND[0, 11]`,
678
+ ` FIELD a_norm: REAL BOUND[0, 1]`,
679
  ` FIELD b_norm: REAL BOUND [0, 1]`,
680
  ` DERIVES a FROM a_idx BY lookup_valid_a`,
681
  ` DERIVES a_norm FROM a_idx BY divide_11`,
 
686
  ` FIELD plaintext: INTEGER BOUND[0, 25] EQUALS ${p}`,
687
  ` FIELD ciphertext: INTEGER BOUND[0, 25]`,
688
  ` DERIVES ciphertext FROM {affine_key.a, plaintext, affine_key.b} BY modular_multiply_add`,
 
689
  ` END ENTITY`,
690
  ` ENTITY affine_inverse`,
691
  ` FIELD a_inv: INTEGER EQUALS ${aInv}`,
692
  ` FIELD recovery: INTEGER`,
693
  ` DERIVES recovery FROM {a_inv, ciphertext, b} BY modular_multiply_add`,
 
694
  ` END ENTITY`,
695
  ` CONTRADICT invertible WITH non_coprime_a`,
696
  ` AT SCOPE affine_cipher`,
 
698
  ` END CONTRADICT`,
699
  ` OBSERVE affine_transform_result.ciphertext EQUALS ${cipher}`,
700
  ` UNKNOWN affine_key.a_norm: REAL BOUND[0, 1]`,
701
+ ` UNKNOWN affine_key.b_norm: REAL BOUND[0, 1]`,
702
  ` COLLAPSE affine_cipher`,
703
  ` GIVEN {affine_transform_result.plaintext, affine_transform_result.ciphertext}`,
704
  ` FIND {affine_key.a_norm, affine_key.b_norm}`,
 
752
  ``,
753
  ` ENTITY decision_variables`,
754
  ...Array.from({length:nVars},(_,j)=>
755
+ ` FIELD c${j}: REAL BOUND[0, 1]`),
756
  ` END ENTITY`,
757
  ``,
758
  ` ENTITY objective_function`,
 
898
  REQUIRES clause is satisfied.
899
 
900
  ENTITY <name>
901
+ FIELD <name>: <type>[BOUND <range>] [CONSERVES] [DISCRETE]
902
  STATE <name>: REQUIRES <condition>
903
  TENDS <field> <direction>
904
  DERIVES FROM <entity_list>
 
1295
  OBSERVE spectral_emission EQUALS {656nm, 486nm, 434nm, 410nm}
1296
 
1297
  UNKNOWN element: SYMBOLIC WITHIN periodic_table
1298
+ UNKNOWN atomic_number: INTEGER BOUND [1, 118]
1299
  UNKNOWN electron_configuration: VECTOR
1300
 
1301
  COLLAPSE atom
 
1321
  # the output must satisfy a bound.
1322
  # ════════════════════════════════════════════════════
1323
 
1324
+ SCOPE bitfield[level: 0]
1325
 
1326
  ASSUME bit EXISTS
1327
  ASSUME bit DISCRETE VALUES {0, 1}
 
1334
  END SCOPE
1335
 
1336
 
1337
+ SCOPE sha256_internals[level: 1]
1338
 
1339
  ASSUME bitfield SCOPE HOLDS
1340
 
 
1541
  END ENTITY
1542
 
1543
  ENTITY dna_polymerase
1544
+ FIELD error_rate: REAL BOUND[1e-9, 1e-9] # one error per billion bases
1545
  TENDS accuracy MAX
1546
  TRANSFORMS dna_strand INTO dna_strand_copy
1547
  CONSERVES sequence UNLESS error_rate TRIGGERS
 
1749
  2. Every sample MUST have all fields in the schema below.
1750
  3. b_raw must be a computed finite float matching the AXL program's logic.
1751
  4. c_values must be in RAW domain units matching the declared bounds in vars_text.
1752
+ DO NOT pre-normalize to[0,1] β€” the pipeline does that. Example: if
1753
  vars_text says "VARS c0 IN [200 800]" then c_values should be like[650, 210].
1754
  5. Every vars_text MUST start with the word VARS.
1755
  6. Every sample must use a DIFFERENT domain or structural pattern.
 
1769
  "subdomain": "<specific topic>",
1770
  "sense": "<EQUAL|MINIMIZE|MAXIMIZE|SELECT|TEND>",
1771
  "n_vars": <integer>,
1772
+ "vars_text": "VARS c0 IN[lo hi] c1 IN [lo hi] ...",
1773
  "expr_text": "EXPR <description>",
1774
  "sense_text": "SENSE <EQUAL|MINIMIZE|MAXIMIZE|SELECT|TEND>",
1775
  "b_raw": <float>,
 
1794
 
1795
  async function callBedrock(prompt) {
1796
  const command = new ConverseCommand({
1797
+ modelId: BEDROCK_MODEL_ID,
1798
  messages: [{ role: "user", content:[{ text: prompt }] }],
1799
  inferenceConfig: {
1800
  maxTokens: 10000,
 
1875
  if (nSynthetic > 0) {
1876
  const gens = Object.values(SYNTHETIC_GENERATORS);
1877
  const perGen = Math.max(1, Math.ceil(nSynthetic / gens.length));
1878
+
1879
+ let tempSynth =[];
1880
+ for (const genFn of gens) {
1881
+ tempSynth.push(...genFn(perGen));
1882
+ }
1883
+
1884
+ // Shuffle slightly for mix, then slice to EXACTLY nSynthetic
1885
+ tempSynth.sort(() => 0.5 - Math.random());
1886
+ tempSynth = tempSynth.slice(0, nSynthetic);
1887
+
1888
+ for (const raw of tempSynth) {
1889
+ if (!validateSample(raw)) { errors++; continue; }
1890
+ const norm = normalizeSample(raw);
1891
+ if (!norm) { errors++; continue; }
1892
+ generated.push(norm);
1893
+ tracker.record(norm.domain);
1894
  }
1895
  log(`Synthetic: ${generated.length} valid`, "OK");
1896
  }
 
1970
  loadDataset();
1971
  app.listen(PORT, '0.0.0.0', () => {
1972
  log(`AXL Dataset Server listening on :${PORT}`, "OK");
1973
+ log(`Model: ${BEDROCK_MODEL_ID}`);
1974
  log(`Dataset: ${DATASET_PATH}`);
1975
  log(`RPS: ${DEFAULT_RPS} default / ${MAX_RPS} max`);
1976
  });