<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Cheikh Mbacke Cisse</title>
    <description>The latest articles on DEV Community by Cheikh Mbacke Cisse (@kaiser_10dev).</description>
    <link>https://dev.to/kaiser_10dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4282199%2Fa1bd620e-0fd6-4896-a8f0-0293dcceb9be.png</url>
      <title>DEV Community: Cheikh Mbacke Cisse</title>
      <link>https://dev.to/kaiser_10dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kaiser_10dev"/>
    <language>en</language>
    <item>
      <title>I pointed a planet-finding algorithm at a symptom diary. Then I tried to break it.</title>
      <dc:creator>Cheikh Mbacke Cisse</dc:creator>
      <pubDate>Fri, 04 Dec 2026 08:17:26 +0000</pubDate>
      <link>https://dev.to/kaiser_10dev/i-pointed-a-planet-finding-algorithm-at-a-symptom-diary-then-i-tried-to-break-it-487h</link>
      <guid>https://dev.to/kaiser_10dev/i-pointed-a-planet-finding-algorithm-at-a-symptom-diary-then-i-tried-to-break-it-487h</guid>
      <description>&lt;p&gt;Built for Kiroween 2026.&lt;/p&gt;

&lt;p&gt;A planet you cannot see still leaves a trace. When it crosses in front of its star, the star dims by a fraction of a percent, and it does it again on a schedule. Astronomers have spent fifty years pulling those signals out of data that is sparse, noisy and full of holes, because the sky is clouded over half the time and the Earth insists on turning.&lt;/p&gt;

&lt;p&gt;Last week I noticed that a symptom diary has the same shape. A person with migraine writes down the days an attack came. Sometimes they forget. Sometimes they travel for three weeks and write nothing. The entries are subjective, the sampling is irregular, and anything periodic hiding inside is faint.&lt;/p&gt;

&lt;p&gt;Those are the exact conditions astronomy solved for. So I pointed the pipeline at the diary and spent the rest of the week trying to prove it wrong.&lt;/p&gt;

&lt;p&gt;Why the obvious tools do not work&lt;/p&gt;

&lt;p&gt;The first instinct is a Fourier transform. It does not survive contact with a diary. Classical Fourier analysis assumes evenly spaced samples, and a single missed day breaks that assumption. Real diaries are missing a lot more than a day.&lt;/p&gt;

&lt;p&gt;Astronomy hit this problem first and solved it in 1976 and 1982: the Lomb-Scargle periodogram is built for unevenly spaced observations. It is in astropy, it is tested against decades of survey data, and it needs no resampling, no interpolation, no filling of gaps. Filling the gaps would be the worst thing you could do, because the gaps are information.&lt;/p&gt;

&lt;p&gt;The second instinct is to average by week, which is what most self-tracking apps show you. An average is exactly the wrong operation. If your attacks return every 26 days, averaging them into weekly buckets destroys the thing you are looking for. The app has the data and throws away the answer.&lt;/p&gt;

&lt;p&gt;The part that mattered: building the adversary first&lt;/p&gt;

&lt;p&gt;A periodogram will always hand you a peak. Something is always the maximum. The entire problem is deciding whether that peak means anything, and this is where I spent most of the project.&lt;/p&gt;

&lt;p&gt;The piece I am proudest of is not the search. It is a module whose only job is to destroy the search's output. It runs four checks and a fifth marked exploratory:&lt;/p&gt;

&lt;p&gt;A permutation test. Shuffle the intensities against the untouched timestamps ten thousand times and record the strongest peak each time. Your logging calendar stays exactly as it was; only the values move. If the real peak does not beat that distribution, it is noise. Taking the maximum over the whole period grid in every shuffle is also what handles the fact that we tested 2,400 candidate periods and kept the best one.&lt;br&gt;
A weekday check. If you tend to fill in your diary on Sundays, a seven-day rhythm appears that belongs to your habit, not your body.&lt;br&gt;
A window-function check. Run the same search on your logging dates alone, with every intensity replaced by one. If your gaps can manufacture a peak at the candidate period, it shows up here.&lt;br&gt;
A harmonics check. A peak at half the period is the same cycle, not a second one.&lt;/p&gt;

&lt;p&gt;And then I wired that adversary into the build itself. Every time I touched the engine, an agent hook re-ran a validation suite: plant known periods in synthetic diaries at several noise levels and several gap patterns, then check the pipeline finds them again and does not invent cycles in pure noise. If recovery dropped below the floor, the hook told the agent to stop, report which periods it missed, and propose the smallest fix. It explicitly forbade loosening a threshold to make the suite pass, because that is the first thing anyone does at two in the morning.&lt;/p&gt;

&lt;p&gt;This is not my invention. It is injection-recovery testing, standard practice for validating a detection pipeline in astronomy. I just put it in a hook.&lt;/p&gt;

&lt;p&gt;The night it caught me&lt;/p&gt;

&lt;p&gt;It earned its place on the first serious run.&lt;/p&gt;

&lt;p&gt;The suite failed. Not spectacularly, just below its floor, and the misses were all in one corner of the grid: diaries with a weekly logging bias. Two of them were worse than a miss. A planted 21-day cycle was coming back certified at 3.0 days, with a confident-looking number attached.&lt;/p&gt;

&lt;p&gt;Here is the arithmetic that was hiding in there:&lt;/p&gt;

&lt;p&gt;1/21 + 2/7 = 1/3&lt;/p&gt;

&lt;p&gt;If someone logs on roughly three fixed weekdays, the sampling itself carries a seven-day structure. Combine a 21-day signal with that structure and you get an alias at three days that is stronger than the real peak. The search found the alias. The window-function check was looking in the wrong place to catch it, because it only compared the candidate period against the window function directly, not against the frequencies the weekly habit folds it onto.&lt;/p&gt;

&lt;p&gt;The fix was to test |1/P ± k/7| for small k whenever the weekday distribution is uneven. Those cases now come back rejected, with the reason written out.&lt;/p&gt;

&lt;p&gt;What strikes me is not the bug. It is that without the gate I would have shipped it, filmed a demo of it, and never known. The number looked right. It was specific, it had a confidence attached, and it was completely wrong.&lt;/p&gt;

&lt;p&gt;The second one, which was quieter and worse&lt;/p&gt;

&lt;p&gt;Days later, reading the code again with fresh eyes, I found something I like even less.&lt;/p&gt;

&lt;p&gt;The app reports a window: the slice of the cycle where attacks cluster. The function that computed it tried every possible contiguous run of phase bins and kept the one with the highest mean intensity.&lt;/p&gt;

&lt;p&gt;Read that again. A run's mean can never exceed its best bin. So the single highest bin always wins, every time, on every dataset. The window was never measured. It was structurally fixed at one twentieth of the cycle, and the precise-looking numbers on the dashboard were an artifact of the bin count.&lt;/p&gt;

&lt;p&gt;The generator was planting a burst across 30% of each cycle. The app was reporting 5%. No test caught it, because the test only checked that the window overlapped the planted burst, which a single bin in the right place does perfectly.&lt;/p&gt;

&lt;p&gt;The replacement is a half-maximum rule, which is a standard way to define the width of a feature: take the baseline, take the peak, and keep the contiguous run above the midpoint. The lesson is in the test, though, not the fix. I had written an assertion that could only ever pass.&lt;/p&gt;

&lt;p&gt;What actually transferred from astronomy&lt;/p&gt;

&lt;p&gt;I started out thinking I was borrowing an algorithm. I was not. The periodogram is one import line.&lt;/p&gt;

&lt;p&gt;What transferred is an attitude: assume your own signal is an artifact until you have genuinely failed to kill it. Astronomers have that reflex because their field has been embarrassed enough times by instruments, sampling windows and wishful thinking. Self-tracked health data has the same failure modes and almost none of the same defences.&lt;/p&gt;

&lt;p&gt;That is also why there is a large language model in the project and why it is kept on a short leash. Hand a diary to a model and ask it to find patterns and it will find them, every time, including in noise. In this build the statistics do the searching and the model only speaks about results that already passed the significance test. The astronomy stack is not the clever part. It is the restraint.&lt;/p&gt;

&lt;p&gt;What this is not&lt;/p&gt;

&lt;p&gt;Diary-based cycle detection is established work, not something I invented. The Seer app already produces seizure-risk forecasts from a seizure diary, and the clinical literature on multi-day cycles is years ahead of anything I built in a week. What I was after was a different property: a tool that shows the null hypothesis it tested, the ways it attacked its own answer, and a plain refusal when the data cannot carry a conclusion.&lt;/p&gt;

&lt;p&gt;Everything in it is validated against synthetic diaries with clean, box-shaped bursts. That demonstrates how the software behaves. It says nothing about clinical performance, and the README says so in a Known Limitations section that is longer than I would like and exactly as long as it should be.&lt;/p&gt;

&lt;p&gt;On the tooling&lt;/p&gt;

&lt;p&gt;The project was built with Kiro for Kiroween 2026, specs first. The part worth copying regardless of which agent you use is the shape: the rules the system must never break live in a steering file that is in context on every single turn, not in a prompt you wrote once and forgot. Mine encodes refusals rather than preferences. No certification below three observed cycles. No analytic false-alarm formula, because analytic formulas assume even sampling. The word "causes" is banned from every string the product emits.&lt;/p&gt;

&lt;p&gt;Writing the code also broke the spec twice, which I did not expect. One requirement asked for a 7-day cycle to be recovered from a diary logged on three fixed weekdays, while another required the weekday check to reject exactly that case. The spec contradicted itself and only the implementation noticed.&lt;/p&gt;

&lt;p&gt;The research, the specs and the interface mockup were drafted with Claude before any code existed; Kiro built the application against them. Both of those facts are in the repository, because a project about showing your work does not get to hide its own.&lt;/p&gt;

&lt;p&gt;Spectre is open source. If you try to break it, I would like to know how.&lt;br&gt;
&lt;a href="https://github.com/CheikhMbackeCisse/spectre" rel="noopener noreferrer"&gt;https://github.com/CheikhMbackeCisse/spectre&lt;/a&gt;&lt;br&gt;
&lt;a href="https://cheikhmbackecisse.github.io/spectre" rel="noopener noreferrer"&gt;https://cheikhmbackecisse.github.io/spectre&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kiroween2026</category>
      <category>python</category>
      <category>datascience</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Two algorithms died before I could prove a debt plan was safe</title>
      <dc:creator>Cheikh Mbacke Cisse</dc:creator>
      <pubDate>Fri, 04 Dec 2026 07:55:36 +0000</pubDate>
      <link>https://dev.to/kaiser_10dev/two-algorithms-died-before-i-could-prove-a-debt-plan-was-safe-4nka</link>
      <guid>https://dev.to/kaiser_10dev/two-algorithms-died-before-i-could-prove-a-debt-plan-was-safe-4nka</guid>
      <description>&lt;p&gt;This post is written as part of the Kiroween 2026 hackathon.&lt;/p&gt;

&lt;p&gt;Most financial planners answer the wrong question. You tell them your debts and your income, and they tell you a date: debt free in seventeen months. What they mean is debt free in seventeen months if nothing goes wrong. For someone with a steady salary and six months of savings, that is a reasonable thing to say. For someone whose income drops by a third twice a year, it is useless. They will not live the average. They will live the month it breaks.&lt;/p&gt;

&lt;p&gt;So I set out to build something that answers a different question. Not how long will this take, but: is there a plan that gets me there whatever the world does, inside limits I declare myself? Not a projection. A proof, scoped to a stated model.&lt;/p&gt;

&lt;p&gt;This is the story of getting that wrong twice before getting it right, with the numbers from each attempt. I built it with Kiro during the Kiroween 2026 hackathon.&lt;/p&gt;

&lt;p&gt;The shape of the problem&lt;/p&gt;

&lt;p&gt;Write the situation as a game. You have a state: cash on hand, a balance per debt, and the month. Each month you choose a move: pay the minimums and bank the rest, put the surplus on the highest rate, put it on the smallest balance, or build a buffer first. The world moves too: your income can drop, an expense can land, a rate can rise. You declare what the world is allowed to do, and how often.&lt;/p&gt;

&lt;p&gt;Two absorbing states end it. All balances at zero is a win. Not being able to cover the minimums is a loss, and there is no coming back from it.&lt;/p&gt;

&lt;p&gt;A plan is guaranteed if, from your position, there is a move such that every reply the world is allowed to make leads to a position that is itself guaranteed. That is the whole definition, and it is recursive, which is the clue I should have read more carefully.&lt;/p&gt;

&lt;p&gt;Attempt one: search the tree&lt;/p&gt;

&lt;p&gt;The obvious implementation is a game tree with alpha-beta pruning. It is the thing every chess engine does, the problem looks like a game, so I wrote the spec that way and asked Kiro to build a spike before anything else.&lt;/p&gt;

&lt;p&gt;The spike is the part I would keep if I could keep only one habit. It is a throwaway script whose only job is to measure the thing the whole design rests on, before the design has anything resting on it.&lt;/p&gt;

&lt;p&gt;The first results looked fine. Two starting positions, 14,410 nodes in 0.17 seconds for one and 2,815 for the other. Comfortable.&lt;/p&gt;

&lt;p&gt;They were comfortable because in both positions the world could force a loss by month two. The tree was cut off almost immediately. The measurement said nothing about the case I actually cared about, which is a position where a guarantee exists and the search has to go all the way to the horizon to find it.&lt;/p&gt;

&lt;p&gt;When I scanned for such a position, the first one took 14,219 nodes. The second never finished. The process ran until it stopped responding, and I had to kill it from Task Manager.&lt;/p&gt;

&lt;p&gt;Here is why, and it is not subtle once you count. Four move types, one of which takes a parameter from zero to six, gives about ten moves per month. Three possible shocks gives the world roughly three replies. Thirty branches per month, over thirty-six months. Alpha-beta prunes that to something like its square root, and the square root of an astronomical number is an astronomical number. Plain minimax, for comparison, needed 1.5 million nodes at a horizon of five and 23.5 million at six. Fifteen times per step.&lt;/p&gt;

&lt;p&gt;The spike did its job. It cost an hour and it killed an approach that would have cost a day.&lt;/p&gt;

&lt;p&gt;Attempt two: solve the states, exactly&lt;/p&gt;

&lt;p&gt;The fix is to stop thinking of it as a tree. The same position reached by two different routes is the same position, and in a tree you solve it twice. In a state space you solve it once.&lt;/p&gt;

&lt;p&gt;So: enumerate the reachable states, then work backwards from the two absorbing sets. A state is winning if some move sends every allowed reply into a state already known winning. Each state is visited once. Exponential in depth becomes linear in states.&lt;/p&gt;

&lt;p&gt;The question is how many states there are, which depends on how you discretise. Cash is continuous, so it has to be bucketed. Balances, I argued, do not: they follow exactly from the sequence of payments you chose, so keep them as exact integers and the model stays sound with no rounding error at all.&lt;/p&gt;

&lt;p&gt;That argument is correct and it is also the reason it fails.&lt;/p&gt;

&lt;p&gt;Month   Distinct states Elapsed Memory&lt;br&gt;
6   17,094  0.2 s   53 MB&lt;br&gt;
8   212,186 2.3 s   138 MB&lt;br&gt;
9   725,356 8.1 s   334 MB&lt;br&gt;
10  2,443,107   28 s    588 MB&lt;br&gt;
11  8,110,351   106 s   1000 MB&lt;/p&gt;

&lt;p&gt;Roughly 3.4 times per month, with no sign of slowing. I killed it at month twelve, and the model needs thirty-six.&lt;/p&gt;

&lt;p&gt;Balances do follow exactly from the payment sequence. That is precisely why there are as many of them as there are payment sequences. With interest rounded every month, two different routes almost never land on the same balance, so nothing merges, and the state space quietly turns back into the tree I had just escaped.&lt;/p&gt;

&lt;p&gt;Attempt three: bucket everything, and round against yourself&lt;/p&gt;

&lt;p&gt;Bucket the balances too. Round them up, round cash down. Always round against the user.&lt;/p&gt;

&lt;p&gt;That rounding rule is the part worth stealing. If every approximation is made in the direction that makes the position look worse than it is, then a state the table marks safe is safe for every real value inside its bucket. The abstraction is sound by construction, and no proof of monotonicity is needed.&lt;/p&gt;

&lt;p&gt;With cash in buckets of 25,000 the whole table solves in 1.8 seconds and 110 MB, over 458,428 reachable states. At 10,000 it is 790,382 states, 3.6 seconds and 169 MB. Both are fine in a web worker, and the table is computed once per position, after which every question is a lookup.&lt;/p&gt;

&lt;p&gt;But look at what the two runs say:&lt;/p&gt;

&lt;p&gt;Cash bucket States  Proved winning  Verdict&lt;br&gt;
25,000  458,428 19,587  36 months&lt;br&gt;
10,000  790,382 297,207 31 months&lt;/p&gt;

&lt;p&gt;Five months apart, and fifteen times as many positions proved safe at the finer bucket. The coarse table is not wrong. It is pessimistic, which is what sound approximation buys you: it never claims safety it cannot back, and it pays for that by missing safety it could have had.&lt;/p&gt;

&lt;p&gt;Which forced a change to the product, not just the code. The answer is not "debt free in nineteen months". It is "debt free in at most nineteen months, guaranteed". An upper bound. Once you say it that way the pressure to find the perfect bucket size disappears, because a coarser table is still true, just less flattering.&lt;/p&gt;

&lt;p&gt;What Kiro did in this&lt;/p&gt;

&lt;p&gt;Three things, concretely.&lt;/p&gt;

&lt;p&gt;The spec came before the code. Requirements in EARS form, written and argued over before a line existed, with Kiro generating the design from them. The requirement that mattered most reads: "the engine shall search with the adversary choosing, at every step, the move that is worst for the user among the moves the domain file allows" and "the engine shall not use probabilities anywhere in the guarantee computation". Both algorithm failures above were caught against that text, not against an opinion.&lt;/p&gt;

&lt;p&gt;A steering file kept the architecture honest. The hard rule of this project is that the language model never produces a number: it turns your sentences into a form you confirm, and turns a result into prose, and is not called during a solve. That rule is one paragraph in .kiro/steering/architecture.md, reloaded on every interaction, and it says in plain words that writing a number into a prompt and reading one back out is the failure the rule exists to prevent. At hour fourteen, tired, that paragraph is doing more work than I am.&lt;/p&gt;

&lt;p&gt;Property based tests, run by a hook on every save under engine/. The one I care about: backward induction returns the same value as exhaustive forward search, on every small generated game. That is the property that says the fast algorithm is the slow algorithm, and it is the only reason I trust a table of half a million states I will never read.&lt;/p&gt;

&lt;p&gt;And one thing that went badly, since a report that only lists successes is not a report. Kiro's terminal wedged for several hours after a runaway Node process from the first spike, returning exit code -1 for every command including echo. The fix was dull: kill the process from outside the editor, restart. The lesson was not: put a hard time and memory guard inside the spike itself, before you run it the first time, not after it has eaten your night.&lt;/p&gt;

&lt;p&gt;The part I would tell someone starting&lt;/p&gt;

&lt;p&gt;Measure the thing your design rests on before the design rests on it, and make sure you measure the hard case. My first spike was fast because it was solving an easy position, and a fast wrong measurement is worse than no measurement, because you believe it.&lt;/p&gt;

&lt;p&gt;And when an approximation forces you to be pessimistic, say so in the product instead of fighting it. "At most nineteen months, guaranteed" is a better sentence than "nineteen months", and it has the advantage of being true.&lt;/p&gt;

</description>
      <category>kiro</category>
      <category>kiroween</category>
      <category>algorithms</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
