mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-31 22:14:25 +01:00
* fix(land-and-deploy): never merge over red, pending or missing CI (#2995) /land-and-deploy gated only on required checks, so a repo with none (every GitHub Free private repo, any repo without branch protection) skipped the CI wait and could merge over red CI. The verdict now comes from bin/gstack-ci-gate, a tested helper bound to the head SHA: all checks by default, cancel/unknown buckets fail, NO_CHECKS needs explicit per-head approval, and both merge commands (including --auto) run only after a PASS for the same SHA they pin with --match-head-commit. Co-authored-by: harshitgavita-07 <harshit.gavita@gmail.com> * fix(slug): give nested-group projects their own state bucket and verify checkpoint identity (#3003, #2901) gstack-slug kept only the last two remote path segments, so customer-a/product/repo and customer-b/product/repo shared one bucket and /context-restore could present another project's checkpoint. - One canonical-remote rule (bash + TS, golden vectors) used by all six resolvers: lowercased host, no userinfo/port/.git, Azure DevOps and Bitbucket Server normalized. 3+ segment remotes get <last-two>-<16 hex>; two-segment remotes (all of GitHub) are unchanged. - Versioned sticky cache (v2:) keeps cache hits git-free. - context-save stamps the credential-free remote and root; context-restore only treats this project's checkpoints as latest, reports foreign/unverified ones first, and treats a different root with the same remote (Conductor handoff) as information. - gstack-slug --adopt-legacy copies only files the user confirms. - question-preference-hook reads the same versioned cache, so never-ask preferences fire; unknown identity asks instead of auto-deciding. * fix(gbrain): brain context loads, managed sync works, memory sync stops duplicating (#2883, #2985, #2922) - brain-context-load called 'gbrain list_pages' (an MCP tool name), so every skill's brain context was 0 bytes. It now uses 'gbrain list' with gbrain's real filter flags, and prints one line when queries fail. - The code-stage sync always passes --no-pull (managed gbrain >= 0.51 refuses without it); a gbrain that rejects the flag fails with an upgrade message and is never retried without it. stderr is streamed with a bounded tail and quoted in failure summaries. - /sync-gbrain gains --sources (and GSTACK_MEMORY_INGEST_SOURCES); by default it skips types already synced through a federated curated source, so curated pages stop being re-duplicated. Co-authored-by: Vitor Cepeda Lopes <vitor@vitorcepedalopes.com> Co-authored-by: harshitgavita-07 <harshit.gavita@gmail.com> * fix(codex,cso): clean Codex reviews stop failing; semgrep and trivy SARIF results import (#2769, #3011) - Codex review gate is PASS / FAIL / UNVERIFIED. Untagged output (what a clean 'codex review --base' prints) is UNVERIFIED, not FAIL, and never a false PASS; P2/P3-only output passes. - import-sarif resolves semgrep's undeclared %SRCROOT% and trivy's ROOTPATH (including git-URL targets) through explicit, captured mappings; declared bases must sit inside the source root or the run's checkout, URIs are percent-decoded, and rejected results are counted with rule, base and path instead of silently dropped. * fix: version strings are not IPs, failed update checks are not 'up to date', private security reporting (#2856, #2786, #2984) - The pre-push redact hook exempts a root VERSION file that is only a version string and the version token in CHANGELOG release headings; the engine allowlist is untouched. - gstack-update-check caches an unreadable remote as CHECK_FAILED with a short TTL instead of UP_TO_DATE; /gstack-upgrade never reports 'latest' after a failed check. - SECURITY.md points reporters at GitHub private vulnerability reporting. - pr-title-sync (pull_request_target, write token) pins actions/checkout to a reviewed SHA. * fix(autoplan): publication guard accepts real Claude Code journals (#3007, #3009, #2968, #2977, #2986, #3006) The guard required a session journal to start with a user message, but Claude Code starts it with SessionStart hook attachments (and a forked compacted session starts with a compact_boundary), so every phase was denied for anyone with a SessionStart hook. Windows path spellings (C:/, /c/, drive case) were rejected too. - Reader accepts the captured startup, compact, clear and fork shapes (claude 2.1.284 fixture), computes root uniqueness over every candidate, and returns typed reason codes instead of one string. - Hard denials (competing root, foreign cwd, sidechain, agent, cycle, malformed, identity) say what happened and how to run the reviews by hand; unflushed journals still retry. - A well-formed, stable journal whose root shape is unrecognized now warns ('phase publication was NOT verified') and continues, without overriding Claude Code's own permission check; no bypass switch. - Windows paths fold before validation, so '..' is still rejected. - Periodic drift canary runs the reader on fresh journals from the pinned claude. Co-authored-by: Charles M Berg <77517285+CharlesBerg85@users.noreply.github.com> Co-authored-by: laurenbdaniels-coder <264343335+laurenbdaniels-coder@users.noreply.github.com> Co-authored-by: Jordan Mayer <176445995+maydaycyber@users.noreply.github.com> Co-authored-by: elmesery-dev <elmesery.dev@gmail.com> * v1.91.13.0: severe bug fix wave release notes, stale gbrain verbs in docs * test: seed the versioned slug cache in the memory-injection deny case (#2901) The preference hook now resolves the project bucket from gstack-slug's v2 slug-cache entry instead of basename(cwd); this fixture still wrote preferences under the basename bucket without the entry the skill preamble always writes first. * fix: full-suite follow-ups for the fix wave - gstack-slug's --help heredoc is over 512B, so it gets the BASH_COMPAT=50 pipe-deadlock guard like the other bins. - Refresh the codex/factory ship goldens for the plan-gates slug change. - The periodic lane gains the autoplan journal drift canary (107 paid files); raise the eval-slices cap to 25 so every slice still starts at once until its recorded duration lets the planner pack it. * fix(plan-eng-review): clearer Step 0 sequencing, write routes and section outputs The workflow judge scored plan-eng-review's instructions at actionability 3.67 (bar 4) on text unchanged from main. Resolve the ambiguities it named together, without changing any gate or output: Step 0 names the Read's order and keeps one STOP; the pending-call, read-only, forbidden-write and failed-save rules become one Write routes block; header/label limits and grid checks are concrete; Performance gets a checklist; each section has a stated output shape; Lake Score is defined. Same total length (parity cap). --------- Co-authored-by: harshitgavita-07 <harshit.gavita@gmail.com> Co-authored-by: Vitor Cepeda Lopes <vitor@vitorcepedalopes.com> Co-authored-by: Charles M Berg <77517285+CharlesBerg85@users.noreply.github.com> Co-authored-by: laurenbdaniels-coder <264343335+laurenbdaniels-coder@users.noreply.github.com> Co-authored-by: Jordan Mayer <176445995+maydaycyber@users.noreply.github.com> Co-authored-by: elmesery-dev <elmesery.dev@gmail.com>
148 lines
6.4 KiB
Bash
148 lines
6.4 KiB
Bash
# shellcheck shell=bash
|
|
# gstack-remote-identity.sh — the one bash owner of git-remote project identity
|
|
# (twin of lib/remote-identity.ts; test/remote-identity-vectors.test.ts runs both
|
|
# against the golden vectors in test/fixtures/remote-identity-vectors.json, so
|
|
# the two can never disagree on a canonical remote or a slug). Sourced, never
|
|
# executed: bin/gstack-slug and browse/bin/remote-slug source it. bash 3.2 safe.
|
|
#
|
|
# Canonical remote (#3003): one spelling per repository, whichever way it was
|
|
# cloned. Hosted remotes (scheme://… or scp-like host:path) become
|
|
# "<host>/<seg>/<seg>…": host lowercased (ASCII, locale-independent), userinfo,
|
|
# credentials and port dropped, one trailing ".git" and stray slashes removed,
|
|
# then host-specific normalization BEFORE segments are counted:
|
|
# - Azure DevOps: ssh "v3/" prefix and https "_git" dropped, ssh.dev.azure.com
|
|
# and *.visualstudio.com folded to dev.azure.com/<org>/<project>/<repo>.
|
|
# - Bitbucket Server: a leading "scm/" (https only spelling) dropped.
|
|
# Local remotes (absolute/relative paths, file://) keep their path as identity.
|
|
#
|
|
# Slug: a hosted remote with 3+ segments (GitLab nested groups, Azure DevOps)
|
|
# files under "<last-two>-<first 16 hex of sha256(canonical)>" so a/product/repo
|
|
# and b/product/repo stop sharing projects/product-repo/. Everything else (all
|
|
# 2-segment remotes, i.e. all of GitHub, and local paths) keeps the legacy
|
|
# last-two parse byte-for-byte, so no existing bucket moves.
|
|
|
|
# _gri_lower — ASCII lowercase, locale-independent.
|
|
_gri_lower() { printf '%s' "$1" | LC_ALL=C tr 'A-Z' 'a-z'; }
|
|
|
|
# gstack_sha256_16 <string> — first 16 hex chars of sha256, portable.
|
|
gstack_sha256_16() {
|
|
_gri_digest=""
|
|
if command -v sha256sum >/dev/null 2>&1; then
|
|
_gri_digest=$(printf '%s' "$1" | sha256sum 2>/dev/null)
|
|
elif command -v shasum >/dev/null 2>&1; then
|
|
_gri_digest=$(printf '%s' "$1" | shasum -a 256 2>/dev/null)
|
|
elif command -v openssl >/dev/null 2>&1; then
|
|
_gri_digest=$(printf '%s' "$1" | openssl dgst -sha256 -r 2>/dev/null)
|
|
fi
|
|
_gri_digest=$(printf '%s' "$_gri_digest" | LC_ALL=C tr -cd '0-9a-f' | cut -c1-16)
|
|
printf '%s' "$_gri_digest"
|
|
}
|
|
|
|
# gstack_legacy_remote_slug <url> — the pre-#3003 parse, kept byte-identical:
|
|
# strip ONE trailing ".git", keep the last two path segments as owner-repo
|
|
# (sed's no-match passthrough leaves the stripped URL itself), sanitize, and
|
|
# reject degenerate results ("", ".", "..").
|
|
gstack_legacy_remote_slug() {
|
|
_gri_l=$(printf '%s' "${1%.git}" | sed -E 's#.*[:/]([^/]+)/([^/]+)$#\1-\2#' | tr -cd 'a-zA-Z0-9._-')
|
|
case "$_gri_l" in ""|.|..) _gri_l="" ;; esac
|
|
printf '%s' "$_gri_l"
|
|
}
|
|
|
|
# gstack_canonical_remote <url> — sets:
|
|
# _gri_canon canonical identity string ("" when the url is empty)
|
|
# _gri_hosted 1 for host-bearing remotes, 0 for local paths
|
|
# _gri_nseg number of path segments after normalization (hosted only)
|
|
# _gri_last2 "<second-to-last>-<last>" segment pair (hosted, nseg >= 2)
|
|
gstack_canonical_remote() {
|
|
_gri_url=$(printf '%s' "$1" | tr -d '\r\n')
|
|
_gri_canon=""; _gri_hosted=0; _gri_nseg=0; _gri_last2=""
|
|
[ -n "$_gri_url" ] || return 0
|
|
_gri_host=""; _gri_path=""; _gri_scheme=""
|
|
if [[ "$_gri_url" =~ ^([A-Za-z][A-Za-z0-9+.-]*)://(.*)$ ]]; then
|
|
_gri_scheme=$(_gri_lower "${BASH_REMATCH[1]}")
|
|
_gri_rest="${BASH_REMATCH[2]}"
|
|
if [ "$_gri_scheme" != "file" ]; then
|
|
_gri_auth="${_gri_rest%%/*}"
|
|
if [ "$_gri_auth" = "$_gri_rest" ]; then _gri_path=""; else _gri_path="${_gri_rest#*/}"; fi
|
|
_gri_auth="${_gri_auth##*@}"
|
|
if [[ "$_gri_auth" =~ ^(\[[^]]*\]) ]]; then
|
|
_gri_host="${BASH_REMATCH[1]}"
|
|
else
|
|
_gri_host="${_gri_auth%%:*}"
|
|
fi
|
|
_gri_hosted=1
|
|
else
|
|
_gri_path="$_gri_rest"
|
|
fi
|
|
elif ! [[ "$_gri_url" =~ ^[A-Za-z]:([/\\]|$) ]] && [[ "$_gri_url" =~ ^([^/:]+):(.*)$ ]]; then
|
|
_gri_host="${BASH_REMATCH[1]##*@}"
|
|
_gri_path="${BASH_REMATCH[2]}"
|
|
_gri_hosted=1
|
|
else
|
|
_gri_path="$_gri_url"
|
|
fi
|
|
|
|
if [ "$_gri_hosted" -eq 0 ]; then
|
|
while [ "${#_gri_path}" -gt 1 ] && [ "${_gri_path%/}" != "$_gri_path" ]; do _gri_path="${_gri_path%/}"; done
|
|
_gri_path="${_gri_path%.git}"
|
|
while [ "${#_gri_path}" -gt 1 ] && [ "${_gri_path%/}" != "$_gri_path" ]; do _gri_path="${_gri_path%/}"; done
|
|
_gri_canon="$_gri_path"
|
|
return 0
|
|
fi
|
|
|
|
_gri_host=$(_gri_lower "$_gri_host")
|
|
while [ "${_gri_path%/}" != "$_gri_path" ]; do _gri_path="${_gri_path%/}"; done
|
|
_gri_path="${_gri_path%.git}"
|
|
_gri_segs=()
|
|
_gri_rem="$_gri_path"
|
|
while [ -n "$_gri_rem" ]; do
|
|
_gri_s="${_gri_rem%%/*}"
|
|
if [ "$_gri_s" = "$_gri_rem" ]; then _gri_rem=""; else _gri_rem="${_gri_rem#*/}"; fi
|
|
if [ -n "$_gri_s" ]; then _gri_segs[${#_gri_segs[@]}]="$_gri_s"; fi
|
|
done
|
|
|
|
case "$_gri_host" in
|
|
ssh.dev.azure.com|vs-ssh.visualstudio.com)
|
|
if [ "${#_gri_segs[@]}" -gt 0 ] && [ "${_gri_segs[0]}" = "v3" ]; then _gri_segs=("${_gri_segs[@]:1}"); fi
|
|
_gri_host="dev.azure.com" ;;
|
|
dev.azure.com) ;;
|
|
*.visualstudio.com)
|
|
if [ "${#_gri_segs[@]}" -gt 0 ] && [ "${_gri_segs[0]}" = "DefaultCollection" ]; then _gri_segs=("${_gri_segs[@]:1}"); fi
|
|
_gri_segs=("${_gri_host%%.*}" ${_gri_segs[@]+"${_gri_segs[@]}"})
|
|
_gri_host="dev.azure.com" ;;
|
|
*)
|
|
if [ "${#_gri_segs[@]}" -ge 3 ] && [ "${_gri_segs[0]}" = "scm" ]; then _gri_segs=("${_gri_segs[@]:1}"); fi ;;
|
|
esac
|
|
if [ "$_gri_host" = "dev.azure.com" ]; then
|
|
_gri_kept=()
|
|
for _gri_s in ${_gri_segs[@]+"${_gri_segs[@]}"}; do
|
|
[ "$_gri_s" = "_git" ] || _gri_kept[${#_gri_kept[@]}]="$_gri_s"
|
|
done
|
|
_gri_segs=(${_gri_kept[@]+"${_gri_kept[@]}"})
|
|
fi
|
|
|
|
_gri_nseg=${#_gri_segs[@]}
|
|
_gri_canon="$_gri_host"
|
|
for _gri_s in ${_gri_segs[@]+"${_gri_segs[@]}"}; do _gri_canon="$_gri_canon/$_gri_s"; done
|
|
if [ "$_gri_nseg" -ge 2 ]; then
|
|
_gri_last2="${_gri_segs[$((_gri_nseg - 2))]}-${_gri_segs[$((_gri_nseg - 1))]}"
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
# gstack_remote_slug <url> — sets _gri_slug (the project slug for this remote,
|
|
# "" when degenerate) and _gri_legacy_slug (the pre-#3003 slug). The two differ
|
|
# only for hosted remotes with 3+ segments.
|
|
gstack_remote_slug() {
|
|
gstack_canonical_remote "$1"
|
|
_gri_legacy_slug=$(gstack_legacy_remote_slug "$1")
|
|
_gri_slug="$_gri_legacy_slug"
|
|
if [ "$_gri_hosted" -eq 1 ] && [ "$_gri_nseg" -ge 3 ]; then
|
|
_gri_hash=$(gstack_sha256_16 "$_gri_canon")
|
|
if [ "${#_gri_hash}" -eq 16 ]; then
|
|
_gri_slug=$(printf '%s-%s' "$_gri_last2" "$_gri_hash" | tr -cd 'a-zA-Z0-9._-')
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|