Secret Bytes Pick the Free Server
A free server is a valid route only after redaction. Latency savings never repay a secret on the wire. Offline work must finish on the machine alone. Remote model quality moves faster than most gates. That movement does
A free server is a valid route only after redaction. Latency savings never repay a secret on the wire. Offline work must finish on the machine alone.
Remote model quality moves faster than most gates. That movement does not relax the exit rule. A sharper answer is still wrong with a leaked key.
Treat the prompt as a packed suitcase at a dock. You do not mail the suitcase to save folding time. You remove the passport, then you time the walk.
This note is a method, not a recorded lab report. The numbers below are fixtures for a dry run. They are not measured speeds from a live service.
Three costs before any client
Local inference keeps bytes inside one process boundary. A free server moves those bytes across a foreign network. The trade buys reach and sells forgotten fields.
Three costs decide the route before any client runs. Secret bytes come first, then delay, then offline survival. Drop any one cost and the choice becomes a guess.
Secret bytes are characters that must never leave. Tokens, passwords, private paths, and customer rows all count. A placeholder is clean, but the raw value is not.
Round-trip time is the gap a person can feel. Measure it with a tiny probe from the real network. A status page does not know your last mile.
Offline survival is the rule that closes the design. If the link drops, local code must still emit a result. A free server cannot be the only brain available.
A gate you can diff
The artifact is a small Python gate you can diff. It never calls a model and never stores a secret. The sample targets Python 3.10 or newer for hints.
The script reads JSON from standard input and counts fields. It compares a local delay fixture with an optional probe. It prints a route plus a redacted copy of the body.
Label the script as a proposal, not a finished study. This draft has not executed it against a live fleet. Treat every threshold as a knob, not a law.
#!/usr/bin/env python3
# hop_gate.py - proposal, not a recorded benchmark.
from __future__ import annotations
import json
import os
import sys
import time
import urllib.request
SECRET_KEYS = {
"api_key",
"token",
"password",
"secret",
"authorization",
"cookie",
"private_key",
"ssn",
"email",
}
MAX_SECRET_BYTES = 0
MIN_RTT_GAIN_MS = 80
PROBE_TIMEOUT_S = 1.5
def secret_bytes(payload: dict) -> int:
total = 0
for key, value in payload.items():
name = str(key).lower()
text = "" if value is None else str(value)
if name in SECRET_KEYS and text not in ("", "[REDACTED]"):
total += len(text.encode("utf-8"))
return total
def redact(payload: dict) -> dict:
clean = {}
for key, value in payload.items():
if str(key).lower() in SECRET_KEYS:
clean[key] = "[REDACTED]"
else:
clean[key] = value
return clean
def probe_rtt_ms(url: str) -> float | None:
start = time.perf_counter()
try:
with urllib.request.urlopen(url, timeout=PROBE_TIMEOUT_S) as resp:
resp.read(64)
except OSError:
return None
return (time.perf_counter() - start) * 1000.0
def decide(payload: dict, local_ms: float, remote_ms: float | None) -> str:
if secret_bytes(payload) > MAX_SECRET_BYTES:
return "local"
if remote_ms is None:
return "local"
gain = local_ms - remote_ms
if gain < MIN_RTT_GAIN_MS:
return "local"
return "free_server"
def main() -> int:
raw = json.loads(sys.stdin.read() or "{}")
local_ms = float(os.environ.get("LOCAL_MS", "400"))
probe = os.environ.get("PROBE_URL", "")
remote_ms = probe_rtt_ms(probe) if probe else None
route = decide(raw, local_ms, remote_ms)
report = {
"route": route,
"secret_bytes": secret_bytes(raw),
"redacted": redact(raw),
"local_ms_fixture": local_ms,
"remote_probe_ms": remote_ms,
}
json.dump(report, sys.stdout, indent=2)
sys.stdout.write("\n")
return 0
if __name__ == "__main__":
raise SystemExit(main())
Feed the gate a fixture, not a live customer record. An empty token is not a leak under this classifier. A filled token is a hard stay on the machine.
Point the probe only at a host you already accept. The sample uses example.com as a stand-in address. It is not an endpoint for the product discussed later.
Read the JSON report before any client sends a body. The redacted object is the only payload allowed out. The original object stays on disk beside the diff.
Where the remote lane fits
MonkeyCode is the optional remote lane inside this gate. Disclosure: This article was prepared as part of MonkeyCode's product outreach. Operator notes cite free model access and a free server option.
This draft states no cap, no hardware, and no duration. Speed figures were not supplied, so none are printed here. Plan capacity from the docs, not from this page.
Read the current project docs before you trust the lane. Then try one redacted hop on a fixture you control. If the docs disagree with this note, trust the docs.
Use that lane only when the gate prints free_server. Keep the local branch able to finish the same task class. If the lane vanishes, the loop should still emit a patch.
An offer can change without notice in this kind of lane. Plan for withdrawal the same way you plan for packet loss. Your local branch is the continuity plan, not a slogan.
Ferry days and bridge days
Picture a ferry beside a short footbridge on an island. The ferry is the free server on a good weather day. The footbridge is local inference, slower but contained.
You board only after the crate has been searched. A found passport means you walk, even if the ferry waits. A late ferry or a closed dock means you walk too.
The order stays stable across tasks and across weeks. Redaction comes before timing, and timing before the send. The send is optional, while the local result is not.
A free server wins inside a narrow and boring band. The payload is clean, and the probe beats your knob. The task is synthesis, not a lookup of private rows.
You must be willing to discard a weak remote answer. A pretty diff is not proof that the route was safe. Safety was decided before the request left the disk.
A free server loses across a much wider set of cases. Any remaining secret byte forces an immediate local stay. A failed probe, a tie, or a dead link does too.
Legal export bans also end the remote option at once. So does a local model that already solves the edit. Reach is not a prize when the island is sufficient.
A rehearsal row can show the arithmetic without a benchmark claim. Set the local fixture at 420 ms and the probe at 90. The gap is 330 ms, so a clean payload may hop.
Swap the probe result to 400 ms and the route stays local. The knob made that call, not the name of the lane. Change the knob only after traces from your own editor.
Four fixtures without source text
Run four fixtures and record the route, not the source. Store counts, routes, and timings in the test log. Leave private file text out of that log entirely.
Fixture A carries a filled token and a short task. Expect local, and expect a secret count above zero. Any other route means you must fix the classifier.
Fixture B has no secret fields and a slow local fixture. Expect free_server only when the probe beats the knob. A slower probe that returns local is still a pass.
Fixture C blocks the probe host or drops the network. Expect local, and expect the probe time to be null. The script must return before the timeout knob expires.
Fixture D replays a saved redacted file with no network. The local editor must still produce a usable diff. Otherwise you have a remote dependency in a local costume.
The function checks below do not touch the network. They lock the route rules before any probe is trusted. Run them after you save the script as hop_gate.py.
mkdir -p fixtures
printf '%s\n' '{"task":"rename symbol","token":"fixture-token-value","path":"src/app.py"}' > fixtures/a_token.json
printf '%s\n' '{"task":"rename symbol","token":"","path":"src/app.py"}' > fixtures/b_clean.json
printf '%s\n' '{"task":"rename symbol","path":"src/app.py"}' > fixtures/c_offline.json
python3 -c 'import hop_gate; assert hop_gate.decide({"token":"x"}, 420, 90)=="local"; assert hop_gate.decide({"task":"rename"}, 420, 90)=="free_server"; assert hop_gate.decide({"task":"rename"}, 420, 400)=="local"; assert hop_gate.decide({"task":"rename"}, 420, None)=="local"'
export LOCAL_MS=420
export PROBE_URL=https://example.com
python3 hop_gate.py < fixtures/a_token.json | tee /tmp/a.json
unset PROBE_URL
python3 hop_gate.py < fixtures/c_offline.json | tee /tmp/c.json
python3 -c 'import json; a=json.load(open("/tmp/a.json")); c=json.load(open("/tmp/c.json")); assert a["route"]=="local"; assert c["route"]=="local"; assert c["remote_probe_ms"] is None'
Keep fixtures in the repo and keep real prompts out. The test proves the gate, not the wit of a model. A green run can still hide a bad client binding.
Teams often measure tokens and skip secret byte counts. A short prompt can still hold a production key. Length is a weak proxy, and field class is stronger.
Another miss is timing only the office happy path. Train wifi and hotel links fail in different ways. Run the probe from the network you actually use.
A third miss prints redaction and then sends the original. The report is not the request your client will make. Bind the client to the redacted object in review.
The remote lane should see the redacted task only. Public error text and a chosen file slice can join it. Shell history and environment files stay off that lane.
Limits and who should walk away
This gate is a heuristic built on key names alone. Secrets buried in prose will pass that shallow net. A pasted connection string is the classic miss.
Add a high-entropy scan if your tasks include blobs. The proposal script does not ship that second scan. Do not pretend the key list is a complete scanner.
The delay knobs are placeholders until your samples replace them. The default local delay exists so the script can run. Do not publish that default as a service benchmark.
This draft records no personal timing study on a fleet. Replace the fixture with traces from your own editor. Until then, treat printed milliseconds as rehearsal data.
Free model access can be limited, changed, or withdrawn. This article does not know the current numeric cap. Do not design a launch around an unnamed quota.
Need a signed capacity number before you ship traffic. Then buy capacity and write that number into a contract. A blog note is the wrong place to store that promise.
Skip this approach for health data and for payment data. Skip it for customer secrets and for air-gapped networks. Redaction by key name is not a compliance program.
The free server is egress, even when the price is zero. Calling the lane free does not make the bytes local. An air-gapped rule forbids that hop without exception.
Skip the pattern if you cannot keep a local fallback. A single remote path is a bet, not a workflow. The gate matters only when both branches can finish.
Skip it when on-device edits are already fast and clean. The hop then adds failure modes without a real gain. Local stays the whole design in that quiet case.
Close on the decision record
Write the route decision beside the diff on disk. A later reader should see why the hop was allowed. Counts, route, and probe time are the fields to keep.
Raw prompts do not belong in that decision record. When the route says local, finish the edit on disk. When it says free_server, send the redacted object only.
When the probe time is null, the island does the work. Remote quality will keep moving over the coming months. Your suitcase rule should stay stubborn and unchanged.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.