<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chathuranga Siriwardhana on Medium]]></title>
        <description><![CDATA[Stories by Chathuranga Siriwardhana on Medium]]></description>
        <link>https://medium.com/@chathurangas?source=rss-ab0c42994557------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*t-INiw5vVwSG3cLUrf4hxg.jpeg</url>
            <title>Stories by Chathuranga Siriwardhana on Medium</title>
            <link>https://medium.com/@chathurangas?source=rss-ab0c42994557------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 09:32:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chathurangas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Local code, real dependencies: local development with OpenChoreo]]></title>
            <link>https://medium.com/swlh/local-code-real-dependencies-local-development-with-openchoreo-3aba462f5ed3?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aba462f5ed3</guid>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[openchoreo]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[tunneling]]></category>
            <category><![CDATA[idevp]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 08:46:28 GMT</pubDate>
            <atom:updated>2026-09-22T08:46:28.303Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3zeLd2OcS7uN-5dzw8Ssog.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@glenovbrankovic?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Glenov Brankovic</a> on <a href="https://unsplash.com/photos/a-man-using-a-grinder-on-a-piece-of-concrete-t9eQm2y1tn8?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In microservices, a small change to one service can require a surprising amount of setup. The service may need a database, another API, credentials, and configuration before you can test it.</p><p>OpenChoreo’s local development feature connects code running on your computer to dependencies in an OpenChoreo environment. You can use your usual editor, runtime, and debugger while the environment supplies the services and resources your application needs.</p><p>The feature is available through occ remote. This article explains the developer experience and the design behind it.</p><h3>A faster developer loop</h3><p>AI-assisted development can help us write code faster, but faster development also needs faster debugging. We need to run a change, inspect its behavior, and try a fix without long waits between steps.</p><p>Committing and pushing each change, waiting for the CICD pipelines to build the images and deploy the changes — all of this adds time before we can check the result. Even a small fix can take longer to verify than to write.</p><p>Running every dependency locally creates a different burden. Databases, services, credentials, and configuration all need setup and maintenance. Manual port forwarding helps with connections, but still leaves developers to find addresses and prepare local settings.</p><p>OpenChoreo shortens this loop by connecting local code to dependencies in an existing environment. Developers can test and debug changes with their usual tools while the platform handles dependency connections and access checks.</p><h3>Local development in practice</h3><p>OpenChoreo uses the dependencies already declared in a workload to prepare a local development session. These may be <a href="https://openchoreo.dev/docs/next/developer-guide/dependencies/endpoints/">endpoints exposed by other components</a> or <a href="https://openchoreo.dev/docs/next/developer-guide/dependencies/resources/">resources</a>, such as a database, secrets, file bindings or environment variables.</p><p>You select the components to run locally and the environment that supplies their remaining dependencies. OpenChoreo resolves the remote connections and prepares the required environment variables and files. Dependencies between selected local components connect directly on your computer.</p><p>Consider the <a href="https://github.com/openchoreo/openchoreo/tree/main/samples/local-development">local development sample</a>. You are working on two components: web-app and db-api. The web application calls the database API and two remote greeter services. The database API needs Postgres and a settings file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IZz-Iy8kC3F_zmrF1KQomg.png" /><figcaption>Local application development scenario with dependencies deployed on an openchoreo environment</figcaption></figure><blockquote>Arrows point from each component to its dependencies.</blockquote><p>occ remote command executed with both workload.yaml files resolves web-app to the db-api connection locally. Also, creates tunnels to the remote services and Postgres resource, fetches the permitted credentials, and writes the settings to a local session file. Then starts a sub-shell with environment variables initialised with the actual values as denoted in the workload.yaml files.</p><p>You can then start your applications from the sub-shell started by occ remote. You can change code, restart a process, or attach a debugger while the remote dependencies remain available. You don&#39;t need to deploy local components to OpenChoreo first, so you can also test a new component before its first deployment.</p><p>When you exit the session, its tunnels close and it removes its temporary files. Shared remote agents remain available for other sessions until they become idle.</p><p>The <a href="https://openchoreo.dev/docs/next/developer-guide/local-development/">local development guide</a> covers the setup and commands for trying this workflow.</p><h3>Architecture</h3><p>The design separates dependency tunnelling traffic from application traffic. The control plane resolves dependencies and checks access. The data plane carries connections to those dependencies.</p><p>On the developer’s computer, occ manages local ports, tunnel connections, and the subshell. In the control plane, openchoreo-api finds the published dependency addresses and creates a signed capability token describing the destinations and values the developer may access.</p><p>The openchoreo-api also creates or reuses a remote agent in each required provider project and environment namespace. Sessions using the same namespace share its agent. A remote agant router provides a shared entrypoint into the data plane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRyxGZi_xIgLfwSxfPddlg.png" /><figcaption>Local development main flow component interaction</figcaption></figure><blockquote>- Red lines shows multiple tunnels.<br>- Blue line shows on-demand remote agent provisioning<br>- Green lines show the automated operations of the system to maintain remote sessions</blockquote><p>The remote-agent-router selects an agent using the server name in the TLS handshake, called SNI. It forwards encrypted bytes without decrypting them. TLS terminates at the agent, whose certificate occ verifies using the certificate returned by the control plane.</p><p>Within a tunnel, yamux lets several independent connections share one network connection. Each new stream carries a capability token and a target key. The agent asks the control plane to verify them, then opens the authorized connection.</p><p>Application data flows through the router and agent, without passing through the control plane. New streams still need the control plane for authorization. The agent can also reach an external resource backend, provided it is a declared, authorized dependency reachable from the data plane.</p><p>The <a href="https://openchoreo.dev/docs/next/platform-engineer-guide/local-development-setup/">platform setup guide</a> explains how to enable the router and configure the required network access.</p><h3>Capability tokens</h3><p>A capability token is a short-lived, signed record of what a developer is allowed to access. After checking user role permissions, the control plane issues a capability token listing the approved dependency addresses and any secret or config–map keys the session may read. The token contains references to those values, not their contents.</p><p>Each new connection or value request carries the token. The remote agent asks the control plane to verify its signature, expiry, and permission for that specific request before proceeding. occ renews the token automatically by resolving dependencies and checking permissions again.</p><p>Capability tokens use EdDSA encryption since it&#39;s fast and secure enough for short-lived tokens. The following is an example of a decoded body of a capability token carrying permission to access</p><pre>{<br>  &quot;iss&quot;: &quot;openchoreo-control-plane&quot;,<br>  &quot;sub&quot;: &quot;developer@example.com&quot;,<br>  &quot;aud&quot;: [&quot;openchoreo-api:remote-connect&quot;],<br>  &quot;iat&quot;: 1790000000,<br>  &quot;exp&quot;: 1790000600,<br>  &quot;sessionStart&quot;: 1790000000,<br>  &quot;namespace&quot;: &quot;default&quot;,<br>  &quot;component&quot;: {<br>    &quot;project&quot;: &quot;default&quot;,<br>    &quot;name&quot;: &quot;db-api&quot;<br>  },<br>  &quot;env&quot;: &quot;development&quot;,<br>  &quot;targets&quot;: [<br>    {<br>      &quot;key&quot;: &quot;res/local-dev-postgres/client&quot;,<br>      &quot;proto&quot;: &quot;tcp&quot;,<br>      &quot;host&quot;: &quot;postgres.dp-default-default-development.svc.cluster.local&quot;,<br>      &quot;port&quot;: 5432,<br>      &quot;agentNamespace&quot;: &quot;dp-default-default-development&quot;<br>    }<br>  ],<br>  &quot;secrets&quot;: [<br>    {<br>      &quot;key&quot;: &quot;sec/local-dev-postgres/password&quot;,<br>      &quot;agentNamespace&quot;: &quot;dp-default-default-development&quot;,<br>      &quot;sourceKind&quot;: &quot;Secret&quot;,<br>      &quot;sourceName&quot;: &quot;postgres-credentials&quot;,<br>      &quot;sourceKey&quot;: &quot;password&quot;<br>    },<br>    {<br>      &quot;key&quot;: &quot;sec/local-dev-config-bundle/settings&quot;,<br>      &quot;agentNamespace&quot;: &quot;dp-default-default-development&quot;,<br>      &quot;sourceKind&quot;: &quot;ConfigMap&quot;,<br>      &quot;sourceName&quot;: &quot;app-settings&quot;,<br>      &quot;sourceKey&quot;: &quot;settings.yaml&quot;<br>    }<br>  ]<br>}</pre><h3>Access and configuration handling</h3><p>OpenChoreo checks access to each dependency separately. Connecting to a component requires component:connect. Connecting to a resource requires resource:connect. Reading its secret-backed values also requires resource:read-secrets. If the permissions need to be restricted to a certain environment, it can be configured with the rolebinding like shown in the following example.</p><pre>apiVersion: openchoreo.dev/v1alpha1<br>kind: ClusterAuthzRoleBinding<br>metadata:<br>  name: developer-binding<br>spec:<br>  effect: allow<br>  entitlement:<br>    claim: groups<br>    value: developers<br>  roleMappings:<br>    - roleRef:<br>        kind: ClusterAuthzRole<br>        name: developer<br>      conditions:<br>        - actions:<br>            - component:connect<br>            - resource:connect<br>            - resource:read-secrets<br>          expression: resource.environment == &quot;default/development&quot;</pre><p>This distinction lets a platform grant access to a database without also granting access to its password. ConfigMap–backed values use the resource connection permission. The <a href="https://openchoreo.dev/docs/next/developer-guide/local-development/#permissions">permissions guide</a> describes the rules in more detail.</p><p>The capability token contains approved destinations and references to permitted Secret or ConfigMap keys. The agent accepts these approved targets; it does not accept an arbitrary destination supplied by the client. Checking a stream verifies the existing token and its grants. User permissions are checked during resolution and renewal.</p><p>For referenced configuration and secrets, the agent reads the values in the data plane and returns them through the tunnel. Their contents do not pass through the control plane on this fetch path.</p><p>File values are written to a temporary directory outside the source tree, with access limited to the file owner. When an environment variable names the corresponding container file path exactly, occ replaces it with the local path. Other path arrangements may need manual wiring, as explained in the <a href="https://openchoreo.dev/docs/next/developer-guide/local-development/#file-bindings">file bindings guide</a>.</p><h3>Resource support and session lifecycle</h3><p>Platform engineers can make a resource type connectable by declaring which outputs contain its host and port in the annotations like shown below. A type can expose several addresses, while a configuration-only Resource can supply values without an address to connect to.</p><pre>apiVersion: openchoreo.dev/v1alpha1<br>kind: ClusterResourceType<br>metadata:<br>  name: postgres<br>  annotations:<br>    openchoreo.dev/local-dev-addresses: client=outputs.host:outputs.port<br># ...<br>spec:<br>  outputs:<br>    - name: host<br>      value: &quot;${metadata.name}.${metadata.namespace}.svc.cluster.local&quot;<br>    - name: port<br>      value: &quot;5432&quot;<br># ...</pre><p>These address declarations are stored with the resource release. Local development uses the release selected for the environment, keeping its connection details aligned with the deployed Resource.</p><p>During a session, occ renews capability tokens before they expire by resolving dependencies again and checking current permissions. Local ports stay in place, and new streams use the updated token. If access is removed, subsequent connections are refused once the updated grant set is applied; an already issued token remains valid until expiry. Existing streams are not immediately closed by token expiry or a permission change.</p><p>The reaper handles a separate concern: unused cluster resources. Resolution, authorized activity, and agent heartbeats refresh the agent’s last-used time. After the configured idle period, the reaper removes the agent and its supporting resources. It can also remove stale value-read permissions while leaving an agent available for service connections.</p><h3>How the design evolved</h3><p>We knew early on that OpenChoreo needed a local development feature. The harder question was how it should work. Several rounds of discussion helped us narrow the scope and arrive at the current design.</p><p>Our first proposal involved running a lightweight OpenChoreo cluster on the developer’s computer and connecting it to a remote cluster. This would let developers test changes without going through version control and CI/CD each time. However, it also meant running and maintaining a local OpenChoreo installation just to debug an application. We decided that this added too much setup and maintenance.</p><p>We also considered supporting local testing of OpenChoreo custom resources defined by platform engineers. This pushed the design toward a local cluster again. These infrastructure changes were less frequent than application changes, and testing them properly would require an environment that closely matched the remote setup. We chose to focus the feature on application developers.</p><p>With the scope settled, we explored ways to connect local applications to remote dependencies. We considered VPN-style connectivity, Telepresence, and a more detailed design using Tailscale. Our priority was to keep the developer’s setup small. We ultimately chose to build tunnelling into OpenChoreo so developers would not need to set up a separate networking tool or third-party service.</p><p>One of the harder problems was deciding how a Resource type should declare the addresses available for tunnelling. Resources expose connection details in different ways. A database might provide a complete connection string, such as postgresql://user:password@host:port/database, or separate host, port, username, and password values. A single Resource might also expose different addresses for client and admin connections.</p><p>An early approach relied on fixed output names such as host, port, and url. That was too restrictive for Resource types with different output names or several addresses. We needed an explicit way to identify the host and port outputs for each connection.</p><p>A later proposal added a dedicated section to the Resource type definition:</p><pre>spec:<br>  resourceEndpoints:<br>    - name: database-client-ep<br>      host: outputs.host<br>      port: outputs.port<br>    - name: database-admin-ep<br>      host: outputs.host<br>      port: outputs.adminPort</pre><p>This proposal established the idea of named host and port pairs, with support for several addresses on one Resource. It became the basis for the current openchoreo.dev/local-dev-addresses annotation.</p><p>The command name evolved too. We considered occ dev connect, occ dep connect, and occ local before settling on occ remote. Some names did not clearly describe the feature; others made it harder to name the supporting system components consistently. The final name fits the workflow: run code locally and connect it to remote dependencies.</p><h3>A few boundaries to keep in mind</h3><p>Local development provides outbound TCP access to dependencies. It does not redirect incoming environment traffic to your computer or start your application processes for you.</p><p>Configuration and credentials are fetched at session startup. Token renewal does not refresh those values or reload edited Workload files; restart the session to pick up those changes. Multiple local components also share one shell environment, so use distinct variable names when their settings differ.</p><p>The platform must enable the feature and provide a router address your computer can reach. Dependencies must already be available in the chosen environment. The supplied <a href="https://openchoreo.dev/docs/next/getting-started/try-it-out/on-k3d-locally/">k3d setup</a> enables local development by default.</p><h3>Try it with your application</h3><p>Choose a component and the environment that supplies its dependencies, then follow the <a href="https://openchoreo.dev/docs/next/developer-guide/local-development/">local development guide</a>. The <a href="https://github.com/openchoreo/openchoreo/tree/main/samples/local-development">sample setup</a> shows how local components, remote services, database access, and configuration fit together in one session.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aba462f5ed3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/local-code-real-dependencies-local-development-with-openchoreo-3aba462f5ed3">Local code, real dependencies: local development with OpenChoreo</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moving Release Confidence Left: The Test Automation Journey Behind OpenChoreo Releases]]></title>
            <link>https://medium.com/@chathurangas/moving-release-confidence-left-the-test-automation-journey-behind-openchoreo-releases-f8347236d5c8?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8347236d5c8</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[openchoreo]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 06:05:43 GMT</pubDate>
            <atom:updated>2026-06-18T06:36:37.393Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EcRh_cTGTSsIEi1bIWNrwA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@dan__burton?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Dan Burton</a> on <a href="https://unsplash.com/photos/woman-lying-on-grass-front-of-sea-at-daytime-3_5OfvOhvl4?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Releasing an open-source developer platform is different from releasing a small library. OpenChoreo has a control plane, data plane, workflow/build plane, observability plane, CLI, APIs, a Backstage-powered portal, GitOps flows, authorization, gateway routing, and Helm-based installation paths. A release is only trustworthy if those pieces still work together in the way users actually consume the platform.</p><p>When we started tightening <a href="https://openchoreo.dev/">OpenChoreo</a> release automation, the pain was very practical: manual smoke testing. It worked, but it cost time and focus. Preparing a release could take two to three days because someone had to install the platform manually, inspect the cluster, exercise key flows, validate the documented steps, and build confidence in the release from scattered checks. That did not scale for an open-source project. It was slow for maintainers, hard to repeat, and too dependent on individual memory.</p><p>The work was not simply “add more tests.” The goal was to move release confidence left: catch as much as possible in unit and integration tests, reserve end-to-end tests for behavior that genuinely requires a real platform installation, and make release automation strict about the exact artifact we ship.</p><h3>Why Automated Tests Matter In Open Source</h3><p>For open-source projects, automated tests are part of the public trust model. They show contributors how quality is checked, give maintainers repeatable release evidence, and make project health visible beyond the core team.</p><p>The <a href="https://www.bestpractices.dev/en/criteria#test">OpenSSF Best Practices automated test-suite criteria</a> require a FLOSS project to use at least one publicly released automated test suite and clearly document how to run it. Kubernetes has unit, integration, and end-to-end testing expectations, and its <a href="https://github.com/kubernetes/community/blob/main/contributors/devel/sig-testing/testing.md">SIG Testing contributor guidance</a> explains that PRs should pass unit and integration tests before submission.</p><p>Mature projects usually go further than a single test command. Kubernetes has unit, integration, and e2e layers. CPython separates normal tests from resource-heavy tests and supports parallel and stricter execution modes. The pattern is clear: serious open-source projects make quality repeatable, inspectable, and layered.</p><h3>Where We Started</h3><p>We started the e2e infrastructure as a platform health test: bring up an OpenChoreo cluster and verify that the platform was alive.</p><p>That first version was useful, but narrow. It proved that the platform could start, but not that the platform behaved correctly across developer, platform-engineer, and release-critical journeys. As the release process matured, the framework had to grow from “is it running?” to “are the important user paths still working?”</p><p>The framework evolved into tiers. The lower tiers covered core platform behaviour such as workload deployment, connection resolution, network policy enforcement, API behaviour, CLI behaviour, MCP behaviour, gateway routing, authorization, and secrets. The higher-cost tier covered behaviour that needed more of the real platform: build-from-source, GitOps, observability signals, and alerts. UI and identity flows became separate Playwright-backed paths because they validate a different kind of user experience.</p><h3>The Test Placement Rule</h3><p>The most important design decision was deciding where each test belongs.</p><p>Unit tests are for basic functions and decision logic. If a function has multiple input combinations, validation branches, defaults, edge cases, or error paths, it belongs in unit tests. If a dependency is needed, mock it where reasonable. The goal is to make the test fast, broad across meaningful inputs and edge cases, and precise when it fails.</p><p>Integration tests are for interactions between components. In OpenChoreo, that often meant behaviour that needed Kubernetes API semantics without a full platform install: controller reconciliation, status-subresource persistence, admission or webhook behaviour, and cases where multiple internal components interact through Kubernetes objects. API service tests covered CRUD and authorization behaviour at the service layer without promoting those checks to e2e.</p><p>End-to-end tests are for user-visible behaviour that only exists when the system is installed as a real platform. These are the tests that justify k3d, Helm charts, gateways, cluster agents, external identity providers, observability backends, GitOps controllers, workflow/build planes, and browser automation.</p><p>That is test-pyramid thinking in practice. Fowler’s <a href="https://martinfowler.com/articles/practical-test-pyramid.html">Practical Test Pyramid</a> explains the economic shape: many small fast tests, fewer integration tests, and a small number of high-level tests. Google’s testing guidance makes the same point from another angle: e2e tests are slower, more expensive, and harder to debug, so they should prove paths that lower layers cannot.</p><p>For OpenChoreo, the practical rule became: push a test as far down the pyramid as possible without losing the behaviour we actually need to prove.</p><h3>Placing E2E Tests Where They Add Unique Signal</h3><p>Not every important behaviour deserves an e2e test. Some behaviour deserves strong unit and integration coverage instead.</p><p>A useful example is representative-path testing. If several tools share the same authentication path, handler wiring, authorization wrapper, response encoding, and backend service path, running every one of them through the full e2e stack may not add meaningful confidence. One representative e2e test can prove the live signal path, while unit and integration tests cover validation, query construction, response handling, and edge cases for the rest.</p><p>That distinction kept the e2e suite focused. E2E tests are valuable when they prove something lower layers cannot: real log ingestion, real metric scraping, real gateway routing, real external identity, real Helm installation, real browser login, or real cross-plane behaviour. They are wasteful when they repeatedly prove the same wiring with slightly different inputs.</p><h3>Coverage As A Feedback Loop</h3><p>We started around 22% coverage. The project is now around 75%, but the more important change was the feedback loop we put around coverage. The project-level target follows the existing baseline with tolerance, while PR-changed-line coverage has a 70% target that is reported back to contributors rather than immediately failing the build. I think of that as a useful trap: every PR sees whether the changed code was tested, so coverage becomes harder to ignore without turning early coverage growth into a noisy blocker.</p><p>This mattered because the goal was not to chase a number in isolation. The goal was to make every change carry some visible testing responsibility. Over time, that changes contributor behaviour more effectively than a sudden, strict global threshold.</p><h3>E2E As A Release Gate</h3><p>Running every e2e path on every PR would have been slow and expensive in feedback time. Even when hosted minutes are available for public repositories, long workflows still delay reviews, consume runner time, and spread diagnostics across larger logs and artefacts.</p><p>So the e2e suite became a release gate rather than a PR tax.</p><p>The gate is sharded into independent legs. Tier 1 and Tier 2 run the core platform and API-facing behaviour. Tier 3 runs heavier multi-plane behaviour. UI tests run through Playwright. External identity uses Dex. Quick Start smoke testing exercises the published quick-start container the way a user would.</p><p>The optimization is not only parallelism. It is a separation of concerns. Each leg has a clear reason to exist, its own setup, and its own diagnostics. A failure points to a smaller area of the platform than a single monolithic e2e job would.</p><h3>Gating The Exact Commit We Release</h3><p>The release gate had to be strict about the artefact being shipped: build-and-test first, e2e against the exact target commit, then tagging.</p><p>That order matters. A release tag should not point to a commit that only passed tests indirectly or approximately. The release workflow waits for the build-and-test workflow at the target commit, runs the e2e gate for that same commit, and only then proceeds to create the release tag.</p><p>There is also a practical optimization: when a release branch creation has already passed the e2e gate for a commit, a later tag operation at the same commit can reuse that green result instead of re-running the entire gate. That keeps the release process strict without wasting time when the tested artefact has not changed.</p><p>Post-release smoke testing adds one more protection layer. It validates the released images and Helm chart after publication, which is useful for cases where someone pushes a tag directly or where the release artefact path itself needs verification.</p><h3>What Still Needs Manual Testing</h3><p>The goal was never to remove manual testing completely.</p><p>Some checks still deserve human review, especially around documentation and definitions. Before a release, someone should still confirm that documented steps make sense as written, terminology is consistent, examples describe the current behaviour, and definitions match the product’s actual concepts.</p><p>Automation can prove that a command exists successfully or that a sample app deploys. It is weaker at judging whether a new user would understand the instructions, whether a concept is explained clearly, or whether release notes accurately communicate upgrade impact.</p><p>The difference is that manual testing became focused. Instead of spending two or three days manually building confidence that the platform basically works, we now spend roughly an hour on the checks that genuinely benefit from human judgment.</p><h3>The Outcome</h3><p>The release process moved from manual smoke testing to layered, repeatable release confidence.</p><p>PRs now get coverage-backed unit and integration feedback without requiring contributors to run the full e2e platform locally for every change. E2E tests validate the platform paths that only exist in a real installation. Release automation gates the exact commit before tagging. Post-release smoke testing validates the published artefacts.</p><p>The biggest change is clarity. Unit tests own local correctness. Integration tests own component interaction. E2E tests own installed-platform behaviour. Manual testing owns documentation quality, release communication, and human judgment.</p><p>That reduced release preparation from two or three days of manual effort to roughly an hour of unavoidable manual validation. More importantly, release confidence became repeatable, public, and reviewable.</p><p>For an open-source platform, that is the real milestone.</p><h3>References</h3><ul><li><a href="https://www.bestpractices.dev/en/criteria">OpenSSF Best Practices criteria</a></li><li><a href="https://github.com/kubernetes/community/blob/main/contributors/devel/sig-testing/testing.md">Kubernetes SIG Testing guidance</a></li><li><a href="https://martinfowler.com/articles/practical-test-pyramid.html">The Practical Test Pyramid</a></li><li><a href="https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html">Google Testing Blog: Just Say No to More End-to-End Tests</a></li><li><a href="https://github.com/openchoreo/openchoreo">OpenChoreo repository</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8347236d5c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Openchoreo into AI agents with MCP]]></title>
            <link>https://medium.com/swlh/integrate-openchoreo-into-your-agent-with-mcp-0a98b1654a1a?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a98b1654a1a</guid>
            <category><![CDATA[openchoreo]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[idp]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[cncf]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 17:16:57 GMT</pubDate>
            <atom:updated>2026-04-21T17:26:40.900Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*erMf3i_LC5zC-skWUmDnZA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@galka_nz?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Galina Nelyubova</a> on <a href="https://unsplash.com/photos/a-name-tag-with-ai-written-on-it-ofEzqDI6yss?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>What if your AI coding assistant could do more than write code? What if it could create projects, deploy services, query logs, and investigate incidents on your internal developer platform — all within the same conversation?</p><p><a href="https://openchoreo.dev/">OpenChoreo</a> is an open-source, Kubernetes-native internal developer platform and a <a href="https://www.cncf.io/projects/openchoreo/">CNCF Sandbox project</a>. It brings together platform abstractions, a Backstage-powered developer portal, application CI/CD, GitOps, and observability into a single, cohesive platform. I got the opportunity to design and implement its MCP servers — the part that makes all of this accessible to AI assistants and agents.</p><p>Here’s how it’s designed and how it works.</p><h3>A Quick Primer: What is MCP?</h3><p>The <a href="https://modelcontextprotocol.io/">Model Context Protocol (MCP)</a> is an open-source standard for connecting AI applications to external systems. It’s a universal way for assistants like Claude, Cursor, or any MCP-compatible AI agent to discover and use tools, prompts and resources exposed by an MCP server.</p><p>MCP tools give the AI agents a clean contract: “Here are the tools I have. Here’s what each one does. Call them with these parameters.” The AI agents read the tool descriptions, figure out which ones to use, and call them to get things done.</p><h3>Architecture of Openchoreo MCP servers</h3><p>OpenChoreo is built on a <a href="https://openchoreo.dev/docs/overview/architecture/">multi-plane architecture</a> that separates concerns across a control plane, data planes, a workflow plane, and an observability plane. Each plane has its own API server. The control plane and the observability plane each expose their own MCP server, giving AI assistants structured access to both platform operations and observability data. This means more MCP servers can naturally emerge as the platform evolves — each plane owns its own AI interface, just as it owns its own API.</p><p>Both controlplane and Observabilityplane MCP servers use HTTP transport. The MCP handlers call the respective action service layers internally. More on this in the authentication and authorization section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*peU6zNBcrIklOxr4zmlVSg.png" /></figure><h4>Authentication</h4><p>Exposing platform operations to AI assistants means authentication and authorization can’t be an afterthought. The MCP servers implement the <a href="https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization">MCP Authorization specification</a>, which builds on a stack of OAuth 2.0 and IETF standards:</p><ul><li><a href="https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13"><strong>OAuth 2.1</strong></a> — The core authorization framework</li><li><a href="https://datatracker.ietf.org/doc/html/rfc9728"><strong>RFC 9728</strong></a> — OAuth 2.0 Protected Resource Metadata, which lets MCP clients discover the authorization server automatically</li><li><a href="https://datatracker.ietf.org/doc/html/rfc8414"><strong>RFC 8414</strong></a> — OAuth 2.0 Authorization Server Metadata, for discovering endpoints and capabilities</li><li><a href="https://datatracker.ietf.org/doc/html/rfc6750"><strong>RFC 6750</strong></a> — Bearer Token Usage, defining how tokens are carried in requests and how scope challenges work</li></ul><p>The MCP spec requires servers to implement RFC 9728, and this is where the flow starts. When an unauthenticated request hits the MCP endpoint, an interceptor middleware produces a 401 with a WWW-Authenticate header pointing to the protected resource metadata:</p><pre>HTTP/1.1 401 Unauthorized<br>www-authenticate: Bearer resource_metadata=&quot;http://api.openchoreo.localhost:8080/.well-known/oauth-protected-resource&quot;</pre><p>The client then fetches the metadata document, which contains the authorization_servers field which points to the OAuth authorization server configured with openchoreo:</p><pre>{<br>  &quot;resource_name&quot;: &quot;OpenChoreo MCP Server&quot;,<br>  &quot;resource&quot;: &quot;http://api.openchoreo.localhost:8080/mcp&quot;,<br>  &quot;authorization_servers&quot;: [&quot;http://sts.openchoreo.localhost:8080&quot;],<br>  &quot;bearer_methods_supported&quot;: [&quot;header&quot;],<br>  &quot;scopes_supported&quot;: []<br>}</pre><p>From there, the client discovers the authorization server’s endpoints via RFC 8414 metadata (token endpoint, authorization endpoint, supported grants, etc.) and initiates the appropriate OAuth flow.</p><p>This means a compliant MCP client, such as Claude Code can connect to OpenChoreo’s MCP server with zero manual token configuration. The client handles the full discovery and authorization dance automatically.</p><p>OpenChoreo ships with two pre-configured OAuth applications out of the box:</p><ul><li><strong>Browser-based OAuth: </strong>A public client using PKCE and the authorization code grant, as required by OAuth 2.1 for public clients. When you connect your AI assistant, it opens a browser window for login. Ideal for interactive use with tools like Claude Code or Cursor.</li><li><strong>Client credentials:</strong> A confidential client using the client credentials grant. Designed for programmatic agents that need headless access without a browser.</li></ul><h4>Authorization</h4><p>Authentication gets you in. Authorization decides what you can do. OpenChoreo has a layered architecture to share the authorization mechanism across multiple interfaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JLF36w_2OqHqj79_iUYV0Q.png" /></figure><p><strong>OpenChoreo services, auth and interface layers</strong></p><p>Authorization is expressed as {resource}:{verb} actions — component:view, namespace:create, releasebinding:update, and so on. Each client (identity provider representation of applications such as AI agents, programmatic access apps) is mapped to one or more roles, and each role grants a set of actions scoped to a resource hierarchy (namespace → project → component). If a token lacks the required action for an operation, the server responds with a 403.</p><p>The same action catalog is consulted in two places:</p><ol><li><strong>Service layer</strong> — the security boundary. Every service method checks the caller’s capabilities before performing the operation. This is where OpenChoreo actually enforces access.</li><li><strong>MCP tool-filter middleware</strong> — a UX layer that hides and rejects tools the caller can’t use, so the agent’s working context isn’t polluted with dead tools it would just get 403s from. The mechanism is discussed in detail in the “Design decisions” section.</li></ol><h3>Design decisions</h3><p>When designing the MCP servers, a handful of decisions ended up shaping almost everything else. Each of these is a deliberate trade-off and worth walking through in its own right.</p><h4>1. Treat the agent’s working context as a scarce resource</h4><p>Most AI agents load every registered tool’s name, description, and parameter schema into their working context at the start of the session, regardless of whether those tools are ever called. Every tool exposed to an agent permanently costs tokens for every request the agent makes, even the ones where the tool is completely irrelevant.</p><p>The control plane alone could easily expose 250+ tools if the underlying API surface were mirrored one-to-one. Doing that would waste thousands of tokens per turn, hurt tool-selection accuracy as the agent sifts through near-duplicates, and in the worst case push the agent over its context limit during a long conversation.</p><p>Two decisions push back on this.</p><p>First, tools are not auto-generated from the API surface. Only 90 tools are hand-selected for the control plane. These are the operations that actually map to how a human or an agent reasons about the platform (“create a component”, “promote a release”), rather than raw CRUD on every internal resource.</p><p>Second, a response transformation layer sits between the service and the MCP tool handler. The internal service layer returns the full Kubernetes object; which is rich with audit fields, internal UIDs, resource version, managed fields, and reconciliation metadata that the agent can&#39;t use. The transformation layer strips these and reshapes the response into a flat, agent-friendly map.</p><p>The transformation is explicit per resource, with a dedicated summary or detail function for each kind (Component, Project, Workload, ReleaseBinding, and so on). Each function picks the handful of fields an agent actually needs — name, namespace, type, status, and a few relationship pointers — and drops everything else.</p><p>The savings are not theoretical. Measuring against the live control plane with a single project and a single component — the smallest interesting shape — and tokenizing both responses with the cl100k_base tokenizer:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2FRn8Io%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2FRn8Io%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2FRn8Io%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="209" frameborder="0" scrolling="no"><a href="https://medium.com/media/17192f94a2e70ec55b3afda49601d5cd/href">https://medium.com/media/17192f94a2e70ec55b3afda49601d5cd/href</a></iframe><p>These are single-item results. The ratio grows with the list length, because the repeated per-item overhead (managedFields, resourceVersion, uid, creationTimestamp, apiVersion, the last-applied-configuration annotation that re-embeds the whole spec) accumulates linearly. A realistic list_components call over a project with twenty components would shift the raw payload well into the five-figure range, while the transformed version stays proportionally lean.</p><p>The same service layer still serves the REST API and the CLI without any compromise. The transformation layer is only bound to the MCP server.</p><h4>2. Group tools into role-based toolsets</h4><p>Even 90 tools are a lot to load blindly. Not every agent needs platform-engineering power tools, and not every user should see them. So the control plane’s tools are partitioned into six toolsets that can be enabled independently per connection:</p><ul><li><strong>Namespace &amp; Project</strong> — the top-level constructs.</li><li><strong>Component</strong> — deployable units, workload configuration, component types and traits.</li><li><strong>Deployment</strong> — release bindings, pipelines, environments, and promotions.</li><li><strong>Build</strong> — CI/CD workflow runs and definitions.</li><li><strong>Platform Engineering</strong> — the power-user toolset covering environments, component types, traits, deployment pipelines, and diagnostic access to events and pod logs.</li></ul><p>A developer connecting Claude Code to ship a service only needs the first four toolsets. A platform engineer investigating why a deployment pipeline is misbehaving may want all five.</p><h4>3. Encode tool relationships inside parameter descriptions</h4><p>An agent rarely has everything it needs to call a tool from the user’s first message. To create a component, it needs a project name. To get logs, it needs a component name and an environment. These intermediate values have to come from somewhere, and that somewhere is usually other tool calls.</p><p>Leaving the agent to figure out the chain from tool names alone fails often in practice, especially on smaller models. So each parameter description explicitly names the tool that produces valid values — get_component&#39;s component_name parameter is documented as <em>&quot;Use list_components to discover valid names&quot;</em>, get_release_binding&#39;s binding_name as <em>&quot;Use list_release_bindings to discover valid names&quot;</em>, and so on through the tool graph.</p><p>This small nudge turns the tool graph from something the agent has to infer into something it can simply read. In practice, it dramatically reduces the number of failed tool calls and the “I don’t know what to pass here” loops on the first turn of a multi-step task.</p><h4>4. Expose type schemas as tools, not inline</h4><p>Some parameters are structured objects with dozens of fields and nested types, such as workload specs, component type definitions, and cluster trait configurations. Inlining the full schema into every tool description that accepts them balloons the initial context payload and forces the agent to pay that token cost on every call, even the ones that use defaults.</p><p>Instead, structured type definitions are exposed as their own tools: get_workload_schema, get_component_type_schema, get_cluster_trait_schema, and so on. The agent fetches a schema only when it&#39;s about to construct a value that needs it, reads the definition on demand, and then calls the tool that consumes it. The schema lookup becomes a deliberate step in the tool chain rather than an always-loaded tax on every session.</p><h4>5. Filter tools by what the user can actually do</h4><p>A token gets the agent in. What the agent can actually do is decided by roles and role bindings on the server side, not by which toolset the client happened to load.</p><p>Every tool declares its required authz action at registration time — list_components maps to component:view, delete_component to component:delete, update_release_binding_state to releasebinding:update, and so on. An MCP receiving middleware reads this map and applies it to both MCP methods that touch tools:</p><ul><li><strong>tools/list</strong> — After the server assembles the list of registered tools, the middleware calls the Policy Decision Point (PDP) for the caller&#39;s profile and removes any tool whose required action has no allowed resource. The agent only sees tools it can actually call.</li><li><strong>tools/call</strong> — Before dispatching to the handler, the middleware re-checks the caller&#39;s capabilities against the tool&#39;s action, scoped to the hierarchy derived from the arguments (namespace_name, project_name, component_name). A call to delete_component on a namespace the caller can only view is rejected with a clear &quot;not authorized&quot; error without ever hitting the service layer.</li></ul><p>The middleware is a UX layer, not the security boundary. The service layer still enforces authz independently for every call, so a buggy or bypassed filter can never result in an unauthorized mutation. This keeps the filter free to use safe defaults: tools with no permission entry pass through (so a new tool added after deploy doesn’t silently disappear), and a PDP error on tools/list returns an empty list rather than the full set.</p><p>The net effect: the same MCP server exposes a different tool surface to different users based on their roles. A developer connecting with a developer role sees the subset they can use; a platform engineer sees everything. Neither has to load, weigh, and reject tools that they would never be allowed to call.</p><h3>Why MCP, Not Just a REST API or CLI?</h3><p>One could ask: “Popular AI agents such as Claude Code, Cursor, opencode, etc., are capable of discovering the installed CLI tools and finding their way with the ‘help’ commands. Why add MCP servers?”</p><p>Before answering the question, let’s have a look at the purpose of each interface.</p><ul><li><strong>REST APIs</strong> are great for programmatic integration — dashboards, CI pipelines, and custom automation scripts that know exactly what endpoints to call.</li><li><strong>The CLI</strong> is optimised for human operators typing commands in a terminal. It handles authentication, output formatting, and interactive workflows.</li><li><strong>MCP</strong> is designed for AI consumption. An AI assistant needs to <em>discover</em> what’s available, <em>understand</em> what each operation does from its description, and <em>decide</em> which tools to chain together based on the user’s natural language request.</li></ul><p>The answer consists of 2 parts.</p><p>1. Not all agents have the capability to execute CLI commands and the REST API calls.</p><p>This means that the only way for these kinds of agents to communicate with external systems like OpenChoreo is to integrate using tools. MCP is the ideal tooling approach.</p><p>2. Using CLI tools may be inefficient for the AI agents</p><p>Depending on how the CLI tool is structured, the AI agent may need to try a couple of command paths and a couple of ‘help’ commands to determine the exact CLI command to execute. In contrast, MCP servers expose tools directly along with their names, parameters, and descriptions, allowing the agent to understand and invoke the correct capability without exploratory probing.</p><h3>Openchoreo MCP server capabilities</h3><h4>1. The Control Plane MCP Server</h4><p>The controlplane MCP server includes 90 tools, and they are organised into role-based toolsets that can be enabled or disabled independently.</p><ul><li><strong>Namespace &amp; Project</strong> — Create namespaces and projects, the top-level constructs in OpenChoreo.</li><li><strong>Component</strong> — Create and configure deployable units (services, jobs, APIs), manage workloads, and inspect component types and traits defined by your platform team.</li><li><strong>Deployment</strong> — Manage release bindings, deployment pipelines, and environments. Promote releases across stages.</li><li><strong>Build</strong> — Trigger CI/CD workflow runs, check build status, and inspect workflow definitions.</li><li><strong>Platform Engineering</strong> — The power-user toolset. Create environments, define component types, manage traits, configure deployment pipelines, and read resource events and pod logs for diagnostics.</li></ul><p>When this MCP server is connected, users can create, build, deploy, promote and manage services easily in a conversational manner with their AI agents. For example:</p><pre>Deploy my react app on Openchoreo using the source: https://github.com/openchoreo/sample-workloads/tree/main/webapp-react-nginx</pre><p>The AI assistant will fetch available namespaces, projects, component types and prompt you to choose where to create a service type component and how to name the component/project. Then it will trigger a build, and deploy once the image is built. Finally, you’ll be given a URL to access your deployed React app.</p><h4>2. The Observer MCP Server</h4><p>Observer MCP server includes 9 tools — query_component_logs, query_workflow_logs, query_resource_metrics, query_http_metrics, query_traces, query_trace_spans, get_span_details, query_alerts, query_incidents — and it covers the full observability functionality.</p><ul><li><strong>Logs</strong> — Runtime application logs and CI/CD workflow logs, with filters for project, component, environment, log level, and free text search.</li><li><strong>Metrics</strong> — CPU and memory resource usage time-series, plus HTTP request counts, latencies, and percentiles (p50, p90, p99).</li><li><strong>Traces</strong> — Distributed tracing. Query traces for a component, drill into individual spans, and inspect full span attributes.</li><li><strong>Alerts &amp; Incidents</strong> — What fired, when, and for which component. Track incident lifecycle and response status.</li></ul><p>When this MCP server is connected, you ask your AI assistant,</p><pre>My checkout service has been slow since yesterday. What’s going on?</pre><p>The AI assistant will autonomously query HTTP metrics to confirm elevated p99 latency, pull traces to identify the slow spans, check resource metrics to see if the service is CPU-throttled, search logs for error patterns during that window, and check if any alerts fired. All in one conversation, without any queries or consoles.</p><h3>Try It Out</h3><p>Getting started is deliberately low-friction. OpenChoreo ships with pre-configured OAuth applications, roles, and role bindings so you can connect your AI assistant and start exploring immediately.</p><p>For Claude Code, it’s a single command:</p><pre>claude mcp add --transport http \<br>  --client-id user_mcp_client \<br>  --callback-port 8075 \<br>  openchoreo-cp \<br>  http://api.openchoreo.localhost:8080/mcp</pre><p>Similar minimal configurations are available for many popular AI agents and advanced configuration guide is available at <a href="https://openchoreo.dev/docs/ai/mcp-servers/">OpenChoreo docs</a>.</p><p>Once connected, try the <a href="https://github.com/openchoreo/openchoreo/tree/main/samples/mcp/getting-started">Getting Started guide</a> to verify your connection, or jump into one of the more involved scenarios:</p><ul><li><a href="https://github.com/openchoreo/openchoreo/tree/main/samples/mcp/service-deployment">Deploy a service from source to production</a> using natural conversation</li><li><a href="https://github.com/openchoreo/openchoreo/tree/main/samples/mcp/log-analysis">Debug a cascading failure</a> using logs, traces, and workload inspection</li><li><a href="https://github.com/openchoreo/openchoreo/tree/main/samples/mcp/build-failures">Diagnose a build failure</a> using workflow logs</li><li><a href="https://github.com/openchoreo/openchoreo/tree/main/samples/mcp/resource-optimization">Optimize resource allocation</a> by comparing actual usage against configured limits</li></ul><p>OpenChoreo is fully open source and actively evolving. If the idea of managing your cloud platform through natural conversation resonates with you, here’s how you can get started:</p><ul><li>Try it out — Follow the <a href="https://openchoreo.dev/docs/getting-started/quick-start-guide/">Quick start guide</a> and experience AI-driven platform engineering firsthand.</li><li>Star the repo — Show your support and help others discover the project on <a href="https://github.com/openchoreo/openchoreo">GitHub</a>.</li><li>Join the community — Connect with us on <a href="https://slack.cncf.io/">Slack</a> to share feedback, ask questions, and see what others are building.</li><li>Contribute — Whether it’s new MCP tools, bug fixes, documentation, or ideas — contributions of all kinds are welcome. Check out the <a href="https://github.com/openchoreo/openchoreo/blob/main/docs/contributors/README.md">contributing guide</a> to get started.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a98b1654a1a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/integrate-openchoreo-into-your-agent-with-mcp-0a98b1654a1a">Integrating Openchoreo into AI agents with MCP</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Talk to Any MCP Server in 3 Curl Commands]]></title>
            <link>https://medium.com/@chathurangas/talk-to-any-mcp-server-in-3-curl-commands-c2fc52d3506d?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2fc52d3506d</guid>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[curl]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 06:11:49 GMT</pubDate>
            <atom:updated>2026-02-12T06:12:41.925Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4QMlKpzKihEz-AXpA62SQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@sarahdorweiler">Sarah Dorweiler</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><p>The Model Context Protocol (MCP) is becoming the standard way AI tools talk to external services. But you don’t need a fancy client to test one. Here’s how to talk to any HTTP-based MCP server using nothing but curl.</p><p><strong>Prerequisites</strong></p><ul><li>An MCP server running over HTTP (e.g., <a href="https://your-mcp-server.example.com/mcp">https://your-mcp-server.example.com/mcp</a>)</li><li>curl and jq installed</li><li>An access token if the server requires auth</li></ul><pre>export MCP_URL=&quot;https://your-mcp-server.example.com/mcp&quot;<br>export ACCESS_TOKEN=&quot;your-token-here&quot;</pre><h3>Step 1: Initialize the Session</h3><p>Every MCP conversation starts with a handshake. Send an initialize request and grab the session ID from the response.</p><pre>curl -s -v -X POST &quot;$MCP_URL&quot; \<br>    -H &quot;Content-Type: application/json&quot; \<br>    -H &quot;Authorization: Bearer $ACCESS_TOKEN&quot; \<br>    -d &#39;{<br>      &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>      &quot;id&quot;: 1,<br>      &quot;method&quot;: &quot;initialize&quot;,<br>      &quot;params&quot;: {<br>        &quot;protocolVersion&quot;: &quot;2024-11-05&quot;,<br>        &quot;capabilities&quot;: {},<br>        &quot;clientInfo&quot;: { &quot;name&quot;: &quot;curl-client&quot;, &quot;version&quot;: &quot;1.0.0&quot; }<br>      }<br>    }&#39; 2&gt;&amp;1 | grep -i &#39;mcp-session-id&#39;</pre><p>Save the session ID:</p><pre>export MCP_SESSION_ID=”&lt;value-from-response-header&gt;”</pre><blockquote>Note: MCP over HTTP uses Server-Sent Events (SSE). Response lines are prefixed with data: . Pipe through grep ‘^data: ‘ | sed ‘s/^data: //’ | jq . to extract clean JSON.</blockquote><h3>Step 2: Discover Available Tools</h3><p>Ask the server what tools it offers:</p><pre>curl -s -X POST &quot;$MCP_URL&quot; \<br>    -H &quot;Content-Type: application/json&quot; \<br>    -H &quot;Authorization: Bearer $ACCESS_TOKEN&quot; \<br>    -H &quot;Mcp-Session-Id: $MCP_SESSION_ID&quot; \<br>    -d &#39;{<br>      &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>      &quot;id&quot;: 2,<br>      &quot;method&quot;: &quot;tools/list&quot;,<br>      &quot;params&quot;: {}<br>    }&#39; | grep &#39;^data: &#39; | sed &#39;s/^data: //&#39; | jq .</pre><p>You’ll get back a list of tools with their names, descriptions, and input schemas — everything you need to call them.</p><h3>Step 3: Call a Tool</h3><p>Pick a tool from the list and call it:</p><pre>curl -s -X POST &quot;$MCP_URL&quot; \<br>    -H &quot;Content-Type: application/json&quot; \<br>    -H &quot;Authorization: Bearer $ACCESS_TOKEN&quot; \<br>    -H &quot;Mcp-Session-Id: $MCP_SESSION_ID&quot; \<br>    -d &#39;{<br>      &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>      &quot;id&quot;: 3,<br>      &quot;method&quot;: &quot;tools/call&quot;,<br>      &quot;params&quot;: {<br>        &quot;name&quot;: &quot;your_tool_name&quot;,<br>        &quot;arguments&quot;: {<br>          &quot;param1&quot;: &quot;value1&quot;<br>        }<br>      }<br>    }&#39; | grep &#39;^data: &#39; | sed &#39;s/^data: //&#39; | jq .</pre><p>Replace your_tool_name and arguments with whatever tools/list returned.</p><p><strong>That’s it. Three requests. No dependencies!</strong></p><h4>Quick Reference</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2FSwlLH%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2FSwlLH%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2FSwlLH%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="240" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf19a4e3ae2689ed45964f39e121bb63/href">https://medium.com/media/bf19a4e3ae2689ed45964f39e121bb63/href</a></iframe><h4>Common Gotchas</h4><ul><li>Always initialize first. Every other call needs the Mcp-Session-Id header.</li><li>SSE format. Responses come as data: {…} lines, not raw JSON. Filter accordingly.</li><li>Increment the id. Each JSON-RPC request should have a unique id.</li><li>Check protocolVersion. Use the version your server supports (2024–11–05 is current).</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2fc52d3506d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring RBAC with Asgardeo and an external IDP]]></title>
            <link>https://medium.com/@chathurangas/configuring-rbac-with-asgardeo-and-an-external-idp-3afbd6544217?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/3afbd6544217</guid>
            <category><![CDATA[choreo]]></category>
            <category><![CDATA[micro-front-end]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[asgardeo]]></category>
            <category><![CDATA[role-based-access-control]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 22:30:04 GMT</pubDate>
            <atom:updated>2025-03-13T20:59:11.543Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5jxUOHfNXHXwuLgFW9TJZQ.png" /></figure><p>Let’s say your organization uses Asgardeo as the IDP, but the users and the user groups are managed in another external IDP. E.g. Okta, another Agardeo org. If you want to configure Role Based Access Control (RBAC) for your access tokens, you’re in the right place.</p><p>In this article, I will be sharing how to configure your Asgardeo organization to refer to the external IDP’s users and the groups and configure the roles and scopes that need to authorize APIs based on the users and their groups.</p><p>For this article, I will use another Asgardeo organization as the external IDP to my primary Asgardeo organization. Let’s call the main Asgardeo organization as “Primary Asgardeo organization” and the external IDP as “External Asgardeo organization”.</p><h3>External IDP configs</h3><p>I have 3 users and 2 groups in my external Asgardeo organization. Ref: <a href="https://wso2.com/asgardeo/docs/guides/users/manage-users/#onboard-users">Onboarding users</a>, <a href="https://wso2.com/asgardeo/docs/guides/users/manage-groups/#manage-groups">Managing groups</a></p><ol><li>johndoe@example.com (HR_Group, Finance_Group)</li><li>hr-user@example.com (HR_Group)</li><li>finance-user@example.com (Finance_Group)</li></ol><p>I want to keep the users and groups on this external Asgardeo organization and keep the role assignment to the users based on the groups on the primary Asgardeo organization. This will create a separation between user attributes and their responsibilities.</p><p>I will be creating a connection to the external IDP from my primary Asgardeo organization. I will need a SAML application on the external IDP, to do this.</p><ol><li>On external IDP, create a SAML application. Optionally, download the metadata file.</li><li>Configure the issuer with a unique and valid issuer name</li><li>Configure the main Assertion consumer service URL with <a href="https://api.asgardeo.io/t/%7Bprimary-asgardeo-org-handle%7D/commonauth">https://api.asgardeo.io/t/{primary-asgardeo-org-handle}/commonauth</a></li><li>Make sure the “Groups” attribute is set to the application and it’s returning the user’s groups as the value.</li></ol><h3>Primary Asgardeo configs</h3><h4><strong>Connection:</strong></h4><p>Now, I’m going to create a SAML connection from my primary Asgardeo organization to the external Asgardeo organization.</p><ol><li>Go to “Connections” and click “Create connection” and choose “Standard based application”</li><li>Enter a unique identity provider name</li><li>Select “SAML” as the protocol and click “Next”</li><li>Service provider entity ID should be the unique issuer name configured on the external IDP’s SAML application</li><li>Enter the external IDP’s jwks endpoint URL</li><li>Click “Finish”</li></ol><p>After creating the connection, add the external IDP’s groups you want to refer. I added the following groups</p><ol><li>HR_Group</li><li>Finance_Group</li></ol><h4><strong>APIs</strong></h4><p>Go to “API Resources” and add the APIs and the respective scopes you want to configure the RBAC. Note that adding APIs is needed to organize the scopes well within the Asgardeo organization. When the API is added, make sure to mark that the scope authorization is needed.</p><p>I added 2 APIs with their scopes as follows</p><ol><li>HR_API (read:employee, write:employee, remove:employee, update:employee)</li><li>Finance_API (read:cost, write:cost, update:cost)</li></ol><h4><strong>Roles</strong></h4><ol><li>Go to the “Roles” page under “User Management” menu.</li><li>Click “New Role”</li><li>Enter a role name and set the role audience to “Organization” and click “Next”</li><li>Select the scopes from the APIs for the role and click “Finish”</li></ol><p>I created the following roles with the scopes. Note that the HR executive has a limited amount of permissions(scopes) from the HR_API. The finance manager has all scopes from the Finance_API and the CEO has all scopes from both APIs.</p><ol><li>HR_Executive (read:employee, write_employee)</li><li>Finance_Manager (read:cost, write:cost, update:cost)</li><li>CEO (read:employee, write:employee, remove:employee, update:employee, read:cost, write:cost, update:cost)</li></ol><p>After creating the roles, go to their edit view and select the “Groups” tab. Select the external IDP you’ve added and map the role to the respective group(s).</p><p>I have mapped my roles to external groups as follows. Note that the CEO belongs in both groups.</p><ol><li>HR_Executive — HR_Group</li><li>Finance_Manager — Finance_Group</li><li>CEO — HR_Group, Finance_Group</li></ol><p>Asgardeo figures out the permissions (scopes) to be granted to each user. Note that users and scopes are not directly mapped, they’re mapped using roles and groups. This clever design lets us configure the users from an external IDP with their scopes without even having to see the users.</p><p>Groups (Users) — Roles (Scopes)</p><h4><strong>User application</strong></h4><p>Now that we’ve created a connection to the external IDP, roles, scopes and added the APIs, let’s create a “Standard based application” to consume the connection. After creating the application, make sure to configure the following on each tab and save them.</p><ol><li>Add “code” grant type and configure the authorize and redirect URLs as per your web application on the “Protocol” tab</li><li>Update the access token type to “JWT” on the “Protocol” tab</li><li>Make sure to check the “Groups” attribute on the “Attributes” tab</li><li>On the “Login flow” tab, use the external IDP instead of the existing authentication</li><li>Add previously created APIs and their scopes to the application on the “API Authorization” tab</li><li>On “Roles” tab, set the role audience to “Organization”</li><li>On “API Authorization” tab, add all APIs with the scopes you want the application have access to. In this example, I have added both “HR_API” and “Finance_API” and their scopes to the application</li></ol><p>Congratulations! You’ve successfully created and configured your Asgardeo application to use in a RBAC scenario. A perfect example would be a web application based on the Micro Frontend Architecture (MFA).</p><h3>Use case</h3><p>I am going to use my user application in my MFA web app, which has multiple micro frontends. I’ll focus on the finance and HR microfrontends for now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IquwpkjDNh_UWdAbZqXR8Q.png" /></figure><p>Users (John Doe, HR-user, finance-user) can log in to the MFA web application. The web application uses the standard-based application we created on our primary Asgardeo organization. Since we have configured the RBAC in our application, users will have their respective set of scopes in their tokens according to the groups they belong to.</p><p>Micro frontend developers don’t have to focus on authentication and authorization. The host web app will take care of the authentication, and the API GW will take care of the authorization of users to the APIs. <a href="https://wso2.com/choreo/">Choreo idevp</a> is a great example of such a backend deployment and API management platform. It easily manages the backend CICD process and offers an API gateway that is easy and intuitive to <a href="https://wso2.com/choreo/docs/tutorials/secure-an-api-with-role-based-access-control/">configure for scenarios like RBAC</a>.</p><p>Let me know if you could use this to set up a working RBAC scenario for your application. Thank you for reading. Happy coding !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3afbd6544217" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A faster approach to write a REST API from scratch]]></title>
            <link>https://medium.com/@chathurangas/a-faster-approach-to-write-a-rest-api-from-scratch-1a6c29a7c48e?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a6c29a7c48e</guid>
            <category><![CDATA[api-first]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[ballerina]]></category>
            <category><![CDATA[rapi-development]]></category>
            <category><![CDATA[rest-service-generation]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Sat, 03 Aug 2024 13:39:56 GMT</pubDate>
            <atom:updated>2024-08-03T13:39:56.201Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8L1Bb7EfbXAPG_FH" /><figcaption>Photo by <a href="https://unsplash.com/@spacex?utm_source=medium&amp;utm_medium=referral">SpaceX</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>API-first, also called the API-first approach, prioritizes APIs at the beginning of the software development process, positioning APIs as the building blocks of software — postman.com</blockquote><h3>Rapid development idea</h3><p>I’ve always wanted to write a simple, yet functional salon appointment system for my local salon. Anyway, I couldn’t spend much time on it. Therefore, I was looking for an approach using which I could finish the backend REST API in under 6 hours. I’ll get to the front-end part in a separate story. I have plenty of experience in the <a href="https://ballerina.io/">Ballerina language</a>, which is a cloud-native computer language and supports generating services from openapi specs. I also have experience in APIs and API first approach. Therefore, I asked ChatGPT to write a swagger for my salon appointment system and generate the REST API spec to kick-start the implementation of my backend.</p><h3>A little chat with AI</h3><p>The prompt is a bit long; so I’ll not clutter this article by pasting it here. You can go to the ChatGPT and check it out yourself using the following link :) <a href="https://chatgpt.com/share/5ed990ed-8249-4d60-a614-4455357e9fb3">https://chatgpt.com/share/5ed990ed-8249-4d60-a614-4455357e9fb3</a></p><p>It took less than half an hour to generate and refine the swagger I wanted.</p><h3>A simple &amp; minimal working system</h3><p>The best way to develop something complex is to start with a simple, yet minimal working version of the final product. That is going to give us the ability to adjust and made it better as we develop in iterations. We call this an <a href="https://inflectiv.co/2022/03/31/mvp-minimum-viable-product/">MVP — Minimim Viable Product</a>. I’ll be implementing the first iteration of the system.</p><h3><strong>Database setup</strong></h3><p>I took the old-school approach of designing the database since there wasn’t much to do on the database. I just drew a single table for appointments first.</p><pre>appointment(date, hour, hour_partition, client_name, barber_name)</pre><p>Note that while the appointment is capable of keeping an appointment record, it can’t include client details or barber details if we wanted the system to have them in the future. This issue can be solved by applying the second normalization to the database. Note that the following tables are functionally independant and can be extended to include or exclude details. Eg: Barber experience, gender, age etc..</p><pre>barber(id, name)<br>slot(date, hour, partition, barber_id)<br>appointment(id, slot_id, user_id, barber_id)</pre><p>Note that for the first iteration, I didn’t include user(client) registrations. Users can use the system by their telephone number or social security number or any unique string of their choice. At a later iteration, another table for users and record their details can be added.</p><p>Database preparation took me about a half an hour.</p><h3>Starting the ballerina project</h3><p>I am using <a href="https://ballerina.io/">Ballerina language</a> for this project. Starting a ballerina project is so easy.</p><pre>bal new salon-appointment-system</pre><h3>Generating the sketch</h3><p>I copied the generated API specification: salon-appointment-system.yaml into the ballerina project root and used the Ballerina openapi gen tool to generate the service sketch along with the type definitions.</p><pre>bal openapi -i salon-appointment-system.yaml --mode service</pre><p>This generated the following files.<br> — salon-appointment-system_service.bal<br> — types.bal</p><h3>Implementing the resource functionality</h3><p>I created a new file called db.bal to keep the database operations. The generated service file is using the functions defined in the db.bal file and it’s handling the errors and issuing the responses from the resources. I won’t be going into details of the implementation. You can find the full code on the GitHub: <a href="https://github.com/chathuranga95/salon-appointment-system">https://github.com/chathuranga95/salon-appointment-system</a>.</p><p>Starting the project, generating the code and implementing the functionality took about 4 hours. GitHub co-pilot helped me in efficiently developing the service.</p><h3>Running the Salon appointment System backend</h3><p>The GitHub repository contains a <a href="https://github.com/chathuranga95/salon-appointment-system/blob/main/README.md">ReadMe file </a>with all the information need to setup and run the project.</p><p>To test the backend, I used <a href="https://www.postman.com/">Postman</a> with the generated swagger.</p><p>Testing and minor improvements took around an hour.</p><h3>Summary</h3><p>In this project, I have written a minimum working prototype of a salon appointment system’s backend REST API. I used Ballerina, MySQL, ChatGPT, GitHub Co-pilot, VScode, DBeaver and Postman to design, develop and test the product rapidly. I could achieve functionalities: retrieving possible appointment slots, placing appointments, retrieving placed appointments and deleting placed appointments in under 6 hours of work.</p><h3>What’s next…</h3><p>I’m going to write a simple frontend application to consume this REST API service and deploy the full working system on a cloud internal developer platform called <a href="https://choreo.dev/">Choreo</a>. Stay tuned for those stories.</p><p><strong>Thanks..</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a6c29a7c48e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boost up brute force with mathematics]]></title>
            <link>https://medium.com/swlh/boost-up-brute-force-with-mathematics-71aa986e27b9?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/71aa986e27b9</guid>
            <category><![CDATA[brute-force]]></category>
            <category><![CDATA[mathematical-modeling]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[prevent-hacking]]></category>
            <category><![CDATA[mathematical-hacking]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Sat, 26 Sep 2020 07:03:40 GMT</pubDate>
            <atom:updated>2020-09-28T13:57:37.416Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZUBCM7LnBqHMrGz0xQrByQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@thisisengineering?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">ThisisEngineering RAEng</a> on <a href="https://unsplash.com/s/photos/mathematics?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In this post, I’m going to discuss a little bit about brute forcing method and a special scenario where I found brute force vulnerable system. In fact, I boosted up the brute force with use of simple mathematics, so I could actually prove that the system is completely manipulable with a finite (relatively small) amount of time. I’ll briefly state everything, stay tuned.</p><h3>What is Brute force?</h3><p>Brute force is trying to get something correct by trial and error. This can be applied to entering to a system with a 4 number pin code. Let’s say some device unlocking requires a 4 digit pin code. Brute force into the system means, try entering all possible combinations of the 4 digits. For example: 0000, 0001, 0002, … , 9998, 9999.</p><p>In real life cases, this brute forcing may not be practical due to 2 main reasons.</p><ol><li><strong>Too many combinations are there to try. </strong><br>In above example, there were 10⁴ (=10,000) trials. Considering average inputs needed to unlock such a system with brute force, we can say (0+10000)/2 = 5000. (The attempt can work on the very first attempt or on the last attempt). But imagine if there is a 8 character password in which a character can be one of 64 character. Then number of all attempts would be 64⁸ = 2.8147498 x 10¹⁴; which is a huge number and brute force will be impractical.</li><li><strong>Limited number of attempts / Attempts are limited with time <br></strong>You have seem this for sure. Your mobile devices let you to try the pin/password incorrectly only for some limited number of times. (say 5 times). After that number of attempts, you should wait 30 seconds. Then if you again get your pin/password incorrect 5 times, the waiting time would get increment, and so on. This way, even if for a simple 4 digit pin, you wouldn’t get to brute force in a decent amount of time. May be after some total number of incorrect attempts, the device will get into a different state from which you can unlock the device by proving your identity in a different way.</li></ol><h3>Brute force vulnerable systems</h3><p>Basically, a brute force vulnerable system would have following behaviors.</p><ol><li>Let the user know the result of his/her input after the attempt. (Not an essential vulnerability characteristic, but this is included in brute force check list)</li><li>Letting the user to try and fail repeatedly without blocking attempts or time breaks.</li><li>Having a small number of input combinations</li></ol><p>But brute force necessarily doesn’t have to be just trial and error on all input combinations. We can use some techniques to reduce the number of attempts. Let’s call such system indirectly brute force-able systems.</p><h3>Indirect brute force vulnerable systems</h3><p>In this post, I’ll mention a real life system, which doesn’t display 2 of above brute force vulnerable characteristics, but yet it can be successfully brute forced in a decent amount if time. (finite number of attempts)</p><h4>The vulnerable competition portal</h4><p>This particular system is a prediction uploading portal for an online AI competition. The competitors should upload a .csv file in which a series of predicted numbers present. The numbers should be as close as to the expected number series. For example, let’s say the expected number series is 40, 50, 25, 72, 100. In the .csv file, competitors can upload any 5 number series. Let’s say some competitor uploaded 38, 45, 27, 75, 100. The only correct answer is 100. But the others are somewhat closer to the answer. Therefore, this competition measures the closeness to the actual number series with a measurement called MAE (Mean Absolute Error). MAE is the average of absolute difference between each expected and provided number.</p><p>Eg: MAE of above example:</p><p>MAE = (|40–38| + |50-45| + |25–27| + |72–75| + |100–100|)/5<br>MAE = 2.4</p><p>The competition portal only lets one user to upload 3 .csv file per day. But competitors can team up and try even more attempts per day. Let’s say 10 competitors team up; then they have 30 attempts. But the expected series can be anything, therefore one can see this cannot be brute forced at all. But that’s not correct. Since the portal calculates the MAE for every upload of a .csv file and return the MAE with a leader board ranking. This way, competitors can measure their progress and see their position on the competition. The competition duration is 3 months and the length of the predicted number series we should upload is 450.</p><p>Let’s see how we can use the legit upload of the .csv files with a little bit of mathematics to come to the very top of the leader board ;)</p><h4>Hacking — Not exactly, but it’ll do the thing</h4><p>Let yᵢ be the expected number for the iᵗʰ position of the number series.<br>Let xᵢ be the competitor uploading number for the iᵗʰ position of the number series.<br>Let E be the MAE of the submission, without the iᵗʰ number counted. Then,</p><p>MAE = (|yᵢ-xᵢ| + E )/n</p><p>By the nature of the competition, let’s say we know that the number is somewhere between 1–1000. Then we’ll need to upload 0 and 10,000 for a particular position and do calculations. (0 and a very large number out of the expected range, you’ll see why in next steps)</p><p>Say, for a particular position i, xᵢ = 0 and xᵢ = 10000 and other values are kept unchanged. Note that this will cost 2 .csv uploads and we can obtain 2 MAEs. Say, MAE₁ and MAE₂. Then,</p><p>|0-yᵢ| + E = n ✕ MAE₁ <br>|10000-yᵢ| + E = n ✕ MAE₂</p><p>Note that since we carefully chose 0 and a very large number, we can simplify above equations’ absolute differences further.</p><p>yᵢ+ E = n ✕ MAE₁ — — — — (1)<br>10000-yᵢ+ E = n ✕ MAE₂ — — — — (2)</p><p>Now, perform (1)-(2)</p><p>=&gt; 2yᵢ-10000 = n(MAE₁-MAE₂)</p><p>=&gt; yᵢ = (n(MAE₁-MAE₂) + 10000) / 2</p><p>Now, we have successfully found expected iᵗʰ number in the series. We’ll have to repeat this by n times.</p><p>Since the competition has a n=450 and 3 per day upload limitations per user, let’s imagine 10 competitors team up and do this hack.</p><p>(2 ✕ 450 attempts)/ (3 ✕ 10 attempts per day)= 30 days</p><p>Yay!, we have mathematically proven that this portal enabled competition can be brute forced with only limited number of attempts and limited amount of time.</p><h3>Final words…</h3><p>Please do not try these kinds of hacks and tricks on real life competitions. If such exists, try to prove them mathematically; specially if you’re building some system, try to perform some mathematical operations on it and see whether you can actually break through it with the information you’re exposing.</p><p>So, this competition could have easily prevented the suggested mathematical brute force by simply not returning the MAE directly to the competitor. Rather, it could have calculated the MAE and return the ranking of the competitor/team.</p><p>Thanks for making it to the end… I hope you learnt something useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71aa986e27b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/boost-up-brute-force-with-mathematics-71aa986e27b9">Boost up brute force with mathematics</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use Own Docker Images on Minikube — Easy Way]]></title>
            <link>https://medium.com/swlh/how-to-use-own-docker-images-on-minikube-easy-way-ed96438edf05?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed96438edf05</guid>
            <category><![CDATA[minikube]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[docker-image-dump]]></category>
            <category><![CDATA[local-kubernetes]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Sat, 19 Sep 2020 06:32:31 GMT</pubDate>
            <atom:updated>2020-09-20T05:41:46.276Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Use Own Docker Images on Minikube — Easy Way</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xBs3af0YWiIJXvZshluNhA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>This brief post will bring you a quick and an effective way to use your own build docker images / docker image dumps on minikube.</p><p>There are some articles like <a href="https://medium.com/bb-tutorials-and-thoughts/how-to-use-own-local-doker-images-with-minikube-2c1ed0b0968">this</a> explaining one method to use <em>Own Local Docker Images With Minikube. </em>For some cases: such as when you are building docker images from a library or a programming language tool like ballerina, you might not be able to use the above mentioned method. Example case: Try to compile <a href="https://ballerina.io/learn/by-example/docker-deployment.html">this ballerina example</a> with having followed previously mentioned method.</p><h4>Easy way</h4><blockquote>Note: When you’re executing following commands, replace myImage with your docker image name. You might need to use sudo privileges to execute docker commands on your local machine.</blockquote><p><strong>Step 1:<br></strong>First, you have to have the docker image dump file. If you have it already, move to step 2. Otherwise, on your local terminal, run following command.</p><pre>docker save myImage &gt; myImage.tar</pre><p><strong>Step 2:<br></strong>Copy the image dump file into minikube cluster. Note that you’ll only need to replace image dump file name.</p><pre>scp -i $(minikube ssh-key) myImage.tar docker@$(minikube ip):/home/docker/</pre><p><strong>Step 3:<br></strong>ssh into minikube cluster. This will shift your local terminal to the minikube cluster’s terminal.</p><pre>minikube ssh</pre><p>Load docker image into minikube cluster’s own docker. Run following command on the minikube cluster’s terminal which was opened with previous command.</p><pre>docker load -i myImage.tar</pre><p>You may check whether the image is loaded correctly by running on the same terminal,</p><pre>docker images</pre><p>Exit the minikube custer’s terminal by,</p><pre>exit</pre><p><strong>Step 4:<br></strong>You’ll need to instruct the kubernetes to not to pull images from the repository by setting the image pull policy to never. You may do this by modifying containers section in your deployment.yaml file.</p><pre>containers:<br>- image: myImage:v1.0<br>  name: myContainer<br>  imagePullPolicy: Never</pre><p>Well, that’s it for the easy way of using your own docker images on the minikube. I hope this was a useful exercise to save your time and bandwidth, since the whole point of having minikube on the local machine is to develop and test everything locally. 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed96438edf05" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-to-use-own-docker-images-on-minikube-easy-way-ed96438edf05">How to Use Own Docker Images on Minikube — Easy Way</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to learn something efficiently]]></title>
            <link>https://medium.com/swlh/how-to-learn-something-efficiently-bba5aa2471fd?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/bba5aa2471fd</guid>
            <category><![CDATA[life-hacking]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[remembering]]></category>
            <category><![CDATA[efficient-learning]]></category>
            <category><![CDATA[life-lessons]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Mon, 10 Feb 2020 15:43:31 GMT</pubDate>
            <atom:updated>2020-02-10T15:43:31.860Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*auF6r-aigJq_mr1xDoohaQ.png" /></figure><p>Hello everyone! If you are tired of the current style of your learning procedure and looking for a better way to learn something new, this post is for you. I should mention that learning anything needs some amount of attention and commitment. However, we can make full use of that commitment to learning very effectively. Let’s breakdown the story into two parts. <br>1. Introducing to the learning<br>2. Common mistakes in learning and tips to learn efficiently</p><h4>What and why learning…</h4><p>Learning is basically getting new experiences, skills and memories so that conscious living beings act accordingly. The learning process is happening in any conscious living being continuously by intentionally or unintentionally. For unintentional learning example, subtle facial expressions can be stated. However, in this post, let’s stick to the intentional learnings.</p><p>The reason why conscious living beings should learn is basically to survive. If they can’t learn who their predators are, that creatures will be extinct. Being a higher conscious living being, the human is having much more complicated needs and wants in learning things in their day-to-day lives. For example, to be social, to educate themselves, do a profession, teach the descendants etc. Humans possess a high capacity for learning. Let’s talk about some common mistakes and some tips to overcome them.</p><h4>Common learning mistakes and tips to learn like a pro…</h4><p>Think about your favourite song. Can you recall the lyrics? Of course, you can. For most of us, our favourite song’s lyrics are in our memory even without we try to remember them. This is very same for memorizing our friends’ names, remembering our favourite movies’ and TV shows’ plots etc. While these things are easily remembered, why can’t we easily remember some mathematic equation or a chemical compound or a quote by a poet? The answer is the need for that particular piece of information in our lives. The song is remembered since the enjoyment. The list of the friend names is remembered since we spend our time with them. This phenomenon seems like in disadvantage for us. But, we can make use of it. The only thing we have to do is make our learning a life need. For example, consider having to learn some theories related to economics. Mapping the theories with real-life and personal related example incidents would make learning the theories much easier. In this manner, you’ll be able to make the theories and learnings your own. Of course, you’ll have to memorize some new technical terms.</p><p>Having a need to know something is also really important. in some exam-related situations, our need is to pass the exam. Actually, what if the actual need was to learn the subject? For example, we learn some games with complex rules such as chess even without having to face exams or take quizzes. I recently listened to <a href="https://www.youtube.com/watch?v=0x2_kWRB8-A">this ted talk</a>, in which the speaker brings the point that if we want to learn a new language, just do it for the purpose of communicating in that language with some real people. Thus, having a genuine need to learn something is always helps.</p><p>Trying to memorize things without focusing on the context is very inefficient. This mistake is commonly done when studying for some exams. Memorization of facts is very important and essential for studies. However, we should manage the limited capacity of our memory effectively. Therefore, some context knowledge would help us in arranging the newly learning stuff in an efficient manner. For example, consider learning about the properties of computers. it is very hard to memorize each type of computer’s components separately. Then, a context should be built to make a real-life hierarchy of the different types of computers in order to facilitate easy learning. For instance, knowing desktop and laptops are computers, first memorizing the components of a computer and distinguishing between the differences in laptop and desktop components reduces the amount of memory to learn those. Then unnecessary redundancies will be eradicated from the memory.</p><p>Even if we are really good at learning things, we might get forgotten some facts we learn really quick. The following image shows how a typical human retains details he/she learnt. We have to be aware of this forgetting (retaining) curve. Remember the chats we had with our friends about cartoons in childhood. Those chats made our memory in those cartoons last longer. We can apply the same for the learnings in our education and everything. Teaching some friend who is unclear about the subject matter, talking and clarifying with a friend on the subject is very helpful. Moreover having a purpose of blogging, telling stories, and sharing own learnings is also helping with the learning process. Read the article on forgetting curve (link in the image caption) for more details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*HQy2odJwWOplHskd4LHIHg.png" /><figcaption>Image from <a href="https://www.growthengineering.co.uk/what-is-the-forgetting-curve/">https://www.growthengineering.co.uk/what-is-the-forgetting-curve/</a></figcaption></figure><h4>Finally…</h4><p>Most of us have come across the saying ‘learn from mistakes’. As the saying states, we should experiment, make mistakes and keep a consistent passion to learn something. I hope you enjoyed the post. you might also have some tips in learning effectively or some different views on the tips pointed here. please let everyone know those in the comments. Happy learning !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bba5aa2471fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-to-learn-something-efficiently-bba5aa2471fd">How to learn something efficiently</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s Crack a Magic Trick]]></title>
            <link>https://medium.com/swlh/lets-crack-a-magic-trick-925080d274bb?source=rss-ab0c42994557------2</link>
            <guid isPermaLink="false">https://medium.com/p/925080d274bb</guid>
            <category><![CDATA[crack-magic]]></category>
            <category><![CDATA[card-tricks]]></category>
            <category><![CDATA[mathematics-in-magic]]></category>
            <category><![CDATA[mathematical-modeling]]></category>
            <category><![CDATA[magic]]></category>
            <dc:creator><![CDATA[Chathuranga Siriwardhana]]></dc:creator>
            <pubDate>Sun, 29 Dec 2019 15:41:20 GMT</pubDate>
            <atom:updated>2019-12-30T09:27:48.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KWyV9x6eYKxkiJfqWnIiHA.png" /></figure><p>Magic is a great entertaining and fascinating art. There are several kinds of magic. Magic usually uses sleight of hand, misdirection, lying (of course), magic props, pre-show work, secret assistant, mathematics etc. A long list of magic types can be seen <a href="https://www.quora.com/Is-there-a-definitive-list-of-the-types-of-magic-trick-performance-techniques-e-g-sleight-of-hand-mentalism-etc">here</a>. I have always been fascinated by both mathematics and magic for a long time. I’m also a kind of person who likes to destroy the fun in a magic trick trying to figure that out. (Kind of conflicting characteristics, I know). In this post, I’ll be teaching you a very simple card trick. Then discuss the internal mechanism of the magic trick using a mathematical model.</p><h3>Let’s do the trick</h3><p>Let’s call the trick “Clubs, Hearts and Diamonds trick”. Since the trick uses these kinds of cards and the exact words when performing. You can watch <a href="https://www.youtube.com/watch?v=jkUYT1WSchY">this </a>youtube video to learn the trick under 4 minutes. I’ll list the steps below to make things clear.</p><p>To perform this trick, we need 3 cards from Clubs, Hearts and Diamonds. Let’s choose J, K, Q cards from each kind. Altogether, 9 cards are used in the trick.</p><ol><li>Make 3 piles such that each pile contains cards from the same kind.</li><li>Ask your spectator(s) to select any pile.</li><li>Deal the 3 cards in that selected pile in 3 separate places.</li><li>Again ask your spectator(s) to select another pile of remaining two piles.</li><li>Again deal the 3 cards in that selected pile on top of the previously dealt places. The order is irreverent.</li><li>Also, take the last remaining pile and deal the 3 cards as did in step 5.</li><li>Now ask the spectator(s) to collect the new 3 piles in any order he/she likes.</li><li>Then, ask the spectator(s) to <a href="https://en.wikipedia.org/wiki/Cut_(cards)">cut</a> the 9 card pile anywhere he(she) wants. You can let any number of cuts to be performed.</li><li><strong>Optional: </strong>Shuffle the 9 card pile by dealing the cards in two separate piles in an alternating manner and collect them in any order.</li><li>Let’s say rotating the card pile by <em>n</em> times is taking a card from the top of the pile and placing it in the bottom, and repeating it <em>n</em> times.</li><li>Now, rotate the 9 card pile 3 times. Count the letters in the word “CLUB” while rotating. As per the letter ‘B’, take the card out and place it in a separate place. (Let’s call this P1)</li><li>Rotate the remaining 8 card pile 4 times with the word “HEART”. As per letter ‘T’, take the card out and place it in a separate place than the previous place. (Let’s call this P2)</li><li>Rotate the remaining 7 card pile 6 times with the word “DIAMOND”. As per the last letter ‘D’, take the card out and place it in a separate place than the previous two places. (Let’s call this P3)</li><li>Now Deal the remaining cards as in the steps 11, 12 and 13 but place them in the places <strong>P3, P2 and P1</strong> instead of placing them in P1, P2 and P3.</li><li>Then there will be 3 cards remaining. Deal those cards without any rotation on the places, <strong>P3, P2 and P1</strong>.</li><li>Now reveal that in each pile P1, P2 and P3, there are only cards from the same kind.</li></ol><h3>What’s Happening</h3><p>In the very beginning of this post, I stated that mathematics is used in some magic tricks. What I mean by that is inside the magic trick, some tautology is being used. Tautology is a logic statement, which is always true.</p><p>Mathematical equivalences are always true statements. For example,</p><p>(x+y)² ≡ x² + 2xy + y²</p><p>((<strong>p</strong>+ 5 - 3)/2 + 1) × 2 ≡ <strong>p</strong></p><p>In childhood, we were used to playing games using these equivalences. There is somewhat similar (considering the algorithm of the trick) happening in the magic trick. Let’s crack the trick.</p><h3>Understanding the presented trick</h3><p>This trick only uses a tautology. To understand the trick, we have to first model the trick in a mathematical model. Then perform the steps on the model. The complications of having the cards face down and unnecessary moves are making the procedure a real magic trick. Since we are going to crack (reveal or understand) the trick, let’s go with the mathematical model, step by step.</p><p>Let’s call the three kinds of cards as <strong>A</strong>,<strong> B </strong>and <strong>C </strong>(our notation for the model). Since their order is not considered, no need to worry which letter is assigned to which kind. Let’s perform the 16 steps of the tricks by using this model.</p><p><strong>Step 1: Place 3 different kinds of cards in 3 different piles, facedown.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*S9nOr17AHlGiGAsxzRN9Ag.png" /></figure><p><strong>Steps 2–6</strong>: Note that since A, B, C could be any of the kinds, we suppose the spectators choose the kinds of A, B and C in the order to make the 3 piles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*z6e07HVd1zkUSrpuzjMvsQ.png" /></figure><p><strong>Step 7</strong>: Since 3 piles are identical(According to the model), the spectator’s choice is un-important in collecting the piles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*vgcnsrnYdwmki4d3nJhQYA.png" /></figure><p><strong>Step 8: Cutting the pile.</strong> Note that cutting doesn’t change the order of a pile of cards. It only rotates the card pile and changes the starting point. Note that our notation for the different cards is just A, B, C, let’s again re-notate the cards to be in the positions of the above figure.</p><p><strong>Step 9: </strong>This step also doesn’t change the order of the 9 card pile. See the following figure. Note that we’ll have to re-notate as A, B, C ← B, A, C to refer the above figure’s pile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GQ6phTU_FEFLIntMT5qmow.png" /></figure><p><strong>Step 11</strong>: Rotating with the word “<strong>CLUB</strong>”. Let’s use a sequence of letters to represent the pile of cards.</p><blockquote>Note that the notation is,<br>Top → <strong>A B C A B C A B C</strong> ← Bottom</blockquote><p>Initial pile: <strong>A B C A B C A B C</strong></p><p>After rotate(3): <strong>A B C A B C A B C</strong></p><p>After dealing: <strong>B C A B C A B C | P1={A}</strong></p><p><strong>Step 12</strong>: Rotating with the word “<strong>HEART</strong>”.</p><p>Initial status: <strong>B C A B C A B C | P1={A}</strong></p><p>After rotate(4): <strong>C A B C B C A B</strong></p><p>After dealing: <strong>A B C B C A B | P1={A}, P2={C}</strong></p><p><strong>Step 13</strong>: Rotating with the word “<strong>DIAMOND</strong>”.</p><p>Initial status: <strong>A B C B C A B | P1={A}, P2={C}</strong></p><p>After rotate(6): <strong>B A B C B C A</strong></p><p>After dealing: <strong>A B C B C A | P1={A}, P2={C}, P3 = {B}</strong></p><p><strong>Step 14</strong>: Rotating for the second time deal.</p><p>Initial status: <strong>A B C B C A | P1={A}, P2={C}, P3 = {B}</strong></p><p>After rotate(3) with “CLUB”: <strong>B C A A B C</strong></p><p>After dealing: <strong>C A A B C | P1={A}, P2={C}, P3 = {B, B}</strong></p><p>After rotate(4) with “HEART”: <strong>C C A A B</strong></p><p>After dealing: <strong>C A A B | P1={A}, P2={C, C}, P3 = {B, B}</strong></p><p>After rotate(6) with “DIAMOND”: <strong>A B C A</strong></p><p>After dealing: <strong>B C A | P1={A, A}, P2={C, C}, P3 = {B, B}</strong></p><p><strong>Step 15:</strong> After dealing the rest, the 3 piles will be as follows. Note that the dealing order is P3, P2 and then P1.</p><p><strong>P1={A, A, A}, P2={C, C, C}, P3 = {B, B, B}</strong></p><p><strong>Step 16: </strong>Voila! It’s no more magic !!!</p><h3>Finally…</h3><p>The choice of the rotation terms “CLUB”, “HEART” and “DIAMOND” is a careful selection to suit the trick. Note that these are not the only terms which can be used with the same trick. You can try to invent a trick involving all 4 kinds and the same procedure. The rotation terms should be then carefully chosen.</p><p>I hope you enjoyed the trick and the mechanism behind it. Now you enjoy one less magic trick !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=925080d274bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/lets-crack-a-magic-trick-925080d274bb">Let’s Crack a Magic Trick</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>