agentleFS
wboayuewboayue/rust-ibapi/.claude/skills/live-probe/SKILL.md

live-probe

Skill400 starsChanged 8 days agoMITView on GitHub

Verify actual TWS wire behavior against the paper gateway before typing a field, constraining a value, documenting a default, or closing a live check. Covers preflight (clock, gateway, paper guard), probe shapes, hang triage, and where findings go.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. edloidas/skills★ 2same name
    2. MediaPlural/agent-proven★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use when the question is "what does TWS actually send/accept", not "does our code handle X".

    line 9
  2. Very specific:

    Read the C# reference (EDecoder.cs for inbound fields, EClient.cs / EClientUtils for what's sent, Order.cs / Contract.cs for types).

    line 21
  3. Very specific:

    Write output to a file and flush after each line, or eprintln!

    line 64
  4. Distinctive:

    Write the finding as you get it, in the entry format (date, session, server version, what was not probed).

    line 90
  5. Distinctive:

    Don't commit probe code; cite the probe in the PR body.

    line 103
  6. Very specific:

    Delete temp #[ignore] / diagnostic tests from the tree before the PR (investigation artifacts, not suite).

    line 107

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Live probe

Use when the question is "what does TWS actually send/accept", not "does our code handle X". Docs, C# samples and field names have each been wrong (stale FundamentalReportType values, VOL units, what_if_type semantics); the paper gateway is the authority.

State the question as one falsifiable sentence before writing code: $ARGUMENTS.

0. Cheaper checks first

A probe costs a gateway session and often a market-hours wait. Try these first:

  • Grep the captured-wire fixtures in src/**/*tests.rs for the field; real TWS values appear there as assertions.
  • Read the C# reference (EDecoder.cs for inbound fields, EClient.cs / EClientUtils for what's sent, Order.cs / Contract.cs for types). See wire enum typing.

Probe when those disagree, are silent, or the question is about what TWS accepts (rejection codes, defaults for absent fields, units). Neither source answers those.

1. Preflight

$S below is your scratchpad directory.

TZ=America/New_York date '+%a %H:%M ET'
lsof -nP -iTCP -sTCP:LISTEN | grep -E ':(4002|7497) '   # expect java; ssh = tunnel, remote may be down
  • Reset windows: the gateway accepts TCP but ignores the handshake. Daily 00:15–01:45 ET (Sun–Fri), weekend Fri 23:00 – Sat 03:00 ET; other regions in troubleshooting. Wait; don't debug.
  • Market session decides what you can observe: RTH 09:30–16:00 ET for fills, live ticks, PnL. What-if, contract details, option chains and order acceptance work off-hours; overnight books are live, so "off-hours" is not "no quote". If the question needs RTH and it isn't, add a - [ ] line to plans/live-checks.md and stop.
  • Paper only. Port 4002 (Gateway) or 7497 (TWS). In the probe, assert managed_accounts() ids start with D before sending anything that mutates state.
  • Client id: pick one outside 200–399 (the integration tests' ibapi_test::ClientId pool) that no other session uses. A 326 "client id already in use" means a clash.
  • Log client.server_version() — every finding is tagged with it.

2. Probe shape

Pick the lightest that answers the question:

QuestionShape
Public API behavior (what a caller sees)Scratchpad bin crate, ibapi = { path = "<repo>" }
Raw frames / request ids / encoder-levelTemp #[ignore] test inside the domain (encoders are domain-private): client.send_request + next_before(deadline) loop counting frames
Enumerating an Other catchallDiagnostic test printing each Other + raw message type, run under several session states (empty, prior open orders, prior subscriptions)
Framing / exact bytesAny of the above with IBAPI_RAW_CAPTURE_DIR=$S/raw; walk with cargo run --example replay_raw_capture -- <file>.bin. IBAPI_RECORDING_DIR for parsed frames

Probe rules:

  • Bound every read with a deadline; on async, check Instant::now() >= deadline at the loop top (timeout_at polls the inner future first and keeps returning queued items).
  • Write output to a file and flush after each line, or eprintln! + RUST_LOG=debug; timeout cmd > file loses block-buffered stdout on kill.
  • Orders: prefer what-if (.analyze()). Otherwise non-marketable limit, then cancel. Paper fills arrive in chunks; re-read filled from the cancel reply before flattening, and flatten anything that filled.
  • Probe each variant/value separately; record which code each draws (e.g. 321 vs 430).
  • A capture covers only the instruments and session it ran against. 512 futures fills carried only BOT / SLD; SSHORT / SLONG need equity short sales. Match both to the question before calling a vocabulary complete, and list what wasn't covered under Not probed.

3. Hang triage

In this order — each has been misdiagnosed as a gateway problem:

  1. Zero output, even pre-connect prints → sample $(pgrep -f <bin>) 1. _dyld_start = macOS holding a freshly built binary (~50s). Give fresh binaries ≥60s before timeout.
  2. Output stops at connect, TCP accepts → re-check the reset window; check the listener is java, not an ssh forwarder.
  3. Outside the window, still silent → post-reset wedge. Ask the user to restart the gateway; don't assume.
  4. Immediate EOF after handshake → 326 client id clash; pick another id.
  5. UnexpectedEof / WouldBlock across many connections → gateway connection limit; serialize (--test-threads=1).

4. Record

Write the finding as you get it, in the entry format (date, session, server version, what was not probed).

  • Durable wire fact (a field's presence, units, accepted values, error code) → docs/wire-facts/<domain>.md. Ships in the PR the fact informs; a probe no PR acts on yet gets its own small docs PR. Rewrite an entry a new probe supersedes (keep the old result as one line).
  • Changes how a caller uses an API → also the item's rustdoc, with a live: <date> note.
  • Check waiting on market hours → plans/live-checks.md under ## #N <title>: - [ ] while pending, ticked - [x] with the line above when run; then move the result to docs/wire-facts/. Not a GitHub issue (plans and issues).
  • Confirms or contradicts a rule node → append to its precedents:.
  • Don't commit probe code; cite the probe in the PR body.

5. Clean up

Delete temp #[ignore] / diagnostic tests from the tree before the PR (investigation artifacts, not suite). Cancel open orders and flatten positions the probe created. Scratchpad crates can stay, but never cite their paths in the repo: they are session-scoped.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.