Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
209339dc57 | ||
|
|
dc34c57a0c | ||
|
|
c97ea01ba9 |
No files matched your search
@@ -5,6 +5,7 @@ on:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
- release/blog-timestamp-limited-20261030
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
@@ -12,10 +13,23 @@ jobs:
|
||||
steps:
|
||||
- name: Run deploy.sh from within the scripts folder
|
||||
env:
|
||||
BRANCH: ${{ github.ref_name }}
|
||||
DEPLOY_REF: ${{ github.ref }}
|
||||
DEPLOY_SHA: ${{ github.sha }}
|
||||
GITHUB_ACTIONS: 'true'
|
||||
run: |
|
||||
set -eu
|
||||
case "${DEPLOY_REF}" in
|
||||
refs/heads/main) BRANCH=main; STAGE_SOURCE_REF= ;;
|
||||
refs/heads/develop|refs/heads/release/blog-timestamp-limited-20261030)
|
||||
BRANCH=develop; STAGE_SOURCE_REF="$DEPLOY_REF" ;;
|
||||
*) printf 'Unsupported deployment ref\n' >&2; exit 2 ;;
|
||||
esac
|
||||
# Bind downloads and both release dispatchers to the exact event commit.
|
||||
case "$DEPLOY_SHA" in
|
||||
*[!0-9a-f]*|'') exit 2 ;;
|
||||
esac
|
||||
[ "${#DEPLOY_SHA}" -eq 40 ] || exit 2
|
||||
export BRANCH STAGE_SOURCE_REF
|
||||
# 1. رفع مشکل DNS و غیرفعال کردن پروکسی برای دامنه محلی
|
||||
echo "87.248.133.138 git.parsaaghayi.ir" >> /etc/hosts
|
||||
export http_proxy=""
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
name: Repair Canina Hermes Git route
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- ops/hermes-git-routing-20261106
|
||||
jobs:
|
||||
routing:
|
||||
runs-on: canina
|
||||
steps:
|
||||
- name: Apply scoped runtime routing without restart
|
||||
env:
|
||||
REPAIR_SHA: ${{ github.sha }}
|
||||
REPAIR_REF: ${{ github.ref }}
|
||||
run: |
|
||||
set -eu
|
||||
[ "$REPAIR_REF" = refs/heads/ops/hermes-git-routing-20261106 ]
|
||||
case "$REPAIR_SHA" in *[!0-9a-f]*|'') exit 2 ;; esac
|
||||
[ "${#REPAIR_SHA}" -eq 40 ]
|
||||
export http_proxy= https_proxy= HTTP_PROXY= HTTPS_PROXY=
|
||||
wget --no-proxy -qO repair.py "https://git.parsaaghayi.ir/parsa/canina/raw/commit/${REPAIR_SHA}/infra/hermes-git-routing/repair.py"
|
||||
python3 repair.py
|
||||
docker exec -i -u 10000 -e HOME=/opt/data -e HERMES_HOME=/opt/data canina-hermes python3 - --apply < repair.py
|
||||
docker exec -u 10000 -e HOME=/opt/data -e HERMES_HOME=/opt/data canina-hermes git ls-remote ssh://git@git.parsaaghayi.ir:222/parsa/canina.git refs/heads/develop
|
||||
docker exec -u 10000 -e HOME=/opt/data -e HERMES_HOME=/opt/data canina-hermes git ls-remote canina-gitea:parsa/canina.git refs/heads/develop
|
||||
@@ -82,9 +82,9 @@ describe('BlogPostPage FAQPage Schema injection (SEO-P1-07)', () => {
|
||||
const jsx=await BlogPostPage({params:Promise.resolve({slug:'fresh'})}); const script:any=React.Children.toArray(jsx.props.children)[0]; const json=JSON.parse(script.props.dangerouslySetInnerHTML.__html); expect(json.dateModified).toBe('2026-01-01T12:00:00.000Z'); expect(json.author['@type']).toBe('Organization'); expect(json.author.name).toBe('کنینا');
|
||||
});
|
||||
|
||||
it('omits dateModified when only technical updatedAt exists', async () => {
|
||||
it('uses publication as dateModified when only technical updatedAt exists', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ok:true,json:async()=>({slug:'technical',title:'Technical',content:'<p>x</p>',publishedAt:'2026-01-01T01:00:00Z',updatedAt:'2026-01-01T12:00:00Z',contentUpdatedAt:null})}));
|
||||
const jsx=await BlogPostPage({params:Promise.resolve({slug:'technical'})}); const script:any=React.Children.toArray(jsx.props.children)[0]; const json=JSON.parse(script.props.dangerouslySetInnerHTML.__html); expect(json.dateModified).toBeUndefined();
|
||||
const jsx=await BlogPostPage({params:Promise.resolve({slug:'technical'})}); const script:any=React.Children.toArray(jsx.props.children)[0]; const json=JSON.parse(script.props.dangerouslySetInnerHTML.__html); expect(json.dateModified).toBe('2026-01-01T01:00:00.000Z');
|
||||
});
|
||||
|
||||
it('uses the stable Organization fallback visibly and in metadata', async () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { validContentUpdatedAt } from "../../../lib/blogDates";
|
||||
import { persianDate, validContentUpdatedAt } from "../../../lib/blogDates";
|
||||
import { resolveBlogAuthorIdentity } from "../../../lib/blogAuthor";
|
||||
import React from "react";
|
||||
import { notFound } from 'next/navigation';
|
||||
@@ -23,7 +23,7 @@ function safeLocalDate(val: any): string {
|
||||
if (!val) return '';
|
||||
try {
|
||||
const d = new Date(val);
|
||||
return isNaN(d.getTime()) ? '' : d.toLocaleDateString('fa-IR');
|
||||
return isNaN(d.getTime()) ? '' : persianDate(d.toISOString());
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
@@ -95,7 +95,8 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str
|
||||
const resolvedAuthor = resolveBlogAuthorIdentity(blog);
|
||||
|
||||
const publishedTime = safeIso(blog.publishedAt) || safeIso(blog.createdAt);
|
||||
const modifiedTime = safeIso(validContentUpdatedAt(blog));
|
||||
// Technical writes are not substantive edits; unedited articles retain the real publication date.
|
||||
const modifiedTime = safeIso(validContentUpdatedAt(blog)) || publishedTime;
|
||||
|
||||
const keywordsList = blog.focusKeywords
|
||||
? blog.focusKeywords.split(',').map((k: string) => k.trim())
|
||||
@@ -181,8 +182,8 @@ export default async function BlogPostPage({ params }: { params: Promise<{ slug:
|
||||
? blog.canonicalUrl.replace(/\/+$/, '')
|
||||
: `${siteUrl}/blog/${slug}`;
|
||||
|
||||
const publishedIso = safeIso(blog.publishedAt) || safeIso(blog.createdAt) || new Date().toISOString();
|
||||
const modifiedIso = safeIso(validContentUpdatedAt(blog));
|
||||
const publishedIso = safeIso(blog.publishedAt) || safeIso(blog.createdAt);
|
||||
const modifiedIso = safeIso(validContentUpdatedAt(blog)) || publishedIso;
|
||||
|
||||
const sanitizedContent = sanitizeBlogHtml(blog.content);
|
||||
const schemaType = blog.schemaType || 'BlogPosting';
|
||||
@@ -210,7 +211,7 @@ export default async function BlogPostPage({ params }: { params: Promise<{ slug:
|
||||
image: blog.imageUrl
|
||||
? [blog.imageUrl.startsWith('http') ? blog.imageUrl : `${siteUrl}${blog.imageUrl.startsWith('/') ? '' : '/'}${blog.imageUrl}`]
|
||||
: [config.ogImageUrl.startsWith('http') ? config.ogImageUrl : `${siteUrl}${config.ogImageUrl.startsWith('/') ? '' : '/'}${config.ogImageUrl}`],
|
||||
datePublished: publishedIso,
|
||||
...(publishedIso ? { datePublished: publishedIso } : {}),
|
||||
...(modifiedIso ? { dateModified: modifiedIso } : {}),
|
||||
author: authorSchema,
|
||||
publisher: {
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import React from 'react';
|
||||
import { afterEach, expect, it, vi } from 'vitest';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import BlogPostPage, { generateMetadata } from './page';
|
||||
import { validContentUpdatedAt } from '../../../lib/blogDates';
|
||||
|
||||
vi.mock('../../../lib/seo', () => ({
|
||||
getSeoConfig: async () => ({ brandNameFa: 'کنینا', canonicalBaseUrl: 'https://canina.ir', ogImageUrl: 'https://canina.ir/default.webp' }),
|
||||
formatPageTitle: (title: string) => title,
|
||||
}));
|
||||
vi.mock('../../../components/BlogPostClient', () => ({
|
||||
default: ({ blog, publishedDate }: { blog: any; publishedDate: string }) => <div>
|
||||
<span>تاریخ انتشار: {publishedDate}</span>
|
||||
{validContentUpdatedAt(blog) && <span>آخرین بهروزرسانی</span>}
|
||||
</div>,
|
||||
}));
|
||||
afterEach(() => { vi.unstubAllGlobals(); vi.unstubAllEnvs(); });
|
||||
const published = '2026-10-29T07:11:40.925Z';
|
||||
|
||||
async function readDates(fields: Record<string, unknown>) {
|
||||
vi.stubEnv('NEXT_PUBLIC_APP_ENV', 'staging');
|
||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true, json: async () => ({
|
||||
title: 'Timestamp contract', content: '<p>Article</p>', ...fields,
|
||||
}) }));
|
||||
const params = Promise.resolve({ slug: 'timestamp-contract' });
|
||||
const metadata = await generateMetadata({ params });
|
||||
const jsx = await BlogPostPage({ params });
|
||||
const script: any = React.Children.toArray(jsx.props.children)[0];
|
||||
return { og: metadata.openGraph as any, robots: metadata.robots,
|
||||
article: JSON.parse(script.props.dangerouslySetInnerHTML.__html), html: renderToStaticMarkup(jsx) };
|
||||
}
|
||||
|
||||
it.each([null, undefined, 'invalid', published, '2026-10-28T00:00:00Z'])(
|
||||
'uses real publication for unedited/invalid/chronologically inapplicable content date %s', async (contentUpdatedAt) => {
|
||||
const { og, article, html, robots } = await readDates({ publishedAt: published,
|
||||
contentUpdatedAt, updatedAt: '2026-10-30T09:00:00Z', imageUrl: '/attached.webp' });
|
||||
expect(og.publishedTime).toBe(published);
|
||||
expect(og.modifiedTime).toBe(published);
|
||||
expect(article.datePublished).toBe(published);
|
||||
expect(article.dateModified).toBe(published);
|
||||
expect(html).not.toContain('آخرین بهروزرسانی');
|
||||
// Stage noindex remains an independent HTTP acceptance check; no robots change in this slice.
|
||||
});
|
||||
it('uses actual substantive update consistently without changing publication', async () => {
|
||||
const modified = '2026-10-29T12:00:00.000Z';
|
||||
const { og, article, html } = await readDates({ publishedAt: published, contentUpdatedAt: modified });
|
||||
expect(og.modifiedTime).toBe(modified);
|
||||
expect(article.dateModified).toBe(modified);
|
||||
expect(article.datePublished).toBe(published);
|
||||
expect(html).toContain('آخرین بهروزرسانی');
|
||||
});
|
||||
it.each([null, 'invalid'])('uses the valid existing createdAt fallback when publishedAt is %s', async (publishedAt) => {
|
||||
const { og, article } = await readDates({ publishedAt, createdAt: published });
|
||||
expect(og.publishedTime).toBe(published);
|
||||
expect(og.modifiedTime).toBe(published);
|
||||
expect(article.datePublished).toBe(published);
|
||||
expect(article.dateModified).toBe(published);
|
||||
});
|
||||
it.each([{}, { publishedAt: 'invalid', createdAt: 'invalid', contentUpdatedAt: '2026-10-30T00:00:00Z' }])(
|
||||
'does not invent rendering-time publication or modification when unknown: %j', async (fields) => {
|
||||
const { og, article } = await readDates(fields);
|
||||
expect(og.publishedTime).toBeUndefined();
|
||||
expect(og.modifiedTime).toBeUndefined();
|
||||
expect(article).not.toHaveProperty('datePublished');
|
||||
expect(article).not.toHaveProperty('dateModified');
|
||||
});
|
||||
it('formats visible publication using Persian calendar and Tehran rather than server timezone', async () => {
|
||||
const { html } = await readDates({ publishedAt: '2026-10-29T21:00:00Z' });
|
||||
const expected = new Intl.DateTimeFormat('fa-IR-u-ca-persian', {
|
||||
year: 'numeric', month: 'numeric', day: 'numeric', timeZone: 'Asia/Tehran',
|
||||
}).format(new Date('2026-10-29T21:00:00Z'));
|
||||
expect(html).toContain(`تاریخ انتشار: ${expected}`);
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, it } from 'vitest';
|
||||
import BlogPostClient from '../../../components/BlogPostClient';
|
||||
|
||||
it.each([null, undefined, 'invalid', '2026-10-29T07:11:40.925Z', '2026-10-28T00:00:00Z'])(
|
||||
'actual client keeps publication but no visible update for %s despite later technical writes', (contentUpdatedAt) => {
|
||||
const html = renderToStaticMarkup(<BlogPostClient
|
||||
blog={{ id: 'timestamp-fixture', slug: 'timestamp-fixture', title: 'Timestamp',
|
||||
publishedAt: '2026-10-29T07:11:40.925Z', contentUpdatedAt,
|
||||
updatedAt: '2026-10-30T10:00:00Z', imageUrl: '/attached.webp' }}
|
||||
publishedDate="۱۴۰۵/۸/۷" sanitizedContent="<p>Article</p>" authorName="کنینا"
|
||||
/>);
|
||||
expect(html).toContain('تاریخ انتشار');
|
||||
expect(html).toContain('۱۴۰۵/۸/۷');
|
||||
expect(html).not.toContain('آخرین بهروزرسانی');
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Narrow Canina gateway Git routing repair; run as UID10000 only."""
|
||||
import hashlib,json,os,pathlib,subprocess,sys,tempfile
|
||||
HOME=pathlib.Path('/opt/data')
|
||||
BLOCK='''\n# Managed Canina repository SSH route (no credential provisioning).
|
||||
Match originalhost git.parsaaghayi.ir user git
|
||||
Port 222
|
||||
IdentityFile /opt/data/.ssh/canina_gitea
|
||||
IdentitiesOnly yes
|
||||
StrictHostKeyChecking yes
|
||||
UserKnownHostsFile /opt/data/.ssh/gitea_known_hosts
|
||||
ConnectTimeout 10
|
||||
'''
|
||||
GUIDANCE='''# Canina execution preflight
|
||||
|
||||
This gateway runs as UID10000 with HOME=HERMES_HOME=/opt/data; Docker root is not the worker identity.
|
||||
Before reporting Git credentials missing, run read-only `git ls-remote canina-gitea:parsa/canina.git refs/heads/develop` from the actual worker. The dedicated existing key is /opt/data/.ssh/canina_gitea; pinned trust is /opt/data/.ssh/gitea_known_hosts. Never print/copy private keys, disable host verification, request a new key/token without testing the existing route, or embed HTTPS tokens in URLs. Browser vault login tools are for website forms, not SSH key provisioning.
|
||||
Raw repository URL: ssh://git@git.parsaaghayi.ir:222/parsa/canina.git. Diagnose URL/SSH host matching independently from repository permissions. A successful read does not establish push permission or CI publication.
|
||||
Use isolated worktrees and exact tool exit/results. Delegation dispatched is not completed; wait for delivered results, and distinguish failed access, implementation, tests, CI and live acceptance. Do not report feature completion from plans, tool presence or another agent's unsupported claim. Do not replay unrelated feature requests while repairing Hermes.
|
||||
Preserve owner approval gates, existing sessions and all unrelated profiles. All code/config repair changes must be tracked in Git and released through CI/CD; never restart gateways or deploy site features merely to test access.
|
||||
'''
|
||||
def config_probe(path,host,user='git'):
|
||||
r=subprocess.run(['ssh','-F',str(path),'-G','-l',user,host],capture_output=True,text=True,timeout=10,check=True)
|
||||
return dict(line.split(' ',1) for line in r.stdout.splitlines() if ' ' in line and line.split(' ',1)[0] in {'port','identitiesonly','stricthostkeychecking','identityfile','userknownhostsfile','hostname'})
|
||||
def test():
|
||||
with tempfile.TemporaryDirectory() as t:
|
||||
p=pathlib.Path(t)/'config'; p.write_text('Host canina-gitea\n HostName git.parsaaghayi.ir\n User git\n Port 222\n IdentityFile /opt/data/.ssh/canina_gitea\n IdentitiesOnly yes\n StrictHostKeyChecking yes\n UserKnownHostsFile /opt/data/.ssh/gitea_known_hosts\n'+BLOCK)
|
||||
d=config_probe(p,'git.parsaaghayi.ir'); assert d['port']=='222' and d['identitiesonly']=='yes' and d['stricthostkeychecking']=='true' and d['identityfile']=='/opt/data/.ssh/canina_gitea',d
|
||||
assert config_probe(p,'unrelated.example')['port']=='22'
|
||||
assert config_probe(p,'git.parsaaghayi.ir','other')['port']=='22'
|
||||
assert config_probe(p,'canina-gitea')['port']=='222'
|
||||
print('PASS: raw git route, alias route, unrelated host and unrelated user isolation')
|
||||
def apply():
|
||||
assert os.getuid()==10000 and os.getenv('HERMES_HOME')=='/opt/data'
|
||||
cfg=HOME/'.ssh/config'; before=cfg.read_text(); guide=HOME/'.hermes.md'
|
||||
assert 'Host canina-gitea\n' in before
|
||||
assert not guide.exists() or guide.read_text()==GUIDANCE,'unmanaged guidance exists'
|
||||
assert 'Match originalhost git.parsaaghayi.ir' not in before or BLOCK in before,'unmanaged raw host route'
|
||||
if BLOCK not in before:
|
||||
assert 'Host git.parsaaghayi.ir' not in before
|
||||
backup=HOME/'.ssh/config.before-canina-routing-20261106'
|
||||
if backup.exists(): assert backup.read_text()==before,'backup conflict'
|
||||
else:
|
||||
fd=os.open(backup,os.O_WRONLY|os.O_CREAT|os.O_EXCL,0o600)
|
||||
with os.fdopen(fd,'w') as f: f.write(before)
|
||||
tmp=cfg.with_suffix('.repair-new'); tmp.write_text(before+BLOCK); tmp.chmod(cfg.stat().st_mode & 0o777); os.replace(tmp,cfg)
|
||||
if not guide.exists():
|
||||
fd=os.open(guide,os.O_WRONLY|os.O_CREAT|os.O_EXCL,0o600)
|
||||
with os.fdopen(fd,'w') as f:f.write(GUIDANCE)
|
||||
d=config_probe(cfg,'git.parsaaghayi.ir'); assert d['port']=='222' and d['identityfile']=='/opt/data/.ssh/canina_gitea',d
|
||||
print(json.dumps({'status':'applied','uid':os.getuid(),'config_sha256':hashlib.sha256(cfg.read_bytes()).hexdigest(),'guidance_sha256':hashlib.sha256(guide.read_bytes()).hexdigest(),'restart':False}))
|
||||
if __name__=='__main__':
|
||||
test()
|
||||
if '--apply' in sys.argv: apply()
|
||||
@@ -98,8 +98,20 @@ done
|
||||
[[ $lock_acquired == true ]] || { printf 'Stage host lock not confirmed\n' >&2; exit 1; }
|
||||
release_stage() {
|
||||
cd "$STAGE_DIR"
|
||||
timeout --foreground --kill-after=2s 60 git fetch origin develop
|
||||
[[ $(git rev-parse origin/develop) == "$DEPLOY_SHA" ]] || exit 2
|
||||
# Stage source ref gate: exact allowlist, never infer production from a short name.
|
||||
case "${STAGE_SOURCE_REF:-refs/heads/develop}" in
|
||||
refs/heads/develop)
|
||||
timeout --foreground --kill-after=2s 60 git fetch origin develop
|
||||
[[ $(git rev-parse origin/develop) == "$DEPLOY_SHA" ]] || exit 2
|
||||
;;
|
||||
refs/heads/release/blog-timestamp-limited-20261030)
|
||||
timeout --foreground --kill-after=2s 60 git fetch origin \
|
||||
refs/heads/release/blog-timestamp-limited-20261030:refs/remotes/origin/release/blog-timestamp-limited-20261030
|
||||
[[ $(git rev-parse refs/remotes/origin/release/blog-timestamp-limited-20261030) == "$DEPLOY_SHA" ]] || exit 2
|
||||
;;
|
||||
*) printf 'Unsupported Stage source ref\n' >&2; exit 2 ;;
|
||||
esac
|
||||
# End Stage source ref gate
|
||||
# Never reset/clean the operational checkout or overwrite its generated configs.
|
||||
# Every attempt has its own directory: retain incomplete and active releases.
|
||||
RELEASE_ROOT=/opt/services/canina/cache-releases
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
"""Execute the tracked workflow route and Stage ref guard without network/daemon."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
RELEASE = 'refs/heads/release/blog-timestamp-limited-20261030'
|
||||
|
||||
|
||||
def workflow_run():
|
||||
source = (ROOT / '.gitea/workflows/deploy.yml').read_text()
|
||||
return '\n'.join(
|
||||
line[10:] for line in source.split(' run: |\n', 1)[1].splitlines())
|
||||
|
||||
|
||||
class LimitedStageRouteTests(unittest.TestCase):
|
||||
def route(self, ref, sha='a' * 40):
|
||||
run = workflow_run()
|
||||
# Execute the actual fail-closed preamble before its first external action.
|
||||
route = run.split('# 1.', 1)[0]
|
||||
result = subprocess.run(['bash', '-c', route + '\nprintf "%s|%s|%s" "$BRANCH" "$STAGE_SOURCE_REF" "$DEPLOY_SHA"'],
|
||||
env=dict(os.environ, DEPLOY_REF=ref, DEPLOY_SHA=sha), text=True, capture_output=True)
|
||||
return result
|
||||
|
||||
def test_exact_push_allowlist_and_sha_binding(self):
|
||||
source = (ROOT / '.gitea/workflows/deploy.yml').read_text()
|
||||
branches = re.findall(r'^ - (.+)$', source.split('\njobs:', 1)[0], re.M)
|
||||
self.assertEqual(branches, ['main', 'develop', RELEASE.removeprefix('refs/heads/')])
|
||||
self.assertIn('DEPLOY_REF: ${{ github.ref }}', source)
|
||||
self.assertIn('DEPLOY_SHA: ${{ github.sha }}', source)
|
||||
self.assertIn('./deploy.sh "${BRANCH}"', source)
|
||||
self.assertNotIn('github.ref_name', source)
|
||||
|
||||
def test_routes(self):
|
||||
for ref, branch, stage_ref in [('refs/heads/main', 'main', ''), ('refs/heads/develop', 'develop', 'refs/heads/develop'), (RELEASE, 'develop', RELEASE)]:
|
||||
with self.subTest(ref=ref):
|
||||
result = self.route(ref)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertEqual(result.stdout, f'{branch}|{stage_ref}|'+ 'a'*40)
|
||||
|
||||
def test_rejects_similar_tags_unknown_refs_and_bad_sha(self):
|
||||
for ref in ['main', 'refs/tags/main', 'refs/tags/'+RELEASE.split('/')[-1], RELEASE+'-other', 'refs/heads/release/other', 'refs/heads/main;touch bad']:
|
||||
self.assertNotEqual(self.route(ref).returncode, 0, ref)
|
||||
for sha in ['', 'abc', 'a'*40+';touch bad', 'A'*40]:
|
||||
self.assertNotEqual(self.route(RELEASE, sha).returncode, 0, sha)
|
||||
|
||||
def test_stage_exact_source_guard(self):
|
||||
source = (ROOT / 'scripts/release-cache-stage.sh').read_text()
|
||||
guard = source.split('# Stage source ref gate', 1)[1].split('# End Stage source ref gate', 1)[0]
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
git = Path(d)/'git'
|
||||
git.write_text('#!/bin/sh\nprintf "%s\\n" "$*" >> "$CALLS"\nif [ "$1" = rev-parse ]; then printf "%s\\n" "$REMOTE_SHA"; fi\n')
|
||||
git.chmod(0o755)
|
||||
calls = Path(d)/'calls'
|
||||
for ref, remote, expected in [('refs/heads/develop', 'a'*40, 0), (RELEASE, 'a'*40, 0), (RELEASE, 'b'*40, 2), ('refs/heads/main', 'a'*40, 2), (RELEASE+'x', 'a'*40, 2)]:
|
||||
calls.unlink(missing_ok=True)
|
||||
result = subprocess.run(['bash', '-c', 'set -euo pipefail\n'+guard], env=dict(os.environ, PATH=d+':'+os.environ['PATH'], CALLS=str(calls), REMOTE_SHA=remote, STAGE_SOURCE_REF=ref, DEPLOY_SHA='a'*40), capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, expected, result.stderr)
|
||||
if ref not in ('refs/heads/develop', RELEASE):
|
||||
self.assertFalse(calls.exists(), 'invalid ref reached git')
|
||||
elif ref == RELEASE:
|
||||
self.assertIn('fetch origin '+RELEASE+':refs/remotes/origin/release/blog-timestamp-limited-20261030', calls.read_text())
|
||||
|
||||
def test_production_dispatch_is_not_selected_for_release(self):
|
||||
deploy = (ROOT / 'scripts/deploy.sh').read_text()
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
root = Path(d)
|
||||
(root/'deploy.sh').write_text(deploy)
|
||||
for target in ('stage', 'prod'):
|
||||
(root/f'release-cache-{target}.sh').write_text(f'printf "{target}|%s" "$DEPLOY_SHA"\n')
|
||||
selected = self.route(RELEASE).stdout.split('|')[0]
|
||||
result = subprocess.run(['bash', str(root/'deploy.sh'), selected], env=dict(os.environ, DEPLOY_SHA='a'*40), capture_output=True, text=True, check=True)
|
||||
self.assertEqual(result.stdout, 'stage|'+'a'*40)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,24 @@
|
||||
# Limited release receipt
|
||||
|
||||
Base and observed running production frontend/backend OCI revision: `00ba4360cf7b161995ee94f220b61f9547e01723`, both running, restartCount 0. Official main matches. Mixed develop `216e05ba258cf7882350f00da9d9b659885d9816` is NOT this release.
|
||||
|
||||
Only timestamp hunks ported; production imagery unchanged. Existing blogDates helper and BlogPostClient identical across main and mixed develop; no scoped dependency needed. All corporate, SEO-tracking, schema/migration, publisher, analytics, null-image work excluded.
|
||||
|
||||
Evidence directory `/opt/data/content-maintenance/recovery-evidence-20261030/`:
|
||||
- `limited-timestamp-red.log`: initial ported tests fail; 11 failures includes missing fixture ogImageUrl (source main retains imagery fallback). Genuine metadata missing-fallback and clock/timezone failures present. Not all failures behavioral.
|
||||
- `limited-timestamp-focused.log`: 3 files / 22 tests pass exit0.
|
||||
- `limited-timestamp-full.log`: 100 files / 518 tests pass exit0, duration279.52 seconds.
|
||||
- `limited-timestamp-typecheck.log`: typecheck exit0 (dedicated rerun; initial combined command hit external300s deadline after full suite passed).
|
||||
- `limited-timestamp-lint.log`: scoped ESLint exit0. Full lint not rerun on limited base; prior mixed-branch lib/slug.ts error must not be represented as this artifact's complete lint result.
|
||||
- `limited-timestamp-build.log`: first build fails because shared node_modules symlink lies outside Turbopack workspace.
|
||||
- `limited-timestamp-build-localdeps.log`: build exit0 after reflink/copy existing dependencies inside worktree. No source config workaround. Warnings: multiple lockfiles and no local API on127.0.0.1:4400 during prerender. Not live API acceptance.
|
||||
|
||||
No backend/admin source changed; no claim their baseline tests certify a new SHA. Official CI rebuild and exact-SHA Stage runtime acceptance remain mandatory.
|
||||
|
||||
Existing Stage receipt `stage-216e05ba-release-receipt.json` reviewed: run1355 attests mixed SHA216e05ba and corporate acceptance only; cannot certify limited release. Its 52 Stage articles all have actual contentUpdatedAt later than publication, so an unedited fallback requires a suitable real record or authorized fixture; do not resave records merely to manufacture timestamps.
|
||||
|
||||
Release owner must resolve develop ref safely: current develop is mixed and limited branch from main is not a fast-forward. Do NOT merge current develop to main. Do NOT silently force/reset develop. Official workflow triggers only develop/main; parent must choose explicit authorized branch-ref reconciliation preserving mixed work before Stage push. Production promotion only after exact limited SHA Stage CI + container revision + HTTP HTML/JSON-LD/visible dates/noindex/canonical/image + unchanged source dates accepted.
|
||||
|
||||
Cause: null contentUpdatedAt correctly means no substantive edit, but renderer omitted modified metadata rather than falling back to real publication; visible formatting used host timezone; unknown publication schema fallback invented render-clock date. Technical updatedAt is not contentUpdatedAt. This changes projections only, never business timestamps or data.
|
||||
|
||||
Publisher remains untouched and gated until parent confirms production acceptance.
|
||||
@@ -0,0 +1,22 @@
|
||||
# Limited release Stage routing — 2026-10-30
|
||||
|
||||
Scope: preserve mixed `develop` and its historical evidence. Add only the explicit `release/blog-timestamp-limited-20261030` push ref to the official deployment workflow. No push or deployment was performed by the preparing worker.
|
||||
|
||||
## Source contract
|
||||
|
||||
- Workflow binds `DEPLOY_REF` to full event `github.ref` and leaves `DEPLOY_SHA` bound to `github.sha`. Unknown refs and malformed SHAs fail before downloads.
|
||||
- Only `refs/heads/main` selects `deploy.sh main`; develop and the exact dedicated release ref select `deploy.sh develop` with an explicit Stage source ref.
|
||||
- `deploy.sh develop` execs `release-cache-stage.sh`. That script previously fetched only develop and required `origin/develop == DEPLOY_SHA`; workflow routing alone was therefore insufficient.
|
||||
- Stage now fetches the exact allowlisted dedicated source into its own remote-tracking ref and requires its SHA to equal `DEPLOY_SHA` before archive/build. The develop path remains unchanged. No force refspec or operational checkout reset is introduced.
|
||||
- `deploy.sh` and `release-cache-prod.sh` are unchanged. Production still fetches main and requires `origin/main == DEPLOY_SHA`. Both official release scripts are code-only, building/recreating only backend/frontend through the existing lock/runtime/provenance checks; no migrations added.
|
||||
|
||||
## Actual local execution
|
||||
|
||||
- New source-executing regression suite was run RED before implementation: missing allowlisted push ref, missing Stage source-ref guard, and missing fail-closed full-ref routing failed.
|
||||
- `python -m unittest scripts.tests.test_limited_stage_route scripts.tests.test_cache_stage_release scripts.tests.test_cache_release_safety -v`: **13 tests passed**, 17.845s. Includes actual embedded workflow shell preamble execution, exact/near-match/tag/injection rejection, invalid SHA rejection, Stage source-ref guard with a fake Git transport, mismatched remote SHA rejection, and actual deploy dispatcher execution with isolated release doubles.
|
||||
- `bash -n scripts/deploy.sh scripts/release-cache-stage.sh scripts/release-cache-prod.sh`: passed.
|
||||
- `git diff --check`: passed.
|
||||
- Additional `test_production_code_only_ci` run: 2 passed, 1 failed because the baseline production script already has `--repair-empty` while an old test forbids it. Reproduced that exact assertion using `git show 00ba4360:scripts/release-cache-prod.sh`; production source is byte-identical to baseline. No production script/test was changed to hide that existing failure.
|
||||
- Local Graphify inventory was queried: deploy.sh nodes exist but their old locations describe an obsolete script and no current release-cache-stage/workflow nodes were present. Actual source above is authoritative; no claim of a fresh graph or graph-derived release acceptance.
|
||||
|
||||
Existing timestamp test files and evidence were preserved byte-for-byte. This evidence is local routing verification only, not official Stage acceptance or Production acceptance. Parent remains sole push owner and must verify CI/run SHA, immutable images, and live timestamp behavior before promoting the identical accepted SHA to main without a merge commit.
|
||||
@@ -0,0 +1,4 @@
|
||||
# Plan
|
||||
|
||||
Port only timestamp hunks from 216e05ba onto production main, not entire page from mixed branch. blogDates helper and BlogPostClient are identical across base and mixed source, no dependency port needed.
|
||||
Graphify navigation graph hash 6a73473cee9e207543fdeeb668bea544f766200a1b16b8a3a9ce18d4e42e51af, bound to older e7ded849f6b1e3bdab2a20d89b3ec7dd0df79cab: stale navigation only. Existing edges show BlogPostPage -> safeLocalDate/safeIso/getBlog and generateMetadata -> getBlog; confirm direct source/tests at base before editing.
|
||||
@@ -0,0 +1,5 @@
|
||||
# Limited timestamp rendering release
|
||||
|
||||
Base official main and running production: 00ba4360cf7b161995ee94f220b61f9547e01723. Scope only article timestamp projection, tests and specifications. No corporate, SEO tracking, imagery, data/schema/migration, seed, publisher or cron changes.
|
||||
|
||||
Acceptance: metadata modified date uses real substantive contentUpdatedAt only when valid and later than publication; otherwise real publication/createdAt. Never invent dates from render clock. Visible update label requires genuine substantive timestamp; Persian dates use Tehran timezone. Preserve all article imagery and canonical behavior. Stage exact limited SHA must pass official CI and live HTML/read-only source-date acceptance before promotion. Parent exclusively owns pushes.
|
||||
@@ -0,0 +1,8 @@
|
||||
# Tasks
|
||||
|
||||
- [x] Verify official main, deployed production revision and scoped dependencies.
|
||||
- [ ] Execute newly ported tests RED on production base.
|
||||
- [ ] Apply only timestamp hunks and update existing assertion.
|
||||
- [ ] Run focused/full storefront tests, typecheck, build, scoped lint.
|
||||
- [ ] Commit limited artifact; parent pushes exact SHA to Stage, validates it, then promotes to main.
|
||||
- [ ] After production accepted, independent publisher may continue.
|
||||
Reference in new issue
Block a user