Mohammad Ali Haider
From Windows Fixes to Gateway Validation — My Contributions to Caracal
How my Caracal contributions grew from Windows compatibility fixes into SDK correctness, provider security, and live Gateway validation.
My contributions to Caracal started with problems I encountered while running the project on Windows. Commands that should have started the stack or opened the Console were failing because of assumptions about paths, terminals, package-manager commands, and Docker.
Investigating those issues gradually took me into other parts of the project. I contributed SDK fixes, provider request validation, tracing improvements, and testing changes. My most recent assignment focused on understanding and validating the complete Gateway request lifecycle.
This post brings that work together, from the initial problems to the implementation and recorded results.
Contribution status last verified on November 19, 2026. My history included 17 merged pull requests, while the Gateway work in PR #493 was open for maintainer review.
My LFX Journey with Caracal
An overview of my Caracal contributions, including Windows fixes, SDK improvements, provider security, tracing, playbooks, and Gateway validation.
Watch on YouTube ↗Understanding the system I was contributing to
Caracal governs access from applications and agents to protected resources. A protected request goes through authorization and policy checks before Gateway forwards it to an upstream service.
The SDK manages application integration and governed calls. The Coordinator manages Sessions and Delegations. The Security Token Service, or STS, evaluates authorization and issues mandates. Gateway performs a fresh STS exchange for each proxied request, while Audit records decisions and outcomes.
Understanding that flow mattered because the visible failure did not always originate in the component where I first noticed it.
Making the Windows workflow more reliable
My early contributions addressed problems in the Windows development experience.
Workspace launchers had trouble resolving package-manager command shims and dynamically importing Windows filesystem paths. I contributed fixes so the commands could resolve correctly and imports received valid file URLs.
I also addressed line-ending conversion. A Windows checkout could convert shell scripts to CRLF, causing Linux containers to fail at startup even though their images had built successfully. Repository attributes made the required line endings explicit.
Other contributions covered Console terminal detection, Docker BuildKit configuration, and the environment variables Docker needed to discover its plugins. I added an early BuildKit check so missing prerequisites produced a useful message before a build started.
Readiness commands also needed to finish cleanly after asynchronous network checks. I contributed changes that preserved the correct exit status while allowing Node to complete its normal cleanup.
These improvements focused on making everyday development commands more reliable and failures easier to diagnose.
Related merged contributions:
- Windows workspace launchers — PR #191
- Repository line endings — PR #193
- Status command shutdown — PR #194
- Console terminal detection — PR #196
- BuildKit and Windows environment forwarding — PR #197
- BuildKit preflight — PR #202
- Shutdown after readiness checks — PR #357
Improving SDK correctness
My SDK work focused on ensuring that transport configuration produced the intended authority and Session behavior.
One contribution updated governed transport cache keys across TypeScript, Python, and Go. The key needed to include effective labels and mandate lifetime. Without those values, transports with different attribution or lifetime requirements could share a cached mandate.
Another fix tightened the TypeScript SDK’s Gateway URL matching. When Gateway is configured under a base path, unrelated paths on the same origin should not receive Caracal authority headers.
I also aligned explicit empty-label handling with the Python and Go SDKs. Empty labels received the expected application-ID default, keeping cache identity and Session provisioning consistent.
In the TypeScript FastMCP adapter, I preserved authentication hints returned by the verifier so callers retained useful debugging guidance.
Related merged contributions:
- Governed transport cache identity — PR #324
- Gateway base-path restriction — PR #326
- Application-label defaults — PR #327
- FastMCP authentication hints — PR #318
Strengthening provider request validation
Provider requests can carry access tokens, refresh tokens, and client credentials. Their destinations therefore need careful validation.
I contributed checks requiring OAuth revocation endpoints to appear in the provider’s configured host allowlist. The destination is checked during configuration and again immediately before the request is sent. The runtime check also protects provider records created before configuration validation existed.
I later worked on shared address-validation logic for provider and notification requests. Separate implementations had drifted, including incomplete handling of the IPv6 link-local range and inconsistent treatment of IPv4-mapped IPv6 addresses and bracketed IPv6 hostnames.
The shared implementation made those checks consistent across the affected paths.
Related merged contributions:
Tracing, testing tools, and playbooks
I contributed a Gateway tracing fix that generated valid trace headers independently of human-readable request IDs. A valid request ID could contain characters that were unsuitable for trace identifiers, so reusing it could break tracing.
I also improved the Go test runner’s handling of environments where race detection was unavailable, while preserving strict CI requirements.
My playbook contributions focused on clearer mapping and policy-authoring guidance, requirement discovery, input validation, unsupported-case handling, and secret protection.
Related merged contributions:
- Gateway tracing — PR #301
- Go test runner — PR #317
- Mapping playbook — PR #250
- Policy playbook — PR #269
Testing the Gateway lifecycle
Gateway Validation and Improvements — One-Minute Demo
A short demonstration of my Gateway assignment, covering request validation, Session suspension, Delegation cleanup, and the recorded test results.
Watch on YouTube ↗My final assignment focused on Gateway performance and end-to-end correctness.
I traced the implementation from an incoming request through STS, policy evaluation, Session and Delegation checks, upstream execution, and audit recording.
I then built a live harness using the actual SDK, Coordinator, STS, Gateway, PostgreSQL, Redis, and Audit services. A controlled upstream recorded executions and checked whether Gateway injected the expected test credential.
The scenarios covered successful requests, invalid credentials, policy denials, expiry, replay, revocation, concurrent applications, upstream errors, and dependency outages.
The upstream execution counters were important. An HTTP error alone does not prove that an unauthorized action never reached the upstream service.
The initial runs exposed two failures. An open stream could remain active after Session suspension, and revoking a child Delegation could interfere with SDK cleanup and the parent’s continued use of shared authority.
I contributed fixes for those paths and updated Gateway readiness to check whether STS was ready to serve traffic.
Gateway implementation and validation — PR #493
Reproducing review findings
Review uncovered additional cases that the initial tests did not cover.
A slow fixed-length response could block while waiting for upstream data. Gateway’s cancellation logic needed to cover that response too, then check revocation again before forwarding bytes.
A delayed heartbeat revealed another problem. Its transaction could start before suspension but complete after resume, moving the Session timestamp backward. Gateway then interpreted a fresh request as belonging to the earlier suspended state.
I reproduced the sequence in the live stack. Before the fix, a fresh request returned HTTP 401. After the fix, the timestamp retained its resume value and the request returned HTTP 200.
I also verified deployment ordering. Gateway requires Session timing information from STS, so upgrades across that change need STS to finish rolling out first. I documented the sequence and tested a governed request with an upgraded STS while the previous Gateway was still running.
Missing timing information still causes the affected request to be rejected. The follow-up also prevents that response from opening the shared STS circuit breaker.
A separate user-backed Session resume issue reproduced on main and was kept outside this follow-up.
Recorded validation results
| Check | Result |
|---|---|
| Live Gateway scenarios | 29/29 passed |
| Live Coordinator checks | 11/11 passed |
| Coordinator unit tests | 227 passed |
| Gateway, STS, and Go Core race suites | Passed |
| Delayed heartbeat after resume | Fresh request returned HTTP 200 |
| STS-first upgrade sequence | Passed in Docker |
| Documentation build | Passed |
| GitHub checks last verified November 19 | Completed without failures |
The Gateway regression checks also failed against the previous behavior and passed with the fixes. That confirmed they exercised the problems being addressed.
Review discussion and implementation
Investigating Audit-related latency
An earlier PR revision showed higher tail latency while the Audit worker was running.
I investigated the query used to locate the audit chain head. That revision contained a materialized-CTE workaround, but main had since gained an index matching the original query.
I compared both queries against the same ledgers using the Audit database role. They returned the same chain head, while the original query used the matching index and took less execution time. I restored it.
| Paired measurement | Earlier query | Restored query |
|---|---|---|
| Run 1 p95 | 41.55 ms | 38.83 ms |
| Run 2 p95 | 40.89 ms | 38.94 ms |
In a separate comparison with Audit running at a target of 60 requests per second, the benchmark PR revision measured 52.88 ms p95, compared with 54.99 ms on main. Neither side recorded request errors.
Across six follow-up runs, all 17,147 successful requests were reconciled with their token-exchange and Gateway audit records. The audit-chain checks found zero sequence or link errors.
These measurements describe the recorded benchmark revision and conditions. They do not represent a new benchmark of every later review fix or a general capacity guarantee. The final Audit query matches main.
Recorded benchmark methodology
What I learned
This work taught me to follow a failure beyond the component where it first appears.
A Windows startup problem can originate in environment forwarding. An SDK cleanup error can involve revocation events. A fresh request can be denied because an earlier heartbeat changed a timestamp unexpectedly.
It also changed how I interpret passing tests. Each test provides evidence about the scenario it exercises. Review helped me identify missing cases, reproduce their behavior, and add regression coverage.
My earlier contributions are merged, while the Gateway work is available for maintainer review. The pull requests contain the implementation, discussion, and supporting evidence.