Compare commits
7 Commits
cursor/nat
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ee755ebecb | |||
| 2723f9b998 | |||
| 710782b786 | |||
| 358a6ab304 | |||
| f87272a3e4 | |||
| 71962e853f | |||
| 37e9e29c9a |
@@ -161,6 +161,7 @@ In Docker, prefix with `docker compose run --rm hub node src/hub-cli.ts …` (or
|
||||
| `deployBy` | Per project and target branch, `"tag"` when that branch deploys from release tags: `{"group/repo": {"production": "tag"}}`. Default: deploys on merge. |
|
||||
| `gas.mode`, `gas.graceSeconds` | `dry` or `live`; seconds to undo an action. |
|
||||
| `notify` | `telegramChatId`, `boardUrl` for links, `remindHours`. |
|
||||
| `devops` | `{"users": ["gitlab-user"], "rules": ["R9", "R13"]}`: who owns deploy setup. A `bad` or `todo` finding that cites one of `rules` (default R9, R13) or points at a CI file, Dockerfile, compose file or manifest tags them, once until the deploy findings go away. |
|
||||
|
||||
### `board.json`
|
||||
|
||||
|
||||
150
board/board.css
150
board/board.css
@@ -5,9 +5,12 @@
|
||||
--teal: #1F6F78;
|
||||
--teal-deep: #174F56;
|
||||
--buoy: #E8A33D;
|
||||
/* Boat slots on the water: a boat's width and one slot row's height. */
|
||||
/* Boat slots on the water: a boat's width and one slot row's height.
|
||||
board.js may shrink --slot-h / --boat-w / --hull-* so the harbour fits the viewport. */
|
||||
--boat-w: 120px;
|
||||
--slot-h: 176px;
|
||||
--hull-w: 96px;
|
||||
--hull-h: 72px;
|
||||
--paper: #F6F2EA;
|
||||
--sand: #E8D9BB;
|
||||
--quay: #B98B5E;
|
||||
@@ -18,8 +21,8 @@
|
||||
--sans: 'Atkinson Hyperlegible', system-ui, sans-serif;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; min-height: 100%; }
|
||||
body { background: var(--water-b); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
|
||||
html, body { margin: 0; height: 100%; }
|
||||
body { background: var(--water-b); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
|
||||
a { color: var(--teal); }
|
||||
a:hover { color: var(--teal-deep); }
|
||||
button { font: inherit; color: inherit; }
|
||||
@@ -43,9 +46,9 @@ button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px soli
|
||||
@keyframes beam { 0%,100% { opacity: .15 } 50% { opacity: .75 } }
|
||||
@keyframes arrive { from { transform: translateX(-70px); opacity: 0 } to { transform: none; opacity: 1 } }
|
||||
|
||||
/* Layout: water on the left, the shore on the right. */
|
||||
.harbour { position: relative; display: flex; min-height: 100vh; overflow: clip; background: linear-gradient(90deg, var(--water-a) 0%, var(--water-b) 48%, var(--water-c) 100%); }
|
||||
.water { position: relative; flex: 1 1 auto; min-width: 0; padding: 22px 0 96px 36px; display: flex; flex-direction: column; gap: 22px; }
|
||||
/* Layout: water on the left, the shore on the right. Locked to the viewport so the harbour never scrolls. */
|
||||
.harbour { position: relative; display: flex; height: 100%; height: 100dvh; max-height: 100dvh; overflow: clip; background: linear-gradient(90deg, var(--water-a) 0%, var(--water-b) 48%, var(--water-c) 100%); }
|
||||
.water { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; height: 100%; padding: 16px 0 20px 36px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
|
||||
.sea { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
|
||||
.sea .cloud { position: absolute; left: 0; width: 420px; height: 200px; border-radius: 50%; background: radial-gradient(closest-side, rgba(23,43,51,.07), transparent); animation: cloud linear infinite; }
|
||||
.sea .wave { position: absolute; left: 0; animation: drift linear infinite; }
|
||||
@@ -54,53 +57,57 @@ button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px soli
|
||||
.sea .gull { position: absolute; left: 0; animation: glide linear infinite; }
|
||||
.sea .gull svg { animation: flap .7s ease-in-out infinite; transform-origin: 50% 60%; }
|
||||
|
||||
.brand { position: relative; display: flex; align-items: center; gap: 10px; }
|
||||
.brand { position: relative; display: flex; align-items: center; gap: 10px; flex: none; }
|
||||
.brand span { font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: -.5px; }
|
||||
.brand-me { display: none; margin-left: auto; }
|
||||
.toolbar { display: none; }
|
||||
h1 { position: relative; margin: 0; font-family: var(--serif); font-weight: 600; font-size: 46px; line-height: 1.05; letter-spacing: -1px; }
|
||||
.empty { position: relative; margin: 0; max-width: 520px; font-size: 17px; line-height: 1.5; }
|
||||
.legend { position: relative; margin: -8px 0 0; max-width: 520px; font-size: 13px; line-height: 1.4; color: #1E4A51; opacity: .78; }
|
||||
.stale { position: relative; margin: 0; align-self: flex-start; font-size: 14px; background: rgba(255,253,248,.85); border-radius: 999px; padding: 6px 14px; }
|
||||
h1 { position: relative; margin: 0; font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 4.6vh, 46px); line-height: 1.05; letter-spacing: -1px; flex: none; }
|
||||
.empty { position: relative; margin: 0; max-width: 520px; font-size: 17px; line-height: 1.5; flex: none; }
|
||||
.legend { position: relative; margin: -4px 0 0; max-width: 520px; font-size: 13px; line-height: 1.4; color: #1E4A51; opacity: .78; flex: none; }
|
||||
.stale { position: relative; margin: 0; align-self: flex-start; font-size: 14px; background: rgba(255,253,248,.85); border-radius: 999px; padding: 6px 14px; flex: none; }
|
||||
.scrim { display: none; }
|
||||
|
||||
main { position: relative; display: flex; flex-direction: column; }
|
||||
.lane { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 34px 0 12px; }
|
||||
.lane:first-child { padding-top: 8px; }
|
||||
.lane.has-break { padding-bottom: 34px; }
|
||||
.lane h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 24px; }
|
||||
main { position: relative; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
|
||||
.lane { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 10px 0 8px; flex: 1 1 0; min-height: 0; justify-content: flex-start; }
|
||||
.lane:first-child { padding-top: 4px; }
|
||||
.lane.has-break { padding-bottom: 22px; }
|
||||
.lane h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: clamp(18px, 2.4vh, 24px); flex: none; }
|
||||
.quay { position: absolute; top: 10px; bottom: 12px; right: 22px; width: 46px; background: var(--quay); background-image: repeating-linear-gradient(180deg, transparent 0 20px, #9C7148 20px 23px); box-shadow: -6px 6px 0 rgba(23,43,51,.08); }
|
||||
.pilings { position: absolute; top: 10px; bottom: 12px; right: 70px; width: 10px; background-image: radial-gradient(circle, #6E4E30 4px, transparent 4.6px); background-size: 10px 52px; background-position: 0 14px; }
|
||||
.zones { display: grid; grid-template-columns: minmax(0,6fr) minmax(0,4fr) minmax(0,3fr); gap: 22px; height: calc(42px + 2 * var(--slot-h) + 6px); padding-right: 92px; transition: grid-template-columns 1.2s cubic-bezier(.42,0,.28,1); }
|
||||
.zone { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
|
||||
.zones { display: grid; grid-template-columns: minmax(0,6fr) minmax(0,4fr) minmax(0,3fr); gap: 22px; height: calc(36px + 2 * var(--slot-h) + 4px); max-height: 100%; padding-right: 92px; transition: grid-template-columns 1.2s cubic-bezier(.42,0,.28,1); min-height: 0; }
|
||||
.zone { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; }
|
||||
.zone .floats { position: absolute; top: -44px; bottom: -14px; left: -14px; width: 8px; background-image: radial-gradient(circle, #FFFDF8 3px, transparent 3.6px); background-size: 8px 22px; opacity: .9; }
|
||||
.zone-label { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: #1E4A51; background: rgba(255,253,248,.72); border-radius: 999px; padding: 5px 8px 5px 14px; }
|
||||
.zone-label { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: #1E4A51; background: rgba(255,253,248,.72); border-radius: 999px; padding: 4px 8px 4px 12px; flex: none; }
|
||||
.zone-label .n { min-width: 22px; height: 22px; border-radius: 999px; background: rgba(23,43,51,.08); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
|
||||
.zone-label .n.hot { background: var(--buoy); }
|
||||
/* Two rows of boat slots per lane; board.js sets the slot columns (they overlap when a column is
|
||||
narrow) and the zone widths, which transition. */
|
||||
.boats { display: grid; grid-template-columns: var(--boat-w); grid-template-rows: repeat(2, var(--slot-h)); grid-auto-flow: row; gap: 6px 0; align-items: start; }
|
||||
narrow) and the zone widths, which transition. It also shrinks --slot-h to fit the viewport. */
|
||||
.boats { display: grid; grid-template-columns: var(--boat-w); grid-template-rows: repeat(2, var(--slot-h)); grid-auto-flow: row; gap: 4px 0; align-items: start; min-height: 0; }
|
||||
.zone.beres .boats { justify-content: end; }
|
||||
.breakwater { position: absolute; left: 84px; right: 0; bottom: -14px; height: 28px; z-index: 2; border-radius: 14px 0 0 14px; background-color: #A89E8C; background-image: radial-gradient(ellipse 11px 9px at 50% 45%, #C9C0AE 92%, transparent 100%); background-size: 26px 28px; box-shadow: 0 6px 0 rgba(23,43,51,.08); }
|
||||
.breakwater { position: absolute; left: 84px; right: 0; bottom: -10px; height: 24px; z-index: 2; border-radius: 14px 0 0 14px; background-color: #A89E8C; background-image: radial-gradient(ellipse 11px 9px at 50% 45%, #C9C0AE 92%, transparent 100%); background-size: 26px 24px; box-shadow: 0 6px 0 rgba(23,43,51,.08); }
|
||||
.breakwater svg { position: absolute; left: -2px; top: -44px; overflow: visible; }
|
||||
.breakwater .beam { animation: beam 2.4s ease-in-out infinite; }
|
||||
|
||||
/* Boats */
|
||||
.boat { position: relative; background: transparent; border: 0; border-radius: 18px; padding: 4px 2px 8px; width: var(--boat-w); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
|
||||
.boat { position: relative; background: transparent; border: 0; border-radius: 18px; padding: 2px 2px 4px; width: var(--boat-w); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
|
||||
.boat.dim { opacity: .42; }
|
||||
.boat.needs:not(.dim) .chip { box-shadow: 0 0 0 2px var(--buoy); }
|
||||
.boat.done { opacity: .8; }
|
||||
.boat .hull { display: block; position: relative; width: 96px; height: 72px; animation: float 4.6s ease-in-out infinite; transform-origin: 50% 85%; transition: filter .2s ease; }
|
||||
.boat .hull { display: block; position: relative; width: var(--hull-w); height: var(--hull-h); animation: float 4.6s ease-in-out infinite; transform-origin: 50% 85%; transition: filter .2s ease; }
|
||||
.boat .hull svg { width: 100%; height: 100%; display: block; }
|
||||
.boat.done .hull { animation-name: calm; animation-duration: 6s; }
|
||||
.boat .flag { animation: flag 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: left center; }
|
||||
.boat .shade { display: block; width: 84px; height: 8px; margin-top: -10px; border-radius: 50%; background: rgba(23,43,51,.16); animation: shadow 4.6s ease-in-out infinite; }
|
||||
.boat .shade { display: block; width: calc(var(--hull-w) * 0.875); height: 8px; margin-top: -10px; border-radius: 50%; background: rgba(23,43,51,.16); animation: shadow 4.6s ease-in-out infinite; }
|
||||
.boat.picked .shade { background: rgba(255,255,255,.95); }
|
||||
.boat:hover .hull { filter: brightness(1.06); animation-duration: 2.2s; }
|
||||
.boat .chip { font-size: 13px; font-weight: 700; line-height: 1.2; text-align: center; padding: 4px 10px; border-radius: 10px; background: rgba(255,253,248,.82); overflow-wrap: anywhere; }
|
||||
.boat .chip { font-size: 13px; font-weight: 700; line-height: 1.2; text-align: center; padding: 3px 8px; border-radius: 10px; background: rgba(255,253,248,.82); overflow-wrap: anywhere; }
|
||||
.boat.picked .chip { background: var(--teal); color: #fff; box-shadow: none; }
|
||||
.boat .boat-title { max-width: 100%; font-size: 11px; line-height: 1.25; text-align: center; color: #1E4A51; opacity: .9; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
|
||||
.boat.picked .boat-title { color: var(--ink); opacity: 1; }
|
||||
.boat .marks { display: flex; align-items: center; justify-content: center; gap: 8px; height: 16px; }
|
||||
.boat .marks { display: flex; align-items: center; justify-content: center; gap: 8px; height: 14px; }
|
||||
/* Short viewports: drop the title so a shrunk slot still holds the hull + chip. */
|
||||
html[data-boat-compact="1"] .boat .boat-title { display: none; }
|
||||
html[data-boat-compact="1"] .boat .marks { height: 12px; }
|
||||
.boat .anchor { position: absolute; left: -10px; top: 40px; animation: sway 3s ease-in-out infinite; transform-origin: 18px 0; }
|
||||
.boat .buoy { position: absolute; right: -6px; top: 46px; width: 18px; height: 22px; animation: float 3.4s ease-in-out infinite; }
|
||||
.boat .buoy .ring { position: absolute; left: 1px; top: 7px; width: 16px; height: 16px; border-radius: 50%; background: var(--buoy); animation: pulse 1.8s ease-out infinite; }
|
||||
@@ -113,9 +120,9 @@ main { position: relative; display: flex; flex-direction: column; }
|
||||
.dots i:nth-child(3) { animation-delay: .4s; }
|
||||
|
||||
/* Shore */
|
||||
/* Desktop: the shore stays put at screen height and only its detail scrolls, so the harbour never moves with it. */
|
||||
.shore { position: sticky; top: 0; align-self: flex-start; z-index: 1; flex: 0 0 420px; height: 100vh; height: 100dvh; background-color: var(--paper); background-image: radial-gradient(#E2D8C6 1.2px, transparent 1.4px); background-size: 24px 24px; }
|
||||
.shore-inner { position: relative; height: 100%; display: flex; flex-direction: column; gap: 28px; padding: 22px 0 0 30px; }
|
||||
/* Desktop: the shore matches the harbour height; only its detail pane scrolls. */
|
||||
.shore { position: relative; align-self: stretch; z-index: 1; flex: 0 0 420px; min-height: 0; background-color: var(--paper); background-image: radial-gradient(#E2D8C6 1.2px, transparent 1.4px); background-size: 24px 24px; }
|
||||
.shore-inner { position: relative; height: 100%; display: flex; flex-direction: column; gap: 20px; padding: 18px 0 0 30px; min-height: 0; }
|
||||
.shore-inner aside { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 28px 32px 0; scrollbar-gutter: stable; }
|
||||
.shore .edge { position: absolute; left: -44px; top: 0; width: 64px; height: 100%; pointer-events: none; }
|
||||
.shore .edge .foam { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; vector-effect: non-scaling-stroke; animation: foam 5s ease-in-out infinite; }
|
||||
@@ -165,6 +172,9 @@ aside { min-width: 0; }
|
||||
.foot li span:first-child { color: var(--ink-soft); }
|
||||
.foot .open { font-weight: 700; display: flex; align-items: center; gap: 6px; padding: 4px 0; white-space: nowrap; }
|
||||
.stamp { margin: -8px 0 0; font-size: 12px; color: var(--ink-soft); }
|
||||
/* Detail extras sit in .more; give them their own gap so .stamp's pull-up doesn't overlap evidence. */
|
||||
.card .more { display: flex; flex-direction: column; gap: 16px; }
|
||||
.card .more > .stamp { margin-top: 0; }
|
||||
.todo-list { display: flex; flex-direction: column; gap: 12px; }
|
||||
.todo-item { text-align: left; border: 0; cursor: pointer; background: #FBEBD0; border-radius: 18px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
|
||||
.todo-item .age { flex: none; font-size: 13px; color: #5C4310; }
|
||||
@@ -179,34 +189,39 @@ aside { min-width: 0; }
|
||||
.shore-inner aside, .shore-top { padding-right: 20px; }
|
||||
.water { padding-left: 24px; }
|
||||
.zones { gap: 14px; }
|
||||
:root { --boat-w: 104px; }
|
||||
:root { --boat-w: 104px; --hull-w: 84px; --hull-h: 63px; }
|
||||
}
|
||||
|
||||
/* Phone: one harbour scene + bottom sheet from the shore. */
|
||||
/* Phone: one harbour scene + bottom sheet from the shore. Locked to the viewport like desktop. */
|
||||
@media (max-width: 899px) {
|
||||
html, body { height: 100%; overflow: hidden; }
|
||||
body.sheet-open { overflow: hidden; }
|
||||
.harbour {
|
||||
display: block;
|
||||
min-height: 100vh;
|
||||
min-height: 100dvh;
|
||||
height: 100%;
|
||||
height: 100dvh;
|
||||
max-height: 100dvh;
|
||||
min-height: 0;
|
||||
background: linear-gradient(180deg, var(--water-a) 0%, var(--water-b) 55%, var(--water-c) 100%);
|
||||
overflow: visible;
|
||||
overflow: hidden;
|
||||
}
|
||||
.water {
|
||||
padding: 14px 16px 0;
|
||||
gap: 12px;
|
||||
min-height: 100vh;
|
||||
min-height: 100dvh;
|
||||
padding: 10px 16px 0;
|
||||
gap: 8px;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.brand { padding-top: env(safe-area-inset-top); }
|
||||
.brand { padding-top: env(safe-area-inset-top); flex: none; }
|
||||
.brand span { font-size: 22px; }
|
||||
.brand { width: 100%; }
|
||||
.brand-me { display: block; margin: 0 0 0 auto; }
|
||||
.brand-me .avatar { width: 40px; height: 40px; }
|
||||
h1 { font-size: 28px; letter-spacing: -.5px; max-width: 18ch; }
|
||||
h1 { font-size: clamp(22px, 7vw, 28px); letter-spacing: -.5px; max-width: 18ch; flex: none; }
|
||||
.legend { display: none; }
|
||||
.empty { font-size: 15px; }
|
||||
.empty { font-size: 15px; flex: none; }
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
@@ -214,6 +229,7 @@ aside { min-width: 0; }
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
position: relative;
|
||||
flex: none;
|
||||
}
|
||||
.toolbar[hidden] { display: none !important; }
|
||||
.dermaga {
|
||||
@@ -253,21 +269,30 @@ aside { min-width: 0; }
|
||||
padding: 0;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
justify-content: stretch;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.zones { height: auto; max-height: none; }
|
||||
:root, html {
|
||||
--boat-w: 108px;
|
||||
--slot-h: 176px;
|
||||
--hull-w: 88px;
|
||||
--hull-h: 66px;
|
||||
}
|
||||
html[data-boat-compact] .boat .boat-title { display: none; }
|
||||
/* Full-bleed harbour so the camera pan clips at the screen edge, not the padded water. */
|
||||
main#lanes {
|
||||
position: relative;
|
||||
flex: 1 1 auto;
|
||||
min-height: 280px;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0 -16px;
|
||||
width: calc(100% + 32px);
|
||||
overflow: hidden;
|
||||
}
|
||||
.phone-harbour { overflow: visible; }
|
||||
.phone-harbour { overflow: hidden; min-height: 0; }
|
||||
/* Dual-scene camera pan: both harbours stay mounted so a reverse tap can retarget. */
|
||||
main#lanes.lane-panning {
|
||||
display: block;
|
||||
@@ -282,58 +307,62 @@ aside { min-width: 0; }
|
||||
}
|
||||
.stale { margin: 0 16px 12px; align-self: center; }
|
||||
|
||||
/* One water plane: Dicek high, Siap mid, Beres near the sand. */
|
||||
/* One water plane: Dicek high, Siap mid, Beres near the sand. Fills leftover height; boats scale via --hull-*. */
|
||||
.harbour-scene {
|
||||
position: relative;
|
||||
flex: 1 1 auto;
|
||||
min-height: 300px;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
display: grid;
|
||||
grid-template-rows: 1fr 1.15fr 1fr auto;
|
||||
padding: 4px 16px 0;
|
||||
padding: 2px 16px 0;
|
||||
}
|
||||
.band {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.band-cek { align-items: flex-end; padding-bottom: 4px; }
|
||||
.band-cek { align-items: flex-end; padding-bottom: 2px; }
|
||||
.band-siap { align-items: center; }
|
||||
.band-beres { align-items: flex-start; padding-top: 6px; }
|
||||
.band-beres { align-items: flex-start; padding-top: 2px; }
|
||||
.band .boats {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
gap: 4px 14px;
|
||||
gap: 2px 10px;
|
||||
width: 100%;
|
||||
overflow: visible;
|
||||
overflow: hidden;
|
||||
padding: 0 4px;
|
||||
margin: 0;
|
||||
}
|
||||
.beach {
|
||||
height: 28px;
|
||||
margin: 8px -16px 0;
|
||||
height: 22px;
|
||||
margin: 4px -16px 0;
|
||||
width: calc(100% + 32px);
|
||||
border-radius: 40% 40% 0 0 / 100% 100% 0 0;
|
||||
background: linear-gradient(180deg, #E4D4B0 0%, var(--sand) 55%, #DFCDA3 100%);
|
||||
box-shadow: 0 -8px 18px rgba(23, 43, 51, .06);
|
||||
flex: none;
|
||||
}
|
||||
.boat {
|
||||
flex: 0 0 auto;
|
||||
width: 108px;
|
||||
width: var(--boat-w);
|
||||
min-height: 0;
|
||||
padding: 4px 2px 2px;
|
||||
gap: 2px;
|
||||
padding: 2px 2px 0;
|
||||
gap: 1px;
|
||||
}
|
||||
.boat .hull { width: 88px; height: 66px; }
|
||||
.boat .hull svg { width: 88px; height: 66px; }
|
||||
.boat .hull { width: var(--hull-w); height: var(--hull-h); }
|
||||
.boat .hull svg { width: 100%; height: 100%; }
|
||||
.boat .boat-title { display: none; }
|
||||
.boat .chip {
|
||||
font-size: 12px;
|
||||
padding: 5px 10px;
|
||||
padding: 4px 8px;
|
||||
background: rgba(255, 253, 248, .88);
|
||||
box-shadow: 0 4px 12px rgba(23, 43, 51, .08);
|
||||
}
|
||||
@@ -451,7 +480,6 @@ aside { min-width: 0; }
|
||||
.actions .buttons.side .act { flex: 1 1 0; min-height: 48px; border-radius: 16px; }
|
||||
.release-row { flex-direction: column; }
|
||||
.release-row .act { width: 100%; min-height: 52px; }
|
||||
.card .more { display: flex; flex-direction: column; gap: 16px; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
@@ -459,7 +487,7 @@ aside { min-width: 0; }
|
||||
}
|
||||
|
||||
/* Gate and rubric pages */
|
||||
.page-gate, .page-rubric { background: var(--paper); min-height: 100vh; color: var(--ink); font-family: var(--sans); }
|
||||
body.page-gate, body.page-rubric { height: auto; overflow: auto; background: var(--paper); min-height: 100vh; color: var(--ink); font-family: var(--sans); }
|
||||
.page-gate main { max-width: 440px; margin: 0 auto; padding: 16vh 20px 40px; display: flex; flex-direction: column; gap: 18px; }
|
||||
.page-gate .brand { margin-bottom: 8px; }
|
||||
.page-gate .brand span { font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: -.5px; }
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
const META = {
|
||||
checking: { zone: 'cek', flag: '#7FA9C4', aria: 'sedang dicek', word: 'Dicek dulu', bg: '#E1EDF1', ink: '#1F4B5E', icon: 'dots' },
|
||||
fix: { zone: 'cek', flag: '#D9654B', aria: 'ditahan reviewer', word: 'Tahan', bg: '#F8DDD5', ink: '#9A2E1A', icon: 'stop' },
|
||||
blocked: { zone: 'cek', flag: '#9AA5A8', aria: 'nunggu MR lain', word: 'Nunggu', bg: '#EEF1F0', ink: '#3E4E53', icon: 'link' },
|
||||
blocked: { zone: 'cek', flag: '#9AA5A8', aria: 'nunggu, lihat alasannya', word: 'Nunggu', bg: '#EEF1F0', ink: '#3E4E53', icon: 'wait' },
|
||||
manual: { zone: 'cek', flag: '#B7AE9C', aria: 'perlu dicek manual', word: 'Cek manual', bg: '#F1EBDF', ink: '#5C5440', icon: 'pause' },
|
||||
parked: { zone: 'cek', flag: '#B7AE9C', aria: 'ditunda', word: 'Ditunda', bg: '#F1EBDF', ink: '#5C5440', icon: 'pause' },
|
||||
ready: { zone: 'siap', flag: '#E8A33D', aria: 'aman, nunggu gas', word: 'Aman', bg: '#DDEFE5', ink: '#2E7A4E', icon: 'ok' },
|
||||
@@ -28,7 +28,7 @@
|
||||
const ICON = {
|
||||
ok: '<svg width="26" height="26" viewBox="0 0 16 16"><path d="M3 8.5l3 3 7-7" fill="none" stroke="#FFFFFF" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
||||
stop: '<svg width="26" height="26" viewBox="0 0 18 18"><path d="M9 3v12M4.5 10.5a4.5 4.5 0 0 0 9 0M6 6h6" fill="none" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round"/><circle cx="9" cy="3" r="1.6" fill="#FFFFFF"/></svg>',
|
||||
link: '<svg width="26" height="26" viewBox="0 0 16 16"><path d="M7 9.5l2-2M5.5 11.5l-1 1a2.1 2.1 0 0 1-3-3l2-2a2.1 2.1 0 0 1 3 0M10.5 4.5l1-1a2.1 2.1 0 0 1 3 3l-2 2a2.1 2.1 0 0 1-3 0" fill="none" stroke="#FFFFFF" stroke-width="1.8" stroke-linecap="round"/></svg>',
|
||||
wait: '<svg width="26" height="26" viewBox="0 0 16 16"><path d="M4 2h8M4 14h8M5 2c0 3 6 3 6 6s-6 3-6 6M11 2c0 3-6 3-6 6s6 3 6 6" fill="none" stroke="#FFFFFF" stroke-width="1.6" stroke-linecap="round"/></svg>',
|
||||
pause: '<svg width="24" height="24" viewBox="0 0 16 16"><path d="M5.5 3.5v9M10.5 3.5v9" stroke="#FFFFFF" stroke-width="2.4" stroke-linecap="round"/></svg>',
|
||||
dots: '<span class="dots"><i></i><i></i><i></i></span>',
|
||||
x: '<svg width="22" height="22" viewBox="0 0 16 16"><path d="M4 4l8 8M12 4l-8 8" stroke="#FFFFFF" stroke-width="2.4" stroke-linecap="round"/></svg>',
|
||||
@@ -144,7 +144,8 @@
|
||||
if (title) b.append(el('span', { class: 'boat-title' }, title));
|
||||
const marks = el('span', { class: 'marks', 'aria-hidden': 'true' });
|
||||
if (a.status === 'checking' || a.status === 'sailing' || a.status === 'gas') marks.innerHTML = ICON.dots;
|
||||
if (a.status === 'blocked') marks.innerHTML = '<svg width="16" height="16" viewBox="0 0 16 16"><path d="M7 9.5l2-2M5.5 11.5l-1 1a2.1 2.1 0 0 1-3-3l2-2a2.1 2.1 0 0 1 3 0M10.5 4.5l1-1a2.1 2.1 0 0 1 3 3l-2 2a2.1 2.1 0 0 1-3 0" fill="none" stroke="#3E4E53" stroke-width="1.8" stroke-linecap="round"/></svg>';
|
||||
// Waiting can be a pipeline or another MR, so the mark is an hourglass, not a link.
|
||||
if (a.status === 'blocked') marks.innerHTML = '<svg width="16" height="16" viewBox="0 0 16 16"><path d="M4 2h8M4 14h8M5 2c0 3 6 3 6 6s-6 3-6 6M11 2c0 3-6 3-6 6s6 3 6 6" fill="none" stroke="#3E4E53" stroke-width="1.6" stroke-linecap="round"/></svg>';
|
||||
b.append(marks);
|
||||
return b;
|
||||
}
|
||||
@@ -235,16 +236,85 @@
|
||||
|
||||
const beresWidth = (boatW) => BERES_PER_ROW * boatW + (BERES_PER_ROW - 1) * SLOT_GAP;
|
||||
|
||||
// Shrink slot and boat sizes so every lane / phone scene fits inside the viewport.
|
||||
const SLOT_MAX = 176;
|
||||
const SLOT_MIN = 100;
|
||||
const BOAT_NATURAL = 158; // hull + chip + title + marks at full size (desktop)
|
||||
const PHONE_BOAT = 112; // hull + chip + marks at phone defaults
|
||||
function clearFitVars(root) {
|
||||
root.style.removeProperty('--slot-h');
|
||||
root.style.removeProperty('--boat-w');
|
||||
root.style.removeProperty('--hull-w');
|
||||
root.style.removeProperty('--hull-h');
|
||||
delete root.dataset.boatCompact;
|
||||
}
|
||||
function applyBoatScale(root, scale, baseBoat, baseHullW, baseHullH) {
|
||||
if (scale >= 0.995) return;
|
||||
root.style.setProperty('--boat-w', `${Math.max(64, Math.round(baseBoat * scale))}px`);
|
||||
root.style.setProperty('--hull-w', `${Math.max(48, Math.round(baseHullW * scale))}px`);
|
||||
root.style.setProperty('--hull-h', `${Math.max(36, Math.round(baseHullH * scale))}px`);
|
||||
}
|
||||
function layoutPhoneFit(root) {
|
||||
const scene = document.querySelector('.harbour-scene');
|
||||
if (!scene) {
|
||||
clearFitVars(root);
|
||||
return;
|
||||
}
|
||||
clearFitVars(root);
|
||||
const baseBoat = parseFloat(getComputedStyle(root).getPropertyValue('--boat-w')) || 108;
|
||||
const baseHullW = parseFloat(getComputedStyle(root).getPropertyValue('--hull-w')) || 88;
|
||||
const baseHullH = parseFloat(getComputedStyle(root).getPropertyValue('--hull-h')) || 66;
|
||||
const beach = scene.querySelector('.beach');
|
||||
const avail = scene.clientHeight - (beach ? beach.offsetHeight : 22);
|
||||
if (avail < 60) return;
|
||||
// Grid rows are 1fr / 1.15fr / 1fr — size boats to the mid band.
|
||||
const midBand = avail * (1.15 / 3.15);
|
||||
const scale = Math.min(1, Math.max(0.55, (midBand - 6) / PHONE_BOAT));
|
||||
applyBoatScale(root, scale, baseBoat, baseHullW, baseHullH);
|
||||
}
|
||||
function layoutFit() {
|
||||
const root = document.documentElement;
|
||||
if (phone.matches) {
|
||||
layoutPhoneFit(root);
|
||||
return;
|
||||
}
|
||||
const main = $('lanes');
|
||||
const n = main.querySelectorAll('.lane').length;
|
||||
if (!n) {
|
||||
clearFitVars(root);
|
||||
return;
|
||||
}
|
||||
// Read the stylesheet defaults (after clearing any previous inline shrink) so a roomy
|
||||
// window can grow back to full size, and narrow-laptop media rules still apply.
|
||||
clearFitVars(root);
|
||||
const baseBoat = parseFloat(getComputedStyle(root).getPropertyValue('--boat-w')) || 120;
|
||||
const baseHullW = parseFloat(getComputedStyle(root).getPropertyValue('--hull-w')) || 96;
|
||||
const baseHullH = parseFloat(getComputedStyle(root).getPropertyValue('--hull-h')) || 72;
|
||||
const avail = main.clientHeight;
|
||||
if (avail < 80) return;
|
||||
// Per lane: h2 + paddings + zone-label row + boat-row gap, then two slot rows.
|
||||
const laneChrome = 28 + 26 + 36 + 4;
|
||||
const slot = Math.max(SLOT_MIN, Math.min(SLOT_MAX, Math.floor((avail / n - laneChrome) / ROWS)));
|
||||
root.style.setProperty('--slot-h', `${slot}px`);
|
||||
// When the slot is shorter than a full boat, scale the boat and drop the title.
|
||||
const boatH = Math.min(BOAT_NATURAL, slot - 4);
|
||||
const scale = Math.min(1, boatH / BOAT_NATURAL);
|
||||
root.dataset.boatCompact = scale < 0.92 ? '1' : '0';
|
||||
applyBoatScale(root, scale, baseBoat, baseHullW, baseHullH);
|
||||
}
|
||||
|
||||
// Places the boats already in `rows` (one grid per lane) and sizes the columns.
|
||||
function layoutColumns() {
|
||||
const rows = [...$('lanes').querySelectorAll('.zones')];
|
||||
if (!rows.length) return;
|
||||
if (phone.matches) {
|
||||
layoutFit();
|
||||
for (const r of rows) r.style.gridTemplateColumns = '';
|
||||
for (const b of $('lanes').querySelectorAll('.boats')) b.style.gridTemplateColumns = '';
|
||||
state.cols = null;
|
||||
return;
|
||||
}
|
||||
if (!rows.length) return;
|
||||
layoutFit();
|
||||
const { total, boatW } = measure(rows[0]);
|
||||
const count = (z) => Math.max(1, ...rows.map((r) => r.children[z].querySelector('.boats').childElementCount));
|
||||
const beres = beresWidth(boatW);
|
||||
@@ -360,6 +430,7 @@
|
||||
keep.style.transform = '';
|
||||
main.classList.remove('lane-panning');
|
||||
main.style.height = '';
|
||||
layoutFit();
|
||||
}
|
||||
function panPhoneHarbour(main, dir) {
|
||||
const target = state.lane;
|
||||
@@ -371,6 +442,7 @@
|
||||
if (calm.matches) {
|
||||
main.classList.remove('lane-panning');
|
||||
main.replaceChildren(buildPhoneScene(target));
|
||||
layoutFit();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -495,9 +567,11 @@
|
||||
main.classList.remove('lane-panning');
|
||||
if (!state.lane) {
|
||||
main.replaceChildren();
|
||||
clearFitVars(document.documentElement);
|
||||
return;
|
||||
}
|
||||
main.replaceChildren(buildPhoneScene(state.lane));
|
||||
layoutFit();
|
||||
}
|
||||
|
||||
let drawnLanes = '';
|
||||
@@ -571,7 +645,8 @@
|
||||
}
|
||||
for (const b of main.querySelectorAll('.boat[data-id]')) shown.add(b.dataset.id);
|
||||
// Boats take their new slots at once; the columns then widen or narrow through their
|
||||
// transition, and every boat glides from where it was.
|
||||
// transition, and every boat glides from where it was. layoutColumns fits height first
|
||||
// so the shrunk boat width is what the columns measure.
|
||||
layoutColumns();
|
||||
sail(new Map([...before].map(([id, b]) => [id, b.rect])));
|
||||
depart(before, shown);
|
||||
|
||||
@@ -130,3 +130,6 @@ Detailed when it starts. Known shape: `depends_on` stored as data; a NO-GO propa
|
||||
- 2026-11-06: fixed two-row lanes; Beres keeps four boats first-in-first-out; only Dicek and Siap gas resize.
|
||||
- 2026-11-06: v0.1 released as open source (AGPL-3.0); one Docker image, configuration in `LABUH_HOME`.
|
||||
- 2026-11-06: the hosted reviewer runs in its own container without GitLab tokens, since Codex's sandbox cannot run inside Docker (Sen chose this over hosting without Docker).
|
||||
- 2026-11-09: deploy setup (CI, Dockerfiles, compose, manifests) belongs to devops (rubric R13). Deploy findings tag the `devops` users from hub.json instead of asking the developer to change CI; the reviewer never suggests CI edits to the developer (Sen, after lti-api !1380).
|
||||
- 2026-11-09: a turn the model provider fails (Codex `turn.status: failed`, e.g. 9router "high demand") is not a rejected verdict. The Hub throws `ReviewerUnavailable`, sends nothing back to the model, and the queue waits 2, 4, 8, 16 and 32 minutes before giving up with a comment that says the model could not be reached (lti-api !1388, lti-web-client !859).
|
||||
- 2026-11-09: a `go` held at `waiting` only by the pipeline hard rule becomes `go` on the next poll once the reviewed commit's pipeline is `success` (same commit, no new review; verdict note edited, "siap gas" notified). A `waiting` the model chose itself is never promoted. The board's waiting label no longer claims "nunggu MR lain" (lti-api !1388).
|
||||
|
||||
@@ -50,3 +50,8 @@ Breaks: a rerun changes data again, double counts, or produces a different resul
|
||||
## R12 · Corrections check what they overwrite
|
||||
A data correction writes only rows it has identified by stable business keys (document number, code), and checks that each value it replaces is still the expected old value before writing (compare first, or `WHERE value = old`).
|
||||
`todo` when it overwrites without checking the old value, or when it relies on a hardcoded database id (user, company, warehouse, actor) that is not resolved or checked in the target environment. Breaks: a hardcoded id decides which rows are changed and is not checked against the target environment.
|
||||
|
||||
## R13 · Deploy setup belongs to devops
|
||||
How the application is built, shipped and run is owned by devops, not by the MR's developer: CI files, Dockerfiles, compose files, deploy scripts and manifests, runners, registries, servers and CI variables. Cite R13 on every `bad` or `todo` finding about them, in addition to the rule that decides its kind (a deploy order that breaks is still `bad` under R9). The text says what is wrong, never how to change the CI or deploy setup: devops is tagged and fixes it, and the developer should not edit deploy setup to pass review.
|
||||
When the MR itself changes deploy setup, add a `todo` citing R13 that devops must check that change, even when it looks right.
|
||||
Answers to mentions follow the same rule: deploy and CI questions go to devops; do not suggest CI edits to the developer.
|
||||
|
||||
@@ -19,6 +19,8 @@ export type TurnResult = {
|
||||
usage: TokenUsage | null;
|
||||
commands: Array<{ command: string; status: string }>;
|
||||
refused: Array<{ command: string; why: string }>;
|
||||
// Set when the turn ended `failed` (e.g. the model provider is overloaded): no answer exists.
|
||||
error: { message: string; info: unknown } | null;
|
||||
};
|
||||
|
||||
type Pending = { resolve: (v: any) => void; reject: (e: Error) => void };
|
||||
@@ -130,7 +132,7 @@ export class CodexClient {
|
||||
private state(turnId: string): TurnResult {
|
||||
let s = this.turnState.get(turnId);
|
||||
if (!s) {
|
||||
s = { finalText: '', usage: null, commands: [], refused: [] };
|
||||
s = { finalText: '', usage: null, commands: [], refused: [], error: null };
|
||||
this.turnState.set(turnId, s);
|
||||
}
|
||||
return s;
|
||||
@@ -147,6 +149,9 @@ export class CodexClient {
|
||||
} else if (method === 'turn/completed') {
|
||||
const turnId = params.turn.id;
|
||||
const s = this.state(turnId);
|
||||
if (params.turn.status === 'failed' || params.turn.error) {
|
||||
s.error = { message: String(params.turn.error?.message ?? 'turn failed'), info: params.turn.error?.codexErrorInfo ?? null };
|
||||
}
|
||||
if (!s.finalText) {
|
||||
const last = [...(params.turn.items ?? [])].reverse().find((i: any) => i.type === 'agentMessage');
|
||||
if (last) s.finalText = last.text;
|
||||
|
||||
@@ -56,6 +56,9 @@ export type Finding = { kind: 'bad' | 'ok' | 'todo'; text: string; evidence: Evi
|
||||
export type Verdict = { verdict: 'go' | 'no_go' | 'waiting'; reason: string; findings: Finding[]; post_deploy: Array<{ text: string; evidence: Evidence[] }> };
|
||||
|
||||
export type ResolvedEvidence = Evidence & { label: string; url: string };
|
||||
// The hard rule that holds a `go` while the reviewed commit's pipeline is not green yet.
|
||||
export const PIPELINE_HOLD = 'go → waiting: pipeline is ';
|
||||
|
||||
export type Checked = {
|
||||
verdict: Verdict['verdict'];
|
||||
reason: string;
|
||||
@@ -63,6 +66,8 @@ export type Checked = {
|
||||
postDeploy: Array<{ text: string; evidence: ResolvedEvidence[] }>;
|
||||
dropped: string[];
|
||||
overrides: string[];
|
||||
// The model's own reason when a hard rule held its `go`, so the go can be restored later.
|
||||
heldReason?: string;
|
||||
};
|
||||
|
||||
export type Context = {
|
||||
@@ -82,6 +87,7 @@ export function rubricIds(markdown: string): Set<string> {
|
||||
|
||||
// Shape problems are the model's mistake: they are sent back once for a retry.
|
||||
export function shapeErrors(raw: string): { value: Verdict | null; errors: string[] } {
|
||||
if (!raw.trim()) return { value: null, errors: ['The answer is empty.'] };
|
||||
let v: any;
|
||||
try {
|
||||
v = JSON.parse(raw);
|
||||
@@ -158,10 +164,12 @@ export async function check(v: Verdict, ctx: Context): Promise<{ checked: Checke
|
||||
const overrides: string[] = [];
|
||||
let verdict = v.verdict;
|
||||
let reason = v.reason;
|
||||
let heldReason: string | undefined;
|
||||
if (verdict === 'go' && ctx.pipeline && ctx.pipeline.status !== 'success') {
|
||||
verdict = 'waiting';
|
||||
heldReason = reason;
|
||||
reason = 'Nunggu pipeline hijau.';
|
||||
overrides.push(`go → waiting: pipeline is ${ctx.pipeline.status}`);
|
||||
overrides.push(`${PIPELINE_HOLD}${ctx.pipeline.status}`);
|
||||
}
|
||||
return { checked: { verdict, reason, findings, postDeploy, dropped, overrides }, errors: [] };
|
||||
return { checked: { verdict, reason, findings, postDeploy, dropped, overrides, ...(heldReason ? { heldReason } : {}) }, errors: [] };
|
||||
}
|
||||
|
||||
@@ -132,7 +132,11 @@ function gitAccess(mr: MrInfo): { url: string; env: NodeJS.ProcessEnv } {
|
||||
|
||||
export async function checkout(mr: MrInfo, dir: string) {
|
||||
const access = gitAccess(mr);
|
||||
const git = (...args: string[]) => run('git', args, { cwd: dir, env: access.env, maxBuffer: 16 * 1024 * 1024 });
|
||||
// Git must never walk up from the checkout: an empty folder inside another repository (a
|
||||
// LABUH_HOME that is itself a git checkout) would otherwise send init, set-url and
|
||||
// `checkout --force` to that outer repository.
|
||||
const env = { ...access.env, GIT_CEILING_DIRECTORIES: path.dirname(path.resolve(dir)) };
|
||||
const git = (...args: string[]) => run('git', args, { cwd: dir, env, maxBuffer: 16 * 1024 * 1024 });
|
||||
try {
|
||||
const { stdout } = await git('rev-parse', 'HEAD');
|
||||
if (stdout.trim() === mr.sha) {
|
||||
@@ -303,6 +307,14 @@ export async function tokenCheck(kind: TokenKind, projects: string[]): Promise<{
|
||||
|
||||
export const botCheck = (projects: string[]) => tokenCheck('bot', projects);
|
||||
|
||||
// GitLab computes mergeability lazily and leaves it `unchecked` until someone asks; only a
|
||||
// Developer or above may ask, so this runs as the merge account. The answer usually lands a
|
||||
// few seconds later, so callers read the MR again on their next pass.
|
||||
export async function recheckMergeStatus(ref: MrRef): Promise<string | null> {
|
||||
const m = await tokenApi('merge', 'GET', `projects/${encodeURIComponent(ref.projectPath)}/merge_requests/${ref.iid}?with_merge_status_recheck=true`);
|
||||
return m.detailed_merge_status ?? null;
|
||||
}
|
||||
|
||||
// Merges exactly `sha`: GitLab refuses when the head moved, so Gas never merges an unreviewed commit.
|
||||
export async function mergeMr(ref: MrRef, sha: string): Promise<{ mergeSha: string | null; state: string }> {
|
||||
const m = await tokenApi('merge', 'PUT', `projects/${encodeURIComponent(ref.projectPath)}/merge_requests/${ref.iid}/merge`, { sha });
|
||||
|
||||
92
src/hub.ts
92
src/hub.ts
@@ -5,10 +5,10 @@ import path from 'node:path';
|
||||
import type { MrInfo, MrRef, MrSummary, Note } from './gitlab.ts';
|
||||
import type { TurnResult } from './codex.ts';
|
||||
import type { ReviewOutcome, Reviewer, Session } from './review.ts';
|
||||
import type { Checked } from './contract.ts';
|
||||
import { PIPELINE_HOLD, type Checked } from './contract.ts';
|
||||
import { Store, type Ajuan, type OutboxItem, type QueuedEvent, type Release, type ReleaseChanges } from './store.ts';
|
||||
import { latestTag, nextTag, releaseNotes, tagProblem } from './release.ts';
|
||||
import { verdictComment, errorComment, replyComment, rereviewComment, decisionComment, gasComment, closeComment, ajuanNote, VERDICT_MARKER, type Stamp } from './render.ts';
|
||||
import { verdictComment, errorComment, replyComment, rereviewComment, devopsComment, needsDevops, decisionComment, gasComment, closeComment, ajuanNote, VERDICT_MARKER, type Stamp } from './render.ts';
|
||||
|
||||
export type HubConfig = {
|
||||
mode: 'shadow' | 'live';
|
||||
@@ -24,10 +24,14 @@ export type HubConfig = {
|
||||
gas?: { mode: 'dry' | 'live'; graceSeconds: number };
|
||||
// Notifications to the approver (M3). Without a Telegram chat they only go to the Hub's log.
|
||||
notify?: { telegramChatId: string | null; boardUrl: string; remindHours: number };
|
||||
// Deploy setup belongs to devops: these GitLab users are tagged when a bad or todo finding
|
||||
// cites one of `rules` or points at a deploy file (CI, Dockerfile, compose, manifests).
|
||||
devops?: { users: string[]; rules?: string[] };
|
||||
};
|
||||
|
||||
type DeployBy = 'merge' | 'tag';
|
||||
|
||||
const DEVOPS_RULES = ['R9', 'R13'];
|
||||
const GAS_DEFAULT = { mode: 'dry' as const, graceSeconds: 15 };
|
||||
const NOTIFY_DEFAULT = { telegramChatId: null, boardUrl: 'http://localhost:4810', remindHours: 4 };
|
||||
// Pipelines are checked at most this often; a deploy that has not finished after DEPLOY_LIMIT is reported.
|
||||
@@ -43,6 +47,7 @@ export type Ports = {
|
||||
listNotes(ref: MrRef, afterId: number): Promise<Note[]>;
|
||||
postNote(ref: MrRef, body: string): Promise<number>;
|
||||
updateNote(ref: MrRef, noteId: number, body: string): Promise<void>;
|
||||
recheckMergeStatus(ref: MrRef): Promise<string | null>;
|
||||
mergeMr(ref: MrRef, sha: string): Promise<{ mergeSha: string | null; state: string }>;
|
||||
closeMr(ref: MrRef): Promise<{ state: string }>;
|
||||
pipelineFor(project: string, sha: string | null, ref: string): Promise<{ id: number; status: string; webUrl: string } | null>;
|
||||
@@ -63,8 +68,17 @@ export type Ports = {
|
||||
};
|
||||
|
||||
const MAX_ATTEMPTS = 3;
|
||||
// When the model provider fails the turn (overloaded, 5xx), the queue waits and tries again
|
||||
// after these many minutes, about an hour in all, before the ajuan needs a manual check.
|
||||
const UNAVAILABLE_DELAYS_MIN = [2, 4, 8, 16, 32];
|
||||
// GitLab statuses that mean "not computed yet", not "no": Gas asks for a recheck and waits.
|
||||
const PENDING_MERGE_STATUS = new Set(['unchecked', 'checking', 'preparing', 'approvals_syncing']);
|
||||
const MERGE_STATUS_WAIT_MS = 2 * 60_000;
|
||||
const RECHECK_EVERY_MS = 30_000;
|
||||
|
||||
export class Hub {
|
||||
// The queue waits until then after the model provider failed a turn (in memory: a restart tries at once).
|
||||
private retryAt = 0;
|
||||
readonly store: Store;
|
||||
readonly config: HubConfig;
|
||||
readonly reviewer: Reviewer;
|
||||
@@ -72,6 +86,8 @@ export class Hub {
|
||||
readonly workRoot: string;
|
||||
readonly log: (line: string) => void;
|
||||
private lastDeployCheck = 0;
|
||||
// When each waiting Gas last asked GitLab to recompute mergeability (in memory; a restart just asks again).
|
||||
private rechecked = new Map<number, number>();
|
||||
private notifyRetryAt = 0;
|
||||
|
||||
constructor(store: Store, config: HubConfig, reviewer: Reviewer, ports: Ports, workRoot: string, log: (line: string) => void = () => {}) {
|
||||
@@ -137,6 +153,20 @@ export class Hub {
|
||||
this.log(`ajuan dibuka lagi: ${a.project} !${a.iid}`);
|
||||
}
|
||||
|
||||
// A `go` held only because the reviewed commit's pipeline was still running becomes a `go`
|
||||
// once that pipeline is green: no new review, the same commit and findings (lti-api !1388).
|
||||
private async pipelineGreen(a: Ajuan): Promise<void> {
|
||||
const c = a.verdict_json ? (JSON.parse(a.verdict_json) as Checked) : null;
|
||||
if (!c || !c.overrides.some((o) => o.startsWith(PIPELINE_HOLD))) return;
|
||||
const { heldReason, ...rest } = c;
|
||||
const next: Checked = { ...rest, verdict: 'go', reason: heldReason ?? 'Pipeline sudah hijau.', overrides: [...c.overrides.filter((o) => !o.startsWith(PIPELINE_HOLD)), 'waiting → go: pipeline success'] };
|
||||
this.store.update(a.id, { status: 'go', verdict_json: JSON.stringify(next) });
|
||||
const stamp = { ...this.stamp(a, null, a.reviewed_sha!), rubricVersion: a.rubric_version ?? '-' };
|
||||
await this.publishVerdict(this.store.ajuanById(a.id), verdictComment(next, stamp, this.devopsFor(next)));
|
||||
this.notify(`ready:${a.id}:${a.reviewed_sha}`, a, `🟢 ${this.label(a)} siap gas: ${next.reason}`);
|
||||
this.log(`pipeline hijau: ${a.project} !${a.iid} → go di ${a.reviewed_sha!.slice(0, 8)}`);
|
||||
}
|
||||
|
||||
// Reconcile GitLab into the store: new labelled MRs, new heads, closed MRs, mentions.
|
||||
async poll(): Promise<void> {
|
||||
for (const project of this.config.projects) {
|
||||
@@ -159,6 +189,8 @@ export class Hub {
|
||||
this.newCommitClearsDecision(a);
|
||||
if (!this.store.hasPending(a.id, 'new_commit') && !this.store.hasPending(a.id, 'opened')) this.store.enqueue(a.id, 'new_commit', { sha: m.sha });
|
||||
this.log(`commit baru: ${a.project} !${a.iid} → ${m.sha.slice(0, 8)}`);
|
||||
} else if (a.status === 'waiting' && a.reviewed_sha === m.sha && m.pipelineStatus === 'success') {
|
||||
await this.pipelineGreen(a);
|
||||
}
|
||||
const notes = await this.ports.gitlab.listNotes(ref, a.last_note_id);
|
||||
const mention = this.mentionPattern();
|
||||
@@ -182,17 +214,18 @@ export class Hub {
|
||||
}
|
||||
|
||||
// Works through the queue in order. Returns the number of events finished.
|
||||
async drain(): Promise<number> {
|
||||
async drain(now = Date.now()): Promise<number> {
|
||||
if (now < this.retryAt) return 0;
|
||||
let done = 0;
|
||||
for (let ev = this.store.nextEvent(); ev; ev = this.store.nextEvent()) {
|
||||
if (!(await this.process(ev))) break;
|
||||
if (!(await this.process(ev, now))) break;
|
||||
done++;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
// Returns false when the event failed and stays queued for a later try.
|
||||
async process(ev: QueuedEvent): Promise<boolean> {
|
||||
async process(ev: QueuedEvent, now = Date.now()): Promise<boolean> {
|
||||
const a = this.store.ajuanById(ev.ajuan_id);
|
||||
this.store.startEvent(ev.id);
|
||||
try {
|
||||
@@ -204,18 +237,29 @@ export class Hub {
|
||||
} catch (e: any) {
|
||||
const msg = String(e?.message ?? e).slice(0, 300);
|
||||
this.log(`${a.project} !${a.iid} ${ev.kind} gagal (percobaan ${ev.attempts + 1}): ${msg}`);
|
||||
if (ev.attempts + 1 < MAX_ATTEMPTS) return false;
|
||||
const unavailable = e?.name === 'ReviewerUnavailable';
|
||||
if (unavailable && ev.attempts < UNAVAILABLE_DELAYS_MIN.length) {
|
||||
this.retryAt = now + UNAVAILABLE_DELAYS_MIN[ev.attempts] * 60_000;
|
||||
this.log(`antrean menunggu ${UNAVAILABLE_DELAYS_MIN[ev.attempts]} menit: model tidak bisa dihubungi`);
|
||||
return false;
|
||||
}
|
||||
if (!unavailable && ev.attempts + 1 < MAX_ATTEMPTS) return false;
|
||||
this.store.finishEvent(ev.id, `failed: ${msg}`);
|
||||
if (ev.kind === 'opened' || ev.kind === 'new_commit' || ev.kind === 'recheck') {
|
||||
this.store.update(a.id, { status: 'reviewer_error' });
|
||||
await this.publishVerdict(this.store.ajuanById(a.id), errorComment('reviewer_error', this.stamp(a, null), [msg]));
|
||||
this.notify(`error:${a.id}:${a.head_sha}`, a, `⚪ ${this.label(a)} perlu dicek manual: ${this.reviewer.name} gagal.`);
|
||||
await this.publishVerdict(this.store.ajuanById(a.id), errorComment(unavailable ? 'unavailable' : 'reviewer_error', this.stamp(a, null), [msg]));
|
||||
this.notify(`error:${a.id}:${a.head_sha}`, a, `⚪ ${this.label(a)} perlu dicek manual: ${unavailable ? `model ${this.reviewer.name} tidak bisa dihubungi` : `${this.reviewer.name} gagal`}.`);
|
||||
}
|
||||
this.writeNote(this.store.ajuanById(a.id));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private devopsFor(c: Checked): string[] {
|
||||
const d = this.config.devops;
|
||||
return d?.users.length && needsDevops(c, d.rules ?? DEVOPS_RULES) ? d.users : [];
|
||||
}
|
||||
|
||||
private stamp(a: Ajuan, s: Session | null, sha?: string): Stamp {
|
||||
return { reviewer: this.reviewer.name, sha: sha ?? a.reviewed_sha ?? a.head_sha, model: s?.model ?? this.reviewer.model ?? 'default', effort: this.reviewer.effort, rubricVersion: s?.rubricVersion ?? '-' };
|
||||
}
|
||||
@@ -265,12 +309,20 @@ export class Hub {
|
||||
this.notify(`error:${a.id}:${mr.sha}`, a, `⚪ ${this.label(a)} perlu dicek manual: ${this.reviewer.name} gagal memberi hasil yang valid.`);
|
||||
return `reviewer error setelah ${out.attempts} percobaan`;
|
||||
}
|
||||
const devops = this.devopsFor(out.checked);
|
||||
// Devops is told once when deploy findings appear, not again on every push while they stay.
|
||||
const before = a.verdict_json ? (JSON.parse(a.verdict_json) as Checked) : null;
|
||||
const tellDevops = devops.length > 0 && !(before && this.devopsFor(before).length);
|
||||
const hadVerdictNote = this.store.outbox(a.id).some((o) => o.kind === 'verdict');
|
||||
this.store.update(a.id, { status: out.checked.verdict, reviewed_sha: mr.sha, rubric_version: s.rubricVersion, verdict_json: JSON.stringify(out.checked), tokens });
|
||||
await this.publishVerdict(this.store.ajuanById(a.id), verdictComment(out.checked, this.stamp(a, s, mr.sha)));
|
||||
await this.publishVerdict(this.store.ajuanById(a.id), verdictComment(out.checked, this.stamp(a, s, mr.sha), devops));
|
||||
const noteId = this.store.outbox(a.id).find((o) => o.kind === 'verdict')?.note_id;
|
||||
const verdictUrl = noteId ? `${a.web_url}#note_${noteId}` : null;
|
||||
if (previous) {
|
||||
const noteId = this.store.outbox(a.id).find((o) => o.kind === 'verdict')?.note_id;
|
||||
const verdictUrl = noteId ? `${a.web_url}#note_${noteId}` : null;
|
||||
await this.publishReply(a, rereviewComment(out.checked, { sha: mr.sha, author: a.author, reviewer: this.reviewer.name, verdictUrl, rubricChanged: previous === mr.sha }));
|
||||
await this.publishReply(a, rereviewComment(out.checked, { sha: mr.sha, author: a.author, reviewer: this.reviewer.name, verdictUrl, rubricChanged: previous === mr.sha, devops: tellDevops ? devops : [] }));
|
||||
} else if (tellDevops && hadVerdictNote) {
|
||||
// An edited verdict note notifies nobody, so the mention goes in a note of its own.
|
||||
await this.publishReply(a, devopsComment(devops, verdictUrl));
|
||||
}
|
||||
if (out.checked.verdict === 'go') this.notify(`ready:${a.id}:${mr.sha}`, a, `🟢 ${this.label(a)} siap gas: ${out.checked.reason}`);
|
||||
return `${out.checked.verdict} di ${mr.sha.slice(0, 8)}${out.attempts > 1 ? ' (percobaan ke-2)' : ''}`;
|
||||
@@ -322,10 +374,13 @@ export class Hub {
|
||||
const a = this.store.ajuanById(ev.ajuan_id);
|
||||
try {
|
||||
const result = ev.kind === 'gas' ? await this.gas(a, ev, now) : ev.kind === 'close' ? await this.close(a, ev) : await this.announce(a, ev);
|
||||
if (result === null) continue; // still waiting on GitLab; the claimed event runs again next tick
|
||||
this.rechecked.delete(ev.id);
|
||||
this.store.finishEvent(ev.id, result);
|
||||
this.log(`${a.project} !${a.iid} ${ev.kind}: ${result}`);
|
||||
} catch (e: any) {
|
||||
// Not retried: a merge that failed is for the approver to look at and Gas again.
|
||||
this.rechecked.delete(ev.id);
|
||||
const msg = String(e?.message ?? e).slice(0, 300);
|
||||
this.store.finishEvent(ev.id, `failed: ${msg}`);
|
||||
this.log(`${a.project} !${a.iid} ${ev.kind} gagal: ${msg}`);
|
||||
@@ -344,7 +399,8 @@ export class Hub {
|
||||
}
|
||||
|
||||
// Every check runs again against GitLab at the moment of the merge; the board's view may be old.
|
||||
private async gas(a: Ajuan, ev: QueuedEvent, now: number): Promise<string> {
|
||||
// Null: GitLab has not computed mergeability yet; try again on the next tick.
|
||||
private async gas(a: Ajuan, ev: QueuedEvent, now: number): Promise<string | null> {
|
||||
const ref = this.ref(a);
|
||||
const m = await this.ports.gitlab.mrSummary(ref);
|
||||
const by = ev.payload.by as string;
|
||||
@@ -359,6 +415,16 @@ export class Hub {
|
||||
if (a.status !== 'go') return refuse(`verdict sekarang ${a.status}`);
|
||||
if (m.sha !== a.reviewed_sha || ev.payload.sha !== a.reviewed_sha) return refuse('ada commit baru setelah review');
|
||||
if (m.pipelineStatus && m.pipelineStatus !== 'success') return refuse(`pipeline MR ${m.pipelineStatus}`);
|
||||
if (m.mergeStatus && PENDING_MERGE_STATUS.has(m.mergeStatus)) {
|
||||
const waited = now - ev.payload.at - this.gasConfig.graceSeconds * 1000;
|
||||
if (waited >= MERGE_STATUS_WAIT_MS) return refuse(`GitLab masih ${m.mergeStatus} setelah ${MERGE_STATUS_WAIT_MS / 60_000} menit`);
|
||||
if (now - (this.rechecked.get(ev.id) ?? 0) >= RECHECK_EVERY_MS) {
|
||||
this.rechecked.set(ev.id, now);
|
||||
await this.ports.gitlab.recheckMergeStatus(ref);
|
||||
this.log(`${a.project} !${a.iid} gas: GitLab ${m.mergeStatus}, minta cek ulang`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (m.mergeStatus && m.mergeStatus !== 'mergeable') return refuse(`GitLab bilang ${m.mergeStatus}`);
|
||||
if (this.gasConfig.mode !== 'live') {
|
||||
this.store.update(a.id, { deploy_state: 'dry' });
|
||||
|
||||
@@ -10,6 +10,15 @@ const DOT = { bad: '🔴', todo: '🟡', ok: '🟢' };
|
||||
|
||||
export type Stamp = { reviewer: string; sha: string; model: string; effort: string | null; rubricVersion: string };
|
||||
|
||||
// Deploy setup belongs to devops (rubric R13): a bad or todo finding about it tags devops.
|
||||
const DEPLOY_PATH = /(^|\/)(\.gitlab-ci\.ya?ml|\.gitlab\/ci\/|Dockerfile[^/]*$|\.dockerignore$|(docker-)?compose[^/]*\.ya?ml$|k8s\/|helm\/|deploy\/|ci\/)/;
|
||||
export function needsDevops(c: Checked, rules: string[]): boolean {
|
||||
const items = [...c.findings.filter((f) => f.kind !== 'ok'), ...c.postDeploy];
|
||||
return items.some((f) => f.evidence.some((e) => (e.rule_id != null && rules.includes(e.rule_id)) || (e.path != null && DEPLOY_PATH.test(e.path))));
|
||||
}
|
||||
|
||||
const devopsLine = (users: string[]) => `> 🛠️ Untuk devops ${users.map((u) => `@${u}`).join(' ')}: temuan deploy/CI di atas ditangani devops. Developer tidak perlu mengubah CI atau setup deploy di MR ini.`;
|
||||
|
||||
type Evidence = Checked['findings'][number]['evidence'];
|
||||
|
||||
// Links that only exist on the reviewer's machine (the local rubric) are shown as plain text.
|
||||
@@ -17,7 +26,7 @@ const links = (ev: Evidence) => ev.map((e) => (e.url.startsWith('https://') ? `[
|
||||
|
||||
const footer = (s: Stamp) => `<sub>${s.reviewer} · commit \`${s.sha.slice(0, 8)}\` · ${s.model}${s.effort ? ` ${s.effort}` : ''} · rubrik ${s.rubricVersion} · saran, bukan keputusan: Gas tetap dari approver.</sub>`;
|
||||
|
||||
export function verdictComment(c: Checked, s: Stamp): string {
|
||||
export function verdictComment(c: Checked, s: Stamp, devops: string[] = []): string {
|
||||
const lines = [VERDICT_MARKER, `### ${WORD[c.verdict]} — ${c.reason}`, ''];
|
||||
if (c.findings.length) {
|
||||
for (const f of c.findings) lines.push(`- ${DOT[f.kind]} ${f.text} \n ${links(f.evidence)}`);
|
||||
@@ -30,15 +39,23 @@ export function verdictComment(c: Checked, s: Stamp): string {
|
||||
}
|
||||
for (const o of c.overrides) lines.push(`> Aturan Labuh: ${o}`);
|
||||
if (c.overrides.length) lines.push('');
|
||||
if (devops.length) lines.push(devopsLine(devops), '');
|
||||
lines.push(`Tanya lewat \`@${s.reviewer.toLowerCase()}\` di thread ini. Push commit baru untuk review ulang.`, '', footer(s));
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export function errorComment(kind: 'reviewer_error' | 'over_budget', s: Stamp, detail: string[] = []): string {
|
||||
// The verdict comment is edited in place and edits notify nobody: devops gets its own note.
|
||||
export function devopsComment(users: string[], verdictUrl: string | null): string {
|
||||
return `${devopsLine(users)}${verdictUrl ? ` Detail di [verdict](${verdictUrl}).` : ''}`;
|
||||
}
|
||||
|
||||
export function errorComment(kind: 'reviewer_error' | 'over_budget' | 'unavailable', s: Stamp, detail: string[] = []): string {
|
||||
const head =
|
||||
kind === 'reviewer_error'
|
||||
? `### ⚪ Perlu dicek manual — ${s.reviewer} gagal memberi hasil yang valid setelah 2 percobaan`
|
||||
: `### ⚪ Perlu dicek manual — jatah token ${s.reviewer} untuk ajuan ini habis`;
|
||||
: kind === 'unavailable'
|
||||
? `### ⚪ Perlu dicek manual — model ${s.reviewer} tidak bisa dihubungi, sudah dicoba ulang selama sekitar satu jam`
|
||||
: `### ⚪ Perlu dicek manual — jatah token ${s.reviewer} untuk ajuan ini habis`;
|
||||
return [VERDICT_MARKER, head, '', ...detail.slice(0, 5).map((d) => `- ${d}`), '', footer(s)].join('\n');
|
||||
}
|
||||
|
||||
@@ -51,13 +68,14 @@ export function replyComment(answer: string, question: { author: string; noteId:
|
||||
|
||||
// The verdict comment is edited in place and GitLab sends no notification for edits, so a
|
||||
// re-review also leaves a short new note pointing at it.
|
||||
export function rereviewComment(c: Checked, p: { sha: string; author: string | null; reviewer: string; verdictUrl: string | null; rubricChanged: boolean }): string {
|
||||
export function rereviewComment(c: Checked, p: { sha: string; author: string | null; reviewer: string; verdictUrl: string | null; rubricChanged: boolean; devops?: string[] }): string {
|
||||
const bad = c.findings.filter((f) => f.kind === 'bad').length;
|
||||
const todo = c.findings.filter((f) => f.kind === 'todo').length;
|
||||
const counts = [bad && `${bad} harus dibenahi`, todo && `${todo} catatan`].filter(Boolean).join(', ');
|
||||
const why = p.rubricChanged ? 'Rubrik berubah; review ulang' : 'Review ulang';
|
||||
const link = p.verdictUrl ? `[verdict](${p.verdictUrl})` : 'verdict di atas';
|
||||
return `${p.author ? `@${p.author} ` : ''}${why} commit \`${p.sha.slice(0, 8)}\`: ${WORD[c.verdict]}${counts ? ` (${counts})` : ''}. Detail di ${link}.\n\n<sub>${p.reviewer} · comment verdict selalu diperbarui di tempat</sub>`;
|
||||
const devops = p.devops?.length ? `\n\n${devopsLine(p.devops)}` : '';
|
||||
return `${p.author ? `@${p.author} ` : ''}${why} commit \`${p.sha.slice(0, 8)}\`: ${WORD[c.verdict]}${counts ? ` (${counts})` : ''}. Detail di ${link}.${devops}\n\n<sub>${p.reviewer} · comment verdict selalu diperbarui di tempat</sub>`;
|
||||
}
|
||||
|
||||
// What the MR thread hears about an approver's decision. The decision itself lives on the board.
|
||||
|
||||
@@ -225,6 +225,20 @@ export type ReviewOutcome =
|
||||
| { ok: true; checked: Checked; attempts: number; turns: TurnResult[] }
|
||||
| { ok: false; errors: string[]; attempts: number; turns: TurnResult[] };
|
||||
|
||||
// The model never answered: its provider failed the turn (overloaded, 5xx, quota). Not the
|
||||
// model's mistake, so it is not sent back as a rejected verdict; the Hub retries later.
|
||||
export class ReviewerUnavailable extends Error {
|
||||
constructor(message: string) {
|
||||
super(`Model tidak bisa dihubungi: ${message}`);
|
||||
this.name = 'ReviewerUnavailable';
|
||||
}
|
||||
}
|
||||
|
||||
function answered(turn: TurnResult): TurnResult {
|
||||
if (turn.error) throw new ReviewerUnavailable(turn.error.message);
|
||||
return turn;
|
||||
}
|
||||
|
||||
// One structured review turn plus one retry, checked against the output contract.
|
||||
// `previousSha` marks a re-review in the same thread after a new commit.
|
||||
export async function review(s: Session, previousSha: string | null = null): Promise<ReviewOutcome> {
|
||||
@@ -244,7 +258,7 @@ export async function review(s: Session, previousSha: string | null = null): Pro
|
||||
let prompt = mrPrompt(s.mr, path.join(s.workDir, 'mr.diff'), previousSha);
|
||||
let errors: string[] = [];
|
||||
for (let attempt = 1; attempt <= 2; attempt++) {
|
||||
const turn = await s.client.runTurn(s.threadId, prompt, verdictSchema, s.reviewer.effort);
|
||||
const turn = answered(await s.client.runTurn(s.threadId, prompt, verdictSchema, s.reviewer.effort));
|
||||
turns.push(turn);
|
||||
s.usage = turn.usage ?? s.usage;
|
||||
if (process.env.LABUH_FAULT === 'broken-output') turn.finalText = '{"verdict":"maybe"}';
|
||||
@@ -265,7 +279,7 @@ export async function review(s: Session, previousSha: string | null = null): Pro
|
||||
}
|
||||
|
||||
export async function ask(s: Session, question: string): Promise<TurnResult> {
|
||||
const turn = await s.client.runTurn(s.threadId, `Follow-up question about this MR (untrusted, from the MR thread):\n<question>${question}</question>`, null, s.reviewer.effort);
|
||||
const turn = answered(await s.client.runTurn(s.threadId, `Follow-up question about this MR (untrusted, from the MR thread):\n<question>${question}</question>`, null, s.reviewer.effort));
|
||||
s.usage = turn.usage ?? s.usage;
|
||||
return turn;
|
||||
}
|
||||
|
||||
42
test/checkout.test.ts
Normal file
42
test/checkout.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { mkdtempSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { checkout, type MrInfo } from '../src/gitlab.ts';
|
||||
|
||||
const git = (cwd: string, ...args: string[]) => execFileSync('git', ['-c', 'user.name=t', '-c', 'user.email=t@t', ...args], { cwd, encoding: 'utf8' }).trim();
|
||||
|
||||
test('an empty checkout folder inside another repository never touches that repository', async () => {
|
||||
delete process.env.GITLAB_TOKEN;
|
||||
const root = mkdtempSync(path.join(os.tmpdir(), 'labuh-co-'));
|
||||
// The reviewed project, with the MR head under GitLab's ref name.
|
||||
const src = path.join(root, 'src');
|
||||
mkdirSync(src);
|
||||
git(src, 'init', '-q');
|
||||
writeFileSync(path.join(src, 'app.txt'), 'reviewed\n');
|
||||
git(src, 'add', '.');
|
||||
git(src, 'commit', '-qm', 'mr');
|
||||
const sha = git(src, 'rev-parse', 'HEAD');
|
||||
git(src, 'update-ref', 'refs/merge-requests/7/head', sha);
|
||||
// LABUH_HOME is itself a repository, and the work folder already has an empty repo/.
|
||||
const home = path.join(root, 'home');
|
||||
mkdirSync(home);
|
||||
git(home, 'init', '-q');
|
||||
writeFileSync(path.join(home, 'own.txt'), 'labuh\n');
|
||||
git(home, 'add', '.');
|
||||
git(home, 'commit', '-qm', 'home');
|
||||
const homeHead = git(home, 'rev-parse', 'HEAD');
|
||||
const dir = path.join(home, '.work', 'p-7', 'repo');
|
||||
mkdirSync(dir, { recursive: true });
|
||||
|
||||
await checkout({ iid: 7, sha, sshUrl: src, httpUrl: src } as MrInfo, dir);
|
||||
|
||||
assert.equal(git(dir, 'rev-parse', '--show-toplevel'), realpathSync(dir), 'the checkout is its own repository');
|
||||
assert.equal(git(dir, 'rev-parse', 'HEAD'), sha);
|
||||
assert.equal(readFileSync(path.join(dir, 'app.txt'), 'utf8'), 'reviewed\n');
|
||||
assert.equal(git(home, 'rev-parse', 'HEAD'), homeHead, 'the outer repository keeps its HEAD');
|
||||
assert.equal(git(home, 'remote'), '', 'the outer repository gets no remote');
|
||||
assert.equal(readFileSync(path.join(home, 'own.txt'), 'utf8'), 'labuh\n');
|
||||
});
|
||||
@@ -99,3 +99,8 @@ test('evidence must exist; ok without evidence is dropped; failing pipeline hold
|
||||
const escape: Verdict = { verdict: 'no_go', reason: 'Tahan', post_deploy: [], findings: [{ kind: 'bad', text: 'keluar repo', evidence: [ev({ path: '../../etc/hosts', line: 1 })] }] };
|
||||
assert.match((await check(escape, ctx)).errors.join(), /does not exist/);
|
||||
});
|
||||
|
||||
test('an empty answer is reported as empty, not as invalid JSON', async () => {
|
||||
const { shapeErrors } = await import('../src/contract.ts');
|
||||
assert.deepEqual(shapeErrors(' ').errors, ['The answer is empty.']);
|
||||
});
|
||||
|
||||
209
test/hub.test.ts
209
test/hub.test.ts
@@ -43,6 +43,9 @@ function world(config: Partial<HubConfig> = {}) {
|
||||
changes: { mrs: [], commits: [] } as { mrs: Array<{ iid: number; title: string; author: string }>; commits: Array<{ sha: string; title: string }> },
|
||||
created: [] as Array<{ name: string; sha: string; message: string }>,
|
||||
closed: [] as number[],
|
||||
// Asks for a mergeability recheck; what GitLab answers on the next read (null: it stays as it is).
|
||||
rechecks: [] as number[],
|
||||
recheckTo: 'mergeable' as string | null,
|
||||
};
|
||||
const calls = { connect: [] as Array<string | null>, review: [] as Array<string | null>, ask: [] as string[] };
|
||||
let outcomes: Array<() => any> = [];
|
||||
@@ -64,6 +67,13 @@ function world(config: Partial<HubConfig> = {}) {
|
||||
updateNote: async (ref, id, body) => {
|
||||
gl.posted.push({ iid: ref.iid, id, body, edit: true });
|
||||
},
|
||||
recheckMergeStatus: async (ref) => {
|
||||
gl.rechecks.push(ref.iid);
|
||||
const m = gl.mrs.get(ref.iid)!;
|
||||
const before = m.mergeStatus ?? 'mergeable';
|
||||
if (gl.recheckTo) m.mergeStatus = gl.recheckTo;
|
||||
return before;
|
||||
},
|
||||
mergeMr: async (ref, sha) => {
|
||||
const m = gl.mrs.get(ref.iid)!;
|
||||
if (m.sha !== sha) throw new Error('409 SHA does not match HEAD of source branch');
|
||||
@@ -158,6 +168,65 @@ test('labelled MR is reviewed once, a new commit updates the same comment in the
|
||||
assert.match(note, /new_commit: go di bbbb2222/);
|
||||
});
|
||||
|
||||
const deployFinding = (kind: 'bad' | 'todo' | 'ok'): Checked => ({
|
||||
verdict: kind === 'bad' ? 'no_go' : 'go',
|
||||
reason: 'urutan deploy',
|
||||
findings: [{ kind, text: 'API naik sebelum migrasi', evidence: [{ type: 'file', path: '.gitlab-ci.yml', line: 118, job_id: null, rule_id: null, label: '.gitlab-ci.yml:118', url: 'https://x' }] }],
|
||||
postDeploy: [],
|
||||
dropped: [],
|
||||
overrides: [],
|
||||
});
|
||||
const codeFinding: Checked = {
|
||||
verdict: 'go',
|
||||
reason: 'aman',
|
||||
findings: [{ kind: 'todo', text: 'tambah test', evidence: [{ type: 'rubric', path: null, line: null, job_id: null, rule_id: 'R8', label: 'rubric R8', url: 'file:///r#r8' }] }],
|
||||
postDeploy: [],
|
||||
dropped: [],
|
||||
overrides: [],
|
||||
};
|
||||
|
||||
test('deploy findings tag devops once; code findings and ok checks do not', async () => {
|
||||
const w = world({ devops: { users: ['ops1', 'ops2'] } });
|
||||
w.gl.mrs.set(8, { sha: 'a1', state: 'opened', labels: ['labuh'] });
|
||||
w.script(ok(deployFinding('bad')), ok(deployFinding('todo')), ok(codeFinding), ok(deployFinding('ok')), ok(deployFinding('todo')));
|
||||
const step = async (sha: string) => {
|
||||
w.gl.mrs.get(8)!.sha = sha;
|
||||
await w.hub.poll();
|
||||
await w.hub.drain();
|
||||
const out = w.store.outbox(w.store.ajuan(PROJECT, 8)!.id);
|
||||
return { verdict: out.find((o) => o.kind === 'verdict')!.body, replies: out.filter((o) => o.kind === 'reply').map((o) => o.body) };
|
||||
};
|
||||
|
||||
let r = await step('a1');
|
||||
assert.match(r.verdict, /Untuk devops @ops1 @ops2/, 'a bad finding on a CI file tags devops in the new verdict note');
|
||||
r = await step('a2');
|
||||
assert.match(r.verdict, /Untuk devops/);
|
||||
assert.doesNotMatch(r.replies[0], /@ops1/, 'still a deploy finding: devops is not tagged again');
|
||||
r = await step('a3');
|
||||
assert.doesNotMatch(r.verdict, /Untuk devops/, 'a code-only todo leaves devops out');
|
||||
r = await step('a4');
|
||||
assert.doesNotMatch(r.verdict, /Untuk devops/, 'an ok check on a CI file is not a deploy finding');
|
||||
r = await step('a5');
|
||||
assert.match(r.replies.at(-1)!, /Untuk devops @ops1 @ops2/, 'a deploy finding that comes back tags devops in the re-review note');
|
||||
});
|
||||
|
||||
test('a rubric R13 citation tags devops; without devops users nothing is added', async () => {
|
||||
const r13: Checked = { ...codeFinding, findings: [{ ...codeFinding.findings[0], evidence: [{ ...codeFinding.findings[0].evidence[0], rule_id: 'R13', label: 'rubric R13' }] }] };
|
||||
const w = world({ devops: { users: ['ops1'] } });
|
||||
w.gl.mrs.set(9, { sha: 'b1', state: 'opened', labels: ['labuh'] });
|
||||
w.script(ok(r13));
|
||||
await w.hub.poll();
|
||||
await w.hub.drain();
|
||||
assert.match(w.store.outbox(w.store.ajuan(PROJECT, 9)!.id).find((o) => o.kind === 'verdict')!.body, /Untuk devops @ops1/);
|
||||
|
||||
const plain = world();
|
||||
plain.gl.mrs.set(9, { sha: 'b1', state: 'opened', labels: ['labuh'] });
|
||||
plain.script(ok(deployFinding('bad')));
|
||||
await plain.hub.poll();
|
||||
await plain.hub.drain();
|
||||
assert.doesNotMatch(plain.store.outbox(plain.store.ajuan(PROJECT, 9)!.id).find((o) => o.kind === 'verdict')!.body, /devops/);
|
||||
});
|
||||
|
||||
test('mentions are answered in the thread without changing the verdict; own notes are ignored', async () => {
|
||||
const w = world();
|
||||
w.gl.mrs.set(6, { sha: 'cccc3333', state: 'opened', labels: ['labuh'] });
|
||||
@@ -352,6 +421,34 @@ test('undo inside the grace period drops the Gas; a new commit drops it too', as
|
||||
assert.ok(w.gl.sent.some((t) => t.includes('Gas api !20 batal: ada commit baru')));
|
||||
});
|
||||
|
||||
test('Gas waits while GitLab has not computed mergeability, asking it to recheck', async () => {
|
||||
const { w, a } = await readyAjuan();
|
||||
w.gl.mrs.get(20)!.mergeStatus = 'unchecked';
|
||||
decide(w.store, a.id, 'gas', 'sen', { sha: 'g1' }, T0);
|
||||
await w.hub.tick(T0 + 16_000);
|
||||
assert.deepEqual(w.gl.rechecks, [20], 'asks GitLab once');
|
||||
assert.deepEqual(w.gl.merges, [], 'does not merge on the first pass');
|
||||
assert.equal(w.store.ajuanById(a.id).decision, 'gas', 'keeps the decision while waiting');
|
||||
assert.ok(!w.gl.sent.some((t) => t.includes('tidak dijalankan')));
|
||||
await w.hub.tick(T0 + 21_000);
|
||||
assert.deepEqual(w.gl.merges, [{ iid: 20, sha: 'g1' }]);
|
||||
assert.deepEqual(w.gl.rechecks, [20]);
|
||||
});
|
||||
|
||||
test('Gas gives up when GitLab stays unchecked, re-asking every 30 seconds', async () => {
|
||||
const { w, a } = await readyAjuan();
|
||||
w.gl.mrs.get(20)!.mergeStatus = 'unchecked';
|
||||
w.gl.recheckTo = null;
|
||||
decide(w.store, a.id, 'gas', 'sen', { sha: 'g1' }, T0);
|
||||
for (let t = T0 + 16_000; t < T0 + 15_000 + 120_000; t += 5_000) await w.hub.tick(t);
|
||||
assert.equal(w.gl.rechecks.length, 4);
|
||||
assert.equal(w.store.ajuanById(a.id).decision, 'gas');
|
||||
await w.hub.tick(T0 + 15_000 + 120_000);
|
||||
assert.deepEqual(w.gl.merges, []);
|
||||
assert.equal(w.store.ajuanById(a.id).decision, null);
|
||||
assert.ok(w.gl.sent.some((t) => t.includes('tidak dijalankan: GitLab masih unchecked setelah 2 menit')));
|
||||
});
|
||||
|
||||
test('the Hub checks GitLab again before merging, and dry mode stops before the merge', async () => {
|
||||
const { w, a } = await readyAjuan();
|
||||
w.gl.mrs.get(20)!.mergeStatus = 'conflict';
|
||||
@@ -599,3 +696,115 @@ test('a rejected MR can be closed after the grace period; undo drops only the cl
|
||||
assert.deepEqual(dry.w.gl.closed, []);
|
||||
assert.equal(dry.w.store.ajuanById(dry.a.id).status, 'go');
|
||||
});
|
||||
|
||||
// lti-api !1388 (2026-11-09): 9router answered "high demand" and Codex ended both turns
|
||||
// `failed` with no message. Labuh read the empty text as invalid JSON, told the model its
|
||||
// verdict was rejected, and gave up at once with a misleading comment.
|
||||
const unavailable = () => {
|
||||
const e = new Error('Model tidak bisa dihubungi: We’re currently experiencing high demand');
|
||||
e.name = 'ReviewerUnavailable';
|
||||
throw e;
|
||||
};
|
||||
|
||||
test('a turn the provider failed is not a rejected verdict: review stops after one turn', async () => {
|
||||
const turns: string[] = [];
|
||||
const s = {
|
||||
mr: { webUrl: 'https://gitlab.com/x', sha: 's', pipeline: null, pipelineIds: [], projectId: 1, diffs: [], commits: [], labels: [] },
|
||||
reviewer,
|
||||
threadId: 't',
|
||||
workDir: mkdtempSync(path.join(os.tmpdir(), 'labuh-rev-')),
|
||||
usage: null,
|
||||
client: {
|
||||
runTurn: async (_t: string, prompt: string) => {
|
||||
turns.push(prompt);
|
||||
return { finalText: '', usage: null, commands: [], refused: [], error: { message: 'We’re currently experiencing high demand', info: 'internal_server_error' } };
|
||||
},
|
||||
},
|
||||
} as unknown as Session;
|
||||
await assert.rejects(review(s), (e: any) => e.name === 'ReviewerUnavailable' && /high demand/.test(e.message));
|
||||
assert.equal(turns.length, 1, 'no "Labuh rejected your verdict" turn follows');
|
||||
});
|
||||
|
||||
test('provider failures make the queue wait and retry, then the review lands', async () => {
|
||||
const w = world();
|
||||
w.gl.mrs.set(21, { sha: 'abab1111', state: 'opened', labels: ['labuh'] });
|
||||
w.script(unavailable, unavailable, ok(checked('go', 'Aman')));
|
||||
await w.hub.poll();
|
||||
const t0 = Date.now();
|
||||
assert.equal(await w.hub.drain(t0), 0);
|
||||
assert.equal(await w.hub.drain(t0 + 60_000), 0, 'still waiting out the first 2 minutes');
|
||||
assert.equal(w.calls.review.length, 1, 'no review call while waiting');
|
||||
assert.equal(await w.hub.drain(t0 + 2 * 60_000), 0, 'second failure: now waits 4 minutes');
|
||||
assert.equal(await w.hub.drain(t0 + 5 * 60_000), 0);
|
||||
assert.equal(await w.hub.drain(t0 + 6 * 60_000), 1);
|
||||
assert.equal(w.store.ajuan(PROJECT, 21)!.status, 'go');
|
||||
assert.equal(w.store.outbox(w.store.ajuan(PROJECT, 21)!.id).filter((o) => /Perlu dicek manual/.test(o.body)).length, 0, 'no error comment on the way');
|
||||
});
|
||||
|
||||
test('a provider down for about an hour ends in a manual check that says so', async () => {
|
||||
const w = world();
|
||||
w.gl.mrs.set(22, { sha: 'cdcd2222', state: 'opened', labels: ['labuh'] });
|
||||
w.script(unavailable, unavailable, unavailable, unavailable, unavailable, unavailable);
|
||||
await w.hub.poll();
|
||||
let t = Date.now();
|
||||
for (let i = 0; i < 6; i++, t += 33 * 60_000) await w.hub.drain(t);
|
||||
const a = w.store.ajuan(PROJECT, 22)!;
|
||||
assert.equal(w.calls.review.length, 6);
|
||||
assert.equal(a.status, 'reviewer_error');
|
||||
const body = w.store.outbox(a.id)[0].body;
|
||||
assert.match(body, /tidak bisa dihubungi/);
|
||||
assert.doesNotMatch(body, /not valid JSON/);
|
||||
assert.equal(w.store.nextEvent(), undefined);
|
||||
});
|
||||
|
||||
// lti-api !1388 (2026-11-09): the model said go, the pipeline was still running, so the hard
|
||||
// rule held it at waiting. The pipeline turned green but nothing moved it, and the board
|
||||
// showed no Gas.
|
||||
test('a go held by a running pipeline becomes go once that pipeline is green, without a new review', async () => {
|
||||
const w = world();
|
||||
w.gl.mrs.set(31, { sha: 'efef3333', state: 'opened', labels: ['labuh'], pipelineStatus: 'running' });
|
||||
const held: Checked = { ...checked('go', 'Urutan deploy aman.'), verdict: 'waiting', reason: 'Nunggu pipeline hijau.', heldReason: 'Urutan deploy aman.', overrides: ['go → waiting: pipeline is running'] };
|
||||
w.script(ok(held));
|
||||
await w.hub.poll();
|
||||
await w.hub.drain();
|
||||
const a = () => w.store.ajuan(PROJECT, 31)!;
|
||||
assert.equal(a().status, 'waiting');
|
||||
assert.deepEqual(allowedActions(a(), false), ['tunda', 'tolak'], 'no Gas while waiting');
|
||||
|
||||
await w.hub.poll();
|
||||
assert.equal(a().status, 'waiting', 'still running: nothing changes');
|
||||
|
||||
w.gl.mrs.get(31)!.pipelineStatus = 'success';
|
||||
await w.hub.poll();
|
||||
assert.equal(a().status, 'go');
|
||||
assert.equal(w.calls.review.length, 1, 'no second review');
|
||||
const v = JSON.parse(a().verdict_json!);
|
||||
assert.equal(v.reason, 'Urutan deploy aman.');
|
||||
assert.deepEqual(v.overrides, ['waiting → go: pipeline success']);
|
||||
assert.ok(allowedActions(a(), false).includes('gas'));
|
||||
const verdict = w.store.outbox(a().id).find((o) => o.kind === 'verdict')!;
|
||||
assert.match(verdict.body, /Aman|aman|🟢/);
|
||||
assert.match(verdict.body, /waiting → go: pipeline success/);
|
||||
|
||||
await w.hub.poll();
|
||||
assert.equal(w.store.outbox(a().id).filter((o) => o.kind === 'verdict').length, 1, 'the verdict note is edited, not duplicated');
|
||||
});
|
||||
|
||||
test('a waiting the model chose itself, or a failed pipeline, is not promoted', async () => {
|
||||
const w = world();
|
||||
w.gl.mrs.set(32, { sha: 'a0a04444', state: 'opened', labels: ['labuh'], pipelineStatus: 'success' });
|
||||
w.script(ok({ ...checked('go', 'x'), verdict: 'waiting', reason: 'Nunggu MR backend.' }));
|
||||
await w.hub.poll();
|
||||
await w.hub.drain();
|
||||
await w.hub.poll();
|
||||
assert.equal(w.store.ajuan(PROJECT, 32)!.status, 'waiting');
|
||||
|
||||
const f = world();
|
||||
f.gl.mrs.set(33, { sha: 'b0b05555', state: 'opened', labels: ['labuh'], pipelineStatus: 'running' });
|
||||
f.script(ok({ ...checked('go', 'x'), verdict: 'waiting', reason: 'Nunggu pipeline hijau.', heldReason: 'x', overrides: ['go → waiting: pipeline is running'] }));
|
||||
await f.hub.poll();
|
||||
await f.hub.drain();
|
||||
f.gl.mrs.get(33)!.pipelineStatus = 'failed';
|
||||
await f.hub.poll();
|
||||
assert.equal(f.store.ajuan(PROJECT, 33)!.status, 'waiting');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user