ARCHOS 525 BLUEPRINT · /d/dgm_code-monotonic-stack-core
Monotonic Stack Core (Next Greater Element & Span Queries)
6 COMPONENTS · 6 FLOWS · UPDATED 2026-11-24
GITHUB README / PR PREVIEW CARD
[](https://archos.sageideas.dev/d/dgm_code-monotonic-stack-core) *Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_code-monotonic-stack-core)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_code-monotonic-stack-core" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="Monotonic Stack Core (Next Greater Element & Span Queries) — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
client_0["Input Series"]
n1_1["Scan Cursor"]
n2a_2[("Monotonic Stack")]
n2b_3["Boundary Resolver"]
n3_4["Span Result Array"]
downstream_5["Downstream & OTel"]
client_0 -->|"1. Next item · O1"| n1_1
n1_1 -->|"2a. Pop · Stack"| n2a_2
n1_1 -->|"2b. Resolve · O1"| n2b_3
n2a_2 -->|"3a. Record · ON"| n3_4
n2b_3 -->|"3b. Merge · RAM"| n3_4
n3_4 -.->|"4. Emit / · OTLP/API"| downstream_5COMPONENT STACK (6)
- Input SeriesSTATELESSArray / Prices / Heights
- Scan CursorSTATELESSIterates elements 0..N-1
- Monotonic StackSTATEFULIndices in increasing/decreasing
- Boundary ResolverSTATELESSPopped item finds right/left bound
- Span Result ArraySTATELESSNearest greater/smaller per idx
- Downstream & OTelSTATELESSConsumers, metrics & SLOs
REQUEST & DATA FLOW (6)
- Input Series → Scan Cursor (Next item)[O1]
- Scan Cursor → Monotonic Stack (Pop)[Stack]
- Scan Cursor → Boundary Resolver (Resolve)[O1]
- Monotonic Stack → Span Result Array (Record)[ON]
- Boundary Resolver → Span Result Array (Merge)[RAM]
- Span Result Array → Downstream & OTel (Emit /)[OTLP/API]