My parser finds bugs in its own reading, without an answer key
submitted by /u/Other_Train9419 [link] [留言]
找到 2553 篇相关文章
submitted by /u/Other_Train9419 [link] [留言]
Inspired by the Google Deepmind Developer, this London Sim City map comes from Isometric NYC submitted by /u/Mastbubbles [link] [留言]
submitted by /u/Business_Mix3602 [link] [留言]
AI coding tools become much more useful when they are given clear boundaries. One practical way to create those boundaries is with Git worktrees. A Git branch gives you separate history. A worktree gives you a separate working directory connected to that branch. Instead of making several AI agents share one workspace, you can give each agent its own isolated environment. What is a Git worktree? A worktree lets you check out multiple branches from the same repository at the same time. For example: git worktree add ../feature-a -b experiment/feature-a git worktree add ../feature-b -b experiment/feature-b You now have two separate directories. Claude Code, OpenAI Codex, or another coding agent can work inside each one without constantly switching branches in your main project. 1. Create different versions of a feature Sometimes there is no obvious best implementation. Instead of asking one agent to repeatedly rewrite the same code, create separate worktrees: Worktree A: simplest implementation Worktree B: performance-focused implementation Worktree C: implementation that follows a different UI or architecture You can then compare the actual code, tests, and tradeoffs before choosing a solution. The unsuccessful versions can be removed without affecting the selected implementation. 2. Give every subagent its own workspace Multiple agents editing the same directory can easily overwrite files or mix unrelated changes. A safer setup is: project/ project-agent-api/ project-agent-ui/ project-agent-tests/ Each agent receives: Its own worktree Its own branch A clearly defined task A list of files it is allowed to change Its own verification requirements This makes every agent’s output easier to understand and review. 3. Work on independent tickets in parallel Worktrees are useful when several tasks do not depend on each other. For example: One agent fixes an API bug Another updates a frontend component Another adds tests or documentation These tasks can progress at the same ti
I built a stale-lock breaker: if the lockfile's owner looked dead, delete the file and take over. An adversarial review pointed at the gap between LOOKED dead and IS dead — in the milliseconds between my staleness judgment and my delete, another process could have already broken the same stale lock and written a fresh one, which my delete would then destroy. Two owners, both convinced they won. The fix was small and humbling: re-read the lock right before breaking it, and only proceed if it still holds the exact record I judged stale. Every check-then-act on shared state has a gap in the middle, and the gap doesn't care how fast your code is. Re-validate at the moment of the irreversible act, not just before it.
I am currently doing a course on Design pattern where i have gained some valuable knowledge about refactoring and code smells. I was looking for open source repositories where i can refactor and put my skills into practice. Thank you. submitted by /u/Leading_Ability752 [link] [留言]
submitted by /u/danie-l [link] [留言]
After re-reading "Clean Architecture" I ended up with some confusion regarding Bob's take on repetition and single responsibility. Ge defines the SRP as a function only serving one actor. Dies that mean, that repetitve code is justified according to him, as long as it serves seperate actors/user groups? I am aware that such decisions depend on the specific situation. I was just wondering if others found the same contradiction, or if i misunderstood it. Thanks submitted by /u/TalesGameStudio [link] [留言]
A short explanation of a wall a lot of developers hit, why it isn't going away, and the five lines that replace it. You wrote a contact form. It worked locally. You deployed it to a Cloudflare Worker, or a Vercel Edge Function, or Deno Deploy, and got something like this: TypeError: Class extends value #<Object> is not a constructor or null Or, if you were luckier and got a useful error: Module not found: Can't resolve 'net' Then you spent an hour trying compatibility flags, polyfills, and bundler aliases. I want to save you the rest of that hour. This isn't a bug, and no amount of configuration will fix it. The actual reason Nodemailer's default transport is SMTP. SMTP is a protocol that runs over a raw TCP connection. To open one in Node.js, you call net.createConnection() . Cloudflare Workers don't run on Node.js. They run on V8 isolates — the same engine as Chrome, without the Node runtime around it. Vercel's Edge Runtime and Deno Deploy are built on similar principles. In that environment, there is no net module, because there are no raw TCP sockets. All networking is handled by managed infrastructure outside the runtime — Cloudflare's own writeup on bringing node:http to Workers is explicit about this: connection pooling, TLS negotiation, and egress IP management are handled at the system level, which is precisely why a subset of Node APIs can never be supported. So the chain is: No raw TCP → no net.createConnection() → no SMTP client → no Nodemailer. There's a second, smaller issue that often gets conflated with this one. Nodemailer issue #1621 points out that Nodemailer imports built-in modules without the node: prefix, which breaks the Workers build step. That one is fixable. But fixing it wouldn't help — you'd just move the failure from build time to runtime, where net still doesn't exist. Issue #1623 covers the broader edge-function problem. It's worth being clear that none of this is a knock on Nodemailer. It's an excellent library, actively maintained,
You've seen some View in every SwiftUI file you've ever opened. Now let's find out what it actually means, why it exists, and why returning a plain protocol doesn't work the same way. Fair warning: this topic is genuinely one of the more brain-bendy things in Swift. I'm going to tell you upfront that you don't need to fully understand the internals to keep going — but you do need to know it exists and roughly what it's doing, because you've already been using it every single time you've written a SwiftUI view. That some View in every SwiftUI file? That's an opaque return type. And now we're going to actually understand what that means. 🍥 Let's Start With Something That Works Two simple functions: func getRandomJutsu () -> Int { Int . random ( in : 1 ... 100 ) } func getRandomSuccess () -> Bool { Bool . random () } Both Int and Bool conform to a protocol called Equatable — which means they can be compared using == . So you can do this: print ( getRandomJutsu () == getRandomJutsu ()) That works fine, comparing two random integers. Now, since both return types conform to Equatable , you might think: what if we simplify both functions to return Equatable instead of their specific types? The Thing That Doesn't Work func getRandomJutsu () -> Equatable { // ❌ Int . random ( in : 1 ... 100 ) } func getRandomSuccess () -> Equatable { // ❌ Bool . random () } Swift refuses this with an error message so confusing it might as well be written in ancient runes: "protocol 'Equatable' can only be used as a generic constraint because it has Self or associated type requirements." Here's the actual problem in plain English: if both functions return Equatable , Swift loses track of what specific type is coming back. And if it doesn't know the specific type, it can't know whether two Equatable things can actually be compared to each other. Think about it: an Int and a Bool both conform to Equatable , but you can't compare them with == . That doesn't make sense. Swift isn't going to let y
submitted by /u/refp [link] [留言]
I kind of feel like OOP has a bad rep in the programming community. Personally, after having programmed Java for over 20 years, its object-oriented programming model feels very natural to me. So, I wanted to share how I think about programming, how I translate my ideas and thoughts to code, and why OOP is actually a really nice programming style for me. Perhaps it could help you out too. submitted by /u/OSBY_Glabay [link] [留言]
State-of-the-art classical optimizer Gurobi for Quadratic Unconstrained Binary Optimization (QUBO) problems. The core gurobipy implementation for QUBO is relatively compact: ```python model = gp.Model() x = model.addMVar(n, vtype=GRB.BINARY) model.setObjective(x @ Q @ x, GRB.MINIMIZE) model.optimize() solution = x.X.astype(int) objective = model.ObjVal ``` Complete workflow in Python. First formulate a graph problem (weighted Max-Cut) as QUBO, solve it with Gurobi, benchmark increasingly large instances, and understand what the solver is doing beyond the optimize() call. Interested in feedback on the modeling, benchmarking methodology, and which additional Gurobi metrics would make the comparison more rigorous. submitted by /u/Future_Ad7567 [link] [留言]
submitted by /u/davidalayachew [link] [留言]
Inference APIs return a small, stable set of failures, and most integrations handle them with a blanket retry that makes two of them worse and hides a third. Knowing which is which takes about ten minutes and saves an outage. The shape of an error Both major dialects return a JSON body with a structured error object alongside the HTTP status. In the OpenAI dialect it is {"error": {"message", "type", "param", "code"}} ; Anthropic returns {"type": "error", "error": {"type", "message"}} . The status tells you the class; the type or code field tells you what to do, and it is the field most client code discards. Log both, and log the request id header — every provider issues one, and it is the only thing a support conversation can proceed from. The distinction that organises everything below is not client-versus-server, which is what the status code nominally encodes. It is will the identical request succeed later? Three answers exist: yes after a wait (capacity and rate conditions), no until something changes in the request (validation, auth, model identity), and no until something changes outside the request entirely (a billing state, a retired snapshot, a regional restriction). Only the first is retryable, the second belongs in an alert on your own deploy, and the third needs a human. Several genuinely different conditions share a status code across that boundary, which is why classifying on status alone produces a retry policy that is wrong in both directions — hammering a wall in one place and giving up on a transient blip in another. Error messages themselves are prose written for a human and are the worst thing to branch on. They get reworded without notice, they are sometimes localised, and the same underlying condition is phrased differently by two providers. Match on the status and the type field, keep the message for the log, and if you must string-match — some providers put the only useful detail in the message — treat that branch as a known liability and cov
“Schedule it for the Friday after next” is one of the most dangerous strings you can hand a language model, because it will confidently return a date, that date will be well formatted, and there is roughly no chance anyone downstream will check it. The model has no clock Start with the thing that is easy to forget: a language model is a pure function of its context. It has no system clock, no timezone database access at inference time and no notion of when “now” is. If the current date is not in the context, the model does what it does with any missing variable — it infers a plausible one from the distribution, which means from the density of dates in its training data. So a model asked for “next Tuesday” with no anchor is computing an offset from a guess, and the guess skews towards its training cutoff. Worse, models will often state the assumed date confidently, or not state it at all, which removes the one signal a reviewer could have used. This is a hallucination in the strict sense: a specific claim about the world, produced with no information behind it. The four failures 1. Missing anchor Everything above. The fix is one line in the system prompt and it is astonishing how often it is missing. Include the full instant, not just the date: Current time: 2026-08-03T14:05:00+02:00 (Europe/Amsterdam, Monday) . Giving the weekday explicitly removes a computation, and giving the offset and the IANA zone removes two more. 2. Date arithmetic, which is just arithmetic Counting days across month boundaries, adding 90 days, computing an age at a past date, finding the number of business days in a range. Every weakness on the numerical reasoning page applies, plus irregular bases: months of unequal length, leap years, and the leap-year rule’s century exceptions. Off-by-one errors here are systematic rather than random, which is what makes them survive casual review. 3. Timezones, offsets and DST The richest source of silent bugs. An offset is not a timezone — +01:00 is a f
A model can be wrong and know it, wrong and not know it, or right for reasons that make its confidence meaningless. Calibration is the statistical machinery for telling these apart, and it is worth learning properly because the sloppy version — treating a logprob as a probability of being correct — fails in a specific and predictable way. The definition A predictor is calibrated if, among all the predictions it made with stated confidence p , a fraction p turn out correct. Say it makes a thousand predictions at 70% confidence; about seven hundred should be right. That is the whole property, and note what it is not: it is not accuracy. A weather model that says “30% chance of rain” every single day in a climate where it rains 30% of days is perfectly calibrated and completely useless. Calibration and discrimination are separate axes, and you want both. The relevance to hallucination is direct. If a model were well calibrated on its own answers, you would not need to detect hallucination at all — you would threshold on confidence and route the low-confidence cases to a human or to a search. The reason that does not work out of the box is the subject of the rest of this page. Reading a reliability diagram The plot everyone shows and few label. Both axes run from 0 to 1. x-axis: predicted confidence. Predictions are sorted into bins — conventionally ten equal-width bins, [0.0, 0.1), [0.1, 0.2) and so on — by the confidence the model stated. For a multiple-choice answer that confidence is the softmax probability of the chosen option. y-axis: observed accuracy. Within each bin, the fraction of predictions that were actually correct. The diagonal. y = x is perfect calibration. Points below the diagonal mean the model was more confident than it deserved: overconfidence. Points above mean it was underconfident. The bin counts. Almost always drawn as a histogram underneath, and they matter — a bin holding twelve predictions can sit anywhere, and a diagram without them invites
Most “spend limits” are notifications. They tell a human that money has already left, which is a useful thing to know and is not a limit. A limit refuses the request. An alert is not a cap The distinction is whether the mechanism sits in the request path. An alert reads spend after the fact and pages someone. A cap is a check before the call that can return an error instead of an answer. Only one of them bounds your loss, and the gap between them is measured in the time it takes a person to wake up, understand, and deploy a fix. The failure this protects against is rarely a gradual overrun. It is a loop: an agent that retries forever, a webhook that reprocesses the same document, a bug that resubmits a queue, a scraper that found an unauthenticated endpoint. These do not creep. They run at whatever rate your concurrency allows, which is usually thousands of times your normal rate, and they are indistinguishable from healthy traffic on every dashboard except the cost one. What the lag costs max_loss = burn_rate * detection_lag burn_rate dollars per minute during the incident detection_lag alert delay + notice + diagnosis + deploy Compute burn_rate for your own worst case rather than guessing it: it is concurrency × requests_per_second_per_worker × cost_per_request × 60 . With an assumed 50 concurrent workers each managing 2 requests per second at $0.004 a request, that is 50 × 2 × 0.004 × 60 = $24 per minute . burn = $24/min usage dashboards refresh hourly ...... 60 min alert fires, engineer notices ........ 15 min diagnose, decide ..................... 20 min ship the fix ......................... 15 min total ... 110 min max_loss = 24 * 110 = $2,640 from a single loop bug, with alerting working perfectly. The dominant term is the first one. If your spend data is an hour stale, no amount of alerting discipline gets the loss below an hour’s burn — which is the argument for a cap in the request path, where the lag is zero by construction. The race at the heart of a ca
You ask for every line item on the invoice. There are ten. You get seven, the JSON validates, and nothing anywhere reports a problem. This is the single most reported structured-output bug and at least half the time the model is not the cause. Four causes, wildly different fixes Cause Description Truncation finish_reason == 'length'. The list was cut off mid-flight. Your max_tokens, not the model's recall. Chunk boundary Items 8-10 were on a page you did not send. Check what text actually reached the model. Dropped constraint You set minItems and the provider ignored it, so nothing enforced anything. Genuine omission Everything was present and the model stopped early. The only one that is actually about the model. Diagnose in that order, because the first three are cheap to rule out and the fourth is the expensive one to work on. Log finish_reason , usage.completion_tokens and the length of the text you sent on every extraction call and the first two answer themselves. The constraint you thought you set minItems and maxItems sit outside the documented supported keyword set for hosted strict modes. Depending on the stack, sending them either gets you a 400 naming the keyword — fine, you learn immediately — or a 200 where the keyword was quietly discarded. The second case is the trap, because your schema is now a comment. You believe a floor is enforced, the API returned success, and the array is short. Nothing in any log says the constraint was never applied. Find out which of the two your endpoint does before you rely on it — and either way, put “every item, do not summarise or skip” in the array’s description , since that reaches the model whether or not the keyword survives. Why counting is hard for a decoder There is no counter. Each token is produced from the context, and the context contains the items already emitted — so “have I got them all” is not a lookup, it is a judgement the model re-makes at every array element from what it can see. Two structural conse
Every team already knows how to put a feature behind a flag. What is different here is that the thing most likely to need changing at three in the morning is not whether the feature is on — it is which model it calls, which prompt it uses, and how much it is allowed to do without asking. Why the usual flag is not enough A conventional feature flag answers one question with a boolean, and it is the right shape because a conventional feature has one failure mode: it is broken. An AI feature has several, and they want different responses. The provider is degraded — you want a different model, not the feature off. A prompt change regressed quality — you want the previous prompt, which is not a code deploy. The feature is fine but a specific customer’s data is producing bad output — you want it off for them and on for everyone else. Spend is running above forecast — you want the cheap model or the degraded path, not an outage. A single boolean answers none of these, so the response to each becomes a deploy, and a deploy is the slowest tool available at the moment you most need speed. There is a second reason, specific to this dependency. The behaviour you are flagging can change without you deploying anything, because the model is somebody else’s and it can be updated underneath you. Flags are usually a mechanism for controlling your own changes; here they are also the mechanism for reacting to changes you did not make, which is why detecting a provider-side behaviour change and having a flag to respond with are two halves of one control. Four things to flag separately Axis Description Feature on/off The ordinary flag. Per-tenant and per-segment, because the common case is a problem confined to one customer's data rather than a global outage. Model selection Which model each call site uses, as configuration. This is what lets you switch providers during an incident, run a canary on a new model, or drop to a cheaper one under budget pressure — without shipping code. Promp