@miller-tech/uap 1.40.0 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -642
- package/dist/.tsbuildinfo +1 -1
- package/dist/cli/deliver-defaults.d.ts +23 -0
- package/dist/cli/deliver-defaults.d.ts.map +1 -0
- package/dist/cli/deliver-defaults.js +121 -0
- package/dist/cli/deliver-defaults.js.map +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +29 -0
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +19 -0
- package/dist/cli/setup.js.map +1 -1
- package/dist/policies/policy-tools.d.ts +7 -0
- package/dist/policies/policy-tools.d.ts.map +1 -1
- package/dist/policies/policy-tools.js +24 -2
- package/dist/policies/policy-tools.js.map +1 -1
- package/docs/INDEX.md +48 -286
- package/docs/architecture/OVERVIEW.md +328 -0
- package/docs/architecture/PROTOCOL.md +204 -0
- package/docs/benchmarks/README.md +17 -192
- package/docs/getting-started/CONFIGURATION.md +237 -0
- package/docs/getting-started/INSTALLATION.md +125 -0
- package/docs/getting-started/QUICKSTART.md +115 -0
- package/docs/guides/COORDINATION.md +162 -0
- package/docs/guides/DELIVER.md +115 -0
- package/docs/guides/DEPLOY_BATCHING.md +212 -0
- package/docs/guides/DROIDS_AND_SKILLS.md +202 -0
- package/docs/guides/LOCAL_MODELS.md +148 -0
- package/docs/guides/MCP_ROUTER.md +195 -0
- package/docs/guides/MEMORY.md +235 -0
- package/docs/guides/MULTI_MODEL.md +223 -0
- package/docs/guides/POLICIES.md +190 -0
- package/docs/guides/WORKTREE_WORKFLOW.md +185 -0
- package/docs/integrations/MCP_ROUTER.md +147 -0
- package/docs/integrations/RTK.md +102 -0
- package/docs/reference/API.md +485 -0
- package/docs/reference/CLI.md +719 -0
- package/docs/reference/CONFIGURATION.md +90 -193
- package/docs/reference/DATABASE_SCHEMA.md +110 -344
- package/docs/reference/FEATURES.md +176 -472
- package/docs/reference/PATTERNS.md +102 -0
- package/docs/reference/PLATFORMS.md +83 -0
- package/package.json +3 -1
- package/src/policies/enforcers/7ebbc721-7540-4e9f-879a-770e0213a09b_architecture_review.py +101 -0
- package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
- package/src/policies/enforcers/_common.py +100 -0
- package/src/policies/enforcers/artifact_hygiene.py +52 -0
- package/src/policies/enforcers/cluster_routing.py +63 -0
- package/src/policies/enforcers/codebase_read_before_plan.py +52 -0
- package/src/policies/enforcers/coord_overlap.py +81 -0
- package/src/policies/enforcers/delivery_enforcement.py +97 -0
- package/src/policies/enforcers/doc_live_over_report.py +50 -0
- package/src/policies/enforcers/expert_review_required.py +135 -0
- package/src/policies/enforcers/iac_parity.py +53 -0
- package/src/policies/enforcers/mcp_router_first.py +37 -0
- package/src/policies/enforcers/memory_before_plan.py +61 -0
- package/src/policies/enforcers/parallel_reads.py +50 -0
- package/src/policies/enforcers/rtk_wrap.py +44 -0
- package/src/policies/enforcers/schema_diff_gate.py +80 -0
- package/src/policies/enforcers/session_memory_write.py +52 -0
- package/src/policies/enforcers/task_required.py +131 -0
- package/src/policies/enforcers/test_gate.py +58 -0
- package/src/policies/enforcers/validate_plan_before_build.py +75 -0
- package/src/policies/enforcers/worktree_required.py +57 -0
- package/src/policies/schemas/policies/architecture-review.md +51 -0
- package/src/policies/schemas/policies/artifact-hygiene.md +29 -0
- package/src/policies/schemas/policies/cluster-routing.md +31 -0
- package/src/policies/schemas/policies/codebase-read-before-plan.md +30 -0
- package/src/policies/schemas/policies/coord-overlap.md +24 -0
- package/src/policies/schemas/policies/delivery-enforcement.md +45 -0
- package/src/policies/schemas/policies/doc-live-over-report.md +32 -0
- package/src/policies/schemas/policies/expert-review-required.md +60 -0
- package/src/policies/schemas/policies/iac-parity.md +31 -0
- package/src/policies/schemas/policies/mandatory-testing-deployment.md +147 -0
- package/src/policies/schemas/policies/mcp-router-first.md +24 -0
- package/src/policies/schemas/policies/memory-before-plan.md +24 -0
- package/src/policies/schemas/policies/merge-deploy-monitor-verify.md +145 -0
- package/src/policies/schemas/policies/parallel-reads.md +24 -0
- package/src/policies/schemas/policies/rtk-wrap.md +26 -0
- package/src/policies/schemas/policies/schema-diff-gate.md +30 -0
- package/src/policies/schemas/policies/session-memory-write.md +24 -0
- package/src/policies/schemas/policies/task-required.md +49 -0
- package/src/policies/schemas/policies/test-gate.md +24 -0
- package/src/policies/schemas/policies/validate-plan-before-build.md +28 -0
- package/src/policies/schemas/policies/worktree-required.md +28 -0
- package/templates/hooks/uap-policy-gate.sh +5 -0
- package/docs/AGENTS.md +0 -423
- package/docs/DOCUMENTATION_AUDIT_REPORT.md +0 -131
- package/docs/GETTING_STARTED.md +0 -288
- package/docs/PROJECT_ANALYSIS_REPORT.md +0 -510
- package/docs/architecture/COMPLETE_ARCHITECTURE.md +0 -748
- package/docs/architecture/EXPERT_STACK.md +0 -137
- package/docs/architecture/MULTI_MODEL.md +0 -224
- package/docs/architecture/PLATFORM_GATING.md +0 -68
- package/docs/architecture/SYSTEM_ANALYSIS.md +0 -334
- package/docs/architecture/UAP_COMPLIANCE.md +0 -217
- package/docs/architecture/UAP_PROTOCOL.md +0 -339
- package/docs/architecture/UAP_STRICT_DROIDS.md +0 -172
- package/docs/archive/BALLS_MODE_SELF_ANALYSIS.md +0 -260
- package/docs/archive/BENCHMARK_GAPS_AND_PLAN.md +0 -146
- package/docs/archive/FAILING_TASKS_SOLUTION_PLAN.md +0 -668
- package/docs/archive/JINJA2-SYSTEM-MESSAGE-FIX.md +0 -209
- package/docs/archive/MODEL_ROUTING_IMPLEMENTATION_SUMMARY.md +0 -281
- package/docs/archive/MODEL_ROUTING_OPTIMIZATION_PLAN.md +0 -320
- package/docs/archive/NPM-PUBLISH-V0.9.1.md +0 -240
- package/docs/archive/OPTIMIZATION_OPTIONS.md +0 -334
- package/docs/archive/PARALLELISM_GAPS_AND_OPTIONS.md +0 -422
- package/docs/archive/POLICY_GATE_IMPLEMENTATION.md +0 -245
- package/docs/archive/SETUP_IMPROVEMENTS.md +0 -213
- package/docs/archive/UAP_GENERIC_OPTIMIZATION_PLAN.md +0 -270
- package/docs/archive/UAP_OPTIMIZATION_PLAN.md +0 -701
- package/docs/archive/UAP_V103_PATTERN_DESIGN.md +0 -315
- package/docs/archive/UAP_V104_COMPLIANCE_DESIGN.md +0 -223
- package/docs/archive/changelog/2026-03-10_uap-100-compliance.md +0 -77
- package/docs/archive/changelog/2026-03-10_uap-full-system-verification.md +0 -109
- package/docs/archive/opencode-integration-guide.md +0 -740
- package/docs/archive/opencode-integration-quickref.md +0 -180
- package/docs/benchmarks/OVERNIGHT_RUNNER.md +0 -341
- package/docs/benchmarks/SPECULATIVE_DECODING_JOURNEY_2026-03.md +0 -221
- package/docs/benchmarks/VALIDATION_PLAN.md +0 -568
- package/docs/blog/SPECULATIVE_DECODING_PRODUCTION_PLAYBOOK.md +0 -139
- package/docs/blog/local-coding-agents.md +0 -266
- package/docs/blog/x-thread.md +0 -254
- package/docs/deployment/DEPLOYMENT.md +0 -895
- package/docs/deployment/DEPLOYMENT_STRATEGIES.md +0 -518
- package/docs/deployment/DEPLOY_BATCHER_ANALYSIS.md +0 -224
- package/docs/deployment/DEPLOY_BATCHING.md +0 -273
- package/docs/deployment/DEPLOY_BUCKETING_ANALYSIS.md +0 -420
- package/docs/deployment/QWEN35_LLAMA_CPP.md +0 -426
- package/docs/deployment/UAP_LLAMA_ANTHROPIC_PROXY_BOOTSTRAP.md +0 -279
- package/docs/getting-started/INTEGRATION.md +0 -628
- package/docs/getting-started/OVERVIEW.md +0 -324
- package/docs/getting-started/SETUP.md +0 -377
- package/docs/integrations/MCP_ROUTER_SETUP.md +0 -445
- package/docs/integrations/RTK_INTEGRATION.md +0 -468
- package/docs/operations/TROUBLESHOOTING.md +0 -660
- package/docs/pr/PR_SPECULATIVE_DOCS_TEMPLATE.md +0 -146
- package/docs/pr/UPSTREAM_PRS.md +0 -424
- package/docs/reference/API_REFERENCE.md +0 -903
- package/docs/reference/EXPERT_DROIDS.md +0 -219
- package/docs/reference/HARNESS-MATRIX.md +0 -318
- package/docs/reference/PATTERN_LIBRARY.md +0 -636
- package/docs/reference/UAP_CLI_REFERENCE.md +0 -620
- package/docs/research/BEHAVIORAL_PATTERNS.md +0 -228
- package/docs/research/DOMAIN_STRATEGIES.md +0 -316
- package/docs/research/MEMORY_SYSTEMS_COMPARISON.md +0 -812
- package/docs/research/PATTERN_ANALYSIS_2026-01-18.md +0 -436
- package/docs/research/PERFORMANCE_ANALYSIS_2026-01-18.md +0 -209
- package/docs/research/PERFORMANCE_TEST_PLAN.md +0 -383
- package/docs/research/TERMINAL_BENCH_LEARNINGS.md +0 -217
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
# UAM Terminal-Bench Optimization Options
|
|
2
|
-
|
|
3
|
-
Research-based options for each failing task. Each section lists 5+ approaches ranked by feasibility.
|
|
4
|
-
|
|
5
|
-
## 1. chess-best-move (0/1) - Finding ALL Checkmate Moves
|
|
6
|
-
|
|
7
|
-
**Current Issue**: Agent outputs wrong moves (e.g., b2b3 instead of e2e4, g2g4). Not finding the SPECIFIC checkmate moves.
|
|
8
|
-
|
|
9
|
-
### Option 1: python-chess Library (RECOMMENDED)
|
|
10
|
-
```python
|
|
11
|
-
import chess
|
|
12
|
-
import chess.engine
|
|
13
|
-
|
|
14
|
-
engine = chess.engine.SimpleEngine.popen_uci("/usr/bin/stockfish")
|
|
15
|
-
board = chess.Board(fen_string)
|
|
16
|
-
|
|
17
|
-
# Analyze with multipv to find ALL good moves
|
|
18
|
-
result = engine.analyse(board, chess.engine.Limit(depth=25), multipv=10)
|
|
19
|
-
for info in result:
|
|
20
|
-
if info.get("score") and info["score"].is_mate():
|
|
21
|
-
print(info["pv"][0]) # First move of the line
|
|
22
|
-
```
|
|
23
|
-
**Pros**: Clean Python API, handles UCI parsing
|
|
24
|
-
**Cons**: Requires python-chess installation
|
|
25
|
-
|
|
26
|
-
### Option 2: Direct Stockfish UCI with Proper Parsing
|
|
27
|
-
```bash
|
|
28
|
-
echo -e "setoption name MultiPV value 10\nposition fen $FEN\ngo depth 25" | stockfish | grep "score mate" | awk '{print $NF}'
|
|
29
|
-
```
|
|
30
|
-
**Key**: Parse lines containing "score mate 1" (checkmate in 1 move) and extract the move from "pv" field
|
|
31
|
-
**Pattern**: `info depth 25 multipv 1 score mate 1 ... pv e2e4 ...`
|
|
32
|
-
|
|
33
|
-
### Option 3: Use Stockfish's "go mate" Command
|
|
34
|
-
```bash
|
|
35
|
-
echo -e "position fen $FEN\ngo mate 3" | stockfish
|
|
36
|
-
```
|
|
37
|
-
Searches specifically for mate-in-N. Returns only mating lines.
|
|
38
|
-
|
|
39
|
-
### Option 4: Chess.js + Stockfish via Node
|
|
40
|
-
```javascript
|
|
41
|
-
const { Chess } = require('chess.js');
|
|
42
|
-
const Stockfish = require('stockfish');
|
|
43
|
-
// Mate search with JS interface
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Option 5: Pre-computed Checkmate Database
|
|
47
|
-
For certain positions (endgames), use Syzygy tablebases or Lomonosov database for perfect play.
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## 2. polyglot-rust-c (0/1) - Single File Compiles as Both Rust AND C
|
|
52
|
-
|
|
53
|
-
**Current Issue**: Syntax errors when compiling. The SAME file must be valid Rust AND valid C.
|
|
54
|
-
|
|
55
|
-
### Option 1: Comment-Based Polyglot (RECOMMENDED)
|
|
56
|
-
```c
|
|
57
|
-
/*
|
|
58
|
-
fn main() {
|
|
59
|
-
for i in 1..=10 {
|
|
60
|
-
let fib = fibonacci(i);
|
|
61
|
-
println!("{}", fib);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
fn fibonacci(n: u64) -> u64 {
|
|
65
|
-
if n <= 1 { n } else { fibonacci(n-1) + fibonacci(n-2) }
|
|
66
|
-
}
|
|
67
|
-
// */
|
|
68
|
-
#include <stdio.h>
|
|
69
|
-
long long fibonacci(int n) { return n <= 1 ? n : fibonacci(n-1) + fibonacci(n-2); }
|
|
70
|
-
int main() { for(int i=1;i<=10;i++) printf("%lld\n", fibonacci(i)); return 0; }
|
|
71
|
-
/*
|
|
72
|
-
*/
|
|
73
|
-
```
|
|
74
|
-
**Key**: Rust treats `/*` as block comment start. C treats it same way. The Rust code is inside a comment for C, and vice versa using `// */` trick.
|
|
75
|
-
|
|
76
|
-
### Option 2: Preprocessor Trick with #if 0
|
|
77
|
-
```rust
|
|
78
|
-
#[cfg(not(any()))] //
|
|
79
|
-
const _: () = {
|
|
80
|
-
#![allow(unused)]
|
|
81
|
-
/*
|
|
82
|
-
#if 0
|
|
83
|
-
*/
|
|
84
|
-
fn main() { /* Rust code */ }
|
|
85
|
-
/*
|
|
86
|
-
#endif
|
|
87
|
-
#include <stdio.h>
|
|
88
|
-
int main() { /* C code */ }
|
|
89
|
-
*/
|
|
90
|
-
};
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Option 3: Search GitHub for Existing Polyglots
|
|
94
|
-
```bash
|
|
95
|
-
# Search for working examples
|
|
96
|
-
curl -s "https://api.github.com/search/code?q=polyglot+rust+c+fibonacci"
|
|
97
|
-
```
|
|
98
|
-
Many working polyglots exist - find and adapt one.
|
|
99
|
-
|
|
100
|
-
### Option 4: Quine-Style Self-Modifying
|
|
101
|
-
Create code that outputs itself differently based on compiler.
|
|
102
|
-
|
|
103
|
-
### Option 5: Minimal Common Subset
|
|
104
|
-
Find syntax that's valid in BOTH languages (very limited but possible for simple programs).
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## 3. winning-avg-corewars (2/3) - Beat stone.red with 75%+ Win Rate
|
|
109
|
-
|
|
110
|
-
**Current Issue**: Only 18% win rate vs stone.red (need 75%+). Beating vampire (95%) and paper (78%) already.
|
|
111
|
-
|
|
112
|
-
### Option 1: Use a Replicator (Paper Strategy) (RECOMMENDED)
|
|
113
|
-
Stone (bomber) is weak against Paper (replicator). Classic rock-paper-scissors.
|
|
114
|
-
```redcode
|
|
115
|
-
;name Paper Beats Stone
|
|
116
|
-
;strategy Fast replicator to overwhelm stone's bombs
|
|
117
|
-
spl 0, 0 ; Split to create copies
|
|
118
|
-
mov -1, 0 ; Copy the split instruction forward
|
|
119
|
-
jmp -2 ; Keep replicating
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Option 2: Imp-Ring with Bombing Hybrid
|
|
123
|
-
```redcode
|
|
124
|
-
;name Imp-Stone Hybrid
|
|
125
|
-
spl #0, <-1000 ; Create imp-ring
|
|
126
|
-
mov.i 0, 1 ; Simple stone-like bombing
|
|
127
|
-
jmp -1
|
|
128
|
-
```
|
|
129
|
-
Imps are small targets that survive stone bombs.
|
|
130
|
-
|
|
131
|
-
### Option 3: Use P-Switcher (Adaptive Strategy)
|
|
132
|
-
```redcode
|
|
133
|
-
;name P-Switcher
|
|
134
|
-
; Check P-space for previous result
|
|
135
|
-
ldp.ab #0, #0
|
|
136
|
-
jmz paper, #0 ; If lost, try paper
|
|
137
|
-
jmp stone ; If won, use stone
|
|
138
|
-
```
|
|
139
|
-
Adapt strategy based on previous rounds.
|
|
140
|
-
|
|
141
|
-
### Option 4: Core Clear Strategy
|
|
142
|
-
```redcode
|
|
143
|
-
;name Core Clear
|
|
144
|
-
; Rapidly clear the entire core
|
|
145
|
-
mov bomb, >ptr
|
|
146
|
-
djn -1, #8000
|
|
147
|
-
bomb dat #0, #0
|
|
148
|
-
ptr dat #0, #0
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Option 5: Quickscan + Attack
|
|
152
|
-
Scan for enemy, then bomb their location specifically:
|
|
153
|
-
```redcode
|
|
154
|
-
;name Scanner
|
|
155
|
-
seq >scan, 100
|
|
156
|
-
jmp found
|
|
157
|
-
add #2, scan
|
|
158
|
-
jmp -3
|
|
159
|
-
found mov bomb, @scan
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## 4. write-compressor (2/3) - Lossless Compression with Round-Trip
|
|
165
|
-
|
|
166
|
-
**Current Issue**: Decompression fails with "UnicodeDecodeError" or buffer issues. Round-trip broken.
|
|
167
|
-
|
|
168
|
-
### Option 1: Use Python's Built-in zlib (RECOMMENDED)
|
|
169
|
-
```python
|
|
170
|
-
import zlib
|
|
171
|
-
|
|
172
|
-
def compress(input_file, output_file):
|
|
173
|
-
with open(input_file, 'rb') as f:
|
|
174
|
-
data = f.read()
|
|
175
|
-
compressed = zlib.compress(data, level=9)
|
|
176
|
-
with open(output_file, 'wb') as f:
|
|
177
|
-
f.write(compressed)
|
|
178
|
-
|
|
179
|
-
def decompress(input_file):
|
|
180
|
-
with open(input_file, 'rb') as f:
|
|
181
|
-
data = f.read()
|
|
182
|
-
return zlib.decompress(data)
|
|
183
|
-
```
|
|
184
|
-
**Key**: Use binary mode ('rb', 'wb') everywhere!
|
|
185
|
-
|
|
186
|
-
### Option 2: Huffman Coding with Proper Bit Handling
|
|
187
|
-
```python
|
|
188
|
-
from collections import Counter
|
|
189
|
-
import heapq
|
|
190
|
-
|
|
191
|
-
def huffman_compress(text):
|
|
192
|
-
# Build frequency table, tree, codes
|
|
193
|
-
# Pack bits properly with struct module
|
|
194
|
-
pass
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
### Option 3: LZ77/LZSS Implementation
|
|
198
|
-
Sliding window compression - good for text with repetitions.
|
|
199
|
-
|
|
200
|
-
### Option 4: Simple RLE (Run-Length Encoding)
|
|
201
|
-
```python
|
|
202
|
-
def rle_compress(data):
|
|
203
|
-
result = []
|
|
204
|
-
i = 0
|
|
205
|
-
while i < len(data):
|
|
206
|
-
count = 1
|
|
207
|
-
while i + count < len(data) and data[i+count] == data[i] and count < 255:
|
|
208
|
-
count += 1
|
|
209
|
-
result.append(count)
|
|
210
|
-
result.append(data[i])
|
|
211
|
-
i += count
|
|
212
|
-
return bytes(result)
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Option 5: BWT + MTF + RLE (Burrows-Wheeler Transform)
|
|
216
|
-
Advanced but very effective for text compression.
|
|
217
|
-
|
|
218
|
-
**Critical Fix for All**:
|
|
219
|
-
```python
|
|
220
|
-
# ALWAYS use binary mode
|
|
221
|
-
# NEVER mix text and binary operations
|
|
222
|
-
# Test round-trip before submitting:
|
|
223
|
-
original = open('input.txt', 'rb').read()
|
|
224
|
-
compressed = compress(original)
|
|
225
|
-
decompressed = decompress(compressed)
|
|
226
|
-
assert original == decompressed, "Round-trip failed!"
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
## 5. adaptive-rejection-sampler (8/9) - R Statistical Sampling
|
|
232
|
-
|
|
233
|
-
**Current Issue**: 1 test failing - `test_can_generate_standard_distribution_samples`. The R function doesn't work for standard normal.
|
|
234
|
-
|
|
235
|
-
### Option 1: Use CRAN 'ars' Package (RECOMMENDED)
|
|
236
|
-
```r
|
|
237
|
-
install.packages("ars")
|
|
238
|
-
library(ars)
|
|
239
|
-
|
|
240
|
-
# Standard normal sampling
|
|
241
|
-
ars <- function(target_density, bounds, n=1000) {
|
|
242
|
-
f <- function(x) log(target_density(x))
|
|
243
|
-
fprima <- function(x) -x # derivative of log(dnorm) = -x
|
|
244
|
-
ars::ars(n=n, f=f, fprima=fprima, x=c(bounds[1]+0.1, 0, bounds[2]-0.1),
|
|
245
|
-
lb=TRUE, xlb=bounds[1], ub=TRUE, xub=bounds[2])
|
|
246
|
-
}
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
### Option 2: Implement from Gilks & Wild (1992)
|
|
250
|
-
The original ARS algorithm:
|
|
251
|
-
1. Initialize with 2+ points where f'(x) changes sign
|
|
252
|
-
2. Build piecewise linear envelope of log f(x)
|
|
253
|
-
3. Sample from envelope, accept/reject based on squeezing
|
|
254
|
-
|
|
255
|
-
### Option 3: Derivative-Free ARS
|
|
256
|
-
For functions where derivative is hard to compute:
|
|
257
|
-
```r
|
|
258
|
-
ars_no_deriv <- function(f, bounds, n) {
|
|
259
|
-
# Use numeric differentiation
|
|
260
|
-
fprima <- function(x) (f(x+1e-6) - f(x-1e-6)) / (2e-6)
|
|
261
|
-
# Rest of ARS...
|
|
262
|
-
}
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
### Option 4: Use arscpp (C++ Backend)
|
|
266
|
-
```r
|
|
267
|
-
devtools::install_github("hunzikp/arscpp")
|
|
268
|
-
library(arscpp)
|
|
269
|
-
# Fast C++ implementation
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### Option 5: Fallback to Standard R Samplers
|
|
273
|
-
```r
|
|
274
|
-
# If ARS fails, use built-in samplers as fallback
|
|
275
|
-
if (is_normal_distribution(target_density)) {
|
|
276
|
-
return(rnorm(n, mean=0, sd=1))
|
|
277
|
-
}
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
**Key Fix**: Ensure the function signature matches what tests expect:
|
|
281
|
-
```r
|
|
282
|
-
ars <- function(target_density, bounds, n=1000) {
|
|
283
|
-
# Must return numeric vector of length n
|
|
284
|
-
# Must work for dnorm(x, mean=0, sd=1)
|
|
285
|
-
}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
## Generalized Patterns Extracted (P32-P36)
|
|
291
|
-
|
|
292
|
-
From analyzing these 5 task failures, we extracted **universal patterns** that apply broadly:
|
|
293
|
-
|
|
294
|
-
### P32: Use Established Libraries Over Custom Implementation
|
|
295
|
-
**Applies to**: chess-best-move, adaptive-rejection-sampler, write-compressor
|
|
296
|
-
- When a well-known algorithm exists (chess engines, compression, statistics), use existing libraries
|
|
297
|
-
- Libraries handle edge cases you'll miss
|
|
298
|
-
- Search: `pip search`, `apt-cache search`, CRAN, npm
|
|
299
|
-
|
|
300
|
-
### P33: Binary Mode for All File I/O
|
|
301
|
-
**Applies to**: write-compressor, any file processing task
|
|
302
|
-
- ALWAYS use `'rb'` and `'wb'` modes
|
|
303
|
-
- NEVER mix text and binary operations
|
|
304
|
-
- Verify round-trip: `assert decompress(compress(data)) == data`
|
|
305
|
-
|
|
306
|
-
### P34: Search for Existing Solutions First
|
|
307
|
-
**Applies to**: polyglot-rust-c, any complex algorithm
|
|
308
|
-
- Search GitHub before implementing from scratch
|
|
309
|
-
- Many problems have solved examples online
|
|
310
|
-
- Adapt existing code rather than inventing
|
|
311
|
-
|
|
312
|
-
### P35: Understand Game Theory / Strategic Domains
|
|
313
|
-
**Applies to**: winning-avg-corewars, any competitive/adversarial task
|
|
314
|
-
- Identify rock-paper-scissors dynamics
|
|
315
|
-
- Counter-strategies beat specific strategies
|
|
316
|
-
- Adaptive strategies are more robust
|
|
317
|
-
|
|
318
|
-
### P36: Multi-Language Polyglot via Comments
|
|
319
|
-
**Applies to**: polyglot tasks, multi-runtime code
|
|
320
|
-
- Use comment syntax differences between languages
|
|
321
|
-
- Hide one language's code inside another's comments
|
|
322
|
-
|
|
323
|
-
## Key Insight
|
|
324
|
-
|
|
325
|
-
**Generalized patterns > Task-specific fixes**
|
|
326
|
-
|
|
327
|
-
The goal is NOT to solve chess-best-move specifically, but to teach the pattern:
|
|
328
|
-
- "When you need a chess engine, use python-chess library" →
|
|
329
|
-
- "When you need a well-known algorithm, use an established library (P32)"
|
|
330
|
-
|
|
331
|
-
This approach:
|
|
332
|
-
1. Works for similar future tasks
|
|
333
|
-
2. Keeps prompt size manageable
|
|
334
|
-
3. Teaches transferable problem-solving strategies
|